Convert all prelude-*-mode-hooks into actual hooks (allow add-hook)

This commit is contained in:
Perry Kundert 2012-02-27 12:50:28 -07:00
parent cc2836c4f6
commit 04b1fe44c3
17 changed files with 111 additions and 49 deletions

View file

@ -99,7 +99,7 @@ by Prelude.")
(when (file-exists-p prelude-personal-dir)
(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"))
;;; init.el ends here

View file

@ -32,18 +32,22 @@
;;; Code:
(defun prelude-c-mode-common-hook ()
(defun prelude-c-mode-common-defaults ()
(setq indent-tabs-mode t)
(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
;; 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 ()
(setq indent-tabs-mode t)
(setq tab-width 4))
(defun prelude-makefile-mode-defaults ()
(setq indent-tabs-mode t))
(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)

View file

@ -39,10 +39,12 @@
;; 2. Invoke M-x clojure-jack-in from a project
(require 'clojure-mode)
(defun prelude-clojure-mode-hook ()
(prelude-lisp-coding-hook))
(defun prelude-clojure-mode-defaults ()
(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)

View file

@ -34,8 +34,8 @@
(require 'coffee-mode)
(defun prelude-coffee-mode-hook ()
"coffee-mode-hook"
(defun prelude-coffee-mode-defaults ()
"coffee-mode-defaults"
;; CoffeeScript uses two spaces.
(set (make-local-variable 'tab-width) 2)
@ -64,7 +64,9 @@
(file-exists-p (coffee-compiled-file-name))
(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)

View file

@ -63,8 +63,8 @@
;; default to SBCL on Linux and Windows
(setq slime-default-lisp 'sbcl))
(add-hook 'lisp-mode-hook 'prelude-lisp-coding-hook)
(add-hook 'slime-repl-mode-hook 'prelude-interactive-lisp-coding-hook)
(add-hook 'lisp-mode-hook (lambda () (run-hooks 'prelude-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
(defun prelude-start-slime ()

View file

@ -42,20 +42,24 @@
(if (file-exists-p (concat buffer-file-name "c"))
(delete-file (concat buffer-file-name "c"))))))
(defun prelude-emacs-lisp-mode-hook ()
(prelude-lisp-coding-hook)
(defun prelude-emacs-lisp-mode-defaults ()
(run-hooks 'prelude-lisp-coding-hook)
(turn-on-eldoc-mode)
(prelude-remove-elc-on-save)
(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
(defun prelude-ielm-mode-hook ()
(prelude-interactive-lisp-coding-hook)
(defun prelude-ielm-mode-defaults ()
(run-hooks 'prelude-interactive-lisp-coding-hook)
(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)

View file

@ -32,13 +32,15 @@
;;; Code:
(defun prelude-haskell-mode-hook ()
(prelude-prog-mode-hook)
(defun prelude-haskell-mode-defaults ()
(run-hooks 'prelude-prog-mode-hook) ;; run manually; not derived from prog-mode
(subword-mode +1)
(turn-on-haskell-doc-mode)
(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)

View file

@ -32,11 +32,13 @@
;;; Code:
(defun prelude-js-mode-hook ()
(defun prelude-js-mode-defaults ()
;; electric-layout-mode doesn't play nice with js-mode
(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)

View file

@ -52,11 +52,13 @@
("PDF Viewer" "open %o")
("HTML Viewer" "open %o")))
(defun prelude-latex-mode-hook ()
(defun prelude-latex-mode-defaults ()
(turn-on-auto-fill)
(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)

View file

@ -36,14 +36,18 @@
(define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
;; a great lisp coding hook
(defun prelude-lisp-coding-hook ()
(defun prelude-lisp-coding-defaults ()
(paredit-mode +1))
(setq prelude-lisp-coding-hook 'prelude-lisp-coding-defaults)
;; interactive modes don't need whitespace checks
(defun prelude-interactive-lisp-coding-hook ()
(defun prelude-interactive-lisp-coding-defaults ()
(paredit-mode +1)
(prelude-turn-off-whitespace))
(setq prelude-interactive-lisp-coding-hook 'prelude-interactive-lisp-coding-defaults)
(provide 'prelude-lisp)
;;; prelude-lisp.el ends here

View file

@ -38,10 +38,12 @@
(global-set-key "\C-cb" 'org-iswitchb)
(setq org-log-done t)
(defun prelude-org-mode-hook ()
(defun prelude-org-mode-defaults ()
(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)

View file

@ -35,7 +35,7 @@
;; use cperl-mode instead of perl-mode
(defalias 'perl-mode 'cperl-mode)
(defun prelude-cperl-mode-hook ()
(defun prelude-cperl-mode-defaults ()
(setq cperl-indent-level 4)
(setq cperl-continued-statement-offset 8)
;; cperl-hairy affects all those variables, but I prefer
@ -56,7 +56,9 @@
(set-face-background 'cperl-hash-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)

View file

@ -95,19 +95,29 @@
(require 'which-func)
(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."
(flyspell-prog-mode)
(prelude-local-comment-auto-fill)
(prelude-turn-on-whitespace)
(prelude-turn-on-abbrev)
(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))
;; in Emacs 24 programming major modes generally derive
;; from a common mode named prog-mode
(add-hook 'prog-mode-hook 'prelude-prog-mode-hook)
(setq prelude-prog-mode-hook 'prelude-prog-mode-defaults)
(add-hook 'prog-mode-hook (lambda () (run-hooks 'prelude-prog-mode-hook)))
(provide 'prelude-programming)
;;; prelude-programming.el ends here

View file

@ -35,11 +35,13 @@
(require 'python)
(defun prelude-python-mode-hook ()
(prelude-prog-mode-hook)
(defun prelude-python-mode-defaults ()
(run-hooks 'prelude-prog-mode-hook) ;; run manually; not derived from prog-mode
(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)

View file

@ -59,30 +59,36 @@
(require 'ruby-block)
(require 'ruby-end)
(defun prelude-ruby-mode-hook ()
(defun prelude-ruby-mode-defaults ()
(inf-ruby-keys)
;; turn off the annoying input echo in irb
(setq comint-process-echoes t)
(ruby-block-mode t)
(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 'scss-mode)
(defun prelude-css-mode-hook ()
(defun prelude-css-mode-defaults ()
(setq css-indent-offset 2)
(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)
;; turn off annoying auto-compile on save
(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
(require 'feature-mode)

View file

@ -32,7 +32,7 @@
;;; 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)

18
personal/example_el Normal file
View 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)