EMACS: Stop using lambdas for hooks

This commit is contained in:
Tom Willemsen 2011-09-06 10:28:41 +02:00
parent 27efcb33ec
commit 135bbeceaf
2 changed files with 73 additions and 74 deletions

View file

@ -129,27 +129,6 @@ Currently adds | & ! . + = - / % * , < > ? : ->"
(if (string-equal suffix "el") (if (string-equal suffix "el")
(byte-compile-file fname))))) (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 () (defun pretty-lambdas ()
(font-lock-add-keywords (font-lock-add-keywords
nil `(("(\\(lambda\\>\\)" nil `(("(\\(lambda\\>\\)"

View file

@ -24,25 +24,49 @@
autopair-blink nil) autopair-blink nil)
(setq-default autopair-dont-pair '(:string (?\' ?\") :comment (?\'))) (setq-default autopair-dont-pair '(:string (?\' ?\") :comment (?\')))
;; Column marker ;;; Column marker
(require 'column-marker)
(defun set-column-markers (cm1 cm2) (defun set-column-markers (cm1 cm2)
(column-marker-1 cm1) (column-marker-1 cm1)
(column-marker-2 cm2)) (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) (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))
(dolist (hook '(prog-mode-hook html-mode-hook)) (add-hook 'html-mode-hook 'oni/html-mode-hook)
(add-hook hook (add-to-list 'auto-mode-alist '("\\.tpl$" . html-mode))
(lambda () (add-html-keywords)
(set-column-markers 73 81))))
(add-hook 'php-mode-hook
(lambda ()
(set-column-markers 76 81)))
;;; Org mode ;;; Org mode
(require 'org-crypt) (require 'org-crypt)
(require 'org-publish) (require 'org-publish)
(defun oni/org-mode-hook ()
(turn-on-flyspell)
(turn-on-auto-fill))
(setq (setq
org-tags-exclude-from-inheritance '("crypt") org-tags-exclude-from-inheritance '("crypt")
org-crypt-key "33E8CC1CC4" org-crypt-key "33E8CC1CC4"
@ -70,10 +94,7 @@
(global-set-key "\C-cl" 'org-store-link) (global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-cc" 'org-capture) (global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-ca" 'org-agenda) (global-set-key "\C-ca" 'org-agenda)
(add-hook 'org-mode-hook (add-hook 'org-mode-hook 'oni/org-mode-hook)
(lambda ()
(flyspell-mode t)
(auto-fill-mode t)))
(org-crypt-use-before-save-magic) (org-crypt-use-before-save-magic)
;;; Rainbow delimiters ;;; Rainbow delimiters
@ -84,15 +105,15 @@
(require 'uniquify) (require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward) (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 'go-mode "go-mode" "Major mode for google go" t)
(autoload 'gofmt "go-mode" "" t) (autoload 'gofmt "go-mode" "" t)
(autoload 'go-fmt-before-save "go-mode" "" t) (autoload 'go-fmt-before-save "go-mode" "" t)
(add-to-list 'auto-mode-alist '("\\.go$" . go-mode)) (add-to-list 'auto-mode-alist '("\\.go$" . go-mode))
(add-hook 'go-mode-hook (add-hook 'go-mode-hook 'oni/go-mode-hook)
(lambda ()
(turn-off-auto-fill)
(column-marker-1 -1)))
;;; Htmlize ;;; Htmlize
(require 'htmlize) (require 'htmlize)
@ -102,47 +123,58 @@
(require 'git) (require 'git)
;;; Markdown mode ;;; Markdown mode
(defun oni/markdown-mode-hook ()
(whitespace-mode 1)
(turn-on-auto-fill))
(autoload 'markdown-mode "markdown-mode" "Major mode for Markdown" t) (autoload 'markdown-mode "markdown-mode" "Major mode for Markdown" t)
(setq whitespace-style '(face trailing)) ; For use with markdown mode (setq whitespace-style '(face trailing)) ; For use with markdown mode
(add-to-list 'auto-mode-alist '("\\.m\\(ark\\)?do?wn$". markdown-mode)) (add-to-list 'auto-mode-alist '("\\.m\\(ark\\)?do?wn$". markdown-mode))
(add-hook 'markdown-mode-hook (add-hook 'markdown-mode-hook 'oni/markdown-mode-hook)
(lambda ()
(whitespace-mode 1)
(turn-on-auto-fill)))
;;; Xmodmap mode ;;; Xmodmap mode
(autoload 'xmodmap-mode "xmodmap-mode" "Major mode for xmodmap" t) (autoload 'xmodmap-mode "xmodmap-mode" "Major mode for xmodmap" t)
(add-to-list 'auto-mode-alist '("\\.[xX]modmap\\(rc\\)?$" . xmodmap-mode)) (add-to-list 'auto-mode-alist '("\\.[xX]modmap\\(rc\\)?$" . xmodmap-mode))
;;; Gtags ;;; Gtags
(autoload 'gtags-mode "gtags" "Minor mode for using gtags" t) (defun oni/gtags-mode-hook ()
(add-hook 'gtags-mode-hook (local-set-key "\M-," 'gtags-find-tag)
(lambda () (local-set-key "\M-." 'gtags-find-rtag))
(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 (autoload 'gtags-mode "gtags" "Minor mode for using gtags" t)
(lambda () (add-hook 'gtags-mode-hook 'oni/gtags-mode-hook)
(gtags-mode t)
(djcb-gtags-create-or-update)))
;;; PHP ;;; 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 mode
(defun oni/php-show-outline () (defun oni/php-show-outline ()
(interactive) (interactive)
(occur "\\(function .*(\\|\\(public\\|private\\|protected\\)\\( static\\)? \\$\\|class \\sw\\)")) (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) (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-default php-mode-warn-if-mumamo-off nil) ; don't warn me about this
(setq php-mode-force-pear t) (setq php-mode-force-pear t)
(add-to-list 'auto-mode-alist '("\\.php[345]?$" . php-mode)) (add-to-list 'auto-mode-alist '("\\.php[345]?$" . php-mode))
(add-hook 'php-mode-hook (add-hook 'php-mode-hook 'oni/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-php-keywords) (add-php-keywords)
;;; bidi ;;; bidi
@ -259,7 +291,6 @@
(add-to-list 'auto-mode-alist '("\\.css$" . css-mode)) (add-to-list 'auto-mode-alist '("\\.css$" . css-mode))
(add-to-list 'auto-mode-alist '("stumpwmrc" . stumpwm-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 '("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 '("\\.vala$" . utf-8))
(add-to-list 'file-coding-system-alist '("\\.vapi$" . 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 'before-save-hook 'on-before-save)
(add-hook 'after-save-hook 'on-after-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 'git-commit-mode-hook 'auto-fill-mode)
(add-hook 'css-mode-hook 'rainbow-mode) (add-hook 'css-mode-hook 'rainbow-mode)
@ -377,7 +398,6 @@
"?>\n" "?>\n"
'(indent-region (point-min) (point-max))) '(indent-region (point-min) (point-max)))
(add-html-keywords)
(make-face 'font-lock-operator-face) (make-face 'font-lock-operator-face)
(make-face 'font-lock-end-statement) (make-face 'font-lock-end-statement)
(set-face-foreground 'font-lock-operator-face "#EDD400") (set-face-foreground 'font-lock-operator-face "#EDD400")