summaryrefslogtreecommitdiffstats
path: root/emacs
diff options
context:
space:
mode:
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.gitignore1
-rw-r--r--emacs/Makefile7
-rw-r--r--emacs/eshell/Makefile2
-rw-r--r--emacs/init.el536
-rw-r--r--emacs/init.org1599
-rw-r--r--emacs/site-lisp/Makefile2
-rw-r--r--emacs/site-lisp/dzen.el1
-rw-r--r--emacs/site-lisp/ext.el7
-rw-r--r--emacs/site-lisp/oni.el165
-rw-r--r--emacs/site-lisp/org-init.el9
-rw-r--r--emacs/snippets/Makefile2
-rw-r--r--emacs/snippets/html-mode/Makefile2
-rw-r--r--emacs/snippets/org-mode/Makefile2
-rw-r--r--emacs/snippets/org-mode/heading10
-rw-r--r--emacs/snippets/python-mode/Makefile2
15 files changed, 1972 insertions, 375 deletions
diff --git a/emacs/.gitignore b/emacs/.gitignore
index 771231f..513ac08 100644
--- a/emacs/.gitignore
+++ b/emacs/.gitignore
@@ -14,3 +14,4 @@ rinit.*
!rinit.org
history
*.html
+init.el
diff --git a/emacs/Makefile b/emacs/Makefile
index 43ee5ec..8d99401 100644
--- a/emacs/Makefile
+++ b/emacs/Makefile
@@ -1,7 +1,12 @@
-DESTDIR:=$(DESTDIR)/.emacs.d
+SUBDIR=.emacs.d
objects=init.elc init.el gnus.elc gnus.el
modules=eshell site-lisp snippets
EMACS=emacs
include ../dotfiles.mk
+
+init.el: init.org
+ $(EMACS) -Q -batch \
+ -eval "(progn (require 'org) (require 'ob-tangle) \
+ (org-babel-tangle-file \"$^\"))"
diff --git a/emacs/eshell/Makefile b/emacs/eshell/Makefile
index fd3b0f2..3b6ce2f 100644
--- a/emacs/eshell/Makefile
+++ b/emacs/eshell/Makefile
@@ -1,4 +1,4 @@
-DESTDIR:=$(DESTDIR)/eshell
+SUBDIR=eshell
objects=alias
modules=
diff --git a/emacs/init.el b/emacs/init.el
index 9198675..3db05da 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -1,35 +1,28 @@
-;;; Turn the menu, scroll-bar and tool-bar off quickly, so they don't
-;;; jump around as much.
-(menu-bar-mode -1)
+(menu-bar-mode -1)
(scroll-bar-mode -1)
-(tool-bar-mode -1)
-
-(defmacro eval-after-init (&rest body)
- "Defer execution of BODY until after Emacs init.
-
-Some functionality is dependent on code loaded by package.el.
-Instead of requiring package.el to load very early on, have some
-functionality deferred to a point after Emacs has initialized and
-package.el is loaded anyway."
- `(add-hook 'emacs-startup-hook #'(lambda () ,@body)))
-
-;;; Add some project directories and my site-lisp directory to the
-;;; load path to make it easy to (auto)load them.
+(tool-bar-mode -1)
+
(mapc #'(lambda (dir)
(add-to-list 'load-path dir)
(let ((loaddefs (concat dir "/loaddefs.el")))
(when (file-exists-p loaddefs)
(load loaddefs))))
- '("~/projects/emacs/mode-icons" "~/.emacs.d/site-lisp"
- "~/projects/emacs/pony-mode/src" "~/projects/emacs/php-mode"))
-
-;;; I have never, yet, accidentally said `y' or `n' when asked.
+ '("~/.emacs.d/site-lisp" "~/projects/emacs/pony-mode/src"
+ "~/projects/emacs/php-mode" "~/.emacs.d/vendor-lisp/org/lisp"
+ "~/.emacs.d/vendor-lisp/org/contrib/lisp"))
+
+(require 'ext)
+(require 'oni)
+
+(setq custom-theme-directory "~/.emacs.d/themes")
+(oni:eval-after-init (load-theme 'yoshi t))
+
(defalias 'yes-or-no-p 'y-or-n-p)
-;;; These are much more feature-rich.
(defalias 'list-buffers 'ibuffer)
+
(defalias 'dabbrev-expand 'hippie-expand)
-
+
(defun ext:comp-finish-function (buf str)
"Close the compilation buffer quickly if everything went OK."
(if (string-match "exited abnormally" str)
@@ -37,30 +30,76 @@ package.el is loaded anyway."
(message "compilation errors, press C-x ` to visit")
;; no errors, make the compilation window go away in 0.5 seconds
(when (member (buffer-name) '("*Compilation*" "*compilation*"))
- (run-at-time 0.5 nil 'delete-windows-on buf)
+ (delete-windows-on buf)
(message "No compilation errors!"))))
(add-to-list 'compilation-finish-functions 'ext:comp-finish-function)
-;;; I close the compilation window if there are no errors. Seeing it
-;;; scroll past lets me see if there were any warnings I might want to
-;;; look at.
(setq compilation-scroll-output t)
-
-;;; Enable the excellent `paredit-mode' for any lisp-like languages.
-(add-hook 'clojure-mode-hook 'paredit-mode)
+
+(add-hook 'prog-mode-hook 'auto-fill-mode)
+(add-hook 'text-mode-hook 'auto-fill-mode)
+
+(add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
+(add-hook 'ielm-mode-hook 'eldoc-mode)
+
+(add-hook 'html-mode-hook 'fci-mode)
+(add-hook 'prog-mode-hook 'fci-mode)
+
+(add-hook 'css-mode-hook 'flycheck-mode)
+(add-hook 'emacs-lisp-mode-hook 'flycheck-mode)
+(add-hook 'go-mode-hook 'flycheck-mode)
+(add-hook 'html-mode-hook 'flycheck-mode)
+(add-hook 'js2-mode-hook 'flycheck-mode)
+(add-hook 'lua-mode-hook 'flycheck-mode)
+(add-hook 'php-mode-hook 'flycheck-mode)
+(add-hook 'python-mode-hook 'flycheck-mode)
+(add-hook 'rst-mode-hook 'flycheck-mode)
+(add-hook 'ruby-mode-hook 'flycheck-mode)
+(add-hook 'rust-mode-hook 'flycheck-mode)
+(add-hook 'sh-mode-hook 'flycheck-mode)
+
+(add-hook 'text-mode-hook 'flyspell-mode)
+
+(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)
-
-;;; Remove the pylint and pyflakes checkers from the flycheck
-;;; configuration so the flake8 checker remains.
+(add-hook 'lisp-mode-hook 'paredit-mode)
+(add-hook 'sawfish-mode-hook 'paredit-mode)
+(add-hook 'scheme-mode-hook 'paredit-mode)
+(add-hook 'ielm-mode-hook 'paredit-mode)
+
+(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
+
+(add-hook 'css-mode-hook 'rainbow-mode)
+
+(add-hook 'js2-mode-hook 'slime-js-minor-mode)
+
+(add-hook 'html-mode-hook 'smartparens-mode)
+(add-hook 'python-mode-hook 'smartparens-mode)
+
+(add-hook 'jabber-chat-mode-hook 'visual-line-mode)
+(add-hook 'erc-mode-hook 'visual-line-mode)
+
+(add-hook 'markdown-mode-hook 'whitespace-mode)
+(add-hook 'python-mode-hook 'whitespace-mode)
+
+(add-hook 'html-mode-hook 'yas-minor-mode)
+(add-hook 'org-mode-hook 'yas-minor-mode)
+(add-hook 'prog-mode-hook 'yas-minor-mode)
+
+(defun oni:turn-on-tagedit-mode ()
+ (require 'tagedit)
+ (tagedit-mode)
+ (tagedit-add-paredit-like-keybindings)
+ (tagedit-add-experimental-features))
+
+(add-hook 'html-mode-hook 'oni:turn-on-tagedit-mode)
+
(eval-after-load "flycheck"
'(progn
(mapc (lambda (c) (delq c flycheck-checkers))
'(python-pylint python-pyflakes))))
-
+
(defun oni:pretty-control-l-function (win)
"Just make a string of either `fci-rule-column' or
`fill-column' length -1. Use the `-' character. WIN is ignored."
@@ -68,61 +107,47 @@ package.el is loaded anyway."
(make-string
(1- (if (boundp 'fci-rule-column) fci-rule-column fill-column)) ?-))
-;;; Use `oni:pretty-control-l-function' to create a nice horizontal
-;;; line.
-(setq pp^L-^L-string-function 'oni:pretty-control-l-function)
+(setq pp^L-^L-string-function 'oni:pretty-control-l-function
+ pp^L-^L-string-pre nil)
-;;; Don't put anything before the pp^L string.
-(setq pp^L-^L-string-pre nil)
-
-;;; Enable pp^L at startup and again for each frame created.
(add-hook 'emacs-startup-hook 'pretty-control-l-mode)
(add-hook 'after-make-frame-functions
'(lambda (arg) (pretty-control-l-mode)))
-
+
(setq erc-autojoin-channels-alist
- '(("freenode.net" "#ninthfloor" "#emacs")))
+ '(("freenode.net" "#ninthfloor" "#emacs" "#dispass")))
+
(setq erc-hide-list '("PART"))
-(setq erc-insert-timestamp-function 'erc-insert-timestamp-left)
-(setq erc-timestamp-format "[%H:%M] ")
-(setq erc-timestamp-only-if-changed-flag nil)
+
+(setq erc-insert-timestamp-function 'erc-insert-timestamp-left
+ erc-timestamp-format "[%H:%M] "
+ erc-timestamp-only-if-changed-flag nil)
+
(setq erc-nick "ryuslash")
-(defun oni:erc-mode-func ()
- "Function for `erc-mode-hook'."
- (erc-fill-mode -1)
- (visual-line-mode)
- (setq truncate-lines nil))
+(defun oni:turn-off-erc-fill-mode () (erc-fill-mode -1))
+(add-hook 'erc-mode-hook 'oni:turn-off-erc-fill-mode)
-(add-hook 'erc-mode-hook 'oni:erc-mode-func)
-
-;;; Since unison requires unbuffered input it should not show up in
-;;; eshell, but a real term shell.
(eval-after-load "em-term"
'(add-to-list 'eshell-visual-commands "unison"))
-;;; To be able to highlight the eshell prompt just as I want it with
-;;; regular text properties the standard highlighting should be turned
-;;; off, otherwise it always overwrites whatever text properties it
-;;; finds.
(setq eshell-highlight-prompt nil)
(defun oni:eshell-prompt-function ()
"Show a pretty shell prompt."
(let ((status (if (zerop eshell-last-command-status) ?+ ?-))
- (hostname (shell-command-to-string "hostname"))
+ (hostname (oni:hostname))
(dir (abbreviate-file-name (eshell/pwd)))
(branch
(shell-command-to-string
- "git branch --contains HEAD 2>/dev/null | sed -e '/^[^*]/d'"))
- (userstatus (if (zerop (user-uid)) ?# ?$)))
+ "git branch --contains HEAD 2>/dev/null | sed -e '/^[^*]/d'")))
(concat
(propertize (char-to-string status)
'face `(:foreground ,(if (= status ?+)
"green"
"red")))
" "
- (propertize (substring hostname 0 -1) 'face 'mode-line-buffer-id)
+ (propertize hostname 'face 'mode-line-buffer-id)
" "
(propertize (oni:shorten-dir dir) 'face 'font-lock-string-face)
" "
@@ -131,19 +156,10 @@ package.el is loaded anyway."
;; Cut off "* " and "\n"
(substring branch 2 -1)
'face 'font-lock-function-name-face))
- " \n"
- (propertize (char-to-string userstatus)
- 'face `(:foreground "blue"))
- "> ")))
+ " \n> ")))
(setq eshell-prompt-function 'oni:eshell-prompt-function
- eshell-prompt-regexp "^[#$]> ")
-
-(defun oni:eshell-mode-func ()
- "Function for `eshell-mode-hook'."
- (setq truncate-lines nil))
-
-(add-hook 'eshell-mode-hook 'oni:eshell-mode-func)
+ eshell-prompt-regexp "^> ")
(defun oni:raise-eshell ()
"Start or switch back to `eshell'.
@@ -151,52 +167,44 @@ Also change directories to current working directory."
(interactive)
(let ((dir (file-name-directory
(or (buffer-file-name) "~/")))
- (hasfile (not (eq (buffer-file-name) nil))))
+ (hasfile (not (eq (buffer-file-name) nil)))
+ (started (and (boundp 'eshell-buffer-name) eshell-buffer-name
+ (buffer-live-p (get-buffer eshell-buffer-name)))))
(eshell)
- (if (and hasfile (eq eshell-process-list nil))
- (progn
- (eshell/cd dir)
- (eshell-reset)))))
+ (when (and hasfile (eq eshell-process-list nil))
+ (eshell/cd dir)
+ (when started
+ (eshell-reset)))))
(global-set-key (kbd "<f8>") 'oni:raise-eshell)
-
-;;; Since I don't ever get any mail from people that use right-to-left
-;;; text, and even if I did I wouldn't be able to read it, I don't
-;;; need bidirectional text support. You shouldn't actually disable it
-;;; (if that's even still possible) since, supposedly, it is an
-;;; integral part of the display engine now, but telling it to always
-;;; use left-to-right should keep it from slowing your emacs down.
+
+(add-hook 'eshell-mode-hook 'buffer-disable-undo)
+
(setq-default bidi-paragraph-direction 'left-to-right)
-
-;;; Enable the following commands because they're useful sometimes and
-;;; I'm not an Emacs beginner anymore, they don't confuse me.
-(put 'upcase-region 'disabled nil)
-(put 'downcase-region 'disabled nil)
+
+(put 'downcase-region 'disabled nil)
+(put 'narrow-to-page 'disabled nil)
(put 'narrow-to-region 'disabled nil)
-(put 'scroll-left 'disabled nil)
-
-(defun oni:jabber-init ()
- "Initialization function for jabber."
- (remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo))
+(put 'scroll-left 'disabled nil)
+(put 'upcase-region 'disabled nil)
-(eval-after-load "jabber" '(oni:jabber-init))
+(eval-after-load "jabber"
+ '(remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo))
(autoload 'jabber-message-libnotify "jabber-libnotify")
-(autoload 'jabber-muc-libnotify "jabber-libnotify")
+(autoload 'jabber-muc-libnotify "jabber-libnotify")
(add-hook 'jabber-alert-message-hooks 'jabber-message-libnotify)
-(add-hook 'jabber-alert-muc-hooks 'jabber-muc-libnotify)
+(add-hook 'jabber-alert-muc-hooks 'jabber-muc-libnotify)
-(setq jabber-history-enabled t
- jabber-history-muc-enabled t)
+(setq jabber-history-enabled t
+ jabber-history-muc-enabled t
+ jabber-use-global-history nil
+ jabber-history-dir "~/.emacs.d/jabber-hist")
-(setq jabber-use-global-history nil
- jabber-history-dir "~/.emacs.d/jabber-hist")
-
-(setq jabber-account-list '(("ryuslash@jabber.org")
- ("tom@ryuslash.org/drd"
+(setq jabber-account-list `((,(concat "tom@ryuslash.org/" (oni:hostname))
(:connection-type . ssl))))
-
+
(defun oni:ido-init ()
"Initialization functionn for ido."
(setq ido-ignore-buffers
@@ -213,7 +221,7 @@ Also change directories to current working directory."
(eval-after-load "ido" '(oni:ido-init))
-(setq ido-auto-merge-delay-time 1000000)
+(setq ido-auto-merge-work-directories-length -1)
(setq ido-default-buffer-method 'selected-window)
@@ -223,166 +231,183 @@ Also change directories to current working directory."
(ido-mode)
-(setq ido-ubiquitous-command-exceptions
- '(org-refile org-capture-refile))
+(setq ido-ubiquitous-command-exceptions '(org-refile org-capture-refile))
(add-hook 'emacs-startup-hook 'ido-ubiquitous-mode)
(global-set-key (kbd "M-n") 'idomenu)
-
+
(setq minibuffer-eldef-shorten-default t)
(minibuffer-electric-default-mode)
-
+
(setq mode-line-default-help-echo "")
-
+
(eval-after-load "jedi" '(setcar jedi:server-command "python2"))
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:tooltip-method nil)
-
-(defface git-commit-summary-face
- '((t (:inherit org-level-1)))
- "Face for the git title line."
- :group 'local)
-
-(defface git-commit-overlong-summary-face
- '((t (:background "#873732")))
- "Face for commit titles that are too long."
- :group 'local)
-
-(defface git-commit-nonempty-second-line-face
- '((t (:inherit git-commit-overlong-summary-face)))
- "Face for the supposedly empty line in commit messages."
- :group 'local)
(eval-after-load "org" '(require 'org-init))
-(defun indent-defun ()
- "Indent the current defun."
- (interactive)
- (save-excursion
- (mark-defun)
- (indent-region (region-beginning) (region-end))))
-
-(global-set-key (kbd "C-M-z") 'indent-defun)
+(global-set-key (kbd "C-M-z") 'ext:indent-defun)
(defadvice term-handle-exit (after oni:kill-buffer-after-exit activate)
"Kill the term buffer if the process finished."
- (let ((msg (ad-get-arg 1)))
- (when (string-equal msg "finished\n")
- (kill-buffer (current-buffer)))))
-
-(defun oni:change-prev-case (num dir)
- (let ((regfunc (if (eq dir 'up) 'upcase-region 'downcase-region))
- (wordfunc (if (eq dir 'up) 'upcase-word 'downcase-word)))
- (if (> num 1)
- (funcall regfunc (point) (- (point) num))
- (funcall wordfunc -1))))
-
-(defun oni:upcase-prev (num)
- (interactive "p")
- (oni:change-prev-case num 'up))
-
-(defun oni:downcase-prev (num)
- (interactive "p")
- (oni:change-prev-case num 'down))
+ (kill-buffer (current-buffer)))
(global-set-key (kbd "C-c u") 'oni:upcase-prev)
(global-set-key (kbd "C-c d") 'oni:downcase-prev)
-(defun oni:vala-mode-func ()
- "Function for `vala-mode-hook'."
- (setq indent-tabs-mode nil))
-
(add-hook 'vala-mode-hook 'oni:vala-mode-func)
-(eval-after-load "rainbow-mode" '(oni:rainbow-mode-init))
-(eval-after-load "smex" '(oni:smex-init))
-(eval-after-load "yasnippet" '(oni:yasnippet-init))
+(global-set-key (kbd "M-x") 'smex)
+(global-set-key (kbd "C-M-x") 'smex-major-mode-commands)
(autoload 'define-slime-contrib "slime")
-(autoload 'gtags-mode "gtags" nil t)
-(autoload 'jabber-connect "jabber" nil t)
-(autoload 'php-mode "php-mode" nil t)
-(autoload 'po-mode "po-mode" nil t)
-(autoload 'pony-mode "pony-mode" nil t)
-(autoload 'sawfish-mode "sawfish" nil t)
-(autoload 'server-running-p "server")
-(autoload 'slime-js-minor-mode "slime-js" nil t)
-(autoload 'xmodmap-mode "xmodmap-mode" nil t)
-(autoload 'w3m-bookmark-view "w3m" nil t)
-(autoload 'w3m-goto-url "w3m" nil t)
+
+(autoload 'gtags-mode "gtags" nil t)
+(autoload 'jabber-connect "jabber" nil t)
+(autoload 'php-mode "php-mode" nil t)
+(autoload 'po-mode "po-mode" nil t)
+(autoload 'pony-mode "pony-mode" nil t)
+(autoload 'sawfish-mode "sawfish" nil t)
+(autoload 'server-running-p "server")
+(autoload 'slime-js-minor-mode "slime-js" nil t)
+(autoload 'w3m-bookmark-view "w3m" nil t)
+(autoload 'w3m-goto-url "w3m" nil t)
+(autoload 'xmodmap-mode "xmodmap-mode" nil t)
(require 'uniquify)
-(require 'ext)
-(require 'oni)
-(setq-default c-basic-offset 4)
+(setq-default c-basic-offset 4
+ tab-width 4)
+
(setq-default fci-rule-column 73)
+
(setq-default indent-tabs-mode nil)
+
(setq-default php-mode-warn-if-mumamo-off nil)
+
(setq-default require-final-newline t)
-(setq-default tab-width 4)
+
(setq-default truncate-lines t)
(setq appt-disp-window-function #'oni:appt-display-window-and-jabber)
+
(setq appt-display-diary nil)
+
(setq auto-mode-case-fold nil)
-(setq auto-save-file-name-transforms oni:auto-save-name-transforms)
-(setq avandu-article-render-function #'avandu-view-w3m)
-(setq backup-directory-alist oni:backup-directory-alist)
-(setq browse-url-browser-function 'browse-url-generic)
-(setq browse-url-generic-program (getenv "BROWSER"))
-(setq c-offsets-alist '((statement-block-intro . +)
- (knr-argdecl-intro . 5)
- (substatement-open . +)
- (substatement-label . 0)
- (label . 0)
- (statement-case-open . +)
- (statement-cont . +)
- (arglist-intro . +)
- (arglist-close . 0)
- (inline-open . 0)
- (brace-list-open . +)
- (topmost-intro-cont first c-lineup-topmost-intro-cont
- c-lineup-gnu-DEFUN-intro-cont)))
-(setq comment-auto-fill-only-comments t)
+
+(setq auto-save-file-name-transforms
+ `((".*" "~/.local/share/emacs/autosave/" t)))
+
+(setq backup-directory-alist `((".*" . "~/.local/share/emacs/backup/")))
+
+(setq browse-url-browser-function 'browse-url-generic
+ browse-url-generic-program (getenv "BROWSER"))
+
+(setq c-offsets-alist
+ '((statement-block-intro . +)
+ (knr-argdecl-intro . 5)
+ (substatement-open . +)
+ (substatement-label . 0)
+ (label . 0)
+ (statement-case-open . +)
+ (statement-cont . +)
+ (arglist-intro . +)
+ (arglist-close . 0)
+ (inline-open . 0)
+ (brace-list-open . +)
+ (topmost-intro-cont first c-lineup-topmost-intro-cont
+ c-lineup-gnu-DEFUN-intro-cont)))
+
(setq custom-file "~/.emacs.d/custom.el")
-(setq custom-theme-directory "~/.emacs.d/themes")
+
(setq default-frame-alist
`((border-width . 0)
(internal-border-width . 0)
(vertical-scroll-bars . nil)
(menu-bar-lines . nil)
(tool-bar-lines . nil)
- (font . "Envy Code R:pixelsize=12")))
+ (font . "Inconsolata:pixelsize=18")))
+
(setq elnode-do-init nil)
-(setq fci-rule-color "darkred")
+
(setq frame-title-format '(:eval (concat "emacs: " (buffer-name))))
+
(setq geiser-repl-history-filename "~/.emacs.d/geiser-history")
+
(setq gnus-init-file "~/.emacs.d/gnus")
+
(setq gtags-auto-update t)
+
(setq help-at-pt-display-when-idle t)
-(setq highlight-80+-columns 72)
-(setq identica-enable-striping t)
-(setq inferior-lisp-program "sbcl")
-(setq inhibit-default-init t)
-(setq inhibit-local-menu-bar-menus t)
-(setq inhibit-startup-message t)
-(setq initial-major-mode 'emacs-lisp-mode)
-(setq initial-scratch-message nil)
+
+(setq inferior-lisp-program "sbcl --noinform --no-linedit")
+
+(setq inhibit-default-init t
+ inhibit-local-menu-bar-menus t
+ inhibit-startup-message t)
+
+(setq initial-major-mode 'emacs-lisp-mode
+ initial-scratch-message nil)
+
(setq jabber-avatar-cache-directory "~/.emacs.d/jabber-avatars/")
-(setq jabber-chat-buffer-format "*jab:%n*")
-(setq jabber-chat-buffer-show-avatar nil)
+
+(setq jabber-chat-buffer-format "+%n"
+ jabber-chat-foreign-prompt-format "%t %u/%r <\n"
+ jabber-chat-local-prompt-format "%t %u/%r >\n"
+ jabber-groupchat-buffer-format "++%n"
+ jabber-groupchat-prompt-format "%t %u --\n")
+
+(setq jabber-chat-buffer-show-avatar nil
+ jabber-vcard-avatars-publish nil
+ jabber-vcard-avatars-retrieve nil)
+
(setq jabber-chat-fill-long-lines nil)
-(setq jabber-chat-foreign-prompt-format "%t %u/%r <\n")
-(setq jabber-chat-local-prompt-format "%t %u/%r >\n")
+
(setq jabber-chatstates-confirm nil)
+
(setq jabber-muc-autojoin '("aethon@muc.ryuslash.org"))
+
(setq jabber-roster-show-bindings nil)
-(setq jabber-vcard-avatars-publish nil)
-(setq jabber-vcard-avatars-retrieve nil)
+(setq jabber-show-offline-contacts nil)
+
(setq jit-lock-defer-time 0.2)
+
+(defun turn-on-compilation-shell-for-pony ()
+ (add-hook 'pony-minor-mode-hook 'compilation-shell-minor-mode nil t))
+(add-hook 'comint-mode-hook 'turn-on-compilation-shell-for-pony)
+
+(defun oni:smartparens-set-keys ()
+ (local-set-key (kbd "DEL") 'sp-backward-delete-char)
+ (local-set-key (kbd "<deletechar>") 'sp-delete-char)
+ (local-set-key (kbd "C-d") 'sp-delete-char))
+
+(add-hook 'smartparens-mode-on-hook 'oni:smartparens-set-keys)
+
+(eval-after-load "emms"
+ `(progn
+ (emms-minimalistic)
+ (emms-default-players)
+
+ (require 'emms-player-mpd)
+ (add-to-list 'emms-player-list 'emms-player-mpd)
+ (setq emms-player-mpd-music-directory "/mnt/music/mp3")
+
+ (require 'emms-mode-line)
+ (setq emms-mode-line-mode-line-function 'oni:mode-line-current-song)
+ (emms-mode-line 1)))
+
+(defun oni:set-smartparens-keys ()
+ (local-set-key (kbd "<C-left>") 'sp-forward-barf-sexp)
+ (local-set-key (kbd "<C-right>") 'sp-forward-slurp-sexp))
+
+(defun oni:local-set-smartparens-hook ()
+ (add-hook 'smartparens-mode-hook 'oni:set-smartparens-keys nil t))
+
+(add-hook 'python-mode-hook 'oni:local-set-smartparens-hook)
+
(setq magit-repo-dirs '("~/projects/"))
(setq message-log-max 1000)
(setq message-send-mail-function 'message-send-mail-with-sendmail)
@@ -399,7 +424,7 @@ Also change directories to current working directory."
(setq pony-tpl-indent-moves t)
(setq rainbow-delimiters-max-face-count 12)
(setq redisplay-dont-pause t)
-(setq send-mail-function 'smtpmail-send-it)
+(setq send-mail-function 'sendmail-send-it)
(setq sendmail-program "/usr/bin/msmtp")
(setq sentence-end-double-space nil)
(setq smex-key-advice-ignore-menu-bar t)
@@ -426,30 +451,25 @@ Also change directories to current working directory."
(add-hook 'css-mode-hook 'oni:css-mode-func)
(add-hook 'diary-display-hook 'oni:diary-display-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 'gtags-mode-hook 'oni:gtags-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 'java-mode-hook 'oni:java-mode-func)
(add-hook 'js-mode-hook 'oni:js-mode-func)
(add-hook 'js2-mode-hook 'oni:js2-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 '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 'prog-mode-hook 'oni:prog-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 'texinfo-mode-hook 'oni:texinfo-mode-func)
(add-hook 'write-file-hooks 'oni:write-file-func)
(add-hook 'yas-minor-mode-hook 'oni:yas-minor-mode-func)
+(define-key key-translation-map (kbd "C-j") (kbd "C-l"))
+(define-key key-translation-map (kbd "C-l") (kbd "C-j"))
+
(global-set-key (kbd "'") 'oni:self-insert-dwim)
(global-set-key (kbd "<XF86HomePage>") 'oni:raise-scratch)
(global-set-key (kbd "<XF86Mail>") 'gnus)
@@ -471,10 +491,7 @@ Also change directories to current working directory."
(global-set-key (kbd "C-c i p") 'identica-update-status-interactive)
(global-set-key (kbd "C-c p") 'oni:show-buffer-position)
(global-set-key (kbd "C-c t") 'oni:raise-ansi-term)
-(global-set-key (kbd "C-d") 'oni:kill-region-or-forward-char)
(global-set-key (kbd "C-e") 'oni:move-end-of-dwim)
-(global-set-key (kbd "C-k") 'oni:kill-region-or-line)
-(global-set-key (kbd "C-w") 'oni:kill-region-or-backward-char)
(global-set-key (kbd "M-0") 'delete-window)
(global-set-key (kbd "M-1") 'delete-other-windows)
(global-set-key (kbd "M-2") 'split-window-below)
@@ -503,13 +520,13 @@ Also change directories to current working directory."
(add-to-list
'display-buffer-alist
- '("^\\*\\(?:.+-\\)?scratch\\*$" . ((display-buffer-same-window . nil))))
+ '("^\\*\\(?:.+-\\)?scratch\\*$" display-buffer-same-window))
(add-to-list
'display-buffer-alist
- '("^\\*git-project-list\\*$" . ((git-project-show-window . nil))))
+ '("^\\*git-project-list\\*$" git-project-show-window))
(add-to-list
'display-buffer-alist
- '("^\\*magit: .*\\*$" . ((display-buffer-same-window . nil))))
+ '("^\\*magit: .*\\*$" display-buffer-same-window))
(blink-cursor-mode -1)
(column-number-mode -1)
@@ -532,11 +549,15 @@ Also change directories to current working directory."
;;; Diminish lighter for a bunch of minor modes that should be on in
;;; certain modes and usually just clogg up the mode line.
(diminish 'auto-fill-function)
-(eval-after-load "eldoc" '(diminish 'eldoc-mode))
-(eval-after-load "paredit" '(diminish 'paredit-mode))
+
(eval-after-load "auto-complete" '(diminish 'auto-complete-mode))
+(eval-after-load "eldoc" '(diminish 'eldoc-mode))
(eval-after-load "flycheck" '(diminish 'flycheck-mode))
+(eval-after-load "paredit" '(diminish 'paredit-mode))
+(eval-after-load "rainbow-mode" '(diminish 'rainbow-mode))
(eval-after-load "smartparens" '(diminish 'smartparens-mode))
+(eval-after-load "yasnippet" '(diminish 'yas-minor-mode))
+
;;; Popping up multiple frames out of the blue does not usually play
;;; well with (manual) tiling window managers.
@@ -560,30 +581,33 @@ Also change directories to current working directory."
(setq eltuki-blog-dir "~/documents/blog")
(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)
"Either scroll down or go to the previous page.
Depending on the value of `buffer-narrowed-p'."
- (interactive "P")
+ (interactive "^P")
(if (buffer-narrowed-p)
- (progn
- (narrow-to-page (or arg -1))
- (goto-char (point-min)))
+ (let ((scroll-error-top-bottom nil))
+ (condition-case nil
+ (scroll-down-command arg)
+ (beginning-of-buffer
+ (narrow-to-page -1)
+ (goto-char (point-min)))))
(scroll-down-command arg)))
(defun oni:scroll-up-or-next-page (arg)
"Either scroll up or go to the next page.
Depending on the value of `buffer-narrowed-p'."
- (interactive "P")
+ (interactive "^P")
(if (buffer-narrowed-p)
- (progn
- (narrow-to-page (or arg 1))
- (goto-char (point-min)))
+ (let ((scroll-error-top-bottom nil))
+ (condition-case nil
+ (scroll-up-command arg)
+ (end-of-buffer
+ (narrow-to-page 1)
+ (goto-char (point-min)))))
(scroll-up-command arg)))
(global-set-key (kbd "<prior>") 'oni:scroll-down-or-prev-page)
@@ -596,15 +620,25 @@ Depending on the value of `buffer-narrowed-p'."
(setq eap-music-library "/mnt/music")
(setq eap-playlist-library "~/music/playlists")
-;;; Turn on `compilation-minor-mode' whenever `pony-minor-mode' starts
-;;; in a `comint-mode' buffer. Since buffers like `*ponymanage*' and
-;;; `*ponyserver*' don't have their own specialized modes, but use
-;;; `comint-mode' and turn on `pony-minor-mode', and I don't want to
-;;; enable `compilation-minor-mode' for *every* `comint-mode' buffer,
-;;; we can add a hook that adds a local hook.
-(defun turn-on-compilation-for-pony ()
- (add-hook 'pony-minor-mode-hook 'compilation-minor-mode nil t))
-(add-hook 'comint-mode-hook 'turn-on-compilation-for-pony)
+;;;; Auto-complete
+
+(setq-default ac-sources '(ac-source-imenu
+ ac-source-gtags
+ ac-source-abbrev
+ ac-source-yasnippet
+ ac-source-words-in-buffer
+ ac-source-words-in-same-mode-buffers
+ ac-source-dictionary
+ ac-source-functions
+ ac-source-symbols
+ ac-source-variables
+ ac-source-features))
+
+;;;; Magit
+
+(setq magit-default-tracking-name-function
+ 'magit-default-tracking-name-branch-only)
+(setq magit-diff-refine-hunk 'all)
;;; Finally, load any `customize' settings and slime.
(load custom-file)
diff --git a/emacs/init.org b/emacs/init.org
new file mode 100644
index 0000000..6605dcd
--- /dev/null
+++ b/emacs/init.org
@@ -0,0 +1,1599 @@
+#+TITLE: Emacs Init
+#+STARTUP: showall
+#+HTML_HEAD: <link href="http://ryuslash.org/bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
+#+PROPERTy: tangle init.el
+#+OPTIONS: num:nil
+
+* Turn off useless visual components :gui:
+
+ Turn the menu, scroll-bar and tool-bar off quickly. If this happens
+ later on then the GUI will show these components for a longer time.
+ Even though these options are also specified in my [[file:../.Xdefaults][Xdefaults]] I like
+ having them here too, as a precaution and to turn them off for
+ non-graphical interfaces as well.
+
+ #+BEGIN_SRC emacs-lisp :padline no
+ (menu-bar-mode -1)
+ (scroll-bar-mode -1)
+ (tool-bar-mode -1)
+ #+END_SRC
+
+* Setup load-path :load_path:
+
+ Not everything can be installed with ~package.el~. Or some things can,
+ but I prefer installing them manually because it's easier. Anyway,
+ some additions should be made to =load-path= and if the file
+ ~loaddefs.el~ exists, load it for the autoloads.
+
+ #+BEGIN_SRC emacs-lisp
+ (mapc #'(lambda (dir)
+ (add-to-list 'load-path dir)
+ (let ((loaddefs (concat dir "/loaddefs.el")))
+ (when (file-exists-p loaddefs)
+ (load loaddefs))))
+ '("~/.emacs.d/site-lisp" "~/projects/emacs/pony-mode/src"
+ "~/projects/emacs/php-mode" "~/.emacs.d/vendor-lisp/org/lisp"
+ "~/.emacs.d/vendor-lisp/org/contrib/lisp"))
+ #+END_SRC
+
+* Load other functions
+
+ Including all the functions being used here would make this file
+ immens and perhaps also somewhat unclear. In any case there are a
+ number of functions that I have found on the web in ~ext.el~, and a
+ number that I have written myself in ~oni.el~. So load them.
+
+ #+BEGIN_SRC emacs-lisp
+ (require 'ext)
+ (require 'oni)
+ #+END_SRC
+
+* Load theme :theme:
+
+ I have been experimenting with my own color theme for quite a while
+ now. I use ~package.el~ to install it, so to load it I need to wait
+ until after it has been loaded to enable it. Some of these settings
+ have also been specified in my [[file:../.Xdefaults][Xdefaults]] so that it doesn't start
+ with a completely white background (for too long).
+
+ #+BEGIN_SRC emacs-lisp
+ (setq custom-theme-directory "~/.emacs.d/themes")
+ (oni:eval-after-init (load-theme 'yoshi t))
+ #+END_SRC
+
+* Replace yes or no with y or n :y_or_n_p:
+
+ I have never had the trouble of accidentally pressing ~y~ at the
+ moment Emacs wants to ask me something. And having to type ~yes <RET>~
+ for a simple question gets in the way of things, so I prefer
+ =y-or-n-p=.
+
+ #+BEGIN_SRC emacs-lisp
+ (defalias 'yes-or-no-p 'y-or-n-p)
+ #+END_SRC
+
+* Replace list-buffers with ibuffer :ibuffer:
+
+ ~ibuffer~ offers some excellent ways to manage buffers. One of which
+ is the function to filter the buffer list on (almost) any predicate,
+ including the buffer's mode. ~list-buffers~ is simplistic compared to
+ this.
+
+ #+BEGIN_SRC emacs-lisp
+ (defalias 'list-buffers 'ibuffer)
+ #+END_SRC
+
+* Replace dabbrev with hippie-expand :hippie_expand:
+
+ =hippie-expand= has an expansion that functions the same as
+ =dabbrev-expand= and it also has many more. I cannot think of a reason
+ why =dabbrev-expand= should be used when =hippie-expand= is also an
+ option.
+
+ #+BEGIN_SRC emacs-lisp
+ (defalias 'dabbrev-expand 'hippie-expand)
+ #+END_SRC
+
+* Hide compilation window after success :compilation:
+
+ If compilation was succesfull I really don't need to see the
+ compilation window. So if either ~*Compilation*~ or ~*compilation*~
+ finishes correctly, delete the windows and show a message instead.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun ext:comp-finish-function (buf str)
+ "Close the compilation buffer quickly if everything went OK."
+ (if (string-match "exited abnormally" str)
+ ;; there were errors
+ (message "compilation errors, press C-x ` to visit")
+ ;; no errors, make the compilation window go away in 0.5 seconds
+ (when (member (buffer-name) '("*Compilation*" "*compilation*"))
+ (delete-windows-on buf)
+ (message "No compilation errors!"))))
+
+ (add-to-list 'compilation-finish-functions 'ext:comp-finish-function)
+ #+END_SRC
+
+* Scroll compilation window :compilation:
+
+ Even though I don't need to see the result of the compilation if
+ everything went as it should, scroll the output window so that I can
+ see whether there are any warnings and I should have a look anyway.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq compilation-scroll-output t)
+ #+END_SRC
+
+* Enable auto-fill-mode :auto_fill:
+
+ =auto-fill-mode= automatically inserts newlines when a line becomes
+ too long. This is useful for both text modes and the comments in
+ programming modes. What it takes for a line to become too long is
+ specified by the =fill-column= variable.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'prog-mode-hook 'auto-fill-mode)
+ (add-hook 'text-mode-hook 'auto-fill-mode)
+ #+END_SRC
+
+* Enable eldoc-mode :eldoc:
+
+ =eldoc-mode= shows the arguments for the function call at point in the
+ minibuffer, or in the mode-line if you're in the minibuffer. This is
+ very useful when writing Emacs Lisp code.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
+ (add-hook 'ielm-mode-hook 'eldoc-mode)
+ #+END_SRC
+
+* Enable fill-column-indicator :fill_column_indicator:
+
+ Emacs has many packages that try to deal with showing a right
+ margin, the 80th column which your code should not go beyond. None
+ of these packages get it quite right, but =fill-column-indicator= gets
+ pretty close.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'html-mode-hook 'fci-mode)
+ (add-hook 'prog-mode-hook 'fci-mode)
+ #+END_SRC
+
+* Enable flycheck-mode :flycheck:
+
+ Flycheck is a modern version of Flymake. They're not actually
+ related, but Flycheck did come from the idea of Flymake. Flycheck
+ has some interesting graphical elements (uses the fringe) and seems
+ to have a pretty flexible way of creating new checkers. I enable it
+ for all the modes that I use it supports.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'css-mode-hook 'flycheck-mode)
+ (add-hook 'emacs-lisp-mode-hook 'flycheck-mode)
+ (add-hook 'go-mode-hook 'flycheck-mode)
+ (add-hook 'html-mode-hook 'flycheck-mode)
+ (add-hook 'js2-mode-hook 'flycheck-mode)
+ (add-hook 'lua-mode-hook 'flycheck-mode)
+ (add-hook 'php-mode-hook 'flycheck-mode)
+ (add-hook 'python-mode-hook 'flycheck-mode)
+ (add-hook 'rst-mode-hook 'flycheck-mode)
+ (add-hook 'ruby-mode-hook 'flycheck-mode)
+ (add-hook 'rust-mode-hook 'flycheck-mode)
+ (add-hook 'sh-mode-hook 'flycheck-mode)
+ #+END_SRC
+
+* Enable flyspell-mode :flyspell:
+
+ What Flymake and Flycheck are to compilation, Flyspell is to
+ spelling. Runs spell checking in the background and highlights
+ spelling errors. It might be useful in programming mode comments,
+ but that seems a bit over the top for me, I care about the code, not
+ so much about the words used. So I only enable it in =text-mode=.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'text-mode-hook 'flyspell-mode)
+ #+END_SRC
+
+* Enable paredit-mode :paredit:
+
+ I had long thought of =paredit-mode= as overly complex and not very
+ useful. Though maybe I did try it out last before I started writing
+ so much Lisp code. In any case, I was wrong, it is one of the best
+ modes to use when editing Lisp and Lisp-like languages, changes your
+ whole perspective on the code.
+
+ #+BEGIN_SRC emacs-lisp
+ (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)
+ (add-hook 'ielm-mode-hook 'paredit-mode)
+ #+END_SRC
+
+* Enable rainbow-delimiters-mode :rainbow_delimiters:
+
+ Any language can have quite deeply nested "delimeters", meaning
+ parentheses, brackets, curly braces. It helps to see their depth
+ visually. Not just in Lisp.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
+ #+END_SRC
+
+* Enable rainbow-mode :rainbow:
+
+ When editing color-heavy "code", like CSS, it's useful to be able to
+ see color you're specifying. =rainbow-mode= does this.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'css-mode-hook 'rainbow-mode)
+ #+END_SRC
+
+* Enable slime-js-minor-mode :js2:
+
+ SLIME is one of the coolest things about using Emacs to edit Lisp
+ code, so if there is something similar for JavaScript, even makes it
+ worth it to use the seemingly over-engineered =js2-mode=.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'js2-mode-hook 'slime-js-minor-mode)
+ #+END_SRC
+
+* Enable smartparens-mode :smartparens:
+
+ =smartparens-mode= is a less strict and less lisp-focused mode that
+ tries to do something similar to =paredit-mode=. It is nice to use if
+ you're not writing in a Lisp-like language.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'html-mode-hook 'smartparens-mode)
+ (add-hook 'python-mode-hook 'smartparens-mode)
+ #+END_SRC
+
+* Enable visual-line-mode :visual_line:
+
+ Having words run off the screen in a chat session is unpleasant.
+ Having the words cut-off wherever the line ends is even worse! Use
+ =visual-line-mode= to get some proper word wrapping behaviour in these
+ buffers.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'jabber-chat-mode-hook 'visual-line-mode)
+ (add-hook 'erc-mode-hook 'visual-line-mode)
+ #+END_SRC
+
+* Enable whitespace-mode :whitespace:
+
+ In most programming languages whitespace is pretty unimportant. As
+ long as the readers can stand it the compilers/interpreters usually
+ don't care. Of course this is not true for Python, and Markdown also
+ has special meanings for some whitespace in some places, so enabling
+ =whitespace-mode= is a good idea, just for these two situations.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'markdown-mode-hook 'whitespace-mode)
+ (add-hook 'python-mode-hook 'whitespace-mode)
+ #+END_SRC
+
+* Enable yas-minor-mode :yas:
+
+ I still need to figure out where this mode comes in in my workflow.
+ I try to limit code-repetition as much as I can and anything that
+ does repeat often is so trivial that it doesn't benefit from
+ snippets. And using snippets for =if= statements and such doesn't
+ strike me as terribly useful either. But perhaps I haven't seen the
+ magic of it yet. I do know that it is an interesting tool and I wish
+ to find a use for it at some point.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'html-mode-hook 'yas-minor-mode)
+ (add-hook 'org-mode-hook 'yas-minor-mode)
+ (add-hook 'prog-mode-hook 'yas-minor-mode)
+ #+END_SRC
+
+* Enable tagedit-mode :tagedit:
+
+ =tagedit-mode= tries to be for XML/HTML what =paredit-mode= is for Lisp.
+ And because of this, it *rocks*. It almost makes me feel sorry that I
+ don't write all that much XML or HTML nowadays. Enable the
+ experimental features as well, so it's really close to =paredit-mode=.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:turn-on-tagedit-mode ()
+ (require 'tagedit)
+ (tagedit-mode)
+ (tagedit-add-paredit-like-keybindings)
+ (tagedit-add-experimental-features))
+
+ (add-hook 'html-mode-hook 'oni:turn-on-tagedit-mode)
+ #+END_SRC
+
+* Disable the pylint and pyflakes checkers :flycheck:
+
+ I use flake8 in =python-mode=, so I have no need for the =python-pylint=
+ and =python-pyflakes= checkers. Since this works on a variable that is
+ defined in the ~flycheck~ package, it should only run *after* ~flycheck~
+ has been loaded.
+
+ #+BEGIN_SRC emacs-lisp
+ (eval-after-load "flycheck"
+ '(progn
+ (mapc (lambda (c) (delq c flycheck-checkers))
+ '(python-pylint python-pyflakes))))
+ #+END_SRC
+
+* Make ^L look pretty :ppcL:
+
+ Occasionally I might put a ~^L~ character in some code to create a
+ page separator. But seeing ~^L~ there isn't all that pretty, not when
+ you have something like ~pp^L-mode~. Show a line of ~-~ all the way to
+ the =fill-column= - =1=. To do this we should also remove the prefix.
+
+ If the variable =fci-rule-colum= is bound, use that, so that it
+ always goes up-to, but not beyond the little red line shown at the
+ right margin.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:pretty-control-l-function (win)
+ "Just make a string of either `fci-rule-column' or
+ `fill-column' length -1. Use the `-' character. WIN is ignored."
+ (ignore win)
+ (make-string
+ (1- (if (boundp 'fci-rule-column) fci-rule-column fill-column)) ?-))
+
+ (setq pp^L-^L-string-function 'oni:pretty-control-l-function
+ pp^L-^L-string-pre nil)
+ #+END_SRC
+
+ This mode should be activated each time a frame is made, since it
+ uses certain frame properties.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'emacs-startup-hook 'pretty-control-l-mode)
+ (add-hook 'after-make-frame-functions
+ '(lambda (arg) (pretty-control-l-mode)))
+ #+END_SRC
+
+* Auto-join some channels in ERC :erc:
+
+ If ever I log in to IRC with ERC I would like to join these
+ channels, seeing as how *if* I talk, it's usually in one of these.
+ Though it's rare.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq erc-autojoin-channels-alist
+ '(("freenode.net" "#ninthfloor" "#emacs" "#dispass")))
+ #+END_SRC
+
+* Don't show part messages in ERC :erc:
+
+ They don't interest me.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq erc-hide-list '("PART"))
+ #+END_SRC
+
+ I used to hide more messages, but I found out that it can be
+ confusing to not be able to see *any* joins and quits at all.
+
+* Move the timestamp in ERC :erc:
+
+ I prefer having a timestamp on the left-side of a message in the
+ form of ~00:00~ instead of te usual. Having it right-aligned messes up
+ the non-filled text and having it only show up when it's changed
+ makes the buffer messy.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq erc-insert-timestamp-function 'erc-insert-timestamp-left
+ erc-timestamp-format "[%H:%M] "
+ erc-timestamp-only-if-changed-flag nil)
+ #+END_SRC
+
+* Set IRC nickname :erc:
+
+ This way I don't have to tell ERC what my nickname is every time.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq erc-nick "ryuslash")
+ #+END_SRC
+
+* Turn off filling in ERC :erc:
+
+ Turn of =erc-fill-mode= so that =visual-line-mode= can do its thing.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:turn-off-erc-fill-mode () (erc-fill-mode -1))
+ (add-hook 'erc-mode-hook 'oni:turn-off-erc-fill-mode)
+ #+END_SRC
+
+* Specify some visual commands for eshell :eshell:
+
+ Eshell uses buffered input, always, but some commands need
+ unbuffered input, put those commands in =eshell-visual-commands= to
+ have them open in a dedicated =*term*= buffer. Since this variable is
+ defined in the ~em-term~ module, it should only be changed after shis
+ module loads.
+
+ #+BEGIN_SRC emacs-lisp
+ (eval-after-load "em-term"
+ '(add-to-list 'eshell-visual-commands "unison"))
+ #+END_SRC
+
+* Disable prompt highlighting in eshell :eshell:
+
+ Since I'm using a custom prompt with some custom colors I don't need
+ the eshell prompt to be highlighted, which overwrites any colors I
+ specify.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq eshell-highlight-prompt nil)
+ #+END_SRC
+
+* Customize eshell prompt :eshell:
+
+ Create a prompt that shows the following:
+
+ - The exit code of the previous command: a green ~+~ for exit code ~0~
+ and a red ~-~ for any non-zero exit code.
+
+ - The hostname of the device running the current Emacs instance.
+
+ - An abbreviated indication of the current directory. To keep things
+ short this abbreviation is the first letter of each parent
+ directory and the full name of the current directory, still
+ separated by ~/~, though.
+
+ - Which branch (if any) the current directory has been checked-out
+ of. This is not shown if the current directory is not a git
+ directory.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:eshell-prompt-function ()
+ "Show a pretty shell prompt."
+ (let ((status (if (zerop eshell-last-command-status) ?+ ?-))
+ (hostname (oni:hostname))
+ (dir (abbreviate-file-name (eshell/pwd)))
+ (branch
+ (shell-command-to-string
+ "git branch --contains HEAD 2>/dev/null | sed -e '/^[^*]/d'")))
+ (concat
+ (propertize (char-to-string status)
+ 'face `(:foreground ,(if (= status ?+)
+ "green"
+ "red")))
+ " "
+ (propertize hostname 'face 'mode-line-buffer-id)
+ " "
+ (propertize (oni:shorten-dir dir) 'face 'font-lock-string-face)
+ " "
+ (when (not (string= branch ""))
+ (propertize
+ ;; Cut off "* " and "\n"
+ (substring branch 2 -1)
+ 'face 'font-lock-function-name-face))
+ " \n> ")))
+ #+END_SRC
+
+ Set the prompt function to the function above and tell eshell the
+ format of its prompt.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq eshell-prompt-function 'oni:eshell-prompt-function
+ eshell-prompt-regexp "^> ")
+ #+END_SRC
+
+* Add a pop-up function for eshell :eshell:
+
+ When working I often need to switch to a shell to issue some quick
+ commands and then be on my merry way again, to help with this I have
+ added a function which tries to move the current working directory
+ to that of the file being worked on and shows eshell. I bind this
+ function to ~f8~ for easy access.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:raise-eshell ()
+ "Start or switch back to `eshell'.
+ Also change directories to current working directory."
+ (interactive)
+ (let ((dir (file-name-directory
+ (or (buffer-file-name) "~/")))
+ (hasfile (not (eq (buffer-file-name) nil)))
+ (started (and (boundp 'eshell-buffer-name) eshell-buffer-name
+ (buffer-live-p (get-buffer eshell-buffer-name)))))
+ (eshell)
+ (when (and hasfile (eq eshell-process-list nil))
+ (eshell/cd dir)
+ (when started
+ (eshell-reset)))))
+
+ (global-set-key (kbd "<f8>") 'oni:raise-eshell)
+ #+END_SRC
+
+* Disable undo in eshell buffers :eshell:
+
+ Eshell buffers can get big and undo does not serve any real purpose
+ in these buffers. Instead of getting boundary limit popups all the
+ time, which I do want to keep for other buffers, it's easier to
+ just turn off undo information for such buffers.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'eshell-mode-hook 'buffer-disable-undo)
+ #+END_SRC
+
+* Disable bidirectional support :bidi:
+
+ Since I don't ever get any mail from people that use right-to-left
+ text, and even if I did I wouldn't be able to read it, I don't need
+ bidirectional text support. You shouldn't actually disable it (if
+ that's even still possible) since, supposedly, it is an integral
+ part of the display engine now, but telling it to always use
+ left-to-right should keep it from slowing your emacs down.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq-default bidi-paragraph-direction 'left-to-right)
+ #+END_SRC
+
+* Enable some "advanced" functions
+
+ These functions are disabled by default, because beginners find them
+ confusing, apparently. Though I won't say I'm an Emacs master or
+ guru, I *can* say that I'm not a beginner, and these functions have
+ not confused me yet. So enable them.
+
+ #+BEGIN_SRC emacs-lisp
+ (put 'downcase-region 'disabled nil)
+ (put 'narrow-to-page 'disabled nil)
+ (put 'narrow-to-region 'disabled nil)
+ (put 'scroll-left 'disabled nil)
+ (put 'upcase-region 'disabled nil)
+ #+END_SRC
+
+* Don't echo status changes for jabber :jabber:
+
+ If I'm talking to someone I'll see their status and if they're
+ offline and I want to say something I can say it anyway, I don't
+ need constant updates in my echo-area on the status of my jabber
+ buddies. But since this relies on something from the ~jabber~ module,
+ only run it after that module has been loaded.
+
+ #+BEGIN_SRC emacs-lisp
+ (eval-after-load "jabber"
+ '(remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo))
+ #+END_SRC
+
+* Use libnotify for jabber notifications :jabber:
+
+ The functions don't seem to be loaded automatically, so add
+ autoloads for the libnotify functions.
+
+ #+BEGIN_SRC emacs-lisp
+ (autoload 'jabber-message-libnotify "jabber-libnotify")
+ (autoload 'jabber-muc-libnotify "jabber-libnotify")
+
+ (add-hook 'jabber-alert-message-hooks 'jabber-message-libnotify)
+ (add-hook 'jabber-alert-muc-hooks 'jabber-muc-libnotify)
+ #+END_SRC
+
+* Enable history :jabber:
+
+ Enable chat history for both regular chats and multi-user chats. I
+ disabled history completely for a long time, but sometimes you miss
+ things that way. Store history in per-contact files under
+ ~HOME/.emacs.d/jabber-hist~.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq jabber-history-enabled t
+ jabber-history-muc-enabled t
+ jabber-use-global-history nil
+ jabber-history-dir "~/.emacs.d/jabber-hist")
+ #+END_SRC
+
+* Setup accounts for jabber :jabber:
+
+ Each account should have the current hostname appended to its
+ account name, so that multiple PCs can log in on the same account at
+ the same time and it's easy to note from where I'm talking.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq jabber-account-list `((,(concat "tom@ryuslash.org/" (oni:hostname))
+ (:connection-type . ssl))))
+ #+END_SRC
+
+* Have ido ignore certain buffers :ido:
+
+ These buffers are either uninteresting, reached through other means
+ (such as a special keybinding) or they get in the way of how I work.
+ For any or all of these reasons I wish to ignore them.
+
+ - ~^\\`\s~ :: Any buffers that start with a space should be ignored.
+
+ - ~^irc\\.~ :: Any buffer that starts with ~irc.~ is a buffer that has
+ informational messages on the irc server I'm connected
+ to, these don't change often and have other ways of
+ grabbing my attention. If I need them I will find them.
+
+ - ~^\\#~ :: Any buffer starting with an ~#~ is most-likely an IRC chat
+ buffer, these have ways of letting me know it there is
+ anything interesting going on there, I don't usually need
+ them clogging up my ido.
+
+ - ~^\\*Customize Option:~ :: Anything starting with ~*Customize Option:~
+ is part of Emacs's customize interface and thus doesn't need to
+ be shown in the ido buffer list.
+
+ - ~*-jabber-roster-*~ :: Is also accessible through ~f6~, so no need for
+ it in my ido list.
+
+ - ~*Messages*~ :: Also accessible through ~C-h e~, so no need for it.
+
+ - ~*fsm-debug*~ :: A buffer used by ~jabber.el~ to track some debug
+ information, I have never had to look at it yet.
+
+ - ~*magit-process*~ :: The buffer where magit's git process runs,
+ usually accessible with ~$~ from any magit buffer, and the only
+ other time I need to find is if I have to kill it to reset
+ magit's process.
+
+ - ~*magit-edit-log*~ :: The commit message buffer from magit. Usually
+ accessible with ~C-c c~ if needed.
+
+ - ~*Backtrace*~ :: Usually only interesting for as long as I'm looking
+ at it, if I bury it, I usually don't need it
+ anymore.
+
+ - ~*Ibuffer*~ :: is reached by the key compination ~C-x C-b~, is
+ therefore not needed to show up when using ido, and
+ even gets glitchy when using ido, because the
+ information doesn't get updated.
+
+ Since this requires a variable defined in the ~ido~ module, delay
+ execution until it is loaded.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:ido-init ()
+ "Initialization functionn for ido."
+ (setq ido-ignore-buffers
+ (list "^\\` " "^irc\\." "^\\#" "^\\*Customize Option:"
+ (eval-when-compile
+ (regexp-opt
+ '("*-jabber-roster-*"
+ "*Messages*"
+ "*fsm-debug*"
+ "*magit-process*"
+ "*magit-edit-log*"
+ "*Backtrace*"
+ "*Ibuffer*"))))))
+
+ (eval-after-load "ido" '(oni:ido-init))
+ #+END_SRC
+
+* Disable automatic merging in ido :ido:
+
+ ido has this wonderful/infuriating feature of trying to correct your
+ mistakes by suggesting files in other directories if it can't find
+ the file you wish to open in the current directory. This becomes
+ bothersome especially when working with django, since the same files
+ tend to show up in several directories. Disable it.
+
+ According to the docstring this should be a way to disable it,
+ previously I just used a very long timeout by setting
+ =ido-auto-merge-delay-time= to ~1000000~.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq ido-auto-merge-work-directories-length -1)
+ #+END_SRC
+
+* Instruct ido to open buffers in selected window :ido:
+
+ By default, when more than one frame exists and you try to switch
+ to a buffer that is already visible in another frame, ido pops up
+ the other frame. This is not what I want, just open the buffer in
+ the selected window no matter what.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq ido-default-buffer-method 'selected-window)
+ #+END_SRC
+
+* Minimize maximum minibuffer height for ido :ido:
+
+ I hate it when the minibuffer gets bigger than one line, so don't
+ let ido do that.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq ido-max-window-height 1)
+ #+END_SRC
+
+* Don't save history for ido :ido:
+
+ I don't see the point in saving that history.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq ido-save-directory-list-file nil)
+ #+END_SRC
+
+* Turn on ido-mode :ido:
+
+ =ido-mode= is an excellent file and buffer selection tool, it
+ improves upon regular selection in numerous ways.
+
+ #+BEGIN_SRC emacs-lisp
+ (ido-mode)
+ #+END_SRC
+
+* Exclude functions from ido-ubiquitous :ido_ubiquitous:
+
+ Not all functions work well with =ido-ubiquitous-mode=, like
+ =org-refile=, so exclude them from using =ido-ubiquitous-mode=.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq ido-ubiquitous-command-exceptions '(org-refile org-capture-refile))
+ #+END_SRC
+
+* Enable ido-ubiquitous-mode :ido_ubiquitous:
+
+ =ido-ubiquitous-mode= lets you use ido for almost anything! Anything
+ which looks and acts like file or buffer selection anyway.
+
+ Since it is installed with ELPA, wait until /after/ emacs has been
+ initialized.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'emacs-startup-hook 'ido-ubiquitous-mode)
+ #+END_SRC
+
+* Enable idomenu :idomenu:
+
+ Imenu is an awesome feature, but since I don't use any menus it is
+ a little lost on me. =idomenu= uses Imenu, but shows it in an
+ ido-like way, which works perfectly. Bind it to ~M-n~.
+
+ #+BEGIN_SRC emacs-lisp
+ (global-set-key (kbd "M-n") 'idomenu)
+ #+END_SRC
+
+* Use electric default in minibuffer :minibuffer:
+
+ The =minibuffer-electric-default-mode= hides the default value if you
+ start typing. This leaves more room for typing. I also want the
+ "short" default indicator (~[default]~ instead of ~(default: default)~).
+
+ #+BEGIN_SRC emacs-lisp
+ (setq minibuffer-eldef-shorten-default t)
+ (minibuffer-electric-default-mode)
+ #+END_SRC
+
+* Don't show help message on empty parts :mode_line:
+
+ When hovering the mouse over empty parts of the mode-line, just show
+ nothing, don't clutter up my echo area and ~*Messages*~ buffer.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq mode-line-default-help-echo "")
+ #+END_SRC
+
+* Enable jedi :jedi:
+
+ jedi is an interesting auto-completion program for the Python
+ programming language. On archlinux the program you usually want to
+ use is ~python2~, so change the =jedi:server-command= accordingly and
+ run =jedi:setup= when =python-mode= starts to enable it.
+
+ #+BEGIN_SRC emacs-lisp
+ (eval-after-load "jedi" '(setcar jedi:server-command "python2"))
+ (add-hook 'python-mode-hook 'jedi:setup)
+ #+END_SRC
+
+* Don't use a tooltip :jedi:
+
+ The coolest thing about jedi is its eldoc-like argument display. If
+ it can figure out what the arguments are they're shown. But please
+ don't use tooltips, just the echo area.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq jedi:tooltip-method nil)
+ #+END_SRC
+
+* Org initialization :org:
+
+ Since my intialization for =org-mode= got so big, I moved it to a
+ separate file. This file should be loaded after the =org= module
+ loads.
+
+ #+BEGIN_SRC emacs-lisp
+ (eval-after-load "org" '(require 'org-init))
+ #+END_SRC
+
+* Indent-defun
+
+ The emacsredux website had an interesting [[http://emacsredux.com/blog/2013/03/28/indent-defun/][tip]].
+
+ #+BEGIN_SRC emacs-lisp
+ (global-set-key (kbd "C-M-z") 'ext:indent-defun)
+ #+END_SRC
+
+* Close term buffer after exit :term:
+
+ When quitting the process in a term buffer, in other words, when
+ quitting the shell, kill the buffer. Killing the shell, but not
+ killing the buffer is a pain, it keeps you from quickly starting a
+ term and quickly closing it too. This advice should be disabled if
+ ever the shell crashes, because it doesn't look at the exit code,
+ since the standard exit code is that of the last run command.
+
+ #+BEGIN_SRC emacs-lisp
+ (defadvice term-handle-exit (after oni:kill-buffer-after-exit activate)
+ "Kill the term buffer if the process finished."
+ (kill-buffer (current-buffer)))
+ #+END_SRC
+
+* Changing case
+
+ I have no capslock key, and holding shift whilst typing big words
+ is annoying, so I wrote a couple of functions to help with that and
+ bind them to ~C-c u~ and ~C-c d~.
+
+ #+BEGIN_SRC emacs-lisp
+ (global-set-key (kbd "C-c u") 'oni:upcase-prev)
+ (global-set-key (kbd "C-c d") 'oni:downcase-prev)
+ #+END_SRC
+
+* Turn off usage of tabs for vala-mode :vala:
+
+ Somehow =vala-mode= thinks it's ok for it to decide that it's users
+ should always use tabs. As far as I'm aware the vala compiler has
+ no such restriction, so turn it off.
+
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'vala-mode-hook 'oni:vala-mode-func)
+ #+END_SRC
+
+* Use smex :smex:
+
+ Smex is to command selection what ido is to file selection. Very
+ similar too, it was written with ido specifically in mind.
+
+ #+BEGIN_SRC emacs-lisp
+ (global-set-key (kbd "M-x") 'smex)
+ (global-set-key (kbd "C-M-x") 'smex-major-mode-commands)
+ #+END_SRC
+
+* Autoload define-slime-contrib :js2:
+
+ =slime-js-minor-mode= uses this function but forgets to require its
+ module, so I set up an autoload function for when I need it and
+ haven't yet used slime.
+
+ #+BEGIN_SRC emacs-lisp
+ (autoload 'define-slime-contrib "slime")
+ #+END_SRC
+
+* Autoload some other functions
+
+ These need to have autoloads specified for various reasons, mostly
+ because they're installed manually or because they're old.
+
+ #+BEGIN_SRC emacs-lisp
+ (autoload 'gtags-mode "gtags" nil t)
+ (autoload 'jabber-connect "jabber" nil t)
+ (autoload 'php-mode "php-mode" nil t)
+ (autoload 'po-mode "po-mode" nil t)
+ (autoload 'pony-mode "pony-mode" nil t)
+ (autoload 'sawfish-mode "sawfish" nil t)
+ (autoload 'server-running-p "server")
+ (autoload 'slime-js-minor-mode "slime-js" nil t)
+ (autoload 'w3m-bookmark-view "w3m" nil t)
+ (autoload 'w3m-goto-url "w3m" nil t)
+ (autoload 'xmodmap-mode "xmodmap-mode" nil t)
+ #+END_SRC
+
+* Uniquify buffers better :uniquify:
+
+ The default way to make sure buffer names are unique is rather
+ uninformative, =uniquify= has a few better options.
+
+ #+BEGIN_SRC emacs-lisp
+ (require 'uniquify)
+ #+END_SRC
+
+* Use 4 spaces per indentation level
+
+ Often I see 8 being used, but that just seems too wide to me.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq-default c-basic-offset 4
+ tab-width 4)
+ #+END_SRC
+
+* Place fill-column-indicator :fill_column_indicator:
+
+ Place the ruler one character farther than what I usually prefer to
+ have my lines wrap to, this will indicate where it should not cross,
+ not where it should not continue.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq-default fci-rule-column 73)
+ #+END_SRC
+
+* Disable use of tabs
+
+ By default, use spaces, not tabs. Tabs are madness.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq-default indent-tabs-mode nil)
+ #+END_SRC
+
+* Don't warn about mumamo :php:
+
+ I haven't yet seen a mode that offers good multiple major modes
+ support. And so I don't use any, so don't warn me that I don't.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq-default php-mode-warn-if-mumamo-off nil)
+ #+END_SRC
+
+* Ensure a final newline
+
+ When looking at diffs, it can be annoying to have 2 extra line
+ changes, just because te previous last line suddenly gets a newline
+ and the new one doesn't. Plus it's very uniform to have a ~\n~ at the
+ end of _every_ line.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq-default require-final-newline t)
+ #+END_SRC
+
+* Truncate lines
+
+ Just let most line run off the screen. I don't like wrapping my code
+ around. I shouldn't make my lines too long in the first place, but
+ in case I have a very small window I prefer the lines to remain
+ unchanged, visually.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq-default truncate-lines t)
+ #+END_SRC
+
+* Send appointments to jabber :jabber:
+
+ When an appointment is coming up, show me in a buffer, but also
+ send a message to my jabber account.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq appt-disp-window-function #'oni:appt-display-window-and-jabber)
+ #+END_SRC
+
+* Don't display diary when appt is initialized :appt:
+
+ If the diary is displayed after the initialization of =appt= I would
+ get a diary buffer each time I load =org-mode=. Since I don't use the
+ diary, except for what =org-mode= puts in there for notifications and
+ such, I really don't want to see it, ever.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq appt-display-diary nil)
+ #+END_SRC
+
+* Don't case fold with auto modes
+
+ I haven't had to deal with wrongly-cased filenames since I stopped
+ using windows.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq auto-mode-case-fold nil)
+ #+END_SRC
+
+* Save all auto saves in /tmp
+
+ Having auto save files everywhere cloggs up the filesystem. Move
+ them all into ~/tmp~, though I should probably use a less volatile
+ location.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq auto-save-file-name-transforms
+ `((".*" "~/.local/share/emacs/autosave/" t)))
+ #+END_SRC
+
+* Save all backup files to /tmp
+
+ Having backuf files everywhere also cloggs up the filesystem. Move
+ them all into ~/tmp~ as well, though here too I should probably use a
+ less volatile location.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq backup-directory-alist `((".*" . "~/.local/share/emacs/backup/")))
+ #+END_SRC
+
+* Automatically determine browser :browse:
+
+ Use the =BROWSER= environment variable to figure out which browser to
+ call for =browse-url=. And use the =browse-url-generic= function to open
+ urls, otherwise this setting would have no meaning.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq browse-url-browser-function 'browse-url-generic
+ browse-url-generic-program (getenv "BROWSER"))
+ #+END_SRC
+
+* Customize C indentation :c:
+
+ When writing C code, when calling a function I prefer the
+ indentation to look like:
+
+ #+BEGIN_SRC c :tangle no
+ call_some_function(
+ argument1,
+ argument2
+ );
+ #+END_SRC
+
+ To be able to shorten lines with long function calls. As opposed to
+ the default:
+
+ #+BEGIN_SRC c :tangle no
+ call_some_function(
+ argument1,
+ argument2,
+ );
+ #+END_SRC
+
+ Which doesn't really help in making lines shorter. And I also
+ happen to think it looks hideous.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq c-offsets-alist
+ '((statement-block-intro . +)
+ (knr-argdecl-intro . 5)
+ (substatement-open . +)
+ (substatement-label . 0)
+ (label . 0)
+ (statement-case-open . +)
+ (statement-cont . +)
+ (arglist-intro . +)
+ (arglist-close . 0)
+ (inline-open . 0)
+ (brace-list-open . +)
+ (topmost-intro-cont first c-lineup-topmost-intro-cont
+ c-lineup-gnu-DEFUN-intro-cont)))
+ #+END_SRC
+
+* Move customize settings into their own file :custom:
+
+ Any settings I change using the customize interface should go into
+ a separate file. My ~init.el~ is under version control and I don't
+ want each local change made in this way to be recorded in the VCS.
+ Plus the code generated by customize is an eyesore.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq custom-file "~/.emacs.d/custom.el")
+ #+END_SRC
+
+* Setup some frame parameters
+
+ Disable borders, disable scroll-bars, tool-bars and menu-bars (this
+ is the third place I'm doing this, I *really* want them gone, don't
+ I). And set the preferred font.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq default-frame-alist
+ `((border-width . 0)
+ (internal-border-width . 0)
+ (vertical-scroll-bars . nil)
+ (menu-bar-lines . nil)
+ (tool-bar-lines . nil)
+ (font . "Inconsolata:pixelsize=18")))
+ #+END_SRC
+
+* Stop elnode from running automatically :elnode:
+
+ I like elnode, but it really should stop starting itself up every
+ time I start emacs. Not only can this cause problems with trying
+ to run on the same port, but also this starts running programs that
+ I have no idea of, whatever I was testing last.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq elnode-do-init nil)
+ #+END_SRC
+
+* Mention the buffer in the frame title
+
+ Having 5 Emacs frames all named "emacs" doesn't help to identify
+ them, so add the opened buffer name to the title.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq frame-title-format '(:eval (concat "emacs: " (buffer-name))))
+ #+END_SRC
+
+* Store geiser history under .emacs.d
+
+ Everything Emacs related should be stored under ~HOME/.emacs.d~ so as
+ not to fill my home directory with a bunch of directories.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq geiser-repl-history-filename "~/.emacs.d/geiser-history")
+ #+END_SRC
+
+* Change gnus init file
+
+ My gnus init file is separate, since I don't always immediately use
+ gnus.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq gnus-init-file "~/.emacs.d/gnus")
+ #+END_SRC
+
+* Automatically update gtags TAGS :gtags:
+
+ Before there was this option I had some complicated function to do
+ the same thing from somewhere, now that isn't necessary anymore.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq gtags-auto-update t)
+ #+END_SRC
+
+* Display help-at-point
+
+ When the cursor is in a location where a help message would be
+ shown by hovering the mouse over it, show that help after a short
+ time of idling on that spot. Another step in using no mouse
+ whatsoever without losing any functionality.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq help-at-pt-display-when-idle t)
+ #+END_SRC
+
+* Set inferior lisp program to SBCL :lisp:
+
+ SBCL seems like a very good Lisp implementation to use, widely
+ supported by packagers too. =--noinform= keeps the copyright message
+ from showing up and =--no-linedit= is used by the =linedit= package to
+ determine that it shouldn't be enabled.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq inferior-lisp-program "sbcl --noinform --no-linedit")
+ #+END_SRC
+
+* Inhibit stuff
+
+ I don't need to see the startup message, I don't want the default
+ init messing with my own stuff and I don't even know what
+ =inhibit-local-menu-bar-menus= does, but it doesn't sound like I need
+ is, since I don't use menu bars.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq inhibit-default-init t
+ inhibit-local-menu-bar-menus t
+ inhibit-startup-message t)
+ #+END_SRC
+
+* Change the initial major mode and message
+
+ The =lisp-interaction-mode= is a nice idea on paper, but usually when
+ I want to use the ~*scratch*~ buffer, it just gets in my way, so use
+ =emacs-lisp-mode= instead. Also, by now I know what the ~*scratch*~
+ buffer is for, so I really don't need that message telling me what
+ it does.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq initial-major-mode 'emacs-lisp-mode
+ initial-scratch-message nil)
+ #+END_SRC
+
+* Store jabber avatar cache under .emacs.d :jabber:
+
+ Even though I don't use avatars anymore I don't want ~jabber.el~
+ creating directories all over the place, so just to be safe I put
+ it under ~HOME/.emacs.d~.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq jabber-avatar-cache-directory "~/.emacs.d/jabber-avatars/")
+ #+END_SRC
+
+* Setup formats :jabber:
+
+ Most of the time I prefer having my message start at the beginning
+ of the line, in case someone sends me a piece of code or I send
+ them some, it's easier to read if you don't have to change it first.
+
+ But that leaves a lot of empty space on that prompt line, best fill
+ it up as mucha as is still useful.
+
+ Also show the chat buffer names as just the contact's name prefixed
+ with a ~+~ to keep them short and clean.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq jabber-chat-buffer-format "+%n"
+ jabber-chat-foreign-prompt-format "%t %u/%r <\n"
+ jabber-chat-local-prompt-format "%t %u/%r >\n"
+ jabber-groupchat-buffer-format "++%n"
+ jabber-groupchat-prompt-format "%t %u --\n")
+ #+END_SRC
+
+* Don't use avatars :jabber:
+
+ I did for a while, but since there is no concensus over what is
+ good and what is bad, buffers start looking messy, so I just
+ disabled them completely. I know most of the people I chat with
+ personally, so it doesn't really add much anyway.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq jabber-chat-buffer-show-avatar nil
+ jabber-vcard-avatars-publish nil
+ jabber-vcard-avatars-retrieve nil)
+ #+END_SRC
+
+* Don't fill :jabber:
+
+ Just like ERC, don't fill lines so that =visual-line-mode= can do
+ its thing.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq jabber-chat-fill-long-lines nil)
+ #+END_SRC
+
+* Don't send chatstates :jabber:
+
+ Don't let people know what I'm doing, don't send them information
+ on that I'm typing or not, etc. This isn't very useful and it
+ sometimes creates confusion when I accidentally start typing in the
+ wrong buffer.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq jabber-chatstates-confirm nil)
+ #+END_SRC
+
+* Autojoin some channels :jabber:
+
+ Just one, really, the only one I'm in.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq jabber-muc-autojoin '("aethon@muc.ryuslash.org"))
+ #+END_SRC
+
+* Keep the roster buffer clean :jabber:
+
+ Most of the time I really don't need to see the keybindings for the
+ roster buffers, so hide them initially. And the offline contacts as
+ well.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq jabber-roster-show-bindings nil)
+ (setq jabber-show-offline-contacts nil)
+ #+END_SRC
+
+* Defer font locking a little :fontlock:
+
+ By deferring font-lock for a very short time it should improve
+ scrolling performance.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq jit-lock-defer-time 0.2)
+ #+END_SRC
+
+* Turn on compilation-shell-minor-mode for pony buffers :pony:
+
+ Turn on =compilation-shell-minor-mode= whenever =pony-minor-mode= starts
+ in a =comint-mode= buffer. Since buffers like ~*ponymanage*~ and
+ ~*ponyserver*~ don't have their own specialized modes, but use
+ =comint-mode= and turn on =pony-minor-mode=, and I don't want to enable
+ =compilation-shell-minor-mode= for *every* =comint-mode= buffer, we can
+ add a hook that adds a local hook.
+
+ I use =compilation-shell-minor-mode= because some pony mode buffers
+ are interactive, such as the pony-shell buffer.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun turn-on-compilation-shell-for-pony ()
+ (add-hook 'pony-minor-mode-hook 'compilation-shell-minor-mode nil t))
+ (add-hook 'comint-mode-hook 'turn-on-compilation-shell-for-pony)
+ #+END_SRC
+
+* Make smartparens a little stricter :smartparens:
+
+ Set the delete and backspace keys to some smartparens keybindings
+ that should make pair balancing a little stricter. These key
+ bindings refuse to delete pair delimeters or skip over them if they
+ still have content.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:smartparens-set-keys ()
+ (local-set-key (kbd "DEL") 'sp-backward-delete-char)
+ (local-set-key (kbd "<deletechar>") 'sp-delete-char)
+ (local-set-key (kbd "C-d") 'sp-delete-char))
+
+ (add-hook 'smartparens-mode-on-hook 'oni:smartparens-set-keys)
+ #+END_SRC
+
+* Initialize EMMS :emms:
+
+ Initialize a minimal EMMS setup. Load the default players so we can
+ use mplayer or any of the generic mp3 and ogg players.
+
+ Load the MPD player so we can connect to MPD and use that if
+ possible, set the music directory to MPD's music directory so it
+ knows how to translate filenames to something MPD understands.
+
+ Load the =emms-mode-line= module so we can display some information in
+ the mode-line about which song is playing and set my preferred
+ function for extracting this information. The =emms-info-mpd= function
+ doesn't seem to return anything, so I've had to improvise to turn
+ absolute file names into something nicer.
+
+ #+BEGIN_SRC emacs-lisp
+ (eval-after-load "emms"
+ `(progn
+ (emms-minimalistic)
+ (emms-default-players)
+
+ (require 'emms-player-mpd)
+ (add-to-list 'emms-player-list 'emms-player-mpd)
+ (setq emms-player-mpd-music-directory "/mnt/music/mp3")
+
+ (require 'emms-mode-line)
+ (setq emms-mode-line-mode-line-function 'oni:mode-line-current-song)
+ (emms-mode-line 1)))
+ #+END_SRC
+
+* Enable some smartparen keybindings in python :smartparens:python:
+
+ Since, for example, HTML mode uses the same keys for similar
+ functions from the ~tagedit~ package, these keys should only be
+ enabled for (for the moment) python mode.
+
+ This should be set before the =smartparens-mode= function is added
+ to the =python-mode-hook= so that the hook will run when smartparens
+ is turned on.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:set-smartparens-keys ()
+ (local-set-key (kbd "<C-left>") 'sp-forward-barf-sexp)
+ (local-set-key (kbd "<C-right>") 'sp-forward-slurp-sexp))
+
+ (defun oni:local-set-smartparens-hook ()
+ (add-hook 'smartparens-mode-hook 'oni:set-smartparens-keys nil t))
+
+ (add-hook 'python-mode-hook 'oni:local-set-smartparens-hook)
+ #+END_SRC
+
+* All the rest
+
+ This still needs to be sorted out and documented, haven't had time
+ for it yet.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq magit-repo-dirs '("~/projects/"))
+ (setq message-log-max 1000)
+ (setq message-send-mail-function 'message-send-mail-with-sendmail)
+ (setq message-sendmail-extra-arguments '("-a" "ryuslash"))
+ (setq package-archives
+ '(("melpa" . "http://melpa.milkbox.net/packages/")
+ ("marmalade" . "http://marmalade-repo.org/packages/")
+ ("gnu" . "http://elpa.gnu.org/packages/")))
+ (setq package-load-list '((htmlize "1.39")
+ (lua-mode "20111107")
+ all))
+ (setq php-function-call-face 'font-lock-function-name-face)
+ (setq php-mode-force-pear t)
+ (setq pony-tpl-indent-moves t)
+ (setq rainbow-delimiters-max-face-count 12)
+ (setq redisplay-dont-pause t)
+ (setq send-mail-function 'sendmail-send-it)
+ (setq sendmail-program "/usr/bin/msmtp")
+ (setq sentence-end-double-space nil)
+ (setq smex-key-advice-ignore-menu-bar t)
+ (setq smex-save-file "~/.emacs.d/smex-items")
+ (setq split-height-threshold 40)
+ (setq time-stamp-active t)
+ (setq time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)")
+ (setq type-break-good-rest-interval (* 60 10))
+ (setq type-break-interval (* 60 50))
+ (setq type-break-keystroke-threshold '(nil . nil))
+ (setq uniquify-buffer-name-style 'post-forward)
+ (setq use-dialog-box nil)
+ (setq user-full-name "Tom Willemse")
+ (setq user-mail-address "tom@ryuslash.org")
+ (setq w3m-fill-column 72)
+ (setq window-combination-resize t)
+ (setq yas-fallback-behavior nil)
+ (setq yas-prompt-functions '(yas-ido-prompt))
+
+ (add-hook 'after-change-major-mode-hook 'set-current-mode-icon)
+ (add-hook 'after-save-hook 'oni:after-save-func t)
+ (add-hook 'before-save-hook 'oni:before-save-func)
+ (add-hook 'c-mode-hook 'oni:c-mode-func)
+ (add-hook 'css-mode-hook 'oni:css-mode-func)
+ (add-hook 'diary-display-hook 'oni:diary-display-func)
+ (add-hook 'emacs-startup-hook 'oni:emacs-startup-func)
+ (add-hook 'go-mode-hook 'oni:go-mode-func)
+ (add-hook 'gtags-mode-hook 'oni:gtags-mode-func)
+ (add-hook 'haskell-mode-hook 'oni:haskell-mode-func)
+ (add-hook 'jabber-roster-mode-hook 'oni:jabber-roster-mode-func)
+ (add-hook 'java-mode-hook 'oni:java-mode-func)
+ (add-hook 'js-mode-hook 'oni:js-mode-func)
+ (add-hook 'js2-mode-hook 'oni:js2-mode-func)
+ (add-hook 'lua-mode-hook 'oni:lua-mode-func)
+ (add-hook 'markdown-mode-hook 'oni:markdown-mode-func)
+ (add-hook 'php-mode-hook 'oni:php-mode-func)
+ (add-hook 'prog-mode-hook 'oni:prog-mode-func)
+ (add-hook 'python-mode-hook 'oni:python-mode-func)
+ (add-hook 'term-mode-hook 'oni:term-mode-func)
+ (add-hook 'write-file-hooks 'oni:write-file-func)
+ (add-hook 'yas-minor-mode-hook 'oni:yas-minor-mode-func)
+
+ (define-key key-translation-map (kbd "C-j") (kbd "C-l"))
+ (define-key key-translation-map (kbd "C-l") (kbd "C-j"))
+
+ (global-set-key (kbd "'") 'oni:self-insert-dwim)
+ (global-set-key (kbd "<XF86HomePage>") 'oni:raise-scratch)
+ (global-set-key (kbd "<XF86Mail>") 'gnus)
+ (global-set-key (kbd "<f10>") 'git-project-show-files)
+ (global-set-key (kbd "<f5>") 'ext:reload-buffer)
+ (global-set-key (kbd "<f6>") 'jabber-switch-to-roster-buffer)
+ (global-set-key (kbd "<f7>") 'magit-status)
+ (global-set-key (kbd "<hiragana>") 'oni:show-org-index)
+ (global-set-key (kbd "C-<") 'oni:indent-shift-left)
+ (global-set-key (kbd "C->") 'oni:indent-shift-right)
+ (global-set-key (kbd "C-M-4") 'split-window-vertically)
+ (global-set-key (kbd "C-M-SPC") 'er/expand-region)
+ (global-set-key (kbd "C-M-d") 'kill-word)
+ (global-set-key (kbd "C-M-w") 'backward-kill-word)
+ (global-set-key (kbd "C-S-k") 'kill-whole-line)
+ (global-set-key (kbd "C-a") 'oni:move-beginning-of-dwim)
+ (global-set-key (kbd "C-c a") 'org-agenda)
+ (global-set-key (kbd "C-c c") 'org-capture)
+ (global-set-key (kbd "C-c i p") 'identica-update-status-interactive)
+ (global-set-key (kbd "C-c p") 'oni:show-buffer-position)
+ (global-set-key (kbd "C-c t") 'oni:raise-ansi-term)
+ (global-set-key (kbd "C-e") 'oni:move-end-of-dwim)
+ (global-set-key (kbd "M-0") 'delete-window)
+ (global-set-key (kbd "M-1") 'delete-other-windows)
+ (global-set-key (kbd "M-2") 'split-window-below)
+ (global-set-key (kbd "M-3") 'split-window-right)
+ (global-set-key (kbd "M-4") 'split-window-horizontally)
+ (global-set-key (kbd "M-o") 'other-window)
+ (global-set-key (kbd "\"") 'oni:self-insert-dwim)
+
+ (if (daemonp)
+ (global-set-key "\C-x\C-c" 'oni:close-client-window))
+
+ (when (or window-system (daemonp))
+ (global-unset-key "\C-z"))
+
+ (add-to-list 'auto-mode-alist '("\\.jl$" . sawfish-mode))
+ (add-to-list 'auto-mode-alist '("\\.js\\(on\\)?$" . js2-mode))
+ (add-to-list 'auto-mode-alist
+ '("\\.m\\(ark\\)?d\\(?:o?wn\\)?$" . markdown-mode))
+ (add-to-list 'auto-mode-alist '("\\.php[345]?$" . php-mode))
+ (add-to-list 'auto-mode-alist '("\\.po\\'\\|\\.po\\." . po-mode))
+ (add-to-list 'auto-mode-alist '("\\.tpl$" . html-mode))
+ (add-to-list 'auto-mode-alist '("^PKGBUILD$" . shell-script-mode))
+ (add-to-list 'auto-mode-alist '("^\\.Xmodmap$" . xmodmap-mode))
+
+ (add-to-list 'debug-ignored-errors "^Can't shift all lines enough")
+
+ (add-to-list
+ 'display-buffer-alist
+ '("^\\*\\(?:.+-\\)?scratch\\*$" display-buffer-same-window))
+ (add-to-list
+ 'display-buffer-alist
+ '("^\\*git-project-list\\*$" git-project-show-window))
+ (add-to-list
+ 'display-buffer-alist
+ '("^\\*magit: .*\\*$" display-buffer-same-window))
+
+ (blink-cursor-mode -1)
+ (column-number-mode -1)
+ (line-number-mode -1)
+ (tooltip-mode -1)
+
+ (package-initialize)
+
+ (auto-insert-mode)
+ (electric-indent-mode)
+ (savehist-mode)
+ (show-paren-mode)
+ (winner-mode)
+
+ (smex-initialize)
+ (help-at-pt-set-timer)
+ (windmove-default-keybindings)
+ (global-diff-hl-mode)
+
+ ;;; Diminish lighter for a bunch of minor modes that should be on in
+ ;;; certain modes and usually just clogg up the mode line.
+ (diminish 'auto-fill-function)
+
+ (eval-after-load "auto-complete" '(diminish 'auto-complete-mode))
+ (eval-after-load "eldoc" '(diminish 'eldoc-mode))
+ (eval-after-load "flycheck" '(diminish 'flycheck-mode))
+ (eval-after-load "paredit" '(diminish 'paredit-mode))
+ (eval-after-load "rainbow-mode" '(diminish 'rainbow-mode))
+ (eval-after-load "smartparens" '(diminish 'smartparens-mode))
+ (eval-after-load "yasnippet" '(diminish 'yas-minor-mode))
+
+
+ ;;; Popping up multiple frames out of the blue does not usually play
+ ;;; well with (manual) tiling window managers.
+ (setq ediff-window-setup-function 'ediff-setup-windows-plain)
+
+ ;;; Not being able to find newly written functions in imenu is a pain.
+ (setq imenu-auto-rescan t)
+
+ ;;; Yanking at click makes not sense to me. I normally have my cursor
+ ;;; where it needs to point and if I *have* to use the mouse I prefer
+ ;;; just clicking it wherever it lands, without having to drag it all
+ ;;; the way to the proper place.
+ (setq mouse-yank-at-point t)
+
+ ;;; Always having to move the cursor around so much after scrolling
+ ;;; gets annoying.
+ (setq scroll-preserve-screen-position t)
+
+ ;;; I store my blog posts in `~/documents/blog', not the default
+ ;;; `~/Blog'.
+ (setq eltuki-blog-dir "~/documents/blog")
+
+ (setq sp-cancel-autoskip-on-backward-movement nil)
+
+ (defun oni:scroll-down-or-prev-page (arg)
+ "Either scroll down or go to the previous page.
+
+ Depending on the value of `buffer-narrowed-p'."
+ (interactive "^P")
+ (if (buffer-narrowed-p)
+ (let ((scroll-error-top-bottom nil))
+ (condition-case nil
+ (scroll-down-command arg)
+ (beginning-of-buffer
+ (narrow-to-page -1)
+ (goto-char (point-min)))))
+ (scroll-down-command arg)))
+
+ (defun oni:scroll-up-or-next-page (arg)
+ "Either scroll up or go to the next page.
+
+ Depending on the value of `buffer-narrowed-p'."
+ (interactive "^P")
+ (if (buffer-narrowed-p)
+ (let ((scroll-error-top-bottom nil))
+ (condition-case nil
+ (scroll-up-command arg)
+ (end-of-buffer
+ (narrow-to-page 1)
+ (goto-char (point-min)))))
+ (scroll-up-command arg)))
+
+ (global-set-key (kbd "<prior>") 'oni:scroll-down-or-prev-page)
+ (global-set-key (kbd "<next>") 'oni:scroll-up-or-next-page)
+
+ ;;; Emacs Alsa Player
+ (add-to-list 'load-path "~/.emacs.d/site-lisp/eap")
+ (load "eap-autoloads")
+
+ (setq eap-music-library "/mnt/music")
+ (setq eap-playlist-library "~/music/playlists")
+
+ ;;;; Auto-complete
+
+ (setq-default ac-sources '(ac-source-imenu
+ ac-source-gtags
+ ac-source-abbrev
+ ac-source-yasnippet
+ ac-source-words-in-buffer
+ ac-source-words-in-same-mode-buffers
+ ac-source-dictionary
+ ac-source-functions
+ ac-source-symbols
+ ac-source-variables
+ ac-source-features))
+
+ ;;;; Magit
+
+ (setq magit-default-tracking-name-function
+ 'magit-default-tracking-name-branch-only)
+ (setq magit-diff-refine-hunk 'all)
+
+ ;;; Finally, load any `customize' settings and slime.
+ (load custom-file)
+ (load (expand-file-name "~/quicklisp/slime-helper.el"))
+ #+END_SRC
diff --git a/emacs/site-lisp/Makefile b/emacs/site-lisp/Makefile
index bf452e9..91ee32e 100644
--- a/emacs/site-lisp/Makefile
+++ b/emacs/site-lisp/Makefile
@@ -1,4 +1,4 @@
-DESTDIR:=$(DESTDIR)/site-lisp
+SUBDIR=site-lisp
objects=dzen.elc dzen.el eltuki.elc eltuki.el ext.elc ext.el \
metalexpress.elc metalexpress.el mu4e-init.elc mu4e-init.el \
oni.elc oni.el org-init.elc org-init.el quick-edit-mode.elc \
diff --git a/emacs/site-lisp/dzen.el b/emacs/site-lisp/dzen.el
index d946458..da83099 100644
--- a/emacs/site-lisp/dzen.el
+++ b/emacs/site-lisp/dzen.el
@@ -25,6 +25,7 @@
;;; Code:
(require 'newst-backend)
+(require 'sawfish)
(defvar dzen-process nil
"Dzen2's process.")
diff --git a/emacs/site-lisp/ext.el b/emacs/site-lisp/ext.el
index eb84a3f..9bfbe34 100644
--- a/emacs/site-lisp/ext.el
+++ b/emacs/site-lisp/ext.el
@@ -38,6 +38,13 @@
buffer-file-name))))
(list "pycheck.sh" (list local-file))))
+(defun ext:indent-defun ()
+ "Indent the current defun."
+ (interactive)
+ (save-excursion
+ (mark-defun)
+ (indent-region (region-beginning) (region-end))))
+
(defun ext:reload-buffer ()
"Reload current buffer."
(interactive)
diff --git a/emacs/site-lisp/oni.el b/emacs/site-lisp/oni.el
index cf73ac1..b90bd4a 100644
--- a/emacs/site-lisp/oni.el
+++ b/emacs/site-lisp/oni.el
@@ -34,6 +34,15 @@ DOT are intentionally being skipped."
(concat (symbol-name user) "@" (symbol-name host) "."
(symbol-name com)))
+(defmacro oni:eval-after-init (&rest body)
+ "Defer execution of BODY until after Emacs init.
+
+ Some functionality is dependent on code loaded by package.el.
+ Instead of requiring package.el to load very early on, have some
+ functionality deferred to a point after Emacs has initialized and
+ package.el is loaded anyway."
+ `(add-hook 'emacs-startup-hook #'(lambda () ,@body)))
+
(defun oni:after-save-func ()
"Function for `after-save-hook'."
(oni:compile-el)
@@ -66,6 +75,13 @@ DOT are intentionally being skipped."
(local-set-key [f9] 'compile)
(local-set-key "\C-j" 'oni:newline-and-indent))
+(defun oni:change-prev-case (num dir)
+ (let ((regfunc (if (eq dir 'up) 'upcase-region 'downcase-region))
+ (wordfunc (if (eq dir 'up) 'upcase-word 'downcase-word)))
+ (if (> num 1)
+ (funcall regfunc (point) (- (point) num))
+ (funcall wordfunc -1))))
+
(defun oni:close-client-window ()
"Close a client's frames."
(interactive)
@@ -86,8 +102,7 @@ DOT are intentionally being skipped."
(defun oni:css-mode-func ()
"Function for `css-mode-hook'."
- (local-set-key "\C-j" 'oni:newline-and-indent)
- (rainbow-mode))
+ (local-set-key "\C-j" 'oni:newline-and-indent))
(defun oni:current-jabber-status ()
"Return a string representing the current jabber status."
@@ -100,9 +115,9 @@ DOT are intentionally being skipped."
"Function for `diary-display-hook'."
(diary-fancy-display))
-(defun oni:emacs-lisp-mode-func ()
- "Function for `emacs-lisp-mode-hook'."
- (eldoc-mode))
+(defun oni:downcase-prev (num)
+ (interactive "p")
+ (oni:change-prev-case num 'down))
(defun oni:emacs-startup-func ()
"Function for `emacs-init-hook'."
@@ -123,11 +138,9 @@ DOT are intentionally being skipped."
"Function for `haskell-mode-hook'."
(turn-on-haskell-indentation))
-(defun oni:html-mode-func ()
- "Function for `html-mode-hook'."
- (yas-minor-mode)
- (fci-mode)
- (flycheck-mode))
+(defun oni:hostname ()
+ "Get the current machine's hostname."
+ (substring (shell-command-to-string "hostname") 0 -1))
(defun oni:indent-shift-left (start end &optional count)
"Rigidly indent region.
@@ -174,10 +187,6 @@ If COUNT has been specified indent by that much, otherwise look at
(notifications-notify :title title
:body text))
-(defun oni:jabber-chat-mode-func ()
- "Function for `jabber-chat-mode-hook'."
- (visual-line-mode))
-
(defun oni:jabber-roster-mode-func ()
"Function for `jabber-roster-mode-hook'."
(setq mode-line-format
@@ -189,68 +198,22 @@ If COUNT has been specified indent by that much, otherwise look at
(defun oni:js-mode-func ()
"Function for `js-mode-hook'."
- (rainbow-delimiters-mode)
(local-set-key "\C-j" 'oni:newline-and-indent))
(defun oni:js2-mode-func ()
"Function for `js2-mode-hook'."
- (oni:prog-mode-func)
(oni:js-mode-func)
- (local-set-key (kbd "<f5>") #'slime-js-reload)
- (slime-js-minor-mode))
-
-(defun oni:kill-region-or-backward-char ()
- "Either `kill-region' or `backward-delete-char-untabify'."
- (interactive)
- (if (region-active-p)
- (kill-region (region-beginning) (region-end))
- (backward-delete-char-untabify 1)))
-
-(defun oni:kill-region-or-forward-char ()
- "Either `kill-region' or `delete-forward-char'."
- (interactive)
- (if (region-active-p)
- (kill-region (region-beginning) (region-end))
- (delete-forward-char 1)))
-
-(defun oni:kill-region-or-line ()
- "Either `kill-region' or `kill-line'."
- (interactive)
- (if (region-active-p)
- (kill-region (region-beginning) (region-end))
- (kill-line)))
+ (local-set-key (kbd "<f5>") #'slime-js-reload))
(defun oni:lua-mode-func()
"Function for `lua-mode-hook'."
(local-unset-key (kbd ")"))
(local-unset-key (kbd "]"))
- (local-unset-key (kbd "}"))
- (flycheck-mode))
-
-(defun oni:magit-log-edit-mode-func ()
- "Function for `magit-log-edit-mode-hook'."
- (auto-fill-mode)
- (font-lock-add-keywords
- nil
- '(("\\`\\(.\\{,50\\}\\)\\(.*\\)\n?\\(.*\\)$"
- (1 'git-commit-summary-face)
- (2 'git-commit-overlong-summary-face)
- (3 'git-commit-nonempty-second-line-face))
- ("`\\([^']+\\)'" 1 font-lock-constant-face))
- t))
+ (local-unset-key (kbd "}")))
(defun oni:markdown-mode-func ()
"Function for `markdown-mode-hook'."
- (setq-local comment-auto-fill-only-comments nil)
- (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))
+ (setq-local whitespace-style '(face trailing)))
(defun oni:mini-fix-timestamp-string (date-string)
"A minimal version of Xah Lee's `fix-timestamp-string'.
@@ -276,6 +239,20 @@ code. Found at http://xahlee.org/emacs/elisp_parse_time.html"
(match-string 2 date-string)
(match-string 1 date-string)))
+(defun oni:mode-line-current-song ()
+ "Extract current song information from a path.
+
+EMMS only shows me the absolute path of a song, this function
+extracts the parts I want to know about."
+ (let* ((song (emms-track-name (emms-playlist-current-selected-track)))
+ (matchp (string-match "\\([^/]+\\)/\\([0-9]\\{4\\}\\) - \\(.+\\)/\\([0-9]\\{2,3\\}\\) - \\(.+\\)\\..\\{3,4\\}$" song))
+ (band (substring song (match-beginning 1) (match-end 1)))
+ (year (substring song (match-beginning 2) (match-end 2)))
+ (album (substring song (match-beginning 3) (match-end 3)))
+ (track (substring song (match-beginning 4) (match-end 4)))
+ (title (substring song (match-beginning 5) (match-end 5))))
+ (format "[%s - %s]" band title)))
+
(defun oni:move-beginning-of-dwim ()
"Move to beginning of line either after indentation or before."
(interactive)
@@ -328,44 +305,25 @@ When dealing with braces, add another line and indent that too."
(save-excursion (newline-and-indent)))
(newline-and-indent))
-(defun oni:org-mode-func ()
- "Function for `org-mode-hook'."
- (auto-fill-mode)
- (yas-minor-mode)
- (set (make-local-variable 'comment-auto-fill-only-comments) nil))
-
(defun oni:php-mode-func ()
"Function for `php-mode-hook'."
(local-set-key "\C-j" 'oni:newline-and-indent)
(c-set-offset 'arglist-intro '+)
(c-set-offset 'arglist-close '0)
- (rainbow-delimiters-mode)
- (setq-local fci-rule-column 80)
- (flycheck-mode))
+ (setq-local fci-rule-column 80))
(defun oni:prog-mode-func ()
"Function for `prog-mode-hook'."
- (rainbow-delimiters-mode)
- (fci-mode)
- (yas-minor-mode)
- (auto-fill-mode))
+ (setq-local comment-auto-fill-only-comments t))
(defun oni:python-mode-func ()
"Function for `python-mode-hook'."
- (flycheck-mode)
(local-set-key (kbd "C->") 'python-indent-shift-right)
(local-set-key (kbd "C-<") 'python-indent-shift-left)
(set (make-local-variable 'electric-indent-chars) nil)
- (rainbow-delimiters-mode)
(setq fci-rule-column 79
fill-column 72)
- (setq-local whitespace-style '(tab-mark))
- (fci-mode)
- (whitespace-mode))
-
-(defun oni:rainbow-mode-init ()
- "Initialization function for rainbow-mode."
- (diminish 'rainbow-mode))
+ (setq-local whitespace-style '(tab-mark)))
(defun oni:raise-ansi-term (arg)
"Create or show an `ansi-term' buffer."
@@ -437,10 +395,6 @@ use. If MODE is not nil, open a new buffer with the name
default-directory "' request-pull " (when patchp "-p ")
from " " url " " to))))))
-(defun oni:rst-mode-func ()
- "Function for `rst-mode-hook'."
- (auto-fill-mode))
-
(defun oni:self-insert-dwim ()
"Execute self insert, but when the region is active call self
insert at the end of the region and at the beginning."
@@ -472,10 +426,12 @@ insert at the end of the region and at the beginning."
(interactive)
(find-file "~/documents/org/index.org"))
-(defun oni:smex-init ()
- "Initialization function for smex."
- (global-set-key (kbd "M-x") 'smex)
- (global-set-key (kbd "C-M-x") 'smex-major-mode-commands))
+(defun oni:skip-ex-tag ()
+ (let ((tags (org-entry-get (point) "TAGS")))
+ (when (and tags (string-match-p ":ex:" tags))
+ (save-excursion
+ (org-forward-element)
+ (point)))))
(defun oni:split-window-interactive (dir)
"Split windows in direction DIR.
@@ -515,10 +471,13 @@ If no direction is given, don't split."
"Function for `term-mode-hook'."
(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:upcase-prev (num)
+ (interactive "p")
+ (oni:change-prev-case num 'up))
+
+(defun oni:vala-mode-func ()
+ "Function for `vala-mode-hook'."
+ (setq indent-tabs-mode nil))
(defun oni:write-file-func ()
"Function for `write-file-hooks'."
@@ -530,18 +489,6 @@ If no direction is given, don't split."
(define-key yas-minor-mode-map [(tab)] nil)
(define-key yas-minor-mode-map (kbd "C-\\") 'yas-expand))
-(defun oni:yasnippet-init ()
- "Initialization function for yasnippet."
- (diminish 'yas-minor-mode))
-
-(defvar oni:auto-save-name-transforms
- `((".*" ,temporary-file-directory t))
- "Place all auto-save files in `temporary-file-directory'.")
-
-(defvar oni:backup-directory-alist
- `((".*" . ,temporary-file-directory))
- "Palce all backup files in `temporary-file-directory'.")
-
(defvar oni:mailbox-map
'("top" ("menu"
("ryulash.org" . "ryuslash")
diff --git a/emacs/site-lisp/org-init.el b/emacs/site-lisp/org-init.el
index 3c698d2..ca822aa 100644
--- a/emacs/site-lisp/org-init.el
+++ b/emacs/site-lisp/org-init.el
@@ -101,10 +101,10 @@
(search . " %i %-12:c")))
(setq org-agenda-sorting-strategy
'((agenda habit-down time-up priority-down category-keep)
- (todo user-defined-down)
+ (todo priority-down user-defined-down)
(tags priority-down category-keep)
(search category-keep)))
-(setq org-agenda-tags-column -101)
+(setq org-agenda-tags-column (1+ (- (window-width))))
(setq org-directory (expand-file-name "~/documents/org"))
(setq org-default-notes-file (concat org-directory "/org"))
(setq org-capture-templates
@@ -112,6 +112,8 @@
"* TODO %?")
("T" "Linked task" entry (file "~/documents/org/tasks")
"* TODO %?\n\n %a")
+ ("a" "Appointment" entry (file "~/documents/org/tasks")
+ "* %?\n SCHEDULED: %^T\n\n %a")
("n" "General note" entry (file ,org-default-notes-file)
(function oni:note-template))))
(setq org-contacts-files '("~/documents/org/misc/contacts.org"))
@@ -132,7 +134,7 @@
(setq org-refile-use-outline-path 'file)
(setq org-return-follows-link t)
(setq org-src-fontify-natively t)
-(setq org-tags-column -101)
+(setq org-tags-column (- 70))
(setq org-tags-exclude-from-inheritance '("crypt"))
(setq org-todo-keyword-faces
'(("TODO" :foreground "#ff756e" :background "#171719" :box (:width 1 :color "#282830"))
@@ -146,6 +148,7 @@
("ACQUIRE" :foreground "#ff756e" :background "#171719" :box (:width 1 :color "#282830"))
("IGNORED" :foreground "#999999" :background "#222224" :box (:width 1 :color "#333335"))))
(setq org-use-fast-todo-selection t)
+(setq org-agenda-skip-function-global 'oni:skip-ex-tag)
(setq org-use-property-inheritance '("slug"))
(add-hook 'org-agenda-mode-hook 'org-agenda-to-appt)
diff --git a/emacs/snippets/Makefile b/emacs/snippets/Makefile
index 12ff544..e003ed3 100644
--- a/emacs/snippets/Makefile
+++ b/emacs/snippets/Makefile
@@ -1,4 +1,4 @@
-DESTDIR:=$(DESTDIR)/snippets
+SUBDIR=snippets
modules=html-mode org-mode python-mode
include ../../dotfiles.mk
diff --git a/emacs/snippets/html-mode/Makefile b/emacs/snippets/html-mode/Makefile
index b2dff78..2d6defe 100644
--- a/emacs/snippets/html-mode/Makefile
+++ b/emacs/snippets/html-mode/Makefile
@@ -1,4 +1,4 @@
-DESTDIR:=$(DESTDIR)/html-mode
+SUBDIR=html-mode
objects=for generic-block
include ../../../dotfiles.mk
diff --git a/emacs/snippets/org-mode/Makefile b/emacs/snippets/org-mode/Makefile
index 34d4cd9..670b139 100644
--- a/emacs/snippets/org-mode/Makefile
+++ b/emacs/snippets/org-mode/Makefile
@@ -1,4 +1,4 @@
-DESTDIR:=$(DESTDIR)/org-mode
+SUBDIR=org-mode
objects=codeblock heading project snippet
include ../../../dotfiles.mk
diff --git a/emacs/snippets/org-mode/heading b/emacs/snippets/org-mode/heading
index 48dca7f..9d5451e 100644
--- a/emacs/snippets/org-mode/heading
+++ b/emacs/snippets/org-mode/heading
@@ -2,8 +2,8 @@
# name: Heading
# key: *
# --
-*$1 ${2:TODO} $3
- ${1:$(make-string (length text) ?\ )} :PROPERTIES:
- ${1:$(make-string (length text) ?\ )} :CATEGORY: $4
- ${1:$(make-string (length text) ?\ )} :END:
- ${1:$(make-string (length text) ?\ )} $0 \ No newline at end of file
+${1:*} ${2:TODO} $3
+${1:$(make-string (length text) ?\ )} :PROPERTIES:
+${1:$(make-string (length text) ?\ )} :CATEGORY: $4
+${1:$(make-string (length text) ?\ )} :END:
+${1:$(make-string (length text) ?\ )} $0 \ No newline at end of file
diff --git a/emacs/snippets/python-mode/Makefile b/emacs/snippets/python-mode/Makefile
index 192657b..8e8b652 100644
--- a/emacs/snippets/python-mode/Makefile
+++ b/emacs/snippets/python-mode/Makefile
@@ -1,4 +1,4 @@
-DESTDIR:=$(DESTDIR)/python-mode
+SUBDIR=python-mode
objects=defm_empty form form_valid import_from permission_guard url
include ../../../dotfiles.mk