Move some minor-mode management from oni.el

This commit is contained in:
Tom Willemse 2013-04-15 01:53:47 +02:00
parent a271d7d0fe
commit 0de90a0228
2 changed files with 75 additions and 73 deletions

View file

@ -1,3 +1,4 @@
;;;; Turn off useless visual components
;;; Turn the menu, scroll-bar and tool-bar off quickly, emacs startup ;;; Turn the menu, scroll-bar and tool-bar off quickly, emacs startup
;;; isn't as jittery. ;;; isn't as jittery.
(menu-bar-mode -1) (menu-bar-mode -1)
@ -52,14 +53,22 @@ package.el is loaded anyway."
;;; look at. ;;; look at.
(setq compilation-scroll-output t) (setq compilation-scroll-output t)
;;; Enable the excellent `paredit-mode' for any lisp-like languages. ;;;; Hooks
(add-hook 'clojure-mode-hook 'paredit-mode) ;;;;; Enable `auto-fill-mode' for some text-heavy modes.
(add-hook 'emacs-lisp-mode-hook 'paredit-mode)
(add-hook 'lisp-mode-hook 'paredit-mode) (add-hook 'prog-mode-hook 'auto-fill-mode)
(add-hook 'sawfish-mode-hook 'paredit-mode) (add-hook 'text-mode-hook 'auto-fill-mode)
(add-hook 'scheme-mode-hook 'paredit-mode)
;;;;; Enable `eldoc-mode' for some nice programming modes.
;;; Enable Flycheck for some modes.
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
;;;;; Enable `fill-column-indicator' for most programming modes.
(add-hook 'html-mode-hook 'fci-mode)
(add-hook 'prog-mode-hook 'fci-mode)
;;;;; Enable `flycheck-mode' for supported modes.
(add-hook 'css-mode-hook 'flycheck-mode) (add-hook 'css-mode-hook 'flycheck-mode)
(add-hook 'emacs-lisp-mode-hook 'flycheck-mode) (add-hook 'emacs-lisp-mode-hook 'flycheck-mode)
@ -73,7 +82,56 @@ package.el is loaded anyway."
(add-hook 'ruby-mode-hook 'flycheck-mode) (add-hook 'ruby-mode-hook 'flycheck-mode)
(add-hook 'rust-mode-hook 'flycheck-mode) (add-hook 'rust-mode-hook 'flycheck-mode)
(add-hook 'sh-mode-hook 'flycheck-mode) (add-hook 'sh-mode-hook 'flycheck-mode)
;;;;; Enable `flyspell-mode' for some text modes.
(add-hook 'text-mode-hook 'flyspell-mode)
;;;;; Enable `paredit-mode' for any lisp-like languages.
;;; Since all of these modes care heavily about their parentheses it
;;; is very easy to edit them as syntax trees, rather than unrelated
;;; bits of text. I also helps keep parens balanced.
(add-hook 'clojure-mode-hook 'paredit-mode)
(add-hook 'emacs-lisp-mode-hook 'paredit-mode)
(add-hook 'lisp-mode-hook 'paredit-mode)
(add-hook 'sawfish-mode-hook 'paredit-mode)
(add-hook 'scheme-mode-hook 'paredit-mode)
;;;;; Enable `rainbow-delimiters-mode' for programming modes.
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
;;;;; Enable `rainbow-mode' for some colorful modes.
(add-hook 'css-mode-hook 'rainbow-mode)
;;;;; Enable `slime-js-minor-mode' for `js2-mode'.
(add-hook 'js2-mode-hook 'slime-js-minor-mode)
;;;;; Enable `smartparens-mode' for some non-lisp modes.
(add-hook 'html-mode-hook 'smartparens-mode)
(add-hook 'python-mode-hook 'smartparens-mode)
;;;;; Enable `visual-line-mode' for some text modes.
(add-hook 'jabber-chat-mode-hook 'visual-line-mode)
;;;;; Enable `whitespace-mode' for some whitespace-caring modes.
(add-hook 'markdown-mode-hook 'whitespace-mode)
(add-hook 'python-mode-hook 'whitespace-mode)
;;;;; Enable `yas-minor-mode' for some heavy-duty modes.
(add-hook 'html-mode-hook 'yas-minor-mode)
(add-hook 'org-mode-hook 'yas-minor-mode)
(add-hook 'prog-mode-hook 'yas-minor-mode)
;;;; Rest
;;; Remove the pylint and pyflakes checkers from the flycheck ;;; Remove the pylint and pyflakes checkers from the flycheck
;;; configuration so the flake8 checker remains. ;;; configuration so the flake8 checker remains.
(eval-after-load "flycheck" (eval-after-load "flycheck"
@ -368,7 +426,6 @@ Also change directories to current working directory."
(brace-list-open . +) (brace-list-open . +)
(topmost-intro-cont first c-lineup-topmost-intro-cont (topmost-intro-cont first c-lineup-topmost-intro-cont
c-lineup-gnu-DEFUN-intro-cont))) c-lineup-gnu-DEFUN-intro-cont)))
(setq comment-auto-fill-only-comments t)
(setq custom-file "~/.emacs.d/custom.el") (setq custom-file "~/.emacs.d/custom.el")
(setq custom-theme-directory "~/.emacs.d/themes") (setq custom-theme-directory "~/.emacs.d/themes")
(setq default-frame-alist (setq default-frame-alist
@ -448,12 +505,9 @@ Also change directories to current working directory."
(add-hook 'css-mode-hook 'oni:css-mode-func) (add-hook 'css-mode-hook 'oni:css-mode-func)
(add-hook 'diary-display-hook 'oni:diary-display-func) (add-hook 'diary-display-hook 'oni:diary-display-func)
(add-hook 'emacs-startup-hook 'oni:emacs-startup-func) (add-hook 'emacs-startup-hook 'oni:emacs-startup-func)
(add-hook 'emacs-lisp-mode-hook 'oni:emacs-lisp-mode-func)
(add-hook 'go-mode-hook 'oni:go-mode-func) (add-hook 'go-mode-hook 'oni:go-mode-func)
(add-hook 'gtags-mode-hook 'oni:gtags-mode-func) (add-hook 'gtags-mode-hook 'oni:gtags-mode-func)
(add-hook 'haskell-mode-hook 'oni:haskell-mode-func) (add-hook 'haskell-mode-hook 'oni:haskell-mode-func)
(add-hook 'html-mode-hook 'oni:html-mode-func)
(add-hook 'jabber-chat-mode-hook 'oni:jabber-chat-mode-func)
(add-hook 'jabber-roster-mode-hook 'oni:jabber-roster-mode-func) (add-hook 'jabber-roster-mode-hook 'oni:jabber-roster-mode-func)
(add-hook 'java-mode-hook 'oni:java-mode-func) (add-hook 'java-mode-hook 'oni:java-mode-func)
(add-hook 'js-mode-hook 'oni:js-mode-func) (add-hook 'js-mode-hook 'oni:js-mode-func)
@ -461,14 +515,10 @@ Also change directories to current working directory."
(add-hook 'lua-mode-hook 'oni:lua-mode-func) (add-hook 'lua-mode-hook 'oni:lua-mode-func)
(add-hook 'magit-log-edit-mode-hook 'oni:magit-log-edit-mode-func) (add-hook 'magit-log-edit-mode-hook 'oni:magit-log-edit-mode-func)
(add-hook 'markdown-mode-hook 'oni:markdown-mode-func) (add-hook 'markdown-mode-hook 'oni:markdown-mode-func)
(add-hook 'message-mode-hook 'oni:message-mode-func)
(add-hook 'org-mode-hook 'oni:org-mode-func)
(add-hook 'php-mode-hook 'oni:php-mode-func) (add-hook 'php-mode-hook 'oni:php-mode-func)
(add-hook 'prog-mode-hook 'oni:prog-mode-func) (add-hook 'prog-mode-hook 'oni:prog-mode-func)
(add-hook 'python-mode-hook 'oni:python-mode-func) (add-hook 'python-mode-hook 'oni:python-mode-func)
(add-hook 'rst-mode-hook 'oni:rst-mode-func)
(add-hook 'term-mode-hook 'oni:term-mode-func) (add-hook 'term-mode-hook 'oni:term-mode-func)
(add-hook 'texinfo-mode-hook 'oni:texinfo-mode-func)
(add-hook 'write-file-hooks 'oni:write-file-func) (add-hook 'write-file-hooks 'oni:write-file-func)
(add-hook 'yas-minor-mode-hook 'oni:yas-minor-mode-func) (add-hook 'yas-minor-mode-hook 'oni:yas-minor-mode-func)
@ -585,9 +635,6 @@ Also change directories to current working directory."
(setq eltuki-blog-dir "~/documents/blog") (setq eltuki-blog-dir "~/documents/blog")
(setq sp-cancel-autoskip-on-backward-movement nil) (setq sp-cancel-autoskip-on-backward-movement nil)
(add-hook 'python-mode-hook 'smartparens-mode)
(add-hook 'html-mode-hook 'smartparens-mode)
(defun oni:scroll-down-or-prev-page (arg) (defun oni:scroll-down-or-prev-page (arg)
"Either scroll down or go to the previous page. "Either scroll down or go to the previous page.
@ -640,3 +687,7 @@ Depending on the value of `buffer-narrowed-p'."
;;; Finally, load any `customize' settings and slime. ;;; Finally, load any `customize' settings and slime.
(load custom-file) (load custom-file)
(load (expand-file-name "~/quicklisp/slime-helper.el")) (load (expand-file-name "~/quicklisp/slime-helper.el"))
;; Local Variables:
;; outline-regexp: ";;;;+"
;; End:

View file

@ -86,8 +86,7 @@ DOT are intentionally being skipped."
(defun oni:css-mode-func () (defun oni:css-mode-func ()
"Function for `css-mode-hook'." "Function for `css-mode-hook'."
(local-set-key "\C-j" 'oni:newline-and-indent) (local-set-key "\C-j" 'oni:newline-and-indent))
(rainbow-mode))
(defun oni:current-jabber-status () (defun oni:current-jabber-status ()
"Return a string representing the current jabber status." "Return a string representing the current jabber status."
@ -100,10 +99,6 @@ DOT are intentionally being skipped."
"Function for `diary-display-hook'." "Function for `diary-display-hook'."
(diary-fancy-display)) (diary-fancy-display))
(defun oni:emacs-lisp-mode-func ()
"Function for `emacs-lisp-mode-hook'."
(eldoc-mode))
(defun oni:emacs-startup-func () (defun oni:emacs-startup-func ()
"Function for `emacs-init-hook'." "Function for `emacs-init-hook'."
(require 'auto-complete-config) (require 'auto-complete-config)
@ -123,11 +118,6 @@ DOT are intentionally being skipped."
"Function for `haskell-mode-hook'." "Function for `haskell-mode-hook'."
(turn-on-haskell-indentation)) (turn-on-haskell-indentation))
(defun oni:html-mode-func ()
"Function for `html-mode-hook'."
(yas-minor-mode)
(fci-mode))
(defun oni:indent-shift-left (start end &optional count) (defun oni:indent-shift-left (start end &optional count)
"Rigidly indent region. "Rigidly indent region.
Region is from START to END. Move Region is from START to END. Move
@ -173,10 +163,6 @@ If COUNT has been specified indent by that much, otherwise look at
(notifications-notify :title title (notifications-notify :title title
:body text)) :body text))
(defun oni:jabber-chat-mode-func ()
"Function for `jabber-chat-mode-hook'."
(visual-line-mode))
(defun oni:jabber-roster-mode-func () (defun oni:jabber-roster-mode-func ()
"Function for `jabber-roster-mode-hook'." "Function for `jabber-roster-mode-hook'."
(setq mode-line-format (setq mode-line-format
@ -188,15 +174,12 @@ If COUNT has been specified indent by that much, otherwise look at
(defun oni:js-mode-func () (defun oni:js-mode-func ()
"Function for `js-mode-hook'." "Function for `js-mode-hook'."
(rainbow-delimiters-mode)
(local-set-key "\C-j" 'oni:newline-and-indent)) (local-set-key "\C-j" 'oni:newline-and-indent))
(defun oni:js2-mode-func () (defun oni:js2-mode-func ()
"Function for `js2-mode-hook'." "Function for `js2-mode-hook'."
(oni:prog-mode-func)
(oni:js-mode-func) (oni:js-mode-func)
(local-set-key (kbd "<f5>") #'slime-js-reload) (local-set-key (kbd "<f5>") #'slime-js-reload))
(slime-js-minor-mode))
(defun oni:kill-region-or-backward-char () (defun oni:kill-region-or-backward-char ()
"Either `kill-region' or `backward-delete-char-untabify'." "Either `kill-region' or `backward-delete-char-untabify'."
@ -227,7 +210,6 @@ If COUNT has been specified indent by that much, otherwise look at
(defun oni:magit-log-edit-mode-func () (defun oni:magit-log-edit-mode-func ()
"Function for `magit-log-edit-mode-hook'." "Function for `magit-log-edit-mode-hook'."
(auto-fill-mode)
(font-lock-add-keywords (font-lock-add-keywords
nil nil
'(("\\`\\(.\\{,50\\}\\)\\(.*\\)\n?\\(.*\\)$" '(("\\`\\(.\\{,50\\}\\)\\(.*\\)\n?\\(.*\\)$"
@ -239,16 +221,7 @@ If COUNT has been specified indent by that much, otherwise look at
(defun oni:markdown-mode-func () (defun oni:markdown-mode-func ()
"Function for `markdown-mode-hook'." "Function for `markdown-mode-hook'."
(setq-local comment-auto-fill-only-comments nil) (setq-local whitespace-style '(face trailing)))
(setq-local whitespace-style '(face trailing))
(auto-fill-mode)
(whitespace-mode))
(defun oni:message-mode-func ()
"Function for `message-mode-hook'."
(setq-local comment-auto-fill-only-comments nil)
(auto-fill-mode)
(flyspell-mode))
(defun oni:mini-fix-timestamp-string (date-string) (defun oni:mini-fix-timestamp-string (date-string)
"A minimal version of Xah Lee's `fix-timestamp-string'. "A minimal version of Xah Lee's `fix-timestamp-string'.
@ -326,38 +299,25 @@ When dealing with braces, add another line and indent that too."
(save-excursion (newline-and-indent))) (save-excursion (newline-and-indent)))
(newline-and-indent)) (newline-and-indent))
(defun oni:org-mode-func ()
"Function for `org-mode-hook'."
(auto-fill-mode)
(yas-minor-mode)
(setq-local comment-auto-fill-only-comments nil))
(defun oni:php-mode-func () (defun oni:php-mode-func ()
"Function for `php-mode-hook'." "Function for `php-mode-hook'."
(local-set-key "\C-j" 'oni:newline-and-indent) (local-set-key "\C-j" 'oni:newline-and-indent)
(c-set-offset 'arglist-intro '+) (c-set-offset 'arglist-intro '+)
(c-set-offset 'arglist-close '0) (c-set-offset 'arglist-close '0)
(rainbow-delimiters-mode)
(setq-local fci-rule-column 80)) (setq-local fci-rule-column 80))
(defun oni:prog-mode-func () (defun oni:prog-mode-func ()
"Function for `prog-mode-hook'." "Function for `prog-mode-hook'."
(rainbow-delimiters-mode) (setq-local comment-auto-fill-only-comments t))
(fci-mode)
(yas-minor-mode)
(auto-fill-mode))
(defun oni:python-mode-func () (defun oni:python-mode-func ()
"Function for `python-mode-hook'." "Function for `python-mode-hook'."
(local-set-key (kbd "C->") 'python-indent-shift-right) (local-set-key (kbd "C->") 'python-indent-shift-right)
(local-set-key (kbd "C-<") 'python-indent-shift-left) (local-set-key (kbd "C-<") 'python-indent-shift-left)
(set (make-local-variable 'electric-indent-chars) nil) (set (make-local-variable 'electric-indent-chars) nil)
(rainbow-delimiters-mode)
(setq fci-rule-column 79 (setq fci-rule-column 79
fill-column 72) fill-column 72)
(setq-local whitespace-style '(tab-mark)) (setq-local whitespace-style '(tab-mark)))
(fci-mode)
(whitespace-mode))
(defun oni:rainbow-mode-init () (defun oni:rainbow-mode-init ()
"Initialization function for rainbow-mode." "Initialization function for rainbow-mode."
@ -433,10 +393,6 @@ use. If MODE is not nil, open a new buffer with the name
default-directory "' request-pull " (when patchp "-p ") default-directory "' request-pull " (when patchp "-p ")
from " " url " " to)))))) from " " url " " to))))))
(defun oni:rst-mode-func ()
"Function for `rst-mode-hook'."
(auto-fill-mode))
(defun oni:self-insert-dwim () (defun oni:self-insert-dwim ()
"Execute self insert, but when the region is active call self "Execute self insert, but when the region is active call self
insert at the end of the region and at the beginning." insert at the end of the region and at the beginning."
@ -511,11 +467,6 @@ If no direction is given, don't split."
"Function for `term-mode-hook'." "Function for `term-mode-hook'."
(setq truncate-lines nil)) (setq truncate-lines nil))
(defun oni:texinfo-mode-func ()
"Function for `texinfo-mode-hook'."
(setq-local comment-auto-fill-only-comments nil)
(auto-fill-mode))
(defun oni:write-file-func () (defun oni:write-file-func ()
"Function for `write-file-hooks'." "Function for `write-file-hooks'."
(time-stamp)) (time-stamp))