Convert all prelude-*-mode-hooks into actual hooks (allow add-hook)
This commit is contained in:
parent
cc2836c4f6
commit
04b1fe44c3
17 changed files with 111 additions and 49 deletions
2
init.el
2
init.el
|
@ -99,7 +99,7 @@ by Prelude.")
|
||||||
(when (file-exists-p prelude-personal-dir)
|
(when (file-exists-p prelude-personal-dir)
|
||||||
(mapc 'load (directory-files prelude-personal-dir nil "^[^#].*el$")))
|
(mapc 'load (directory-files prelude-personal-dir nil "^[^#].*el$")))
|
||||||
|
|
||||||
(message "Emacs Prelude is ready to do thy bidding, Master, %s!"
|
(message "Emacs Prelude is ready to do thy bidding, Master %s!"
|
||||||
(getenv "USER"))
|
(getenv "USER"))
|
||||||
|
|
||||||
;;; init.el ends here
|
;;; init.el ends here
|
||||||
|
|
|
@ -32,18 +32,22 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(defun prelude-c-mode-common-hook ()
|
(defun prelude-c-mode-common-defaults ()
|
||||||
|
(setq indent-tabs-mode t)
|
||||||
(setq c-basic-offset 4))
|
(setq c-basic-offset 4))
|
||||||
|
|
||||||
|
(setq prelude-c-mode-common-hook 'prelude-c-mode-common-defaults)
|
||||||
|
|
||||||
;; this will affect all modes derived from cc-mode, like
|
;; this will affect all modes derived from cc-mode, like
|
||||||
;; java-mode, php-mode, etc
|
;; java-mode, php-mode, etc
|
||||||
(add-hook 'c-mode-common-hook 'prelude-c-mode-common-hook)
|
(add-hook 'c-mode-common-hook (lambda () (run-hooks 'prelude-c-mode-common-hook)))
|
||||||
|
|
||||||
(defun prelude-makefile-mode-hook ()
|
(defun prelude-makefile-mode-defaults ()
|
||||||
(setq indent-tabs-mode t)
|
(setq indent-tabs-mode t))
|
||||||
(setq tab-width 4))
|
|
||||||
|
|
||||||
(add-hook 'makefile-mode-hook 'prelude-makefile-mode-hook)
|
(setq prelude-makefile-mode-hook 'prelude-makefile-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'makefile-mode-hook (lambda () (run-hook 'prelude-makefile-mode-hook)))
|
||||||
|
|
||||||
(provide 'prelude-c)
|
(provide 'prelude-c)
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,12 @@
|
||||||
;; 2. Invoke M-x clojure-jack-in from a project
|
;; 2. Invoke M-x clojure-jack-in from a project
|
||||||
(require 'clojure-mode)
|
(require 'clojure-mode)
|
||||||
|
|
||||||
(defun prelude-clojure-mode-hook ()
|
(defun prelude-clojure-mode-defaults ()
|
||||||
(prelude-lisp-coding-hook))
|
(run-hooks 'prelude-lisp-coding-hook))
|
||||||
|
|
||||||
(add-hook 'clojure-mode-hook 'prelude-clojure-mode-hook)
|
(setq prelude-clojure-mode-hook 'prelude-clojure-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'clojure-mode-hook (lambda () (run-hooks 'prelude-clojure-mode-hook)))
|
||||||
|
|
||||||
(provide 'prelude-clojure)
|
(provide 'prelude-clojure)
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
|
|
||||||
(require 'coffee-mode)
|
(require 'coffee-mode)
|
||||||
|
|
||||||
(defun prelude-coffee-mode-hook ()
|
(defun prelude-coffee-mode-defaults ()
|
||||||
"coffee-mode-hook"
|
"coffee-mode-defaults"
|
||||||
|
|
||||||
;; CoffeeScript uses two spaces.
|
;; CoffeeScript uses two spaces.
|
||||||
(set (make-local-variable 'tab-width) 2)
|
(set (make-local-variable 'tab-width) 2)
|
||||||
|
@ -64,7 +64,9 @@
|
||||||
(file-exists-p (coffee-compiled-file-name))
|
(file-exists-p (coffee-compiled-file-name))
|
||||||
(coffee-cos-mode t)))
|
(coffee-cos-mode t)))
|
||||||
|
|
||||||
(add-hook 'coffee-mode-hook 'prelude-coffee-mode-hook)
|
(setq prelude-coffee-mode-hook 'prelude-coffee-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'coffee-mode-hook (lambda () (run-hooks 'prelude-coffee-mode-hook)))
|
||||||
|
|
||||||
(provide 'prelude-coffee)
|
(provide 'prelude-coffee)
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@
|
||||||
;; default to SBCL on Linux and Windows
|
;; default to SBCL on Linux and Windows
|
||||||
(setq slime-default-lisp 'sbcl))
|
(setq slime-default-lisp 'sbcl))
|
||||||
|
|
||||||
(add-hook 'lisp-mode-hook 'prelude-lisp-coding-hook)
|
(add-hook 'lisp-mode-hook (lambda () (run-hooks 'prelude-lisp-coding-hook)))
|
||||||
(add-hook 'slime-repl-mode-hook 'prelude-interactive-lisp-coding-hook)
|
(add-hook 'slime-repl-mode-hook (lambda () (run-hooks 'prelude-interactive-lisp-coding-hook)))
|
||||||
|
|
||||||
;; start slime automatically when we open a lisp file
|
;; start slime automatically when we open a lisp file
|
||||||
(defun prelude-start-slime ()
|
(defun prelude-start-slime ()
|
||||||
|
|
|
@ -42,20 +42,24 @@
|
||||||
(if (file-exists-p (concat buffer-file-name "c"))
|
(if (file-exists-p (concat buffer-file-name "c"))
|
||||||
(delete-file (concat buffer-file-name "c"))))))
|
(delete-file (concat buffer-file-name "c"))))))
|
||||||
|
|
||||||
(defun prelude-emacs-lisp-mode-hook ()
|
(defun prelude-emacs-lisp-mode-defaults ()
|
||||||
(prelude-lisp-coding-hook)
|
(run-hooks 'prelude-lisp-coding-hook)
|
||||||
(turn-on-eldoc-mode)
|
(turn-on-eldoc-mode)
|
||||||
(prelude-remove-elc-on-save)
|
(prelude-remove-elc-on-save)
|
||||||
(rainbow-mode +1))
|
(rainbow-mode +1))
|
||||||
|
|
||||||
(add-hook 'emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-hook)
|
(setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'emacs-lisp-mode-hook (lambda () (run-hooks 'prelude-emacs-lisp-mode-hook)))
|
||||||
|
|
||||||
;; ielm is an interactive Emacs Lisp shell
|
;; ielm is an interactive Emacs Lisp shell
|
||||||
(defun prelude-ielm-mode-hook ()
|
(defun prelude-ielm-mode-defaults ()
|
||||||
(prelude-interactive-lisp-coding-hook)
|
(run-hooks 'prelude-interactive-lisp-coding-hook)
|
||||||
(turn-on-eldoc-mode))
|
(turn-on-eldoc-mode))
|
||||||
|
|
||||||
(add-hook 'ielm-mode-hook 'prelude-ielm-mode-hook)
|
(setq prelude-ielm-mode-hook 'prelude-ielm-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'ielm-mode-hook (lambda () (run-hooks 'prelude-ielm-mode-hook)))
|
||||||
|
|
||||||
(define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
|
(define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,15 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(defun prelude-haskell-mode-hook ()
|
(defun prelude-haskell-mode-defaults ()
|
||||||
(prelude-prog-mode-hook)
|
(run-hooks 'prelude-prog-mode-hook) ;; run manually; not derived from prog-mode
|
||||||
(subword-mode +1)
|
(subword-mode +1)
|
||||||
(turn-on-haskell-doc-mode)
|
(turn-on-haskell-doc-mode)
|
||||||
(turn-on-haskell-indentation))
|
(turn-on-haskell-indentation))
|
||||||
|
|
||||||
(add-hook 'haskell-mode-hook 'prelude-haskell-mode-hook)
|
(setq prelude-haskell-mode-hook 'prelude-haskell-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'haskell-mode-hook (lambda () (run-hooks 'prelude-haskell-mode-hook)))
|
||||||
|
|
||||||
(provide 'prelude-haskell)
|
(provide 'prelude-haskell)
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,13 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(defun prelude-js-mode-hook ()
|
(defun prelude-js-mode-defaults ()
|
||||||
;; electric-layout-mode doesn't play nice with js-mode
|
;; electric-layout-mode doesn't play nice with js-mode
|
||||||
(electric-layout-mode -1))
|
(electric-layout-mode -1))
|
||||||
|
|
||||||
(add-hook 'js-mode-hook 'prelude-js-mode-hook)
|
(setq prelude-js-mode-hook 'prelude-js-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'js-mode-hook (lambda () (run-hooks 'prelude-js-mode-hook)))
|
||||||
|
|
||||||
(provide 'prelude-js)
|
(provide 'prelude-js)
|
||||||
|
|
||||||
|
|
|
@ -52,11 +52,13 @@
|
||||||
("PDF Viewer" "open %o")
|
("PDF Viewer" "open %o")
|
||||||
("HTML Viewer" "open %o")))
|
("HTML Viewer" "open %o")))
|
||||||
|
|
||||||
(defun prelude-latex-mode-hook ()
|
(defun prelude-latex-mode-defaults ()
|
||||||
(turn-on-auto-fill)
|
(turn-on-auto-fill)
|
||||||
(abbrev-mode +1))
|
(abbrev-mode +1))
|
||||||
|
|
||||||
(add-hook 'LaTeX-mode-hook 'prelude-latex-mode-hook)
|
(setq prelude-latex-mode-hook 'prelude-latex-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'LaTeX-mode-hook (lambda () (run-hooks 'prelude-latex-mode-hook)))
|
||||||
|
|
||||||
(provide 'prelude-latex)
|
(provide 'prelude-latex)
|
||||||
|
|
||||||
|
|
|
@ -36,14 +36,18 @@
|
||||||
(define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
|
(define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
|
||||||
|
|
||||||
;; a great lisp coding hook
|
;; a great lisp coding hook
|
||||||
(defun prelude-lisp-coding-hook ()
|
(defun prelude-lisp-coding-defaults ()
|
||||||
(paredit-mode +1))
|
(paredit-mode +1))
|
||||||
|
|
||||||
|
(setq prelude-lisp-coding-hook 'prelude-lisp-coding-defaults)
|
||||||
|
|
||||||
;; interactive modes don't need whitespace checks
|
;; interactive modes don't need whitespace checks
|
||||||
(defun prelude-interactive-lisp-coding-hook ()
|
(defun prelude-interactive-lisp-coding-defaults ()
|
||||||
(paredit-mode +1)
|
(paredit-mode +1)
|
||||||
(prelude-turn-off-whitespace))
|
(prelude-turn-off-whitespace))
|
||||||
|
|
||||||
|
(setq prelude-interactive-lisp-coding-hook 'prelude-interactive-lisp-coding-defaults)
|
||||||
|
|
||||||
(provide 'prelude-lisp)
|
(provide 'prelude-lisp)
|
||||||
|
|
||||||
;;; prelude-lisp.el ends here
|
;;; prelude-lisp.el ends here
|
||||||
|
|
|
@ -38,10 +38,12 @@
|
||||||
(global-set-key "\C-cb" 'org-iswitchb)
|
(global-set-key "\C-cb" 'org-iswitchb)
|
||||||
(setq org-log-done t)
|
(setq org-log-done t)
|
||||||
|
|
||||||
(defun prelude-org-mode-hook ()
|
(defun prelude-org-mode-defaults ()
|
||||||
(electric-indent-mode -1))
|
(electric-indent-mode -1))
|
||||||
|
|
||||||
(add-hook 'org-mode-hook 'prelude-org-mode-hook)
|
(setq prelude-org-mode-hook 'prelude-org-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'org-mode-hook (lambda () (run-hooks 'prelude-org-mode-hook)))
|
||||||
|
|
||||||
(provide 'prelude-org)
|
(provide 'prelude-org)
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
;; use cperl-mode instead of perl-mode
|
;; use cperl-mode instead of perl-mode
|
||||||
(defalias 'perl-mode 'cperl-mode)
|
(defalias 'perl-mode 'cperl-mode)
|
||||||
|
|
||||||
(defun prelude-cperl-mode-hook ()
|
(defun prelude-cperl-mode-defaults ()
|
||||||
(setq cperl-indent-level 4)
|
(setq cperl-indent-level 4)
|
||||||
(setq cperl-continued-statement-offset 8)
|
(setq cperl-continued-statement-offset 8)
|
||||||
;; cperl-hairy affects all those variables, but I prefer
|
;; cperl-hairy affects all those variables, but I prefer
|
||||||
|
@ -56,7 +56,9 @@
|
||||||
(set-face-background 'cperl-hash-face nil)
|
(set-face-background 'cperl-hash-face nil)
|
||||||
(setq cperl-invalid-face nil))
|
(setq cperl-invalid-face nil))
|
||||||
|
|
||||||
(add-hook 'cperl-mode-hook 'prelude-cperl-mode-hook t)
|
(setq prelude-cperl-mode-hook 'prelude-cperl-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'cperl-mode-hook (lambda () (run-hooks 'prelude-cperl-mode-hook)) t)
|
||||||
|
|
||||||
(provide 'prelude-perl)
|
(provide 'prelude-perl)
|
||||||
|
|
||||||
|
|
|
@ -95,19 +95,29 @@
|
||||||
(require 'which-func)
|
(require 'which-func)
|
||||||
(which-func-mode 1)
|
(which-func-mode 1)
|
||||||
|
|
||||||
(defun prelude-prog-mode-hook ()
|
;; in Emacs 24 programming major modes generally derive from a common
|
||||||
|
;; mode named prog-mode; for others, we'll arrange for our mode
|
||||||
|
;; defaults function to run prelude-prog-mode-hook directly. To
|
||||||
|
;; augment and/or counteract these defaults your own function
|
||||||
|
;; to prelude-prog-mode-hook, using:
|
||||||
|
;;
|
||||||
|
;; (add-hook 'prelude-prog-mode-hook 'my-prog-mode-defaults t)
|
||||||
|
;;
|
||||||
|
;; (the final optional t sets the *append* argument)
|
||||||
|
|
||||||
|
(defun prelude-prog-mode-defaults ()
|
||||||
"Default coding hook, useful with any programming language."
|
"Default coding hook, useful with any programming language."
|
||||||
(flyspell-prog-mode)
|
(flyspell-prog-mode)
|
||||||
(prelude-local-comment-auto-fill)
|
(prelude-local-comment-auto-fill)
|
||||||
(prelude-turn-on-whitespace)
|
(prelude-turn-on-whitespace)
|
||||||
(prelude-turn-on-abbrev)
|
(prelude-turn-on-abbrev)
|
||||||
(prelude-add-watchwords)
|
(prelude-add-watchwords)
|
||||||
;; keep the whitespace decent all the time
|
;; keep the whitespace decent all the time (in this buffer)
|
||||||
(add-hook 'before-save-hook 'whitespace-cleanup nil t))
|
(add-hook 'before-save-hook 'whitespace-cleanup nil t))
|
||||||
|
|
||||||
;; in Emacs 24 programming major modes generally derive
|
(setq prelude-prog-mode-hook 'prelude-prog-mode-defaults)
|
||||||
;; from a common mode named prog-mode
|
|
||||||
(add-hook 'prog-mode-hook 'prelude-prog-mode-hook)
|
(add-hook 'prog-mode-hook (lambda () (run-hooks 'prelude-prog-mode-hook)))
|
||||||
|
|
||||||
(provide 'prelude-programming)
|
(provide 'prelude-programming)
|
||||||
;;; prelude-programming.el ends here
|
;;; prelude-programming.el ends here
|
||||||
|
|
|
@ -35,11 +35,13 @@
|
||||||
|
|
||||||
(require 'python)
|
(require 'python)
|
||||||
|
|
||||||
(defun prelude-python-mode-hook ()
|
(defun prelude-python-mode-defaults ()
|
||||||
(prelude-prog-mode-hook)
|
(run-hooks 'prelude-prog-mode-hook) ;; run manually; not derived from prog-mode
|
||||||
(electric-indent-mode -1))
|
(electric-indent-mode -1))
|
||||||
|
|
||||||
(add-hook 'python-mode-hook 'prelude-python-mode-hook)
|
(setq prelude-python-mode-hook 'prelude-python-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'python-mode-hook (lambda () (run-hooks 'prelude-python-mode-hook)))
|
||||||
|
|
||||||
(provide 'prelude-python)
|
(provide 'prelude-python)
|
||||||
|
|
||||||
|
|
|
@ -59,30 +59,36 @@
|
||||||
(require 'ruby-block)
|
(require 'ruby-block)
|
||||||
(require 'ruby-end)
|
(require 'ruby-end)
|
||||||
|
|
||||||
(defun prelude-ruby-mode-hook ()
|
(defun prelude-ruby-mode-defaults ()
|
||||||
(inf-ruby-keys)
|
(inf-ruby-keys)
|
||||||
;; turn off the annoying input echo in irb
|
;; turn off the annoying input echo in irb
|
||||||
(setq comint-process-echoes t)
|
(setq comint-process-echoes t)
|
||||||
(ruby-block-mode t)
|
(ruby-block-mode t)
|
||||||
(local-set-key (kbd "C-h r") 'yari))
|
(local-set-key (kbd "C-h r") 'yari))
|
||||||
|
|
||||||
(add-hook 'ruby-mode-hook 'prelude-ruby-mode-hook)
|
(setq prelude-ruby-mode-hook 'prelude-ruby-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'ruby-mode-hook (lambda () (run-hooks 'prelude-ruby-mode-hook)))
|
||||||
|
|
||||||
(require 'haml-mode)
|
(require 'haml-mode)
|
||||||
(require 'scss-mode)
|
(require 'scss-mode)
|
||||||
|
|
||||||
(defun prelude-css-mode-hook ()
|
(defun prelude-css-mode-defaults ()
|
||||||
(setq css-indent-offset 2)
|
(setq css-indent-offset 2)
|
||||||
(rainbow-mode +1))
|
(rainbow-mode +1))
|
||||||
|
|
||||||
(add-hook 'css-mode-hook 'prelude-css-mode-hook)
|
(setq prelude-css-mode-hook 'prelude-css-mode-defaults)
|
||||||
|
|
||||||
(defun prelude-scss-mode-hook ()
|
(add-hook 'css-mode-hook (lambda () (run-hooks 'prelude-css-mode-hook)))
|
||||||
|
|
||||||
|
(defun prelude-scss-mode-defaults ()
|
||||||
(prelude-css-mode-hook)
|
(prelude-css-mode-hook)
|
||||||
;; turn off annoying auto-compile on save
|
;; turn off annoying auto-compile on save
|
||||||
(setq scss-compile-at-save nil))
|
(setq scss-compile-at-save nil))
|
||||||
|
|
||||||
(add-hook 'scss-mode-hook 'prelude-scss-mode-hook)
|
(setq prelude-scss-mode-hook 'prelude-scss-mode-defaults)
|
||||||
|
|
||||||
|
(add-hook 'scss-mode-hook (lambda () (run-hooks 'prelude-scss-mode-hook)))
|
||||||
|
|
||||||
;; cucumber support
|
;; cucumber support
|
||||||
(require 'feature-mode)
|
(require 'feature-mode)
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(add-hook 'scheme-mode-hook 'prelude-lisp-coding-hook)
|
(add-hook 'scheme-mode-hook (lambda () (run-hooks 'prelude-lisp-coding-hook)))
|
||||||
|
|
||||||
(provide 'prelude-scheme)
|
(provide 'prelude-scheme)
|
||||||
|
|
||||||
|
|
18
personal/example_el
Normal file
18
personal/example_el
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
;; example_el -- Rename to example.el to activate, and restart emacs
|
||||||
|
|
||||||
|
;; Here are some examples of how to override the defaults for the
|
||||||
|
;; various prelude-emacs settings. To *append* to any of the
|
||||||
|
;; configurations attached to prelude-*-hooks, you can attach a
|
||||||
|
;; function to the appropriate hook:
|
||||||
|
|
||||||
|
(add-hook 'prelude-prog-mode-hook
|
||||||
|
(lambda ()
|
||||||
|
(prelude-turn-off-whitespace)
|
||||||
|
(remove-hook 'before-save-hook 'whitespace-cleanup)) t)
|
||||||
|
|
||||||
|
;; For other global settings, just run the appropriate function; all
|
||||||
|
;; personal/*.el files will be evaluate after prelude-emacs is loaded.
|
||||||
|
|
||||||
|
(global-hl-line-mode -1)
|
||||||
|
(blink-cursor-mode t)
|
Loading…
Reference in a new issue