summaryrefslogtreecommitdiffstats
path: root/.emacs.d
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2011-09-06 10:28:41 +0200
committerGravatar Tom Willemsen2011-09-06 10:28:41 +0200
commit135bbeceaf3e7b058504819ca1fab6c4f00f7176 (patch)
treec101eb0c111ab98addb98d5329077d99c1ba531d /.emacs.d
parent27efcb33ece59af5c0f843f047758f2d31b7f55e (diff)
downloaddotfiles-135bbeceaf3e7b058504819ca1fab6c4f00f7176.tar.gz
dotfiles-135bbeceaf3e7b058504819ca1fab6c4f00f7176.zip
EMACS: Stop using lambdas for hooks
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/functions.el21
-rw-r--r--.emacs.d/init.el126
2 files changed, 73 insertions, 74 deletions
diff --git a/.emacs.d/functions.el b/.emacs.d/functions.el
index 5f3f1c0..8ceed5b 100644
--- a/.emacs.d/functions.el
+++ b/.emacs.d/functions.el
@@ -129,27 +129,6 @@ Currently adds | & ! . + = - / % * , < > ? : ->"
(if (string-equal suffix "el")
(byte-compile-file fname)))))
-(defun on-prog-mode ()
- (font-lock-add-keywords
- nil
- '(("\\b\\(0[xX][0-9a-fA-F]+[lL]?\\|[0-9]+\\.?[0-9]*\\([eE][-+]?[0-9]+\\)?\\([lL]\\|[fF]\\|[dD]\\)?\\)\\b"
- 0 font-lock-constant-face)
- ("\\b\\(\\.[0-9]+\\([eE][-+]?[0-9]+\\)?\\([lL]\\|[fF]\\|[dD]\\)?\\)\\b"
- 0 font-lock-constant-face)))
- (rainbow-delimiters-mode)
- (pretty-lambdas))
-
-(defun on-c-mode ()
- (local-set-key [f8] 'c-toggle-header-source)
- (local-set-key [f9] 'compile)
- (local-set-key [C-m] 'newline-and-indent)
- (local-set-key [C-return] 'newline))
-
-(defun on-html-mode ()
- (local-set-key [f9] 'browse-to-current-file)
- (setq fill-column 73)
- (auto-fill-mode))
-
(defun pretty-lambdas ()
(font-lock-add-keywords
nil `(("(\\(lambda\\>\\)"
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index eef5c4e..cb85a78 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -24,25 +24,49 @@
autopair-blink nil)
(setq-default autopair-dont-pair '(:string (?\' ?\") :comment (?\')))
-;; Column marker
+;;; Column marker
+(require 'column-marker)
+
(defun set-column-markers (cm1 cm2)
(column-marker-1 cm1)
(column-marker-2 cm2))
+
+;;; Prog mode
+(defun oni/prog-mode-hook ()
+ (font-lock-add-keywords
+ nil
+ '(("\\b\\(0[xX][0-9a-fA-F]+[lL]?\\|[0-9]+\\.?[0-9]*\\([eE][-+]?[0-9]+\\)?\\([lL]\\|[fF]\\|[dD]\\)?\\)\\b"
+ 0 font-lock-constant-face)
+ ("\\b\\(\\.[0-9]+\\([eE][-+]?[0-9]+\\)?\\([lL]\\|[fF]\\|[dD]\\)?\\)\\b"
+ 0 font-lock-constant-face)))
+ (rainbow-delimiters-mode)
+ (pretty-lambdas)
+ (set-column-markers 73 81))
-(require 'column-marker)
-
-(dolist (hook '(prog-mode-hook html-mode-hook))
- (add-hook hook
- (lambda ()
- (set-column-markers 73 81))))
+(if (>= emacs-major-version 24)
+ (add-hook 'prog-mode-hook 'oni/prog-mode-hook)
+ (add-hook 'c-mode-common-hook 'oni/prog-mode-hook)
+ (add-hook 'go-mode-hook 'oni/prog-mode-hook)
+ (add-hook 'emacs-lisp-mode-hook 'oni/prog-mode-hook))
+
+;;; HTML mode
+(defun oni/html-mode-hook ()
+ (set-column-markers 73 81)
+ (local-set-key [f9] 'browse-to-current-file)
+ (setq fill-column 73))
-(add-hook 'php-mode-hook
- (lambda ()
- (set-column-markers 76 81)))
+(add-hook 'html-mode-hook 'oni/html-mode-hook)
+(add-to-list 'auto-mode-alist '("\\.tpl$" . html-mode))
+(add-html-keywords)
;;; Org mode
(require 'org-crypt)
(require 'org-publish)
+
+(defun oni/org-mode-hook ()
+ (turn-on-flyspell)
+ (turn-on-auto-fill))
+
(setq
org-tags-exclude-from-inheritance '("crypt")
org-crypt-key "33E8CC1CC4"
@@ -70,10 +94,7 @@
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-ca" 'org-agenda)
-(add-hook 'org-mode-hook
- (lambda ()
- (flyspell-mode t)
- (auto-fill-mode t)))
+(add-hook 'org-mode-hook 'oni/org-mode-hook)
(org-crypt-use-before-save-magic)
;;; Rainbow delimiters
@@ -84,15 +105,15 @@
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward)
-;;; Go
+;;; Go mode
+(defun oni/go-mode-hook ()
+ (turn-off-auto-fill))
+
(autoload 'go-mode "go-mode" "Major mode for google go" t)
(autoload 'gofmt "go-mode" "" t)
(autoload 'go-fmt-before-save "go-mode" "" t)
(add-to-list 'auto-mode-alist '("\\.go$" . go-mode))
-(add-hook 'go-mode-hook
- (lambda ()
- (turn-off-auto-fill)
- (column-marker-1 -1)))
+(add-hook 'go-mode-hook 'oni/go-mode-hook)
;;; Htmlize
(require 'htmlize)
@@ -102,47 +123,58 @@
(require 'git)
;;; Markdown mode
+(defun oni/markdown-mode-hook ()
+ (whitespace-mode 1)
+ (turn-on-auto-fill))
+
(autoload 'markdown-mode "markdown-mode" "Major mode for Markdown" t)
(setq whitespace-style '(face trailing)) ; For use with markdown mode
(add-to-list 'auto-mode-alist '("\\.m\\(ark\\)?do?wn$". markdown-mode))
-(add-hook 'markdown-mode-hook
- (lambda ()
- (whitespace-mode 1)
- (turn-on-auto-fill)))
+(add-hook 'markdown-mode-hook 'oni/markdown-mode-hook)
;;; Xmodmap mode
(autoload 'xmodmap-mode "xmodmap-mode" "Major mode for xmodmap" t)
(add-to-list 'auto-mode-alist '("\\.[xX]modmap\\(rc\\)?$" . xmodmap-mode))
;;; Gtags
+(defun oni/gtags-mode-hook ()
+ (local-set-key "\M-," 'gtags-find-tag)
+ (local-set-key "\M-." 'gtags-find-rtag))
+
(autoload 'gtags-mode "gtags" "Minor mode for using gtags" t)
-(add-hook 'gtags-mode-hook
- (lambda ()
- (local-set-key (kbd "M-,") 'gtags-find-tag) ; find a tag,
- ; also M-.
- (local-set-key (kbd "M-.") 'gtags-find-rtag))) ; reverse
- ; tag
-
-(add-hook 'c-mode-common-hook
- (lambda ()
- (gtags-mode t)
- (djcb-gtags-create-or-update)))
+(add-hook 'gtags-mode-hook 'oni/gtags-mode-hook)
+
+;;; C mode
+(defun oni/c-mode-common-hook ()
+ (gtags-mode t)
+ (djcb-gtags-create-or-update))
+
+(defun oni/c-mode-hook ()
+ (local-set-key [f8] 'c-toggle-header-source)
+ (local-set-key [f9] 'compile)
+ (local-set-key [C-m] 'newline-and-indent)
+ (local-set-key [C-return] 'newline))
+
+(add-hook 'c-mode-common-hook 'oni/c-mode-common-hook)
+(add-hook 'c-mode-hook 'oni/c-mode-hook)
-;;; PHP
+;;; PHP mode
(defun oni/php-show-outline ()
(interactive)
(occur "\\(function .*(\\|\\(public\\|private\\|protected\\)\\( static\\)? \\$\\|class \\sw\\)"))
+(defun oni/php-mode-hook ()
+ (c-set-offset 'arglist-intro '+)
+ (c-set-offset 'arglist-close '0)
+ (local-set-key [f6] 'comment-line)
+ (local-set-key [f7] 'oni/php-show-outline)
+ (set-column-markers 76 81))
+
(autoload 'php-mode "php-mode" "Major mode for PHP" t)
(setq-default php-mode-warn-if-mumamo-off nil) ; don't warn me about this
(setq php-mode-force-pear t)
(add-to-list 'auto-mode-alist '("\\.php[345]?$" . php-mode))
-(add-hook 'php-mode-hook
- (lambda ()
- (c-set-offset 'arglist-intro '+)
- (c-set-offset 'arglist-close '0)
- (local-set-key [f6] 'comment-line)
- (local-set-key [f7] 'oni/php-show-outline)))
+(add-hook 'php-mode-hook 'oni/php-mode-hook)
(add-php-keywords)
;;; bidi
@@ -259,7 +291,6 @@
(add-to-list 'auto-mode-alist '("\\.css$" . css-mode))
(add-to-list 'auto-mode-alist '("stumpwmrc" . stumpwm-mode))
(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG$" . git-commit-mode))
-(add-to-list 'auto-mode-alist '("\\.tpl$" . html-mode))
(add-to-list 'file-coding-system-alist '("\\.vala$" . utf-8))
(add-to-list 'file-coding-system-alist '("\\.vapi$" . utf-8))
@@ -282,16 +313,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'before-save-hook 'on-before-save)
(add-hook 'after-save-hook 'on-after-save)
-
-(if (>= emacs-major-version 24)
- (add-hook 'prog-mode-hook 'on-prog-mode)
- (progn
- (add-hook 'c-mode-common-hook 'on-prog-mode)
- (add-hook 'go-mode-hook 'on-prog-mode)
- (add-hook 'emacs-lisp-mode-hook 'on-prog-mode)))
-
-(add-hook 'c-mode-hook 'on-c-mode)
-(add-hook 'html-mode-hook 'on-html-mode)
(add-hook 'git-commit-mode-hook 'auto-fill-mode)
(add-hook 'css-mode-hook 'rainbow-mode)
@@ -377,7 +398,6 @@
"?>\n"
'(indent-region (point-min) (point-max)))
-(add-html-keywords)
(make-face 'font-lock-operator-face)
(make-face 'font-lock-end-statement)
(set-face-foreground 'font-lock-operator-face "#EDD400")