Emacs init
Table of Contents
- 1 Loading files
- 2 Asking for confirmation concisely
- 3 Listing opened buffers
- 4 Code Folding
- 5 Showing a right margin
- 6 Keeping track of TV shows with org-agenda
- 7 Communicating
- 8 Change cursor according to buffer's mode
- 9 Managing Packages
- 10 Automatically compile and make executable
- 11 Replacing special chars and deleting whitespace
- 12 Coding in …
- 13 Using emacs as a daemon
- 14 Org
- 15 Displaying a diary
- 16 Automatically opening room for blocks
- 17 EMMS
- 18 ERC
- 19 Eshell
- 20 Flymake
- 21 Gtags
- 22 DWIM
- 23 Magit
- 24 Markdown
- 25 Message mode
- 26 Browse the web
- 27 Uniquify buffer names better
- 28 The
*scratch*buffer - 29 Reloading
- 30 Term
- 31 Texinfo
- 32 Xmodmap
- 33 Shift indent
- 34 PO-mode
- 35 Sawfish
- 36 Misc global modes
- 37 Time-stamp
- 38 Ido
- 39 Smex
- 40 Dead keys
- 41 General settings
- 41.1 Bi-directional text
- 41.2 git-auto-commit-mode
- 41.3 Indentation
- 41.4 Final newline
- 41.5 Truncate lines
- 41.6 PKGBUILDs
- 41.7 Autoloading
- 41.8 Autosave and backup files
- 41.9 External browser
- 41.10 Customizations
- 41.11 Theme
- 41.12 Default frame style
- 41.13 Display time
- 41.14 Frame title
- 41.15 Help at point
- 41.16 Sauron
- 42 Misc
1 Loading files
Since everything that isn't installed through Managing Packages is
stored under my .emacs.d directory I don't want tons of
add-to-list calls in my init file, so I add everything under
.emacs.d to the load path.
(let ((default-directory "~/.emacs.d/")) (normal-top-level-add-subdirs-to-load-path))
2 Asking for confirmation concisely
Being asked to type in yes explicitly all the time gets very
tedious. I understand that it is safer since y is much easier to
type in accidentally than yes and so the potential to say yes to
things you don't want is there, but I haven't had any such problems
yet.
(defalias 'yes-or-no-p 'y-or-n-p)
3 Listing opened buffers
Since ibuffer is (almost?) completely compatible with list-buffers
but also includes more features than list-buffers, it is safe (and
nice) to switch them.
(defalias 'list-buffers 'ibuffer)
Then we can use some of its nicer features like buffer grouping.
(defun oni:ibuffer-mode-func () "Function for `ibuffer-mode-hook'." (ibuffer-switch-to-saved-filter-groups "default")) (setq-default ibuffer-saved-filter-groups '(("default" ("emacs" (or (filename . "emacs\\.d") (mode . emacs-lisp-mode))) ("work" (filename . "/aethon/")) ("jabber" (name . "^\\*jabber-")) ("org" (filename . ".*\\.org$")) ("magit" (name . "^\\*magit-.*\\*$")) ("mu4e" (name . "^\\*mu4e-.*\\*$")) ("scratch" (name . "^\\*.*\\*$"))))) (add-hook 'ibuffer-mode-hook 'oni:ibuffer-mode-func)
4 Code Folding
Code folding can make a buffer filled with code look a lot less daunting.
4.1 outline-minor-mode
Having to put the same 4 function calls in each hook that is going to use it is tedious, we have ways of simplifying that.
(defmacro oni:generic-outline (regex) `(progn (outline-minor-mode) (set (make-local-variable 'outline-regexp) ,regex) (hide-body) (local-set-key [C-tab] 'outline-toggle-children)))
4.2 hs-minor-mode
Sometimes outline-minor-mode isn't the best way to fold a
buffer. Sometimes you need to be able to tell the folding mode
where to stop the folding, this is much easier in hs-minor-mode.
Since there is no real correlation between which modes I use
outline-minor-mode and in which I use something else it's useful
to have a function that takes care of initializing it.
(defun oni:hs-minor-mode-func () "Function for `hs-minor-mode-hook'." (local-set-key [C-tab] 'hs-toggle-hiding) (hs-hide-all)) (add-hook 'hs-minor-mode-hook 'oni:hs-minor-mode-func)
5 Showing a right margin
Code that goes on too long on a line doesn't look nice, having to
check each line you write to see whether or not it is too long is no
fun, having auto-fill-mode split your code lines at the worst
possible point is not handy, showing an annoying line whenever a
piece of code gets too long is motivation enough to want to fix it.
Usually, when coding, I try not to go beyond 72 characters per line, it is handy to have an indication of this margin.
(setq-default fci-rule-column 73)
The default color is not exactly what I want, I think a dark red margin might be quite appropriate.
(setq fci-rule-color "darkred")
6 Keeping track of TV shows with org-agenda
I watch a few TV shows, and I like them to be listed in my org agenda. This way I can be reminded of what I need to look for.
(defun oni:mini-fix-timestamp-string (date-string) "A minimal version of Xah Lee's `fix-timestamp-string' function, found at http://xahlee.org/emacs/elisp_parse_time.html" (setq date-string (replace-regexp-in-string "Jan" "01" date-string) date-string (replace-regexp-in-string "Feb" "02" date-string) date-string (replace-regexp-in-string "Mar" "03" date-string) date-string (replace-regexp-in-string "Apr" "04" date-string) date-string (replace-regexp-in-string "May" "05" date-string) date-string (replace-regexp-in-string "Jun" "06" date-string) date-string (replace-regexp-in-string "Jul" "07" date-string) date-string (replace-regexp-in-string "Aug" "08" date-string) date-string (replace-regexp-in-string "Sep" "09" date-string) date-string (replace-regexp-in-string "Oct" "10" date-string) date-string (replace-regexp-in-string "Nov" "11" date-string) date-string (replace-regexp-in-string "Dec" "12" date-string)) (string-match "^\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{4\\}\\)$" date-string) (format "%s-%s-%s" (match-string 3 date-string) (match-string 2 date-string) (match-string 1 date-string))) (defun oni:myepisodes-formatter (plist) (let ((str (plist-get plist :title))) (string-match "^\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]$" str) (let* ((title (match-string 1 str)) (episode (match-string 2 str)) (name (match-string 3 str)) (date (oni:mini-fix-timestamp-string (match-string 4 str)))) (format "* ACQUIRE %s %s - %s <%s>" title episode name date)))) (setq org-feed-alist '(("MyEpisodes" "http://www.myepisodes.com/rss.php?feed=mylist&uid=Slash&pwdmd5=04028968e1f0b7ee678b748a4320ac17" "~/documents/org/org" "MyEpisodes" :formatter oni:myepisodes-formatter)))
7 Communicating
Emacs has many programs to facilitate communication with others, from email and chat to integration with social networks.
7.1 Reading/Sending email
There are a few email programs for emacs, but so far the one I like best is mu4e, which is fairly new. It doesn't seem to be designed for use with multiple accounts, so I've written some wrappers for that.
(autoload 'mu4e "mu4e" nil t) (eval-after-load "mu4e" '(add-to-list 'org-capture-templates '("c" "Contact" entry (file "~/documents/org/misc/contacts.org") (concat "* %(mu4e-view-snarf-from 'name)\n" " :PROPERTIES:\n" " :EMAIL: %(mu4e-view-snarf-from 'email)\n" " :END:")))) (defun oni:prepare-aethon-mail () "Set necessary variables for `mu4e' for my aethon email account." (setq mu4e-mu-home "/home/slash/.mu/aethon" mu4e-maildir "/home/slash/documents/mail/aethon" mu4e-get-mail-command "offlineimap -oa aethon" mu4e-main-buffer-name "*mu4e-aethon*" user-mail-address "thomas@aethon.nl" message-sendmail-extra-arguments '("-a" "aethon") message-signature-file "/home/slash/documents/work/aethon/signature.txt")) (defun oni:prepare-gmail-mail () "Set necessary variables for `mu4e' for my gmail email account." (setq mu4e-mu-home "/home/slash/.mu/gmail" mu4e-maildir "/home/slash/documents/mail/gmail" mu4e-get-mail-command "offlineimap -oa gmail" mu4e-main-buffer-name "*mu4e-gmail*" user-mail-address "ryuslash@gmail.com" message-sendmail-extra-arguments '("-a" "gmail") message-signature-file nil)) (defun oni:prepare-ninthfloor-mail () "Set necessary variables for `mu4e' for my ninthfloor email account." (setq mu4e-mu-home "/home/slash/.mu/ninthfloor" mu4e-maildir "/home/slash/documents/mail/ninthfloor" mu4e-get-mail-command "offlineimap -oa ninthfloor" mu4e-main-buffer-name "*mu4e-ninthfloor*" user-mail-address "ryuslash@ninthfloor.org" message-sendmail-extra-arguments '("-a" "ninthfloor") message-signature-file nil)) (defun oni:prepare-ryu-mail () "Set necessary variables for `mu4e' for my ryu email account." (setq mu4e-mu-home "/home/slash/.mu/ryuslash" mu4e-maildir "/home/slash/documents/mail/ryuslash.org" mu4e-get-mail-command "offlineimap -oa ryuslash.org" mu4e-main-buffer-name "*mu4e-ryuslash*" user-mail-address "tom@ryuslash.org" message-sendmail-extra-arguments '("-a" "ryuslash") message-signature-file nil))
These functions would be almost useless without an easy way to call
them. I found out about tmm-prompt from one of the emacs mailing
lists and thought it would be a perfect solution.
(defvar oni:mailbox-map '("top" ("menu" ("ryulash.org" . "ryu") ("ninthfloor" . "ninthfloor") ("gmail" . "gmail") ("aethon" . "aethon"))) "A mailbox map for use with `tmm-prompt'.") (defun oni:view-mail () "Show a menu with all mailbox options from `oni:mailbox-map' for easy selection." (interactive) (require 'tmm) (let* ((tmm-completion-prompt "Choose a mailbox\n") (inbox (tmm-prompt oni:mailbox-map))) (if inbox (progn (require 'mu4e) (funcall (intern (concat "oni:prepare-" inbox "-mail"))) (mu4e)))))
Then all I need is an easy key binding.
(global-set-key [XF86Mail] 'oni:view-mail)
7.2 identi.ca
identi.ca is a twitter-like web service which runs on statusnet, which is open source.
7.2.1 Loading
The only way I ever call identica-mode is through the
identica-mode function.
(autoload 'identica-mode "identica-mode" nil t)
7.2.2 New dents
There are a few ways that one can be informed of new dents.
- X11
When new dents arrive I want to be notified. I used to use these functions for that, all I really use now is the Icon and Sauron.
(defun oni:identica-new-dents-func () "Function for `identica-new-dents-hook'." (oni:identica-notify-send)) (defun oni:identica-notify-send () "Use `oni:notify-send' to indicate new dents." (oni:notify-send "New dents:" (format "%d" identica-new-dents-count)))
- Icon
With this I show an icon in the mode-line whenever there are any new dents.
(defun oni:identica-print-new-dents-icon () "Print `identica-active-indicator-image' if there are new dents." (unless (zerop identica-new-dents-count) (propertize " " 'display identica-active-indicator-image))) (eval-after-load "identica-mode" '(add-to-list 'global-mode-string '(:eval (oni:identica-print-new-dents-icon))))
7.2.3 Posting
This key binding is very nice for quickly posting new dents.
(global-set-key "\C-cip" 'identica-update-status-interactive)
7.3 Jabber
jabber is a IM service running on the XMPP protocol, which is an open protocol anyone could implement, if they felt like it.
When looking at jabber chat buffers I prefer not to just continue lines onto the next one, but actually put the whole word on the next line if the current one isn't wide enough.
Since the person I'm chatting with is already shown in other places I really don't need to see their (screen) name every time they type something, and I certainly don't need to see mine.
(defun oni:jabber-chat-mode-func () "Function for `jabber-chat-mode-hook'." (visual-line-mode)) (setq jabber-account-list '(("ryuslash@jabber.org")) jabber-chat-fill-long-lines nil jabber-chat-foreign-prompt-format "[%t] < " jabber-chat-local-prompt-format "[%t] > " jabber-roster-show-bindings nil jabber-roster-show-offline-contacts nil jabber-chat-buffer-show-avatar nil) (add-hook 'jabber-chat-mode-hook 'oni:jabber-chat-mode-func) (global-set-key [f6] 'jabber-switch-to-roster-buffer)
Store history and such under .emacs.d to keep HOME clean.
(setq jabber-history-dir "~/.emacs.d/jabber")
Don't let people know what I'm doing.
(setq jabber-chatstates-confirm nil)
8 Change cursor according to buffer's mode
Seeing Ovwrt in the mode-line when overwrite-mode is on and %%
instead of -- when a buffer is read-only is not good enough, a
proper indication, much like vi, of what we're in for is needed.
(defvar oni:normal-color "yellow" "Cursor color to pass along to `set-cursor-color' for normal buffers.") (defvar oni:normal-cursor-type 'bar "A `cursor-type' for normal buffers.") (defvar oni:overwrite-color "red" "Cursor color to pass along to `set-cursor-color' for buffers in overwrite mode.") (defvar oni:overwrite-cursor-type 'box "A `cursor-type' for buffers in overwrite mode.") (defvar oni:read-only-color "gray" "Cursor color to pass along to `set-cursor-color' for read-only buffers.") (defvar oni:read-only-cursor-type 'hbar "A `cursor-type' for read-only buffers.") (defun oni:set-cursor-according-to-mode () "Change cursor color and type according to some minor modes." (cond (buffer-read-only (set-cursor-color oni:read-only-color) (setq cursor-type oni:read-only-cursor-type)) (overwrite-mode (set-cursor-color oni:overwrite-color) (setq cursor-type oni:overwrite-cursor-type)) (t (set-cursor-color oni:normal-color) (setq cursor-type oni:normal-cursor-type)))) (defun oni:post-command-func () "Function for `post-command-hook'." (oni:set-cursor-according-to-mode)) (add-hook 'post-command-hook 'oni:post-command-func)
9 Managing Packages
With package.el we have a real package manager for emacs, and it
is nice to have.
(defvar oni:required-packages '(graphviz-dot-mode htmlize jabber magit rainbow-delimiters rainbow-mode yasnippet markdown-mode flymake flymake-cursor pony-mode python sauron) "List of all the packages I have (want) installed") (defun oni:required-packages-installed-p () "Check if all the packages I need are installed." (let ((tmp-packages oni:required-packages) (result t)) (while (and tmp-packages result) (if (not (package-installed-p (car tmp-packages))) (setq result nil)) (setq tmp-packages (cdr tmp-packages))) result)) (setq package-archives '(("melpa" . "http://melpa.milkbox.net/packages/") ("ELPA" . "http://tromey.com/elpa/") ("gnu" . "http://elpa.gnu.org/packages/") ("marmalade" . "http://marmalade-repo.org/packages/"))) (package-initialize) (unless (oni:required-packages-installed-p) (message "%s" "Refreshing package database...") (package-refresh-contents) (message "%s" " done.") (mapc #'(lambda (package) (when (not (package-installed-p package)) (package-install package))) oni:required-packages))
9.1 Specific versions
Since htmlize is now also in MELPA, org gets confused about its
version (1.39 vs 20120620 for example), so I'd like to keep using
1.39.
(setq package-load-list '((htmlize "1.39")
all))
10 Automatically compile and make executable
When writing emacs lisp scripts/programs its nice to have them automatically compiled, catches some errors at times and makes them nice and speedy.
When writing python, shell and other scripts its also nice to have
them marked as executable when saved. This way I don't have to
chmod them myself.
(defun oni:compile-el () "Compile the current buffer file if it is an .el file." (let* ((full-file-name (buffer-file-name)) (file-name (file-name-nondirectory full-file-name)) (suffix (file-name-extension file-name))) (if (and (not (string-equal file-name ".dir-locals.el")) (string-equal suffix "el")) (byte-compile-file full-file-name)))) (defun oni:after-save-func () "Function for `after-save-hook'." (oni:compile-el) (executable-make-buffer-file-executable-if-script-p))
11 Replacing special chars and deleting whitespace
When editing HTML files it can be useful to have certain characters
replaced by their HTML-safe codes. Right now this is only é, since
I haven't had a need for any others yet.
The only mode that I know I use that cares about white space is
markdown-mode since ~ ~ (two spaces) there means <br>, but any
other mode I want all of it gone.
(defun oni:what-major-mode (buffer-or-string) "Find out which major-mode is currently used" (with-current-buffer buffer-or-string major-mode)) (defun oni:replace-occurrences (from to) (save-excursion (goto-char (point-min)) (while (search-forward from nil t) (replace-match to)))) (defun oni:replace-html-special-chars () (oni:replace-occurrences "é" "é")) (defun oni:before-save-func () "Function for `before-save-hook'." (if (eq (oni:what-major-mode (current-buffer)) 'html-mode) (oni:replace-html-special-chars)) (if (not (eq (oni:what-major-mode (current-buffer)) 'markdown-mode)) (delete-trailing-whitespace)))
12 Coding in …
I'm a programmer, or at the moment officially a Software Engineer, and I like it. Emacs makes it even more fun.
Many programming modes derive from prog-mode, this makes it easy to
collectively configure both rainbow-delimiters-mode for many of
these, as well as Fill Column Indicator.
(defun oni:prog-mode-func () "Function for `prog-mode-hook'." (rainbow-delimiters-mode) (fci-mode)) (add-hook 'prog-mode-hook 'oni:prog-mode-func)
12.1 … C-like languages
cc-mode is a collection of some very nice programming modes for
C, C++ and Java (and more?). This makes some customizations easy
for all the modes in it.
For C-like languages, well for C really, I like hs-minor-mode
best since I can have a struct declaration above some variables and
not lose sight of them.
(defun oni:c-mode-common-func () "Function for `c-mode-common-hook'." (setq hs-adjust-block-beginning 'hs-c-like-adjust-block-beginning) (hs-minor-mode)) (add-hook 'c-mode-common-hook 'oni:c-mode-common-func)
Use 4 spaces for indentation in any cc-mode based mode.
(setq-default c-basic-offset 4)
12.2 … C
When coding in C I like to have the f9 key start compilation,
although I don't use this as much as I should, and I like
Automatically opening room for blocks. Folding is handled through
c-mode-common-hook.
I still keep an old outline-minor-mode regexp around so that I
don't forget it.
(defconst oni:c-outline-regex (eval-when-compile (concat "\\(?:static\\s +\\)?\\(?:\\sw+\\(?: \\|\t\\|\n\\)*?\\*?\\)" "\\(?:\\s \\|\t\\|\n\\)\\(?:\\sw\\|_\\)+([^)]*)[^;\n]*$")) "Regex for `outline-minor-mode' for `c-mode'.") (defun oni:c-mode-func () "Function for `c-mode-hook'." (local-set-key [f9] 'compile) (local-set-key "\C-j" 'oni:newline-and-indent)) (add-hook 'c-mode-hook 'oni:c-mode-func)
12.3 … CSS
Since I write mostly web applications for work, and some non-professionally too, I sometimes have to work with CSS.
For CSS I tried using outline-minor-mode, but it didn't quite
work. Since CSS doesn't allow nesting and outline-minor-mode
almost expects it, it would fold longer selectors under shorter
ones, this is not the desired effect, at least not for me. I am
trying hs-minor-mode now.
Another thing I like is Automatically opening room for blocks.
rainbow-mode is also very nice for CSS as it shows the colors as
backgrounds for their definition.
(defun oni:css-mode-func () "Function for `css-mode-hook'." (setq hs-adjust-block-beginning 'hs-c-like-adjust-block-beginning) (hs-minor-mode) (local-set-key "\C-j" 'oni:newline-and-indent) (rainbow-mode)) (add-hook 'css-mode-hook 'oni:css-mode-func)
12.4 … Emacs lisp
Since I use emacs, and, as you can see, don't have a small init file and have some emacs lisp projects, I have to have some customizations as well.
eldoc-mode is pretty awesome. I don't really care for auto
completion other than making you type faster, but seeing the
parameters for the function you're calling is pretty nice.
hs-minor-mode works surprisingly nicely for emacs lisp code as
well.
(defun oni:emacs-lisp-mode-func () "Function for `emacs-lisp-mode-hook'." (eldoc-mode) (when (buffer-file-name) (hs-minor-mode))) (add-hook 'emacs-lisp-mode-hook 'oni:emacs-lisp-mode-func)
12.5 … Go
The people responsible for Google Go (Google perhaps?) are awesome enough to have included a major mode for emacs in their development.
The strange thing is, though, that it seems to absolutely want
indent-tabs-mode and I don't.
Again, Automatically opening room for blocks is very handy here.
(defun oni:go-mode-func () "Function for `go-mode-hook'." (setq indent-tabs-mode nil) (local-set-key "\C-j" 'oni:newline-and-indent)) (add-hook 'go-mode-hook 'oni:go-mode-func)
12.6 … HTML
Writing HTML can hardly be called coding, but it does have to get done. My needs when HTML is concerned are fairly simple, just show me the margin and I'm happy.
(defun oni:html-mode-func () "Function for `html-mode-hook'." (fci-mode)) (add-hook 'html-mode-hook 'oni:html-mode-func)
12.7 … JavaScript
I don't have to write in JavaScript a lot.
(defconst oni:javascript-outline-regex "function \\(\\w\\|_\\)+(" "Regex for `outline-minor-mode' for `js-mode'.") (defun oni:js-mode-func () "Function for `js-mode-hook'." (oni:generic-outline oni:javascript-outline-regex) (rainbow-delimiters-mode) (local-set-key "\C-j" 'oni:newline-and-indent)) (add-hook 'js-mode-hook 'oni:js-mode-func)
Automatically call js-mode, not javascript-mode for .js and .json
files.
(add-to-list 'auto-mode-alist '("\\.js\\(on\\)?$" . js-mode))
12.8 … Lisp
Well, I don't actually code in (Common) Lisp, but I do code in both Emacs lisp and Scheme, so this is handy anyway.
(defun oni:lisp-mode-func () "Function for `lisp-mode-hook'." (hs-minor-mode)) (add-hook 'lisp-mode-hook 'oni:lisp-mode-func)
12.9 … Python
I currently use python at work, so it is a major part of my day.
I prefer my own outline regexp over the default one.
(defconst oni:python-outline-regex (eval-when-compile (concat "^[ \t]*\\(?:@[a-zA-Z0-9_]+\\(?:([a-zA-Z0-9_=, ]*)\\)?" "\n\\)*[ \t]*\\(?:\\(class\\|def\\)[ \t]+\\(\\sw\\|\\s_\\)+" "\\(([^)]*):\\)?\\|\\#[ a-zA-Z0-9]*\\#\\)")) "Regex for `outline-minor-mode' for `python-mode'.") (defun oni:python-mode-func () "Function for `python-mode-hook'." (flymake-mode) (local-set-key (kbd "C->") 'python-indent-shift-right) (local-set-key (kbd "C-<") 'python-indent-shift-left) (local-set-key [C-tab] 'outline-toggle-children) (oni:generic-outline oni:python-outline-regex) (set (make-local-variable 'electric-indent-chars) nil) (rainbow-delimiters-mode) (fci-mode)) (add-hook 'python-mode-hook 'oni:python-mode-func)
12.9.1 Django
Since it seems that pony-mode doesn't add any of the functions I
use to start it as autoloads it must be done manually.
(autoload 'pony-mode "pony-mode" nil t)
12.10 … PHP
When not working in Python I work in PHP, at work, since that is what our old project was written in.
(defconst oni:php-outline-regex (eval-when-compile (concat "^ *\\(\\(?:namespace\\|interface\\) [a-zA-Z0-9_]\\|\\(\\(abstract" "\\|final\\) \\)?class [a-zA-Z0-9_]+\\( extends [\\a-zA-Z0-9_]+\\)?" "\\|\\(abstract \\)?\\(public\\|private\\|protected\\)?" "\\( static\\)? function [a-zA-Z0-9_]+(\\|/\\*\\*\\)")) "Regex for `outline-minor-mode' for `php-mode'.") (defun oni:php-mode-func () "Function for `php-mode-hook'." (flymake-mode) ;; (oni:gtags-for-php) (local-set-key "\C-j" 'oni:newline-and-indent) (c-set-offset 'arglist-intro '+) (c-set-offset 'arglist-close '0) (rainbow-delimiters-mode) (setq fci-rule-column 81)) (autoload 'php-mode "php-mode" nil t) (setq-default php-mode-warn-if-mumamo-off nil) (setq php-function-call-face 'font-lock-function-name-face php-mode-force-pear t) (add-to-list 'auto-mode-alist '("\\.php[345]?$" . php-mode)) (add-hook 'php-mode-hook 'oni:php-mode-func)
12.10.1 Smarty
Automatically call html-mode for .tpl files.
(add-to-list 'auto-mode-alist '("\\.tpl$" . html-mode))
12.11 … Guile (scheme)
I recently found out about geiser, it is just awesome.
It…
- turns on
hs-minor-mode.
(defun oni:scheme-mode-func () "Function for `scheme-mode-hook'." (hs-minor-mode))
12.11.1 Geiser
Use guile with geiser and store the REPL history somewhere in
~.emacs.d.
(require 'geiser-install) (setq geiser-active-implementations '(guile) geiser-repl-history-filename "~/.emacs.d/geiser-history")
13 Using emacs as a daemon
Since I have quite a big init file by now (as you can see) and being able to communicate with emacs from other processes is a cool thing, I usually start emacs with:
emacs --daemon
This starts emacs in the background and then later on you can create a new frame for it by calling:
emacsclient -c
This way other programs can call the emacsclient program as well
to either create new frames of open new files in an existing frame.
This does create some other problems, for example I would often
accidentally close the daemon by using C-xC-c. I fixed this by
changing the C-xC-c key binding when a the daemon is being run.
(defun oni:close-client-window () "Close a client's frames." (interactive) (server-save-buffers-kill-terminal nil)) (when (daemonp) (global-set-key "\C-x\C-c" 'oni:close-client-window))
14 Org
org-mode is awesome, I use it quite a bit. I use it to keep track of
my tasks, I use it to build/maintain my website, I use it to blog
and now I even use it to maintain my emacs init file, this file.
(defun oni:org-mode-func () "Function for `org-mode-hook'." (flyspell-mode) (auto-fill-mode))
When org loads, load appt, org-protocol, org-habit and
org-contacts. Add org-habit to the enabled org-modules, enable
org-indent-mode, send org tasks with dates to the diary and activate
automatic updating of the diary file with org tasks.
(eval-after-load "org" '(progn (require 'appt) (require 'org-protocol) (require 'org-habit) (require 'org-contacts) (add-to-list 'org-modules 'habit) (org-indent-mode t) (org-agenda-to-appt) (ad-activate 'org-agenda-redo)))
When org-crypt gets loaded, make sure that entries that should be
encrypted get encrypted.
(eval-after-load "org-crypt" '(org-crypt-use-before-save-magic))
14.1 Making it look good
I just saw this question on stackoverflow. I had no idea it was
possible to hide the markup elements. org-mode FTW again.
(setq org-hide-emphasis-markers t)
14.2 Refiling
When I refile I do want to be able to specify new parents.
(setq org-refile-allow-creating-parent-nodes t)
14.3 Updating the diary
Update the diary file whenever the org agenda is shown.
(defadvice org-agenda-redo (after org-agenda-redo-add-appts) "Pressing `r' on the agenda will also add appointments." (progn (setq appt-time-msg-list nil) (org-agenda-to-appt)))
15 Displaying a diary
diary can be used to show, for example, appointments. Since I'm not
interested in editing it I can easily display it in the fancy way.
(defun oni:diary-display-func () "Function for `diary-display-hook'." (diary-fancy-display))
And I don't want my diary to be the first thing I see when starting emacs/org.
(setq appt-display-diary nil)
16 Automatically opening room for blocks
When writing code that uses { } to signify the beginning and end of
blocks, it's nice to have them place themselves in the correct
position automatically. Once an opening block has been placed,
electric-pair-mode takes care of that, when I then press C-j it is
nice to have the } jump to a new line and indent itself.
(defun oni:newline-and-indent () (interactive) (if (and (not (or (= (point) (point-max)) (= (point) (point-min)))) (or (and (char-equal (char-before) ?{) (char-equal (char-after) ?})) (and (char-equal (char-before) ?\() (char-equal (char-after) ?\))))) (save-excursion (newline-and-indent))) (newline-and-indent))
17 EMMS
emms is the Emacs Multimedia System, it allows you to control a
number of external music players, such as mplayer, mpd, ogg123, etc,
from within emacs.
(defun oni:emms-toggle-playing () "Toggle between playing/paused states." (interactive) (if (eq emms-player-playing-p nil) (emms-start) (emms-pause))) (eval-after-load "emms-source-file" '(progn (require 'emms-setup) (emms-standard) (require 'emms-player-mpd) (setq emms-player-mpd-server-name "localhost") (setq emms-player-mpd-server-port "6600") (add-to-list 'emms-info-functions 'emms-info-mpd) (add-to-list 'emms-player-list 'emms-player-mpd) (setq emms-player-mpd-music-directory "/mnt/music/mp3"))) (setq emms-source-file-default-directory "/mnt/music/") (global-set-key [XF86AudioNext] 'emms-next) (global-set-key [XF86AudioPlay] 'oni:emms-toggle-playing) (global-set-key [XF86AudioPrev] 'emms-previous) (global-set-key [XF86AudioStop] 'emms-stop) (global-set-key [XF86Tools] 'emms)
18 ERC
IRC is a fun and interesting way to communicate with people. erc is
a fun and interesting way to use IRC.
I don't like the way erc does filling, so I use visual-line-mode
instead.
(defun oni:erc-mode-func () "Function for `erc-mode-hook'." (erc-fill-mode -1) (visual-line-mode) (setq truncate-lines nil)) (setq erc-autojoin-channels-alist '(("freenode.net" "#herbstluftwm" "#ninthfloor" "#emacs" "#dispass"))) (setq erc-nick "ryuslash") (add-hook 'erc-mode-hook 'oni:erc-mode-func)
18.1 The timestamp
By default the timestamp is only shown when it has changed since the last time it was shown. I don't like that, and I don't like seeing it on the right side of my screen.
Since it is not made to be shown on the left by default, the timestamp doesn't quite look right there, but all it needs is some space really.
(setq erc-insert-timestamp-function 'erc-insert-timestamp-left
erc-timestamp-format "[%H:%M] "
erc-timestamp-only-if-changed-flag nil)
18.2 Hide stuff
I don't need to see everyone joining and leaving, it's very distracting.
(setq erc-hide-list '("JOIN" "PART" "QUIT"))
19 Eshell
eshell is an awesome cross between an emacs lisp REPL and a full-on
shell.
Since eshell doesn't really deal with sentences and such I prefer
setting truncate-lines to nil over using visual-line-mode so that
whatever shows up is just cut off to the next line.
(defun oni:eshell-mode-func () "Function for `eshell-mode-hook'." (setq truncate-lines nil)) (add-hook 'eshell-mode-hook 'oni:eshell-mode-func)
19.1 The prompt
I like to know a little bit more about the system I'm on when using
eshell. It shows a few things:
- hostname
- The host name is very important, since I share my
configuration files across at least 3 computers
(desktop, server, netbook) that all connect to each
other from time to time through
ssh, it can get confusing, it has happened a few times that I want to reboot my desktop PC, but accidentally tell my server to reboot. - directory
- Seeing
/h/s/c/p/e/git-auto-commit-modeon every line is much nicer, in my opinion, than/home/slash/code/projects/emacs/git-auto-commit-mode. - git branch
- The git branch isn't really necessary, but its fun and sometimes handy.
- exit code
- To me, seeing whether or not a program executed successfully can be very useful.
- privileges
- Since I don't use tramp much this doesn't come up all that often, but since it was in the default function and it can come up, I've left it there.
(require 'cl) (defun oni:shorten-dir (dir) "Shorten a directory, (almost) like fish does it." (let ((scount (1- (count ?/ dir)))) (dotimes (i scount) (string-match "\\(/\\.?.\\)[^/]+" dir) (setq dir (replace-match "\\1" nil nil dir)))) dir) (defun oni:eshell-prompt-function () (let ((status (if (zerop eshell-last-command-status) ?+ ?-)) (hostname (shell-command-to-string "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)) ?# ?$))) (format "%c%s:%s@%s %c " status (substring hostname 0 -1) (oni:shorten-dir dir) (when (not (string= branch "")) (substring branch 2 -1)) userstatus))) (setq eshell-prompt-function 'oni:eshell-prompt-function)
19.2 Summoning it
I usually just use one eshell instance and move around in that a
lot, so I find it useful to go to the directory of the file I'm
currently working on.
(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)))) (eshell) (if (and hasfile (eq eshell-process-list nil)) (progn (eshell/cd dir) (eshell-reset))))) (global-set-key [f8] 'oni:raise-eshell)
19.3 Visual commands
eshell supports commands that require unbarred input by running
them in a separate term buffer.
unison is a very cool tool for synchronizing files across a
network. It also expects non-buffered input which eshell doesn't
allow.
(eval-after-load "em-term" '(add-to-list 'eshell-visual-commands "unison"))
20 Flymake
flymake is an excellent tool to help during development. When set up
correctly it will show you the error of your ways.
Anywhere where flymake is running it should be easy to find the
generated errors.
pyflakes is a very nice error checking tool for python.
flymake-cursor is the awesome functionality of showing the flymake
generated error near the text cursor in the minibuffer instead of
showing the one near the mouse pointer in a tooltip.
I had a working setup of using flymake with go. It just uses the
normal makefile based approach to flymake as is done with c and
such, but the trouble with it was that it needed to actually compile
the code, it had no syntax only option.
(defun oni:flymake-mode-func () "Function for `flymake-mode-hook'." (local-set-key [M-P] 'flymake-goto-prev-error) (local-set-key [M-N] 'flymake-goto-next-error)) (add-hook 'flymake-mode-hook 'oni:flymake-mode-func) (defun oni:flymake-pyflakes-init () "Initialize function for flymake with pyflakes." (let* ((temp-file (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)) (local-file (file-relative-name temp-file (file-name-directory buffer-file-name)))) (list "pyflakes" (list local-file)))) (eval-after-load "flymake" '(progn (require 'flymake-cursor) (add-to-list ; Make sure pyflakes is loaded 'flymake-allowed-file-name-masks ; for python files. '("\\.py\\'" oni:flymake-pyflakes-init)) (add-to-list ; Error line repexp for go 'flymake-err-line-patterns ; compilation. '("^\\([a-zA-Z0-9_]+\\.go\\):\\([0-9]+\\):\\(.*\\)$" 1 2 nil 3)) (add-to-list ; Go uses makefiles, makes 'flymake-allowed-file-name-masks ; flymaking 'easy'. '("\\.go$" flymake-simple-make-init))))
21 Gtags
There are at least 3 tag browsers that I know of, etags,
(exuberant?) ctags and GNU Global. That last one works especially
well, at least for php.
I got the oni:gtags-create-or-update function from emacs-fu.
(autoload 'gtags-mode "gtags" nil t) (defun oni:gtags-create-or-update () "Create or update the GNU Global tag file" (interactive) (if (not (= 0 (call-process "global" nil nil nil " -p"))) (let ((olddir default-directory) (topdir (read-directory-name "gtags: top of source tree:" default-directory))) (cd topdir) (shell-command "~/bin/create_gtags") (cd olddir)) ;; Tagfile already exists; update it (shell-command "~/bin/update_gtags"))) (defun oni:gtags-for-php () "Setup gtags for `php-mode'." (let* ((file-name (buffer-file-name)) (fext (if (not (eq nil file-name)) (file-name-extension (buffer-file-name)) nil))) (if (equal fext "php") (progn (gtags-mode) (oni:gtags-create-or-update))))) (defun oni:gtags-mode-func () "Function for `gtags-mode-hook'." (local-set-key "\M-," 'gtags-find-tag) (local-set-key "\M-." 'gtags-find-rtag)) (add-hook 'gtags-mode-hook 'oni:gtags-mode-func)
21.1 Automatically update
I have just read about a new feature in gtags vesion 6.2.3:
gtags-auto-update, which would make the old function obsolete.
(setq gtags-auto-update t)
22 DWIM
Do What I Mean commands are very cool. Only comment-dwim is shipped
with emacs, but it has inspired me to look into writing some other
ones. Some of these functions aren't really DWIM, but they were
inspired by it.
(require 'newcomment) (defun oni:kill-region-or-backward-char () "Kill either the active region, or delete the character left of the cursor" (interactive) (if (region-active-p) (kill-region (region-beginning) (region-end)) (backward-delete-char-untabify 1))) (defun oni:kill-region-or-forward-char () "Kill either the active region, or delete the character right of the cursor" (interactive) (if (region-active-p) (kill-region (region-beginning) (region-end)) (delete-forward-char 1))) (defun oni:kill-region-or-line () "Kill either the active region, or the rest of the line, depending on whether or not `region-active-p' is t" (interactive) (if (region-active-p) (kill-region (region-beginning) (region-end)) (kill-line))) (defun oni:move-beginning-of-dwim () "Move to the beginning of line, either after the indentatoin of before." (interactive) (let ((start (point))) (back-to-indentation) (if (= start (point)) (beginning-of-line)))) (defun oni:move-end-of-dwim () "Move to the end of line, either before any comments or after them." (interactive) (let ((start (point)) (eolpos (line-end-position))) (beginning-of-line) (if (and comment-start (comment-search-forward eolpos t)) (progn (search-backward-regexp (concat "[^ \t" comment-start "]")) (forward-char) (when (or (bolp) (= start (point))) (end-of-line))) (end-of-line)))) (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." (interactive) (if (region-active-p) (let ((electric-pair-mode nil) (beginning (region-beginning)) (end (region-end))) (goto-char end) (self-insert-command 1) (save-excursion (goto-char beginning) (self-insert-command 1))) (self-insert-command 1)))
23 Magit
I use git a lot, and magit is the best git interface (emacs or otherwise) I know. I'll admit I don't know that many since I've never felt a need for any interface to git other than its own command line one, but having it in emacs is just cooler.
(defun oni:magit-log-edit-mode-func () "Function for `magit-log-edit-mode-hook'." (auto-fill-mode) (flyspell-mode)) (add-hook 'magit-log-edit-mode-hook 'oni:magit-log-edit-mode-func) (global-set-key [f7] 'magit-status)
24 Markdown
Markdown is the only place where I might intentionally leave
whitespace in the file, since that is the equivalent of <br/>.
Also, seeing as how it's a text mode auto-fill-mode is vary useful
here.
(defun oni:markdown-mode-func () "Function for `markdown-mode-hook'." (auto-fill-mode) (whitespace-mode)) (add-hook 'markdown-mode-hook 'oni:markdown-mode-func) (add-to-list 'auto-mode-alist '("\\.m\\(ark\\)?do?wn$" . markdown-mode))
25 Message mode
message-mode is excellent for writing emails. In fact, that's
exactly what it is made for.
(defun oni:message-mode-func () "Function for `message-mode-hook'." (auto-fill-mode) (flyspell-mode) (ispell-change-dictionary (read-string "New dictionary: "))) (setq message-send-mail-function 'message-send-mail-with-sendmail) (add-hook 'message-mode-hook 'oni:message-mode-func)
26 Browse the web
Browsing the web for documentation, which is usually text-only anyway, can be very handy in emacs.
(require 'w3m-load)
27 Uniquify buffer names better
The default way of ensuring unique buffer names is not a very nice one.
(require 'uniquify) (setq uniquify-buffer-name-style 'post-forward)
28 The *scratch* buffer
Sometimes its useful to have a buffer ready to put some elisp code
in for testing, especially when you're writing some elisp. I don't
care much for the lisp-interaction-mode that is uses by default, I'm
too used to using C-j for newline+indent to be comfortable with it
evaluating each expression behind it when I use it.
(defun oni:raise-scratch () "Show the *scratch* buffer." (interactive) (switch-to-buffer "*scratch*")) (setq initial-major-mode 'emacs-lisp-mode initial-scratch-message nil) (global-set-key [XF86HomePage] 'oni:raise-scratch)
29 Reloading
When a buffer gets updated outside of emacs it is nice to be able to easily reload it to its state on disk.
(defun oni:reload-buffer () "Reload current buffer." (interactive) (revert-buffer nil t nil)) (global-set-key [f5] 'oni:reload-buffer)
30 Term
Don't truncate lines, just having them continue on the next line is fine for terminal output.
(defun oni:term-mode-func () "Function for `term-mode-hook'." (setq truncate-lines nil))
31 Texinfo
Automatically fill paragraphs while writing, makes for nice, readable, paragraphs.
(defun oni:texinfo-mode-func () "Function for `texinfo-mode-hook'." (auto-fill-mode))
32 Xmodmap
Load xmodmap-mode when xmodmap-mode is called and automatically call
xmodmap-mode when loading files named .Xmodmap.
(autoload 'xmodmap-mode "xmodmap-mode" nil t) (add-to-list 'auto-mode-alist '("^\\.Xmodmap$" . xmodmap-mode))
33 Shift indent
These functions were copied and modified from python-mode. They
shift indentation left or right by tab-width columns. If they can't,
the error Can't shift all lines enough is thrown, this is to be
expected, so it should not be caught by the debugger.
(defun oni:indent-shift-left (start end &optional count) (interactive (if mark-active (list (region-beginning) (region-end) current-prefix-arg) (list (line-beginning-position) (line-end-position) current-prefix-arg))) (if count (setq count (prefix-numeric-value count)) (setq count tab-width)) (when (> count 0) (let ((deactivate-mark nil)) (save-excursion (goto-char start) (while (< (point) end) (if (and (< (current-indentation) count) (not (looking-at "[ \t]*$"))) (error "Can't shift all lines enough")) (forward-line)) (indent-rigidly start end (- count)))))) (add-to-list 'debug-ignored-errors "^Can't shift all lines enough") (defun oni:indent-shift-right (start end &optional count) (interactive (if mark-active (list (region-beginning) (region-end) current-prefix-arg) (list (line-beginning-position) (line-end-position) current-prefix-arg))) (let ((deactivate-mark nil)) (if count (setq count (prefix-numeric-value count)) (setq count tab-width)) (indent-rigidly start end count)))
These should be usable in just about any situation.
(global-set-key (kbd "C-<") 'indent-shift-left) (global-set-key (kbd "C->") 'indent-shift-right)
34 PO-mode
Automatically load po-mode when po-mode is called and automatically
call po-mode for .po and .po.* files.
(autoload 'po-mode "po-mode" nil t) (add-to-list 'auto-mode-alist '("\\.po\\'\\|\\.po\\." . po-mode))
35 Sawfish
A window manager that has a configuration file format that looks a lot like emacs-lisp. It also has some great features for emacs integration.
(autoload 'sawfish-mode "sawfish-mode" nil t)
36 Misc global modes
Enable…
column-number-mode- Shows the current column in the mode-line.
electric-indent-mode- Automatically indent lines.
electric-pair-mode- Automatically add closing braces and such upon opening them.
show-paren-mode- Highlight the opening/closing parenthesis.
savehist-mode- Save minibuffer history across emacs sessions.
(column-number-mode) (electric-indent-mode) (electric-pair-mode) (show-paren-mode) (savehist-mode)
Disable…
blink-cursor-mode- Blinking cursors are distracting.
menu-bar-mode- No menu bar is needed. Takes up screen space.
scroll-bar-mode- This information is also shown in the mode-line.
tool-bar-mode- No tool bar is needed. Takes up screen space.
tooltip-mode- Not very useful, there are other ways to get this information.
(blink-cursor-mode -1) (menu-bar-mode -1) (scroll-bar-mode -1) (tool-bar-mode -1) (tooltip-mode -1)
37 Time-stamp
Only useful in very specific situations, usually only a bit of fun. Update any time-stamp found before saving the file.
(defun oni:write-file-func () "Function for `write-file-hooks'." (time-stamp))
38 Ido
Turn on ido-mode at startup.
(ido-mode)
Don't let ido show its file suggestions so quickly. It would be better to turn it off completely, but how.
(setq ido-auto-merge-delay-time 1000000)
Don't save any history, it just takes up space.
(setq ido-save-directory-list-file nil)
Make ido ignore buffers like *scratch*, irc.freenode.net:6938 and
#emacs, these clutter up the file list and aren't actually useful
when writing software. They will still show up if searched for and
there are only ignored buffers that match.
Make sure that ido is loaded before setting this, otherwise
ido-ignore-buffers would be unbound and unusable.
(eval-after-load "ido" '(setq ido-ignore-buffers `(,@ido-ignore-buffers "^\\*.*\\*$" "^irc\\." "^\\#")))
39 Smex
Enable smex.
(smex-initialize)
Bind smex keys to <dead-circumflex> and C-<dead-circumflex>. These
keys are effectively AltGR-x and C-AltGR-x on a colemak keyboard.
(eval-after-load "smex" '(progn (global-set-key (kbd "<dead-circumflex>") 'smex) (global-set-key (kbd "C-<dead-circumflex>") 'smex-major-mode-commands)))
Don't save any history or the likes in HOME.
(setq smex-save-file "~/.emacs.d/smex-items")
Since smex isn't bound to M-x, it is not useful to have the prompt say
so.
(setq smex-prompt-string "smex ")
40 Dead keys
In order to be able to easily write characters like ë, iso-transl is
required.
(require 'iso-transl)
41 General settings
Emacs has so many settings, its hard to keep track of them all.
41.1 Bi-directional text
Bidi should never be turned off, the emacs display system is,
apparently, too dependent on it. However, telling it to always
print text left-to-right should speed things up if you never have
any bi-directional text to view.
(setq-default bidi-paragraph-direction 'left-to-right)
41.2 git-auto-commit-mode
By default, try to push any changes upstream after committing.
(setq-default gac-automatically-push-p t)
41.3 Indentation
Use spaces for indentation. Use 4.
(setq-default indent-tabs-mode nil
tab-width 4)
41.4 Final newline
Make sure there is one, and only one, final newline at the end of a file when saving it.
(setq-default require-final-newline t)
41.5 Truncate lines
Just let lines disappear beyond the right border of the window.
(setq-default truncate-lines t)
41.6 PKGBUILDs
Automatically call shell-script-mode for PKGBUILD files.
(add-to-list 'auto-mode-alist '("^PKGBUILD$" . shell-script-mode))
41.7 Autoloading
Don't worry about case in autoload calls, I usually try to get them
right.
(setq auto-mode-case-fold nil)
41.8 Autosave and backup files
Keep them out of whichever working directory you're in, store them all separately.
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t))
backup-directory-alist
`((".*" . ,temporary-file-directory)))
41.9 External browser
Use the generic browse functions and get the actual browser from
the BROWSER environment variable.
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program (getenv "BROWSER"))
41.10 Customizations
Put anything from the customize interface of emacs in its own file.
(setq custom-file "~/.emacs.d/custom.el")
41.11 Theme
Set themes directory and add naquadah-theme to load path.
(setq custom-theme-directory "~/.emacs.d/themes") (add-to-list 'custom-theme-load-path (concat custom-theme-directory "/naquadah-theme")) (load-theme 'naquadah t)
41.12 Default frame style
Don't show a border, either inside or outside, turn off scrollbars, menubar and toolbar and set default font.
(setq
default-frame-alist
`((border-width . 0)
(internal-border-width . 0)
(vertical-scroll-bars . nil)
(menu-bar-lines . nil)
(tool-bar-lines . nil)
(font . "DejaVu Sans Mono:pixelsize=16")))
41.13 Display time
Display the time of day in the mode-line using 24h format.
(setq display-time-24hr-format t) (display-time-mode)
41.14 Frame title
Show the name of the current buffer in the frame title.
(setq frame-title-format '(:eval (concat "emacs: " (buffer-name))))
41.15 Help at point
Show help at point after 1 second.
(setq help-at-pt-display-when-idle t) (help-at-pt-set-timer)
41.16 Sauron
Tell sauron that it can use as much space as it wants and add
sauron-identica and sauron-jabber to sauron-modules.
(setq sauron-max-line-length 189) (eval-after-load "sauron" '(setq sauron-modules (append '(sauron-identica sauron-jabber) sauron-modules)))
42 Misc
I'm still working on this…
(setq inhibit-default-init t) ; I don't use it. (setq inhibit-local-menu-bar-menus t) ; I don't think I use them. (setq inhibit-startup-message t) ; I don't care, I know it. (setq inhibit-x-resources t) ; I'll set my own settings. (setq jit-lock-defer-time 0.2) ; Faster scrolling. (setq line-move-visual nil) ; Just move around. (setq mail-header-separator "") ; Empty line. (setq message-log-max 1000) ; 100 is not always enough. (setq mode-line-position ; Hide the TOP/BOT part. (cdr mode-line-position)) (setq org2blog/wp-blog-alist ; My wordpress blogs '(("wordpress" :url "http://ryuslash.wordpress.com/xmlrpc.php" :username "ryuslash"))) (setq org-agenda-custom-commands ; Overwrite default `t' list. '(("b" "Bookmarks to look at." todo "LOOKAT") ("w" "Work todo." tags-todo "CATEGORY=\"Work\""))) (setq org-blank-before-new-entry ; Insert blank line before new '((heading . t) ; headings/list items. (plain-list-item . t))) (setq org-directory ; Where my org files live. (expand-file-name "~/documents/org")) (setq org-agenda-files `(,(concat org-directory "/org") ,(concat org-directory "/misc/contacts.org") ,(concat org-directory "/misc/bookmarks.org"))) (setq org-agenda-include-diary t) ; Do include my diary. (setq org-agenda-sorting-strategy ; How to sort my agenda. '((agenda habit-down time-up priority-down category-keep) (todo priority-down category-up) (tags priority-down category-keep) (search category-keep))) (setq org-blog-directory ; Location for finished posts. "~/code/projects/orgweb/blog") (setq org-blog-unfinished-directory ; And drafts here. "~/documents/blog/drafts") (setq org-capture-templates ; What to capture when. '(("t" "Task" entry (file+headline "" "tasks") "* TODO %^{Description}\n %u\n\n %?") ("T" "Task with link" entry (file+headline "" "tasks") "* TODO %^{Description}\n %u\n\n %a\n %?") ("h" "Habit" entry (file+headline "" "tasks") (concat "* TODO %^{Description}\n" " SCHEDULED: %^T\n" " :PROPERTIES:\n" " :STYLE: habit\n" " :END:") :immediate-finish t) ("l" "Log" entry (file+headline "" "notes") (concat "* %n %<%d-%m-%Y %H:%M:%S>\n" " %a\n\n" " %?") :prepend t :empty-lines 1) ("a" "Appointment" entry (file+headline "" "appointments") "* %^{Description} %^T" :immediate-finish t) ("b" "Bookmark" entry (file "~/documents/org/misc/bookmarks.org") "* %c\n\n %:initial"))) (setq org-contacts-files ; To store my contacts in. '("~/documents/org/misc/contacts.org")) (setq org-crypt-key "33E8CC1CC4") ; Shhhh, don't tell anyone. (setq org-default-notes-file (concat org-directory "/org")) (setq org-export-htmlize-output-type ; Make it color-agnostic? 'css) (setq ; Keep completions clean. org-outline-path-complete-in-steps t) (setq org-refile-targets ; Where to allow sending it. '((nil . (:maxlevel . 5)))) (setq org-refile-use-outline-path ; Select file first. 'file) (setq org-return-follows-link t) ; Easy url opening. (setq org-src-fontify-natively t) ; Fontification of code. (setq org-tags-exclude-from-inheritance ; Don't inherit crypt. '("crypt")) (setq org-todo-keyword-faces ; What they look like. '(("TODO" :foreground "red") ("IN PROGRESS" :foreground "yellow") ("DONE" :foreground "forest green") ("SUCCEEDED" :foreground "forest green") ("WAITING" :foreground "orange") ("CANCELLED" :foreground "orangered") ("FAILED" :foreground "orangered"))) (setq org-todo-keywords ; States for todo items. '((sequence "TODO(t)" "IN PROGRESS" "WAITING(@/!)" "|" "DONE(!/!)" "CANCELLED(@/!)"))) (setq org-use-fast-todo-selection t) ; Faster, FASTER! (setq rainbow-delimiters-max-face-count ; That's quite enough. 8) (setq redisplay-dont-pause t) ; Speedup? Don't remember. (setq sauron-column-alist ; I don't need as much '((timestamp . 6) ; information as the default. (message))) (setq sauron-hide-mode-line t) ; No need in that frame. (setq sauron-max-line-length 53) ; Less info == less space. (setq sauron-timestamp-format "%H:%M") ; Even less space. (setq sauron-watch-nicks '("ryuslash")) ; I'm important. (setq sauron-watch-patterns ; Very important. '("ryuslash")) (setq scroll-conservatively 101) ; Move screen a single line. (setq send-mail-function ; Use smtpmail to send email. 'smtpmail-send-it) (setq sendmail-program ; sendmail is actually msmtp. "/usr/bin/msmtp") (setq special-display-buffer-names ; Treat sauron specially. '("*Sauron*")) (setq special-display-frame-alist ; No minibuffer for sauron. '((minibuffer . nil) (right-fringe . 0))) (setq time-stamp-active t) ; I kinda like it. (setq time-stamp-format ; I like this format. "%04y-%02m-%02d %02H:%02M:%02S (%u)") (setq use-dialog-box nil) ; I hate them. (setq user-full-name "Tom Willemsen") ; For things not changelog. (setq whitespace-style ; Only trailing whitespace. '(face trailing))
(add-hook 'after-save-hook 'oni:after-save-func) (add-hook 'before-save-hook 'oni:before-save-func) (add-hook 'diary-display-hook 'oni:diary-fancy-func) (add-hook 'org-mode-hook 'oni:org-mode-func) (add-hook 'scheme-mode-hook 'oni:scheme-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) (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 "'" 'oni:self-insert-dwim) (global-set-key "\"" 'oni:self-insert-dwim) (global-set-key "\C-\M-d" 'kill-word) (global-set-key "\C-\M-w" 'backward-kill-word) (global-set-key "\C-a" 'oni:move-beginning-of-dwim) (global-set-key "\C-ca" 'org-agenda) (global-set-key "\C-cc" 'org-capture) (global-set-key "\C-d" 'oni:kill-region-or-forward-char) (global-set-key "\C-e" 'oni:move-end-of-dwim) (global-set-key "\C-j" 'newline-and-indent) (global-set-key "\C-k" 'oni:kill-region-or-line) (global-set-key "\C-l" 'recenter-top-bottom) (global-set-key "\C-w" 'oni:kill-region-or-backward-char) (global-set-key "\C-x n r" 'narrow-to-region) (global-set-key "\M-0" 'delete-window) (global-set-key "\M-1" 'delete-other-windows) (global-set-key "\M-2" 'split-window-below) (global-set-key "\M-3" 'split-window-right) (global-set-key "\M-s" 'other-window) (global-set-key (kbd "C-'") 'execute-extended-command) (global-set-key (kbd "C-S-k") 'kill-whole-line) (when (or window-system (daemonp)) (global-unset-key "\C-z"))
(load custom-file)
(load "rudel-loaddefs.el")
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'narrow-to-region 'disabled nil)