summaryrefslogtreecommitdiffstats
path: root/.emacs.d
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-12-31 02:16:30 +0100
committerGravatar Tom Willemse2013-12-31 02:28:56 +0100
commita34f8dd9161f8b8943cb1b41ac771f589c5ff40d (patch)
treefb520b2942c376ce555bdf8b94758b1ae0282d5c /.emacs.d
parenta131dca8a3550532aa9799787b16374802c629ad (diff)
downloademacs-a34f8dd9161f8b8943cb1b41ac771f589c5ff40d.tar.gz
emacs-a34f8dd9161f8b8943cb1b41ac771f589c5ff40d.zip
Reorder hooks
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/init.el189
1 files changed, 106 insertions, 83 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 0356162..ba5fd23 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -49,6 +49,18 @@ FEATURE may be an unquoted feature symbol or a file name, see
(eval-after-load ',feature
`(funcall (function ,(lambda () ,@forms)))))))
+(defmacro oni:add-hooks (hook &rest functions)
+ "Add to HOOK each function in FUNCTIONS."
+ (declare (indent 1))
+ `(progn
+ ,@(mapcar (lambda (func) `(add-hook ,hook ,func)) functions)))
+
+(defmacro oni:add-function-to-hooks (func &rest hooks)
+ "Add FUNCTION to each hook in HOOKS."
+ (declare (indent 1))
+ `(progn
+ ,@(mapcar (lambda (hook) `(add-hook ,hook ,func)) hooks)))
+
(defmacro oni:email (user at host dot com)
"Turn arguments into an email address.
The resulting email address will look like: USER@HOST.COM, AT and
@@ -95,14 +107,6 @@ MODE1 is enabled and vice-versa."
(add-hook ',(intern (concat mode1-name "-hook"))
#',function-name))))
-(defmacro oni:mode-hooks (&rest lst)
- "Apply `add-mode-hooks' to each element of LST."
- (declare (indent 0))
- `(progn
- ,@(level (mapcar
- #'(lambda (itm)
- (add-mode-hooks (car itm) (list 'quote (cadr itm)))) lst))))
-
(defmacro oni:stumpwm (&rest body)
"Execute BODY in stumpwm."
(declare (indent 0))
@@ -338,6 +342,11 @@ If COUNT has been specified indent by that much, otherwise look at
"Function for `js2-mode-hook'."
(oni:js-mode-func))
+(defun level (lst)
+ "Reduce a 2-level list LST to a flat list."
+ (let ((lsts (mapcar (lambda (l) (if (listp l) l (list l))) lst)))
+ (apply #'append lsts)))
+
(defun init-locally-enable-double-spaces ()
"Specify that two spaces end a sentence in the current buffer."
(setq-local sentence-end-double-space t))
@@ -361,6 +370,11 @@ If COUNT has been specified indent by that much, otherwise look at
(when (buffer-file-name)
(fci-mode)))
+(defun oni:maybe-prettify-symbols-mode (&optional arg)
+ "See of `prettify-symbols-mode' is bound and call it if so."
+ (when (fboundp 'prettify-symbols-mode)
+ (prettify-symbols-mode arg)))
+
(defun oni:mini-fix-timestamp-string (date-string)
"A minimal version of Xah Lee's `fix-timestamp-string'.
Turn DATE-STRING into something else that can be worked with in
@@ -793,21 +807,6 @@ If no direction is given, don't split."
;;;;; Macro support
(eval-and-compile
- (defun add-hooks (hooks function &optional append local)
- "`add-hook' for each in HOOKS."
- (mapcar (lambda (h)
- `(add-hook (quote ,h) ,function ,append ,local))
- hooks))
-
- (defun add-mode-hooks (modes function &optional append local)
- "`add-hooks' with MODES renamed to mode-mode-hook."
- (let ((mode-names (mapcar #'make-mode-hook-name modes)))
- (add-hooks mode-names function append local)))
-
- (defun level (lst)
- (let ((lsts (mapcar (lambda (l) (if (listp l) l (list l))) lst)))
- (apply #'append lsts)))
-
(defun loadpath-add-and-autoload (path)
"Add PATH to `load-path' and load a `loaddefs.el' if it exists."
(add-to-list 'load-path path)
@@ -1206,76 +1205,100 @@ If no direction is given, don't split."
;;;; Hooks
-;; Use double spaces to end lines in Emacs Lisp. The checkdoc
-;; function starts complaining if you don't.
-(add-hook 'emacs-lisp-mode-hook #'init-locally-enable-double-spaces)
-
(add-hook 'after-save-hook 'oni:after-save-func t)
(add-hook 'before-save-hook 'oni:before-save-func)
-(add-hook 'c-mode-hook #'smartparens-strict-mode)
-(add-hook 'c-mode-hook 'oni:c-mode-func)
-(add-hook 'css-mode-hook 'oni:css-mode-func)
+(add-hook 'comint-mode-hook #'turn-on-compilation-shell-for-pony)
(add-hook 'diary-display-hook 'oni:diary-display-func)
-(add-hook 'emacs-lisp-mode-hook #'init-set-emacs-lisp-symbols)
-(add-hook 'go-mode-hook 'oni:go-mode-func)
(add-hook 'haskell-mode-hook 'oni:haskell-mode-func)
-(add-hook 'jabber-chat-mode-hook #'init-set-keys-for-jabber-chat)
(add-hook 'java-mode-hook 'oni:java-mode-func)
-(add-hook 'javascript-mode-hook 'moz-minor-mode)
-(add-hook 'js-mode-hook 'oni:js-mode-func)
-(add-hook 'js2-mode-hook #'tern-mode)
-(add-hook 'js2-mode-hook 'oni:js2-mode-func)
-(add-hook 'lisp-mode-hook #'init-set-emacs-lisp-symbols)
-(add-hook 'lua-mode-hook 'oni:lua-mode-func)
-(add-hook 'markdown-mode-hook 'oni:markdown-mode-func)
+(add-hook 'org-mode-hook #'yas-minor-mode)
(add-hook 'outline-minor-mode-hook #'init-set-tab-maybe-toggle-outline)
-(add-hook 'php-mode-hook 'oni:php-mode-func)
-(add-hook 'prog-mode-hook 'oni:prog-mode-func)
-(add-hook 'python-mode-hook #'init-set-python-symbols)
-(add-hook 'python-mode-hook 'oni:python-mode-func)
+(add-hook 'slime-mode-hook #'set-up-slime-ac)
+(add-hook 'smartparens-mode-hook #'set-smartparens-keys)
+(add-hook 'sql-interactive-mode-hook #'init-augment-sql-prompt)
(add-hook 'term-mode-hook 'oni:term-mode-func)
+(add-hook 'vala-mode-hook #'oni:vala-mode-func)
(add-hook 'write-file-hooks 'oni:write-file-func)
(add-hook 'yas-minor-mode-hook 'oni:yas-minor-mode-func)
-(when (fboundp 'prettify-symbols-mode)
- (add-hook 'prog-mode-hook 'prettify-symbols-mode))
-
-(oni:mode-hooks
- ((clojure emacs-lisp lisp sawfish scheme ielm geiser-repl slime-repl)
- paredit-mode)
- ((comint) turn-on-compilation-shell-for-pony)
- ((css) rainbow-mode)
- ((emacs-lisp go html lua perl php python rst ruby rust sh)
- flycheck-mode)
- ((emacs-lisp ielm) eldoc-mode)
- ((emacs-lisp ielm) set-emacs-lisp-keys)
- ((eshell) buffer-disable-undo)
- ((eshell) init-set-keys-for-eshell)
- ((git-commit text) auto-fill-mode)
- ((git-commit text) flyspell-mode)
- ((html org prog) yas-minor-mode)
- ((html prog) init-maybe-fci-mode)
- ((html) tagedit-mode)
- ((html) turn-off-flyspell)
- ((html) turn-off-auto-fill)
- ((hy) paredit-mode)
- ((hy) init-set-keys-for-hy)
- ((js2 python) smartparens-strict-mode)
- ((markdown python) whitespace-mode)
- ((message org gnus-summary gnus-article gnus-group magit-log-edit Info
- info org-agenda jabber-chat)
- init-make-readable)
- ((prog) rainbow-delimiters-mode)
- ((python) init-set-python-imenu-function)
- ((python) jedi:setup)
- ((python) subword-mode)
- ((slime slime-repl) set-up-slime-ac)
- ((smartparens) set-smartparens-keys)
- ((sql-interactive) init-augment-sql-prompt)
- ((tagedit) tagedit-add-experimental-features)
- ((tagedit) tagedit-add-paredit-like-keybindings)
- ((tagedit) init-set-keys-for-tagedit)
- ((vala) oni:vala-mode-func))
+(oni:add-function-to-hooks #'flycheck-mode
+ 'perl-mode-hook 'rst-mode-hook 'ruby-mode-hook 'rust-mode-hook
+ 'sh-mode-hook)
+
+(oni:add-function-to-hooks #'init-make-readable
+ 'Info-mode-hook 'gnus-article-mode-hook 'gnus-group-mode-hook
+ 'gnus-summary-mode-hook 'org-agenda-mode-hook)
+
+(oni:add-function-to-hooks #'paredit-mode
+ 'clojure-mode-hook 'geiser-repl-mode-hook 'sawfish-mode-hook
+ 'scheme-mode-hook)
+
+(oni:add-hooks 'c-mode-hook
+ #'smartparens-strict-mode #'oni:c-mode-func)
+
+(oni:add-hooks 'css-mode-hook
+ #'oni:css-mode-func #'rainbow-mode)
+
+(oni:add-hooks 'emacs-lisp-mode-hook
+ #'init-locally-enable-double-spaces #'init-set-emacs-lisp-symbols
+ #'paredit-mode #'flycheck-mode #'eldoc-mode #'set-emacs-lisp-keys)
+
+(oni:add-hooks 'eshell-mode-hook
+ #'buffer-disable-undo #'init-set-keys-for-eshell)
+
+(oni:add-hooks 'go-mode-hook
+ #'oni:go-mode-func #'flycheck-mode)
+
+(oni:add-hooks 'html-mode-hook
+ #'flycheck-mode #'yas-minor-mode #'init-maybe-fci-mode #'tagedit-mode
+ #'turn-off-flyspell #'turn-off-auto-fill)
+
+(oni:add-hooks 'hy-mode-hook
+ #'paredit-mode #'init-set-keys-for-hy)
+
+(oni:add-hooks 'ielm-mode-hook
+ #'paredit-mode #'eldoc-mode #'set-emacs-lisp-keys)
+
+(oni:add-hooks 'jabber-chat-mode-hook
+ #'init-set-keys-for-jabber-chat #'init-make-readable)
+
+(oni:add-hooks 'js-mode-hook
+ #'moz-minor-mode #'oni:js-mode-func)
+
+(oni:add-hooks 'js2-mode-hook
+ #'tern-mode #'oni:js2-mode-func #'smartparens-strict-mode
+ #'moz-minor-mode)
+
+(oni:add-hooks 'lisp-mode-hook
+ #'init-set-emacs-lisp-symbols #'paredit-mode)
+
+(oni:add-hooks 'lua-mode-hook
+ #'oni:lua-mode-func #'flycheck-mode)
+
+(oni:add-hooks 'markdown-mode-hook
+ #'oni:markdown-mode-func #'whitespace-mode)
+
+(oni:add-hooks 'php-mode-hook
+ #'oni:php-mode-func #'flycheck-mode)
+
+(oni:add-hooks 'prog-mode-hook
+ #'oni:prog-mode-func #'yas-minor-mode #'init-maybe-fci-mode
+ #'rainbow-delimiters-mode #'oni:maybe-prettify-symbols-mode)
+
+(oni:add-hooks 'python-mode-hook
+ #'init-set-python-symbols #'oni:python-mode-func #'flycheck-mode
+ #'smartparens-strict-mode #'whitespace-mode
+ #'init-set-python-imenu-function #'jedi:setup #'subword-mode)
+
+(oni:add-hooks 'slime-repl-mode-hook
+ #'paredit-mode #'set-up-slime-ac)
+
+(oni:add-hooks 'tagedit-mode-hook
+ #'tagedit-add-experimental-features
+ #'tagedit-add-paredit-like-keybindings #'init-set-keys-for-tagedit)
+
+(oni:add-hooks 'text-mode-hook
+ #'auto-fill-mode #'flyspell-mode #'init-make-readable)
;;;; Keybindings