Replace usages of eval-after-load with with-eval-after-load

`with-eval-after-load` was introduced in Emacs 24.4 and its
usage results in a cleaner code.

`eval-after-load` is considered ill-behaved because it is a function,
not a macro, and thus requires the code inside it to be quoted, which
means that it cannot be byte-compiled. It also accepts only one form,
so if you have more than one, you need to use `progn`.

More details - https://stackoverflow.com/questions/21880139/what-is-with-eval-after-load-in-emacs-lisp
This commit is contained in:
Bozhidar Batsov 2018-09-14 09:50:00 +03:00
parent 0ce648b699
commit cecae9ca19
15 changed files with 145 additions and 160 deletions

View file

@ -137,8 +137,8 @@ by Prelude.")
;; Patch security vulnerability in Emacs versions older than 25.3
(when (version< emacs-version "25.3")
(eval-after-load "enriched"
'(defun enriched-decode-display-prop (start end &optional param)
(with-eval-after-load "enriched"
(defun enriched-decode-display-prop (start end &optional param)
(list start end))))
(prelude-eval-after-init

View file

@ -35,8 +35,7 @@
(require 'prelude-lisp)
(prelude-require-packages '(clojure-mode cider))
(eval-after-load 'clojure-mode
'(progn
(with-eval-after-load 'clojure-mode
(defun prelude-clojure-mode-defaults ()
(subword-mode +1)
(run-hooks 'prelude-lisp-coding-hook))
@ -44,10 +43,9 @@
(setq prelude-clojure-mode-hook 'prelude-clojure-mode-defaults)
(add-hook 'clojure-mode-hook (lambda ()
(run-hooks 'prelude-clojure-mode-hook)))))
(run-hooks 'prelude-clojure-mode-hook))))
(eval-after-load 'cider
'(progn
(with-eval-after-load 'cider
(setq nrepl-log-messages t)
(add-hook 'cider-mode-hook 'eldoc-mode)
@ -59,7 +57,7 @@
(setq prelude-cider-repl-mode-hook 'prelude-cider-repl-mode-defaults)
(add-hook 'cider-repl-mode-hook (lambda ()
(run-hooks 'prelude-cider-repl-mode-hook)))))
(run-hooks 'prelude-cider-repl-mode-hook))))
(provide 'prelude-clojure)

View file

@ -35,8 +35,7 @@
(require 'prelude-programming)
(prelude-require-package 'coffee-mode)
(eval-after-load 'coffee-mode
'(progn
(with-eval-after-load 'coffee-mode
;; CoffeeScript uses two spaces.
(setq coffee-tab-width 2)
@ -54,7 +53,7 @@
(setq prelude-coffee-mode-hook 'prelude-coffee-mode-defaults)
(add-hook 'coffee-mode-hook (lambda ()
(run-hooks 'prelude-coffee-mode-hook)))))
(run-hooks 'prelude-coffee-mode-hook))))
(provide 'prelude-coffee)
;;; prelude-coffee.el ends here

View file

@ -71,14 +71,13 @@
(smartparens-strict-mode +1)
(whitespace-mode -1)))
(eval-after-load "slime"
'(progn
(with-eval-after-load "slime"
(setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol
slime-fuzzy-completion-in-place t
slime-enable-evaluate-in-emacs t
slime-autodoc-use-multiline-p t
slime-auto-start 'always)
(define-key slime-mode-map (kbd "C-c C-s") 'slime-selector)))
(define-key slime-mode-map (kbd "C-c C-s") 'slime-selector))
(provide 'prelude-common-lisp)

View file

@ -32,8 +32,7 @@
;;; Code:
(eval-after-load 'css-mode
'(progn
(with-eval-after-load 'css-mode
(prelude-require-packages '(rainbow-mode))
(setq css-indent-offset 2)
@ -45,7 +44,7 @@
(setq prelude-css-mode-hook 'prelude-css-mode-defaults)
(add-hook 'css-mode-hook (lambda ()
(run-hooks 'prelude-css-mode-hook)))))
(run-hooks 'prelude-css-mode-hook))))
(provide 'prelude-css)
;;; prelude-css.el ends here

View file

@ -92,17 +92,16 @@ Start `ielm' if it's not already running."
(add-hook 'ielm-mode-hook (lambda ()
(run-hooks 'prelude-ielm-mode-hook)))
(eval-after-load "elisp-slime-nav"
'(diminish 'elisp-slime-nav-mode))
(eval-after-load "rainbow-mode"
'(diminish 'rainbow-mode))
(eval-after-load "eldoc"
'(diminish 'eldoc-mode))
(with-eval-after-load "elisp-slime-nav"
(diminish 'elisp-slime-nav-mode))
(with-eval-after-load "rainbow-mode"
(diminish 'rainbow-mode))
(with-eval-after-load "eldoc"
(diminish 'eldoc-mode))
(eval-after-load "ielm"
'(progn
(with-eval-after-load "ielm"
(define-key ielm-map (kbd "M-(") (prelude-wrap-with "("))
(define-key ielm-map (kbd "M-\"") (prelude-wrap-with "\""))))
(define-key ielm-map (kbd "M-\"") (prelude-wrap-with "\"")))
;; enable elisp-slime-nav-mode
(dolist (hook '(emacs-lisp-mode-hook ielm-mode-hook))

View file

@ -44,9 +44,8 @@
(when (require 'erlang-start nil t)
(eval-after-load 'erlang-mode
'(progn
(flymake-mode)))
(with-eval-after-load 'erlang-mode
(flymake-mode))
(when (not (null wrangler-path))
(add-to-list 'load-path wrangler-path)

View file

@ -44,8 +44,7 @@
(define-key 'help-command (kbd "G") 'godoc)
(eval-after-load 'go-mode
'(progn
(with-eval-after-load 'go-mode
(defun prelude-go-mode-defaults ()
;; Add to default go-mode key bindings
(let ((map go-mode-map))
@ -78,7 +77,7 @@
(setq prelude-go-mode-hook 'prelude-go-mode-defaults)
(add-hook 'go-mode-hook (lambda ()
(run-hooks 'prelude-go-mode-hook)))))
(run-hooks 'prelude-go-mode-hook))))
(provide 'prelude-go)
;;; prelude-go.el ends here

View file

@ -35,8 +35,7 @@
(require 'prelude-programming)
(prelude-require-packages '(haskell-mode))
(eval-after-load 'haskell-mode
'(progn
(with-eval-after-load 'haskell-mode
(defun prelude-haskell-mode-defaults ()
(subword-mode +1)
(eldoc-mode +1)
@ -46,7 +45,7 @@
(setq prelude-haskell-mode-hook 'prelude-haskell-mode-defaults)
(add-hook 'haskell-mode-hook (lambda ()
(run-hooks 'prelude-haskell-mode-hook)))))
(run-hooks 'prelude-haskell-mode-hook))))
(provide 'prelude-haskell)

View file

@ -41,8 +41,7 @@
(add-to-list 'auto-mode-alist '("\\.pac\\'" . js2-mode))
(add-to-list 'interpreter-mode-alist '("node" . js2-mode))
(eval-after-load 'js2-mode
'(progn
(with-eval-after-load 'js2-mode
(defun prelude-js-mode-defaults ()
;; electric-layout-mode doesn't play nice with smartparens
(setq-local electric-layout-rules '((?\; . after)))
@ -51,7 +50,7 @@
(setq prelude-js-mode-hook 'prelude-js-mode-defaults)
(add-hook 'js2-mode-hook (lambda () (run-hooks 'prelude-js-mode-hook)))))
(add-hook 'js2-mode-hook (lambda () (run-hooks 'prelude-js-mode-hook))))
(provide 'prelude-js)

View file

@ -37,10 +37,9 @@
;; for case
(require 'cl)
(eval-after-load "company"
'(progn
(with-eval-after-load "company"
(prelude-require-packages '(company-auctex))
(company-auctex-init)))
(company-auctex-init))
(defcustom prelude-latex-fast-math-entry 'LaTeX-math-mode
"Method used for fast math symbol entry in LaTeX."

View file

@ -41,8 +41,7 @@
(define-key 'help-command (kbd "R") 'yari)
(eval-after-load 'ruby-mode
'(progn
(with-eval-after-load 'ruby-mode
(defun prelude-ruby-mode-defaults ()
(inf-ruby-minor-mode +1)
;; CamelCase aware editing operations
@ -51,7 +50,7 @@
(setq prelude-ruby-mode-hook 'prelude-ruby-mode-defaults)
(add-hook 'ruby-mode-hook (lambda ()
(run-hooks 'prelude-ruby-mode-hook)))))
(run-hooks 'prelude-ruby-mode-hook))))
(provide 'prelude-ruby)
;;; prelude-ruby.el ends here

View file

@ -44,8 +44,7 @@
(setq rust-format-on-save t)
(eval-after-load 'rust-mode
'(progn
(with-eval-after-load 'rust-mode
(add-hook 'rust-mode-hook 'racer-mode)
(add-hook 'racer-mode-hook 'eldoc-mode)
(add-hook 'rust-mode-hook 'cargo-minor-mode)
@ -60,7 +59,7 @@
(setq prelude-rust-mode-hook 'prelude-rust-mode-defaults)
(add-hook 'rust-mode-hook (lambda ()
(run-hooks 'prelude-rust-mode-hook)))))
(run-hooks 'prelude-rust-mode-hook))))
(provide 'prelude-rust)
;;; prelude-rust.el ends here

View file

@ -38,8 +38,7 @@
(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode))
(eval-after-load 'typescript-mode
'(progn
(with-eval-after-load 'typescript-mode
(defun prelude-ts-mode-defaults ()
(interactive)
(tide-setup)
@ -53,7 +52,7 @@
(setq prelude-ts-mode-hook 'prelude-ts-mode-defaults)
(add-hook 'typescript-mode-hook (lambda () (run-hooks 'prelude-ts-mode-hook)))))
(add-hook 'typescript-mode-hook (lambda () (run-hooks 'prelude-ts-mode-hook))))
(provide 'prelude-ts)

View file

@ -61,13 +61,12 @@
(sp-local-tag "=" "<%= " " %>")
(sp-local-tag "#" "<%# " " %>"))
(eval-after-load 'web-mode
'(progn
(with-eval-after-load 'web-mode
(defun prelude-web-mode-defaults ())
(setq prelude-web-mode-hook 'prelude-web-mode-defaults)
(add-hook 'web-mode-hook (lambda ()
(run-hooks 'prelude-web-mode-hook)))))
(run-hooks 'prelude-web-mode-hook))))
(provide 'prelude-web)
;;; prelude-web.el ends here