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:
parent
0ce648b699
commit
cecae9ca19
15 changed files with 145 additions and 160 deletions
6
init.el
6
init.el
|
@ -137,9 +137,9 @@ 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)
|
||||
(list start end))))
|
||||
(with-eval-after-load "enriched"
|
||||
(defun enriched-decode-display-prop (start end &optional param)
|
||||
(list start end))))
|
||||
|
||||
(prelude-eval-after-init
|
||||
;; greet the use with some useful tip
|
||||
|
|
|
@ -35,31 +35,29 @@
|
|||
(require 'prelude-lisp)
|
||||
(prelude-require-packages '(clojure-mode cider))
|
||||
|
||||
(eval-after-load 'clojure-mode
|
||||
'(progn
|
||||
(defun prelude-clojure-mode-defaults ()
|
||||
(subword-mode +1)
|
||||
(run-hooks 'prelude-lisp-coding-hook))
|
||||
(with-eval-after-load 'clojure-mode
|
||||
(defun prelude-clojure-mode-defaults ()
|
||||
(subword-mode +1)
|
||||
(run-hooks 'prelude-lisp-coding-hook))
|
||||
|
||||
(setq prelude-clojure-mode-hook 'prelude-clojure-mode-defaults)
|
||||
(setq prelude-clojure-mode-hook 'prelude-clojure-mode-defaults)
|
||||
|
||||
(add-hook 'clojure-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-clojure-mode-hook)))))
|
||||
(add-hook 'clojure-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-clojure-mode-hook))))
|
||||
|
||||
(eval-after-load 'cider
|
||||
'(progn
|
||||
(setq nrepl-log-messages t)
|
||||
(with-eval-after-load 'cider
|
||||
(setq nrepl-log-messages t)
|
||||
|
||||
(add-hook 'cider-mode-hook 'eldoc-mode)
|
||||
(add-hook 'cider-mode-hook 'eldoc-mode)
|
||||
|
||||
(defun prelude-cider-repl-mode-defaults ()
|
||||
(subword-mode +1)
|
||||
(run-hooks 'prelude-interactive-lisp-coding-hook))
|
||||
(defun prelude-cider-repl-mode-defaults ()
|
||||
(subword-mode +1)
|
||||
(run-hooks 'prelude-interactive-lisp-coding-hook))
|
||||
|
||||
(setq prelude-cider-repl-mode-hook 'prelude-cider-repl-mode-defaults)
|
||||
(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)))))
|
||||
(add-hook 'cider-repl-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-cider-repl-mode-hook))))
|
||||
|
||||
(provide 'prelude-clojure)
|
||||
|
||||
|
|
|
@ -35,26 +35,25 @@
|
|||
(require 'prelude-programming)
|
||||
(prelude-require-package 'coffee-mode)
|
||||
|
||||
(eval-after-load 'coffee-mode
|
||||
'(progn
|
||||
;; CoffeeScript uses two spaces.
|
||||
(setq coffee-tab-width 2)
|
||||
(with-eval-after-load 'coffee-mode
|
||||
;; CoffeeScript uses two spaces.
|
||||
(setq coffee-tab-width 2)
|
||||
|
||||
;; remove the "Generated by CoffeeScript" header
|
||||
(add-to-list 'coffee-args-compile "--no-header")
|
||||
;; remove the "Generated by CoffeeScript" header
|
||||
(add-to-list 'coffee-args-compile "--no-header")
|
||||
|
||||
(defun prelude-coffee-mode-defaults ()
|
||||
;; Update the already compiled js on save
|
||||
(and (buffer-file-name)
|
||||
(file-exists-p (buffer-file-name))
|
||||
(file-exists-p (coffee-compiled-file-name (buffer-file-name)))
|
||||
(coffee-cos-mode t))
|
||||
(subword-mode +1))
|
||||
(defun prelude-coffee-mode-defaults ()
|
||||
;; Update the already compiled js on save
|
||||
(and (buffer-file-name)
|
||||
(file-exists-p (buffer-file-name))
|
||||
(file-exists-p (coffee-compiled-file-name (buffer-file-name)))
|
||||
(coffee-cos-mode t))
|
||||
(subword-mode +1))
|
||||
|
||||
(setq prelude-coffee-mode-hook 'prelude-coffee-mode-defaults)
|
||||
(setq prelude-coffee-mode-hook 'prelude-coffee-mode-defaults)
|
||||
|
||||
(add-hook 'coffee-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-coffee-mode-hook)))))
|
||||
(add-hook 'coffee-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-coffee-mode-hook))))
|
||||
(provide 'prelude-coffee)
|
||||
|
||||
;;; prelude-coffee.el ends here
|
||||
|
|
|
@ -71,14 +71,13 @@
|
|||
(smartparens-strict-mode +1)
|
||||
(whitespace-mode -1)))
|
||||
|
||||
(eval-after-load "slime"
|
||||
'(progn
|
||||
(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)))
|
||||
(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))
|
||||
|
||||
(provide 'prelude-common-lisp)
|
||||
|
||||
|
|
|
@ -32,20 +32,19 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(eval-after-load 'css-mode
|
||||
'(progn
|
||||
(prelude-require-packages '(rainbow-mode))
|
||||
(with-eval-after-load 'css-mode
|
||||
(prelude-require-packages '(rainbow-mode))
|
||||
|
||||
(setq css-indent-offset 2)
|
||||
(setq css-indent-offset 2)
|
||||
|
||||
(defun prelude-css-mode-defaults ()
|
||||
(rainbow-mode +1)
|
||||
(run-hooks 'prelude-prog-mode-hook))
|
||||
(defun prelude-css-mode-defaults ()
|
||||
(rainbow-mode +1)
|
||||
(run-hooks 'prelude-prog-mode-hook))
|
||||
|
||||
(setq prelude-css-mode-hook 'prelude-css-mode-defaults)
|
||||
(setq prelude-css-mode-hook 'prelude-css-mode-defaults)
|
||||
|
||||
(add-hook 'css-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-css-mode-hook)))))
|
||||
(add-hook 'css-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-css-mode-hook))))
|
||||
|
||||
(provide 'prelude-css)
|
||||
;;; prelude-css.el ends here
|
||||
|
|
|
@ -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
|
||||
(define-key ielm-map (kbd "M-(") (prelude-wrap-with "("))
|
||||
(define-key ielm-map (kbd "M-\"") (prelude-wrap-with "\""))))
|
||||
(with-eval-after-load "ielm"
|
||||
(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))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -44,41 +44,40 @@
|
|||
|
||||
(define-key 'help-command (kbd "G") 'godoc)
|
||||
|
||||
(eval-after-load 'go-mode
|
||||
'(progn
|
||||
(defun prelude-go-mode-defaults ()
|
||||
;; Add to default go-mode key bindings
|
||||
(let ((map go-mode-map))
|
||||
(define-key map (kbd "C-c a") 'go-test-current-project) ;; current package, really
|
||||
(define-key map (kbd "C-c m") 'go-test-current-file)
|
||||
(define-key map (kbd "C-c .") 'go-test-current-test)
|
||||
(define-key map (kbd "C-c b") 'go-run)
|
||||
(define-key map (kbd "C-h f") 'godoc-at-point))
|
||||
(with-eval-after-load 'go-mode
|
||||
(defun prelude-go-mode-defaults ()
|
||||
;; Add to default go-mode key bindings
|
||||
(let ((map go-mode-map))
|
||||
(define-key map (kbd "C-c a") 'go-test-current-project) ;; current package, really
|
||||
(define-key map (kbd "C-c m") 'go-test-current-file)
|
||||
(define-key map (kbd "C-c .") 'go-test-current-test)
|
||||
(define-key map (kbd "C-c b") 'go-run)
|
||||
(define-key map (kbd "C-h f") 'godoc-at-point))
|
||||
|
||||
;; Prefer goimports to gofmt if installed
|
||||
(let ((goimports (executable-find "goimports")))
|
||||
(when goimports
|
||||
(setq gofmt-command goimports)))
|
||||
;; Prefer goimports to gofmt if installed
|
||||
(let ((goimports (executable-find "goimports")))
|
||||
(when goimports
|
||||
(setq gofmt-command goimports)))
|
||||
|
||||
;; gofmt on save
|
||||
(add-hook 'before-save-hook 'gofmt-before-save nil t)
|
||||
;; gofmt on save
|
||||
(add-hook 'before-save-hook 'gofmt-before-save nil t)
|
||||
|
||||
;; stop whitespace being highlighted
|
||||
(whitespace-toggle-options '(tabs))
|
||||
;; stop whitespace being highlighted
|
||||
(whitespace-toggle-options '(tabs))
|
||||
|
||||
;; Company mode settings
|
||||
(set (make-local-variable 'company-backends) '(company-go))
|
||||
;; Company mode settings
|
||||
(set (make-local-variable 'company-backends) '(company-go))
|
||||
|
||||
;; El-doc for Go
|
||||
(go-eldoc-setup)
|
||||
;; El-doc for Go
|
||||
(go-eldoc-setup)
|
||||
|
||||
;; CamelCase aware editing operations
|
||||
(subword-mode +1))
|
||||
;; CamelCase aware editing operations
|
||||
(subword-mode +1))
|
||||
|
||||
(setq prelude-go-mode-hook 'prelude-go-mode-defaults)
|
||||
(setq prelude-go-mode-hook 'prelude-go-mode-defaults)
|
||||
|
||||
(add-hook 'go-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-go-mode-hook)))))
|
||||
(add-hook 'go-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-go-mode-hook))))
|
||||
|
||||
(provide 'prelude-go)
|
||||
;;; prelude-go.el ends here
|
||||
|
|
|
@ -35,18 +35,17 @@
|
|||
(require 'prelude-programming)
|
||||
(prelude-require-packages '(haskell-mode))
|
||||
|
||||
(eval-after-load 'haskell-mode
|
||||
'(progn
|
||||
(defun prelude-haskell-mode-defaults ()
|
||||
(subword-mode +1)
|
||||
(eldoc-mode +1)
|
||||
(haskell-indentation-mode +1)
|
||||
(interactive-haskell-mode +1))
|
||||
(with-eval-after-load 'haskell-mode
|
||||
(defun prelude-haskell-mode-defaults ()
|
||||
(subword-mode +1)
|
||||
(eldoc-mode +1)
|
||||
(haskell-indentation-mode +1)
|
||||
(interactive-haskell-mode +1))
|
||||
|
||||
(setq prelude-haskell-mode-hook 'prelude-haskell-mode-defaults)
|
||||
(setq prelude-haskell-mode-hook 'prelude-haskell-mode-defaults)
|
||||
|
||||
(add-hook 'haskell-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-haskell-mode-hook)))))
|
||||
(add-hook 'haskell-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-haskell-mode-hook))))
|
||||
|
||||
(provide 'prelude-haskell)
|
||||
|
||||
|
|
|
@ -41,17 +41,16 @@
|
|||
(add-to-list 'auto-mode-alist '("\\.pac\\'" . js2-mode))
|
||||
(add-to-list 'interpreter-mode-alist '("node" . js2-mode))
|
||||
|
||||
(eval-after-load 'js2-mode
|
||||
'(progn
|
||||
(defun prelude-js-mode-defaults ()
|
||||
;; electric-layout-mode doesn't play nice with smartparens
|
||||
(setq-local electric-layout-rules '((?\; . after)))
|
||||
(setq mode-name "JS2")
|
||||
(js2-imenu-extras-mode +1))
|
||||
(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)))
|
||||
(setq mode-name "JS2")
|
||||
(js2-imenu-extras-mode +1))
|
||||
|
||||
(setq prelude-js-mode-hook 'prelude-js-mode-defaults)
|
||||
(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)
|
||||
|
||||
|
|
|
@ -37,10 +37,9 @@
|
|||
;; for case
|
||||
(require 'cl)
|
||||
|
||||
(eval-after-load "company"
|
||||
'(progn
|
||||
(prelude-require-packages '(company-auctex))
|
||||
(company-auctex-init)))
|
||||
(with-eval-after-load "company"
|
||||
(prelude-require-packages '(company-auctex))
|
||||
(company-auctex-init))
|
||||
|
||||
(defcustom prelude-latex-fast-math-entry 'LaTeX-math-mode
|
||||
"Method used for fast math symbol entry in LaTeX."
|
||||
|
|
|
@ -41,17 +41,16 @@
|
|||
|
||||
(define-key 'help-command (kbd "R") 'yari)
|
||||
|
||||
(eval-after-load 'ruby-mode
|
||||
'(progn
|
||||
(defun prelude-ruby-mode-defaults ()
|
||||
(inf-ruby-minor-mode +1)
|
||||
;; CamelCase aware editing operations
|
||||
(subword-mode +1))
|
||||
(with-eval-after-load 'ruby-mode
|
||||
(defun prelude-ruby-mode-defaults ()
|
||||
(inf-ruby-minor-mode +1)
|
||||
;; CamelCase aware editing operations
|
||||
(subword-mode +1))
|
||||
|
||||
(setq prelude-ruby-mode-hook 'prelude-ruby-mode-defaults)
|
||||
(setq prelude-ruby-mode-hook 'prelude-ruby-mode-defaults)
|
||||
|
||||
(add-hook 'ruby-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-ruby-mode-hook)))))
|
||||
(add-hook 'ruby-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-ruby-mode-hook))))
|
||||
|
||||
(provide 'prelude-ruby)
|
||||
;;; prelude-ruby.el ends here
|
||||
|
|
|
@ -44,23 +44,22 @@
|
|||
|
||||
(setq rust-format-on-save t)
|
||||
|
||||
(eval-after-load 'rust-mode
|
||||
'(progn
|
||||
(add-hook 'rust-mode-hook 'racer-mode)
|
||||
(add-hook 'racer-mode-hook 'eldoc-mode)
|
||||
(add-hook 'rust-mode-hook 'cargo-minor-mode)
|
||||
(add-hook 'rust-mode-hook 'flycheck-rust-setup)
|
||||
(add-hook 'flycheck-mode-hook 'flycheck-rust-setup)
|
||||
(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)
|
||||
(add-hook 'rust-mode-hook 'flycheck-rust-setup)
|
||||
(add-hook 'flycheck-mode-hook 'flycheck-rust-setup)
|
||||
|
||||
(defun prelude-rust-mode-defaults ()
|
||||
(local-set-key (kbd "C-c C-d") 'racer-describe)
|
||||
;; CamelCase aware editing operations
|
||||
(subword-mode +1))
|
||||
(defun prelude-rust-mode-defaults ()
|
||||
(local-set-key (kbd "C-c C-d") 'racer-describe)
|
||||
;; CamelCase aware editing operations
|
||||
(subword-mode +1))
|
||||
|
||||
(setq prelude-rust-mode-hook 'prelude-rust-mode-defaults)
|
||||
(setq prelude-rust-mode-hook 'prelude-rust-mode-defaults)
|
||||
|
||||
(add-hook 'rust-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-rust-mode-hook)))))
|
||||
(add-hook 'rust-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-rust-mode-hook))))
|
||||
|
||||
(provide 'prelude-rust)
|
||||
;;; prelude-rust.el ends here
|
||||
|
|
|
@ -38,22 +38,21 @@
|
|||
|
||||
(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode))
|
||||
|
||||
(eval-after-load 'typescript-mode
|
||||
'(progn
|
||||
(defun prelude-ts-mode-defaults ()
|
||||
(interactive)
|
||||
(tide-setup)
|
||||
(flycheck-mode +1)
|
||||
(setq flycheck-check-syntax-automatically '(save mode-enabled))
|
||||
(eldoc-mode +1)
|
||||
(tide-hl-identifier-mode +1))
|
||||
(with-eval-after-load 'typescript-mode
|
||||
(defun prelude-ts-mode-defaults ()
|
||||
(interactive)
|
||||
(tide-setup)
|
||||
(flycheck-mode +1)
|
||||
(setq flycheck-check-syntax-automatically '(save mode-enabled))
|
||||
(eldoc-mode +1)
|
||||
(tide-hl-identifier-mode +1))
|
||||
|
||||
;; formats the buffer before saving
|
||||
(add-hook 'before-save-hook 'tide-format-before-save)
|
||||
;; formats the buffer before saving
|
||||
(add-hook 'before-save-hook 'tide-format-before-save)
|
||||
|
||||
(setq prelude-ts-mode-hook 'prelude-ts-mode-defaults)
|
||||
(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)
|
||||
|
||||
|
|
|
@ -61,13 +61,12 @@
|
|||
(sp-local-tag "=" "<%= " " %>")
|
||||
(sp-local-tag "#" "<%# " " %>"))
|
||||
|
||||
(eval-after-load 'web-mode
|
||||
'(progn
|
||||
(defun prelude-web-mode-defaults ())
|
||||
(setq prelude-web-mode-hook 'prelude-web-mode-defaults)
|
||||
(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)))))
|
||||
(add-hook 'web-mode-hook (lambda ()
|
||||
(run-hooks 'prelude-web-mode-hook))))
|
||||
|
||||
(provide 'prelude-web)
|
||||
;;; prelude-web.el ends here
|
||||
|
|
Loading…
Reference in a new issue