emacs/init.el

This commit is contained in:
Tom Willemsen 2012-09-07 15:21:59 +02:00
parent e81cc4865d
commit 6bc9482e0b

View file

@ -1,9 +1,16 @@
;;; init.el --- ryuslash's emacs init
;;; Commentary:
;; Does so much and changes so often
(require 'geiser-install) (require 'geiser-install)
(require 'iso-transl) (require 'iso-transl)
(require 'newcomment) (require 'newcomment)
(require 'uniquify) (require 'uniquify)
(require 'w3m-load) (require 'w3m-load)
;;; Code:
(eval-and-compile (eval-and-compile
(package-initialize) (package-initialize)
@ -14,34 +21,6 @@
'("/usr/share/emacs/site-lisp" "~/.emacs.d/site-lisp")) '("/usr/share/emacs/site-lisp" "~/.emacs.d/site-lisp"))
(add-to-list 'load-path "~/.emacs.d/")) (add-to-list 'load-path "~/.emacs.d/"))
(eval-when-compile
(require 'appt)
(require 'browse-url)
(require 'em-dirs)
(require 'em-prompt)
(require 'emms-source-file)
(require 'erc-join)
(require 'erc-stamp)
(require 'fill-column-indicator)
(require 'geiser-repl)
(require 'gtags)
(require 'hideshow)
(require 'jabber)
(require 'message)
(require 'mu4e)
(require 'org-capture)
(require 'org-contacts)
(require 'org-feed)
(require 'org-html)
(require 'php-mode)
(require 'rainbow-delimiters)
(require 'sauron)
(require 'sendmail)
(require 'smex)
(require 'time-stamp)
(require 'whitespace)
(require 'yasnippet))
(autoload 'gtags-mode "gtags" nil t) (autoload 'gtags-mode "gtags" nil t)
(autoload 'identica-mode "identica-mode" nil t) (autoload 'identica-mode "identica-mode" nil t)
(autoload 'mu4e "mu4e" nil t) (autoload 'mu4e "mu4e" nil t)
@ -71,10 +50,10 @@
(concat (concat
"\\(?:static\\s +\\)?\\(?:\\sw+\\(?: \\|\t\\|\n\\)*?\\*?\\)" "\\(?:static\\s +\\)?\\(?:\\sw+\\(?: \\|\t\\|\n\\)*?\\*?\\)"
"\\(?:\\s \\|\t\\|\n\\)\\(?:\\sw\\|_\\)+([^)]*)[^;\n]*$")) "\\(?:\\s \\|\t\\|\n\\)\\(?:\\sw\\|_\\)+([^)]*)[^;\n]*$"))
"Regex for `outline-minor-mode' for `c-mode'.") "Regex for command `outline-minor-mode' for `c-mode'.")
(defconst oni:javascript-outline-regex "function \\(\\w\\|_\\)+(" (defconst oni:javascript-outline-regex "function \\(\\w\\|_\\)+("
"Regex for `outline-minor-mode' for `js-mode'.") "Regex for command `outline-minor-mode' for `js-mode'.")
(defconst oni:php-outline-regex (defconst oni:php-outline-regex
(eval-when-compile (eval-when-compile
@ -83,14 +62,14 @@
"\\|final\\) \\)?class [a-zA-Z0-9_]+\\( extends [\\a-zA-Z0-9_]+\\)?" "\\|final\\) \\)?class [a-zA-Z0-9_]+\\( extends [\\a-zA-Z0-9_]+\\)?"
"\\|\\(abstract \\)?\\(public\\|private\\|protected\\)?" "\\|\\(abstract \\)?\\(public\\|private\\|protected\\)?"
"\\( static\\)? function [a-zA-Z0-9_]+(\\|/\\*\\*\\)")) "\\( static\\)? function [a-zA-Z0-9_]+(\\|/\\*\\*\\)"))
"Regex for `outline-minor-mode' for `php-mode'.") "Regex for command `outline-minor-mode' for `php-mode'.")
(defconst oni:python-outline-regex (defconst oni:python-outline-regex
(eval-when-compile (eval-when-compile
(concat "^[ \t]*\\(?:@[a-zA-Z0-9_]+\\(?:([a-zA-Z0-9_=, ]*)\\)?" (concat "^[ \t]*\\(?:@[a-zA-Z0-9_]+\\(?:([a-zA-Z0-9_=, ]*)\\)?"
"\n\\)*[ \t]*\\(?:\\(class\\|def\\)[ \t]+\\(\\sw\\|\\s_\\)+" "\n\\)*[ \t]*\\(?:\\(class\\|def\\)[ \t]+\\(\\sw\\|\\s_\\)+"
"\\(([^)]*):\\)?\\|\\#[ a-zA-Z0-9]*\\#\\)")) "\\(([^)]*):\\)?\\|\\#[ a-zA-Z0-9]*\\#\\)"))
"Regex for `outline-minor-mode' for `python-mode'.") "Regex for command `outline-minor-mode' for `python-mode'.")
(defface oni:mode-line-buffer-column (defface oni:mode-line-buffer-column
'((t (:inherit font-lock-type-face))) '((t (:inherit font-lock-type-face)))
@ -123,7 +102,9 @@
:group 'local) :group 'local)
(defmacro oni:define-mailbox (name email &optional signature longname) (defmacro oni:define-mailbox (name email &optional signature longname)
"Define a mailbox function." "Define a mailbox function for mailbox NAME with address EMAIL.
Optionally set signature to SIGNATURE and use LONGNAME as the
actual account name."
`(defun ,(make-symbol (concat "oni:" name "-mailbox")) () `(defun ,(make-symbol (concat "oni:" name "-mailbox")) ()
,(concat "Settings for " name " mailbox") ,(concat "Settings for " name " mailbox")
(setq mu4e-mu-home ,(expand-file-name (concat "~/.mu/" name)) (setq mu4e-mu-home ,(expand-file-name (concat "~/.mu/" name))
@ -137,12 +118,15 @@
message-signature-file ,signature))) message-signature-file ,signature)))
(defmacro oni:email (user at host dot com) (defmacro oni:email (user at host dot com)
"Turn arguments into an email address." "Turn arguments into an email address.
The resulting email address will look like: USER@HOST.COM, AT and DOT are
intentionally being skipped."
(concat (symbol-name user) "@" (symbol-name host) "." (concat (symbol-name user) "@" (symbol-name host) "."
(symbol-name com))) (symbol-name com)))
(defmacro oni:generic-outline (regex) (defmacro oni:generic-outline (regex)
"Prepare for enabling `outline-minor-mode'." "Prepare for enabling command `outline-minor-mode'.
Argument REGEX will be used to set `outline-regexp' for this buffer."
`(progn `(progn
(when (buffer-file-name) (when (buffer-file-name)
(outline-minor-mode) (outline-minor-mode)
@ -151,6 +135,7 @@
(local-set-key [C-tab] 'outline-toggle-children)))) (local-set-key [C-tab] 'outline-toggle-children))))
(defmacro oni:color (name) (defmacro oni:color (name)
"Fetch color NAME from the naquadah color theme."
`(naquadah-get-colors (quote ,name))) `(naquadah-get-colors (quote ,name)))
(defvar oni:mailbox-map (defvar oni:mailbox-map
@ -167,7 +152,7 @@
flymake-cursor pony-mode sauron dispass flymake-cursor pony-mode sauron dispass
expand-region fill-column-indicator expand-region fill-column-indicator
git-auto-commit-mode idomenu magit smex) git-auto-commit-mode idomenu magit smex)
"List of all the packages I have (want) installed") "List of all the packages I have (want) installed.")
(defun oni:after-save-func () (defun oni:after-save-func ()
"Function for `after-save-hook'." "Function for `after-save-hook'."
@ -175,7 +160,7 @@
(executable-make-buffer-file-executable-if-script-p) (executable-make-buffer-file-executable-if-script-p)
(let ((dom-dir (locate-dominating-file (buffer-file-name) "Makefile"))) (let ((dom-dir (locate-dominating-file (buffer-file-name) "Makefile")))
(when dom-dir (when dom-dir
(shell-command (concat "make -C " dom-dir " TAGS 2>&1 >/dev/null"))))) (shell-command (concat "make -C " dom-dir " TAGS >/dev/null 2>&1")))))
(defun oni:before-save-func () (defun oni:before-save-func ()
"Function for `before-save-hook'." "Function for `before-save-hook'."
@ -245,6 +230,7 @@
(setq truncate-lines nil)) (setq truncate-lines nil))
(defun oni:eshell-prompt-function () (defun oni:eshell-prompt-function ()
"Show a pretty shell prompt."
(let ((status (if (zerop eshell-last-command-status) ?+ ?-)) (let ((status (if (zerop eshell-last-command-status) ?+ ?-))
(hostname (shell-command-to-string "hostname")) (hostname (shell-command-to-string "hostname"))
(dir (abbreviate-file-name (eshell/pwd))) (dir (abbreviate-file-name (eshell/pwd)))
@ -305,6 +291,10 @@
(fci-mode)) (fci-mode))
(defun oni:indent-shift-left (start end &optional count) (defun oni:indent-shift-left (start end &optional count)
"Rigidly indent region.
Region is from START to END. Move
COUNT number of spaces if it is non-nil otherwise use
`tab-width'."
(interactive (interactive
(if mark-active (if mark-active
(list (region-beginning) (region-end) current-prefix-arg) (list (region-beginning) (region-end) current-prefix-arg)
@ -326,6 +316,9 @@
(indent-rigidly start end (- count)))))) (indent-rigidly start end (- count))))))
(defun oni:indent-shift-right (start end &optional count) (defun oni:indent-shift-right (start end &optional count)
"Indent region between START and END rigidly to the right.
If COUNT has been specified indent by that much, otherwise look at
`tab-width'."
(interactive (interactive
(if mark-active (if mark-active
(list (region-beginning) (region-end) current-prefix-arg) (list (region-beginning) (region-end) current-prefix-arg)
@ -350,27 +343,25 @@
"Function for `js-mode-hook'." "Function for `js-mode-hook'."
(oni:generic-outline oni:javascript-outline-regex) (oni:generic-outline oni:javascript-outline-regex)
(rainbow-delimiters-mode) (rainbow-delimiters-mode)
(local-set-key "\C-j" 'oni:newline-and-indent)) (local-set-key "\C-j" 'oni:newline-and-indent)
(pretty-symbols-mode -1))
(defun oni:kill-region-or-backward-char () (defun oni:kill-region-or-backward-char ()
"Kill either the active region, or delete the character left of "Either `kill-region' or `backward-delete-char-untabify'."
the cursor"
(interactive) (interactive)
(if (region-active-p) (if (region-active-p)
(kill-region (region-beginning) (region-end)) (kill-region (region-beginning) (region-end))
(backward-delete-char-untabify 1))) (backward-delete-char-untabify 1)))
(defun oni:kill-region-or-forward-char () (defun oni:kill-region-or-forward-char ()
"Kill either the active region, or delete the character right "Either `kill-region' or `delete-forward-char'."
of the cursor"
(interactive) (interactive)
(if (region-active-p) (if (region-active-p)
(kill-region (region-beginning) (region-end)) (kill-region (region-beginning) (region-end))
(delete-forward-char 1))) (delete-forward-char 1)))
(defun oni:kill-region-or-line () (defun oni:kill-region-or-line ()
"Kill either the active region, or the rest of the line, "Either `kill-region' or `kill-line'."
depending on whether or not `region-active-p' is t"
(interactive) (interactive)
(if (region-active-p) (if (region-active-p)
(kill-region (region-beginning) (region-end)) (kill-region (region-beginning) (region-end))
@ -405,8 +396,9 @@
(ispell-change-dictionary (read-string "New dictionary: "))) (ispell-change-dictionary (read-string "New dictionary: ")))
(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'.
function, found at http://xahlee.org/emacs/elisp_parse_time.html" Turn DATE-STRING into something else that can be worked with in
code. Found at http://xahlee.org/emacs/elisp_parse_time.html"
(setq date-string (replace-regexp-in-string "Jan" "01" date-string) (setq date-string (replace-regexp-in-string "Jan" "01" date-string)
date-string (replace-regexp-in-string "Feb" "02" date-string) date-string (replace-regexp-in-string "Feb" "02" date-string)
date-string (replace-regexp-in-string "Mar" "03" date-string) date-string (replace-regexp-in-string "Mar" "03" date-string)
@ -428,8 +420,7 @@
(match-string 1 date-string))) (match-string 1 date-string)))
(defun oni:move-beginning-of-dwim () (defun oni:move-beginning-of-dwim ()
"Move to the beginning of line, either after the indentatoin of "Move to beginning of line either after indentation or before."
before."
(interactive) (interactive)
(let ((start (point))) (let ((start (point)))
(back-to-indentation) (back-to-indentation)
@ -437,8 +428,7 @@
(beginning-of-line)))) (beginning-of-line))))
(defun oni:move-end-of-dwim () (defun oni:move-end-of-dwim ()
"Move to the end of line, either before any comments or after "Move to end of line, either before any comments or after."
them."
(interactive) (interactive)
(let ((start (point)) (let ((start (point))
(eolpos (line-end-position))) (eolpos (line-end-position)))
@ -455,7 +445,8 @@
(end-of-line)))) (end-of-line))))
(defun oni:myepisodes-formatter (plist) (defun oni:myepisodes-formatter (plist)
"Format RSS items from MyEpisodes as org tasks." "Format RSS items from MyEpisodes as org tasks.
PLIST contains all the pertinent information."
(let ((str (plist-get plist :title))) (let ((str (plist-get plist :title)))
(string-match (string-match
"^\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]$" "^\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]$"
@ -467,6 +458,8 @@
(format "* ACQUIRE %s %s - %s <%s>" title episode name date)))) (format "* ACQUIRE %s %s - %s <%s>" title episode name date))))
(defun oni:newline-and-indent () (defun oni:newline-and-indent ()
"`newline-and-indent', but with a twist.
When dealing with braces, add another line and indent that too."
(interactive) (interactive)
(if (and (not (or (= (point) (point-max)) (if (and (not (or (= (point) (point-max))
(= (point) (point-min)))) (= (point) (point-min))))
@ -477,19 +470,6 @@
(save-excursion (newline-and-indent))) (save-excursion (newline-and-indent)))
(newline-and-indent)) (newline-and-indent))
(defun oni:org-capture-before-finalize-func ()
(save-excursion
(goto-char (point-min))
(while (re-search-forward "<<FIRSTLINE>>" nil t)
(let (beg end)
(save-match-data
(search-forward "\n\n")
(skip-syntax-forward " ")
(setq beg (point))
(search-forward "\n")
(setq end (1- (point))))
(replace-match (buffer-substring beg end) t t)))))
(defun oni:org-mode-func () (defun oni:org-mode-func ()
"Function for `org-mode-hook'." "Function for `org-mode-hook'."
(flyspell-mode) (flyspell-mode)
@ -520,11 +500,13 @@
(oni:generic-outline oni:python-outline-regex) (oni:generic-outline oni:python-outline-regex)
(set (make-local-variable 'electric-indent-chars) nil) (set (make-local-variable 'electric-indent-chars) nil)
(rainbow-delimiters-mode) (rainbow-delimiters-mode)
(setq fci-rule-column 80
fill-column 72)
(fci-mode)) (fci-mode))
(defun oni:raise-eshell () (defun oni:raise-eshell ()
"Start or switch back to `eshell'. Also change directories to "Start or switch back to `eshell'.
current working directory." Also change directories to current working directory."
(interactive) (interactive)
(let ((dir (file-name-directory (let ((dir (file-name-directory
(or (buffer-file-name) "~/"))) (or (buffer-file-name) "~/")))
@ -536,10 +518,10 @@
(eshell-reset))))) (eshell-reset)))))
(defun oni:raise-scratch (&optional mode) (defun oni:raise-scratch (&optional mode)
"Show the *scratch* buffer. If called with a universal "Show the *scratch* buffer.
argument, ask the user which mode to use. If MODE is not nil, If called with a universal argument, ask the user which mode to
open a new buffer with the name *MODE-scratch* and load MODE as use. If MODE is not nil, open a new buffer with the name
its major mode." *MODE-scratch* and load MODE as its major mode."
(interactive (list (if current-prefix-arg (interactive (list (if current-prefix-arg
(read-string "Mode: ") (read-string "Mode: ")
nil))) nil)))
@ -563,6 +545,7 @@ its major mode."
(revert-buffer nil t nil)) (revert-buffer nil t nil))
(defun oni:replace-html-special-chars () (defun oni:replace-html-special-chars ()
"Replace special characters with HTML escaped entities."
(oni:replace-occurrences "é" "&eacute;")) (oni:replace-occurrences "é" "&eacute;"))
(defun oni:replace-occurrences (from to) (defun oni:replace-occurrences (from to)
@ -589,7 +572,7 @@ its major 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."
(interactive) (interactive)
(if (region-active-p) (if (region-active-p)
(let ((electric-pair-mode nil) (let ((electric-pair-mode nil)
@ -806,7 +789,7 @@ for easy selection."
(vertical-scroll-bars . nil) (vertical-scroll-bars . nil)
(menu-bar-lines . nil) (menu-bar-lines . nil)
(tool-bar-lines . nil) (tool-bar-lines . nil)
(font . "DejaVu Sans Mono:pixelsize=18") (font . "LiberationMono:pixelsize=16")
(left-fringe . 0))) (left-fringe . 0)))
(setq emms-source-file-default-directory "/mnt/music/") (setq emms-source-file-default-directory "/mnt/music/")
(setq erc-autojoin-channels-alist (setq erc-autojoin-channels-alist
@ -825,12 +808,13 @@ for easy selection."
(setq flymake-log-file-name (expand-file-name "~/.emacs.d/flymake.log")) (setq flymake-log-file-name (expand-file-name "~/.emacs.d/flymake.log"))
(setq flymake-log-level 0) (setq flymake-log-level 0)
(setq frame-title-format '(:eval (concat "emacs: " (buffer-name)))) (setq frame-title-format '(:eval (concat "emacs: " (buffer-name))))
(setq geiser-active-implementations '(guile))
(setq geiser-repl-history-filename "~/.emacs.d/geiser-history") (setq geiser-repl-history-filename "~/.emacs.d/geiser-history")
(setq gtags-auto-update t) (setq gtags-auto-update t)
(setq help-at-pt-display-when-idle t) (setq help-at-pt-display-when-idle t)
(setq ido-auto-merge-delay-time 1000000) (setq ido-auto-merge-delay-time 1000000)
(setq ido-max-window-height 1)
(setq ido-save-directory-list-file nil) (setq ido-save-directory-list-file nil)
(setq ido-ubiquitous-exceptions '(tmm-prompt))
(setq inferior-lisp-program "sbcl") (setq inferior-lisp-program "sbcl")
(setq inhibit-default-init t) (setq inhibit-default-init t)
(setq inhibit-local-menu-bar-menus t) (setq inhibit-local-menu-bar-menus t)
@ -875,15 +859,8 @@ for easy selection."
(tags priority-down category-keep) (tags priority-down category-keep)
(search category-keep))) (search category-keep)))
(setq org-capture-templates (setq org-capture-templates
'(("t" "Task" entry (file "") '(("t" "Task" entry (file "~/documents/org/tasks")
"* TODO <<FIRSTLINE>> "* TODO %?")
:PROPERTIES:
:DIRECTORY: %(directory-file-name (or (org-capture-get :original-file) org-default-notes-file))
:FILE: %f
:END:
%u
%?%a")
("h" "Habit" entry (file "") ("h" "Habit" entry (file "")
(concat "* TODO %^{Description}\n" (concat "* TODO %^{Description}\n"
" SCHEDULED: %^T\n" " SCHEDULED: %^T\n"
@ -958,12 +935,14 @@ for easy selection."
(setq special-display-buffer-names '("*Sauron*")) (setq special-display-buffer-names '("*Sauron*"))
(setq special-display-frame-alist '((minibuffer . nil) (setq special-display-frame-alist '((minibuffer . nil)
(right-fringe . 0))) (right-fringe . 0)))
(setq split-height-threshold 40)
(setq time-stamp-active t) (setq time-stamp-active t)
(setq time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)") (setq time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)")
(setq uniquify-buffer-name-style 'post-forward) (setq uniquify-buffer-name-style 'post-forward)
(setq use-dialog-box nil) (setq use-dialog-box nil)
(setq user-full-name "Tom Willemsen") (setq user-full-name "Tom Willemsen")
(setq whitespace-style '(face trailing)) (setq whitespace-style '(face trailing))
(setq window-combination-resize t)
(setq yas-prompt-functions '(yas-ido-prompt)) (setq yas-prompt-functions '(yas-ido-prompt))
(add-hook 'after-save-hook 'oni:after-save-func t) (add-hook 'after-save-hook 'oni:after-save-func t)
@ -987,8 +966,6 @@ for easy selection."
(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 'message-mode-hook 'oni:message-mode-func)
(add-hook 'org-capture-before-finalize-hook
'oni:org-capture-before-finalize-func)
(add-hook 'org-mode-hook 'oni:org-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)
@ -1069,6 +1046,7 @@ for easy selection."
(ido-mode) (ido-mode)
(savehist-mode) (savehist-mode)
(show-paren-mode) (show-paren-mode)
(auto-insert-mode)
(smex-initialize) (smex-initialize)
(help-at-pt-set-timer) (help-at-pt-set-timer)
@ -1078,3 +1056,7 @@ for easy selection."
(load custom-file) (load custom-file)
(load "rudel-loaddefs.el") (load "rudel-loaddefs.el")
(load (expand-file-name "~/quicklisp/slime-helper.el")) (load (expand-file-name "~/quicklisp/slime-helper.el"))
(provide 'init)
;;; init.el ends here