1 #+TITLE: emacs.org - Ganneffs emacs configuration
2 #+DESCRIPTION: My current Emacs configuration
3 #+KEYWORDS: org-mode Emacs configuration
4 #+STARTUP: align fold nodlcheck hidestars oddeven lognotestate
5 #+SETUPFILE: ~/.emacs.d/elisp/org-templates/level-0.org
11 :ID: b6e6cf73-9802-4a7b-bd65-fdb6f9745319
13 The following functions are used throughout my config, and so I load
16 safe-load does not break emacs initialization, should a file be
17 unreadable while emacs boots up.
18 #+BEGIN_SRC emacs-lisp tangle:yes
19 (defvar safe-load-error-list ""
20 "*List of files that reported errors when loaded via safe-load")
22 (defun safe-load (file &optional noerror nomessage nosuffix)
23 "Load a file. If error on load, report back, wait for
24 a key stroke then continue on"
26 (condition-case nil (load file noerror nomessage nosuffix)
29 (setq safe-load-error-list (concat safe-load-error-list " " file))
30 (message "****** [Return to continue] Error loading %s" safe-load-error-list )
34 (defun safe-load-check ()
35 "Check for any previous safe-load loading errors. (safe-load.el)"
37 (if (string-equal safe-load-error-list "") ()
38 (message (concat "****** error loading: " safe-load-error-list))))
41 match-paren will either jump to the "other" paren or simply insert %
42 #+BEGIN_SRC emacs-lisp tangle:yes
43 (defun match-paren (arg)
44 "Go to the matching parenthesis if on parenthesis otherwise insert %."
46 (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
47 ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
48 (t (self-insert-command (or arg 1)))))
51 I have some stuff put away in my local dir. I don't want to load it all
52 at startup time, so it is using the autoload feature. For that to work
53 load the loaddefs, so autoload knows where to grab stuff
54 #+BEGIN_SRC emacs-lisp tangle:yes
55 (load-file (concat jj-elisp-dir "/tiny/loaddefs.el"))
56 (load-file (concat jj-elisp-local-dir "/loaddefs.el"))
60 Always ensure to have a scratch buffer around.
61 #+BEGIN_SRC emacs-lisp tangle:yes
63 (set-buffer (get-buffer-create "*scratch*"))
64 (lisp-interaction-mode)
65 (make-local-variable 'kill-buffer-query-functions)
66 (add-hook 'kill-buffer-query-functions 'kill-scratch-buffer))
69 Handier way to add modes to auto-mode-alist
70 #+BEGIN_SRC emacs-lisp tangle:yes
71 (defun add-auto-mode (mode &rest patterns)
72 "Add entries to `auto-mode-alist' to use `MODE' for all given file `PATTERNS'."
73 (dolist (pattern patterns)
74 (add-to-list 'auto-mode-alist (cons pattern mode))))
78 Helpers for the config
79 #+BEGIN_SRC emacs-lisp tangle:yes
80 (require 'use-package)
86 We need to define the load-path. As I have lots of things I add
87 locally, its getting a few entries. I only leave out org-mode here, as
88 that is already done in =init.el=.
90 I also disliked the repeated /add-to-list/ lines, so I now just have
91 one variable and go over that in a loop.
92 #+BEGIN_SRC emacs-lisp tangle:yes
93 (defvar jj-elisp-subdirs '(local gnus icicle org/contrib tiny mo-git-blame cedet
94 cedet/eieio ecb jdee/lisp sunrise multiple-cursors
95 auto-complete yasnippet magit mmm)
96 "List of subdirectories in jj-elisp-dir to add to load-path")
99 (dolist (dirval jj-elisp-subdirs)
100 (let ((name (expand-file-name (symbol-name dirval) jj-elisp-dir)))
101 (when (file-exists-p name)
102 (add-to-list 'load-path name)))))
103 ;; For older emacsen we need an extra directory, which should be at
104 ;; THE END of the load path
105 (when (< emacs-major-version 24)
106 (add-to-list 'load-path (expand-file-name "emacs23" jj-elisp-dir) t))
111 Help emacs to find the info files
112 #+BEGIN_SRC emacs-lisp tangle:yes
113 (setq Info-directory-list '("~/emacs/info"
114 "/usr/local/share/info/"
116 "/usr/local/gnu/info/"
117 "/usr/local/gnu/lib/info/"
118 "/usr/local/gnu/lib/emacs/info/"
119 "/usr/local/emacs/info/"
120 "/usr/local/lib/info/"
121 "/usr/local/lib/emacs/info/"
122 "/usr/share/info/emacs-23"
125 (setq Info-default-directory-list
126 (cons "~/emacs/info" Info-default-directory-list))
132 :ID: 0a1560d9-7e55-47ab-be52-b3a8b8eea4aa
134 I dislike the startup message
135 #+BEGIN_SRC emacs-lisp tangle:yes
136 (setq inhibit-splash-screen t)
137 (setq inhibit-startup-message t)
140 Usually I want the lines to break at 72 characters.
141 #+BEGIN_SRC emacs-lisp tangle:yes
142 (if (> emacs-major-version 22)
143 (setq fill-column 72)
144 (setq default-fill-column 72))
147 And it is nice to have a final newline in files.
148 #+BEGIN_SRC emacs-lisp tangle:yes
149 (setq require-final-newline t)
152 After I typed 300 characters or took a break for more than a minute it
153 would be nice of emacs to save whatever I am on in one of its auto-save
154 backups. See [[info:emacs#Auto%20Save%20Control][info:emacs#Auto Save Control]] for more details.
155 #+BEGIN_SRC emacs-lisp tangle:yes
156 (setq auto-save-interval 300)
157 (setq auto-save-timeout 60)
160 Set my full name and my default mail address - for whatever wants to use
161 it later. Also, I am using gnus.
162 #+BEGIN_SRC emacs-lisp tangle:yes
163 (setq user-full-name "Joerg Jaspert")
164 (setq user-mail-address "joerg@ganneff.de")
165 (setq mail-user-agent (quote gnus-user-agent))
168 My default mail server. Well, simply a localhost, I have a forwarder that
169 puts mail off the right way, no need for emacs to have any further
171 #+BEGIN_SRC emacs-lisp tangle:yes
172 (setq smtpmail-default-smtp-server "localhost")
173 (setq smtpmail-smtp-server "localhost")
176 Enable automatic handling of compressed files.
177 #+BEGIN_SRC emacs-lisp tangle:yes
178 (auto-compression-mode 1)
181 Emacs forbids a certain set of commands, as they can be very confusing
182 for new users. Enable them.
183 #+BEGIN_SRC emacs-lisp tangle:yes
184 (put 'narrow-to-region 'disabled nil)
185 (put 'narrow-to-page 'disabled nil)
186 (put 'narrow-to-defun 'disabled nil)
187 (put 'upcase-region 'disabled nil)
188 (put 'downcase-region 'disabled nil)
192 I've tried various different fonts and while I like the Terminus font
193 most for my shells, in Emacs Inconsolata clearly wins.
194 #+BEGIN_SRC emacs-lisp tangle:yes
195 (if (> emacs-major-version 22)
196 (set-frame-font "Inconsolata-14")
197 (set-default-font "Inconsolata-14"))
200 I always use dark backgrounds, so tell Emacs about it. No need to
202 #+BEGIN_SRC emacs-lisp tangle:yes
203 (setq-default frame-background-mode 'dark)
206 And I always liked dark backgrounds with colors setup for them. So I
207 switched through multiple themes doing it in emacs too, but never
208 entirely liked it. Until I found solarized, which is now not only my
209 emacs theme, but also for most of my other software too, especially my
210 shell. Consistent look is great.
211 #+BEGIN_SRC emacs-lisp tangle:yes
212 (if (boundp 'custom-theme-load-path)
214 (defun jj-init-theme ()
216 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
217 (load-theme 'solarized-light t))
218 (set-face-attribute 'org-date nil :underline nil)
219 (message "Initializing theme solarized-dark")
221 (add-to-list 'custom-theme-load-path jj-theme-dir)
222 (add-hook 'after-init-hook 'jj-init-theme)
224 (message "Emacs version too old, using non-solarize theme")
225 (defvar custom-theme-load-path jj-theme-dir)
226 (require 'naquadah-theme))
229 Make the fringe (gutter) smaller, the argument is a width in pixels (the default is 8)
230 #+BEGIN_SRC emacs-lisp tangle:yes
231 (if (fboundp 'fringe-mode)
235 A bit more spacing between buffer lines
236 #+BEGIN_SRC emacs-lisp tangle:yes
237 (setq-default line-spacing 0.1)
240 [2013-04-21 So 20:54]
241 I do not want my cursor to blink.
242 #+BEGIN_SRC emacs-lisp tangle:yes
243 (blink-cursor-mode -1)
245 *** Menu, Tool and Scrollbar
246 I don't want to see the menu-bar, tool-bar or scrollbar.
247 #+BEGIN_SRC emacs-lisp tangle:yes
251 (set-scroll-bar-mode nil))
253 **** When using emacs in daemon mode
254 Emacs has a very nice mode where it detaches itself and runs as daemon -
255 and you can just open /frames/ (windows) from it by using [[http://www.emacswiki.org/emacs/EmacsClient][Emacs
256 Client]]. It's fast, it's nice, it's convinient.
258 Except that Emacs behaves stupid when you do that and ignores your
259 menu/tool/scrollbar settings. Sucks.
261 For them to work even then, we have to do two things.
262 1. We have to set the frame alist. We simple set both,
263 =initial-frame-alist= and =default-frame-alist= to the same value here.
264 #+BEGIN_SRC emacs-lisp tangle:yes
265 (setq initial-frame-alist '(
266 (horizontal-scroll-bars . nil)
267 (vertical-scroll-bars . nil)
270 (setq default-frame-alist (copy-alist initial-frame-alist))
272 2. We have to disable the toolbar using the customize interface, so you
273 can find that in the [[id:0102208d-fdf6-4928-9e40-7e341bd3aa3a][Customized variables]] section.
275 *** Hilight current line in buffer
276 As it says, it does a hilight of the current line.
277 #+BEGIN_SRC emacs-lisp tangle:yes
278 (global-hl-line-mode +1)
280 *** Allow recursive minibuffers
281 This allows (additional) minibuffer commands while in the minibuffer.
282 #+BEGIN_SRC emacs-lisp tangle:yes
283 (setq enable-recursive-minibuffers 't)
286 *** Modeline related changes
287 I want to see line and column numbers, so turn them on.
288 Size indication lets me know how far I am in a buffer.
290 And modeline-posn is great. It will hilight the column number in the
291 modeline in red as soon as you are over the defined limit.
293 #+BEGIN_SRC emacs-lisp tangle:yes
295 (column-number-mode 1)
296 (size-indication-mode 1)
297 (display-time-mode 1)
298 (setq display-time-day-and-date nil)
299 (setq display-time-24hr-format t)
300 (setq modelinepos-column-limit 72)
302 (require 'modeline-posn)
303 (set-face-foreground 'modelinepos-column-warning "grey20")
304 (set-face-background 'modelinepos-column-warning "red")
307 [2013-04-22 Mon 11:27]
308 The modeline is easily cluttered up with stuff I don't really need to
309 see. So lets hide those. There are two ways, one of them uses diminish
310 to get entirely rid of some modes, the other is a function taken from
311 "Mastering Emacs" which replaces the modes text with an own (set of)
313 #+BEGIN_SRC emacs-lisp tangle:yes
315 (diminish 'auto-fill-function)
316 (defvar mode-line-cleaner-alist
317 `((auto-complete-mode . " α")
318 (yas-minor-mode . " y")
319 (paredit-mode . " π")
323 (lisp-interaction-mode . "λ")
326 (emacs-lisp-mode . "EL")
328 (org-indent-mode . "")
330 (nxhtml-mode . "nx"))
332 "Alist for `clean-mode-line'.
334 When you add a new element to the alist, keep in mind that you
335 must pass the correct minor/major mode symbol and a string you
336 want to use in the modeline *in lieu of* the original.
338 Want some symbols? Go:
340 ;ςερτζθιοπασδφγηξκλυχψωβνμ
341 :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
342 @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
346 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
349 Unfortunately icicles breaks this with the way it adds/removes itself,
350 so take it our for now...
353 Back when I started with text-mode. But nowadays I want default mode to
354 be org-mode - it is just so much better to use. And does sensible things
355 with many README files out there, and various other "crap" you get to
357 #+BEGIN_SRC emacs-lisp tangle:yes
358 (if (> emacs-major-version 22)
359 (setq major-mode 'org-mode)
360 (setq default-major-mode 'org-mode))
361 (setq initial-major-mode 'org-mode)
365 [2013-04-23 Tue 16:43]
366 Shell. zsh in my case.
367 #+BEGIN_SRC emacs-lisp tangle:yes
368 (setq shell-file-name "zsh")
369 (setq shell-command-switch "-c")
370 (setq explicit-shell-file-name shell-file-name)
371 (setenv "SHELL" shell-file-name)
372 (setq explicit-sh-args '("-login" "-i"))
373 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
374 (setq comint-scroll-to-bottom-on-input t) ; always insert at the bottom
375 (setq comint-scroll-to-bottom-on-output t) ; always add output at the bottom
376 (setq comint-scroll-show-maximum-output t) ; scroll to show max possible output
377 (setq comint-completion-autolist t) ; show completion list when ambiguous
378 (setq comint-input-ignoredups t) ; no duplicates in command history
379 (setq comint-completion-addsuffix t) ; insert space/slash after file completion
383 Basic settings for emacs integrated shell
384 #+BEGIN_SRC emacs-lisp tangle:yes
385 (setq eshell-cmpl-cycle-completions nil
386 eshell-save-history-on-exit t
387 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
388 (eval-after-load 'esh-opt
393 ;; TODO: for some reason requiring this here breaks it, but
394 ;; requiring it after an eshell session is started works fine.
395 ;; (require 'eshell-vc)
396 (setenv "PAGER" "cat")
397 ; (set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
398 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
399 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
400 (add-hook 'eshell-preoutput-filter-functions
401 'ansi-color-filter-apply)
402 (add-to-list 'eshell-visual-commands "ssh")
403 (add-to-list 'eshell-visual-commands "tail")
404 (add-to-list 'eshell-command-completions-alist
406 (add-to-list 'eshell-command-completions-alist
407 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))))
412 Incremental search is great, but annoyingly you need to type whatever
413 you want. If you want to search for just the next (or previous)
414 occurence of what is at your cursor position use the following.
415 *C-x* will insert the current word while *M-up* and *M-down* will just
416 jump to the next/previous occurence of it.
417 #+BEGIN_SRC emacs-lisp tangle:yes
418 (define-key isearch-mode-map (kbd "C-x") 'sacha/isearch-yank-current-word)
419 (global-set-key '[M-up] 'sacha/search-word-backward)
420 (global-set-key '[M-down] 'sacha/search-word-forward)
423 *** Frame configuration
424 I want to see the buffername and its size, not the host I am on in my
426 #+BEGIN_SRC emacs-lisp tangle:yes
427 (setq frame-title-format "%b (%i)")
430 *** Protect some buffers
431 I don't want some buffers to be killed, **scratch** for example.
432 In the past I had a long function that just recreated them, but the
433 =keep-buffers= package is easier.
434 #+BEGIN_SRC emacs-lisp tangle:yes
435 (require 'keep-buffers)
436 (keep-buffers-mode 1)
437 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
438 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
439 (push '("\\`*Group" . nil) keep-buffers-protected-alist)
443 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
445 #+BEGIN_SRC emacs-lisp tangle:yes
446 (defalias 'yes-or-no-p 'y-or-n-p)
449 *** Language/i18n stuff
450 In this day and age, UTF-8 is the way to go.
451 #+BEGIN_SRC emacs-lisp tangle:yes
452 (set-language-environment 'utf-8)
453 (set-default-coding-systems 'utf-8)
454 (set-terminal-coding-system 'utf-8)
455 (set-keyboard-coding-system 'utf-8)
456 (set-clipboard-coding-system 'utf-8)
457 (prefer-coding-system 'utf-8)
458 (set-charset-priority 'unicode)
459 (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
462 *** Hilight matching parentheses
463 While I do have the nifty shortcut to jump to the other parentheses,
464 hilighting them makes it obvious where they are.
465 #+BEGIN_SRC emacs-lisp tangle:yes
467 (setq show-paren-style 'parenthesis)
470 *** Kill other buffers
471 While many editors allow you to close "all the other files, not the one
472 you are in", emacs doesn't have this... Except, now it will.
473 #+BEGIN_SRC emacs-lisp tangle:yes
474 (global-set-key (kbd "C-c k") 'prelude-kill-other-buffers)
477 Default scrolling behaviour in emacs is a bit annoying, who wants to
479 #+BEGIN_SRC emacs-lisp tangle:yes
480 (setq scroll-margin 0)
481 (setq scroll-conservatively 100000)
482 (setq scroll-up-aggressively 0.0)
483 (setq scroll-down-aggressively 0.0)
484 (setq scroll-preserve-screen-position t)
487 *** Copy/Paste with X
488 [2013-04-09 Di 23:31]
489 The default how emacs handles cutting/pasting with the primary selection
490 changed in emacs24. I am used to the old way, so get it back.
491 #+BEGIN_SRC emacs-lisp tangle:yes
492 (setq x-select-enable-primary t)
493 (setq x-select-enable-clipboard t ;; copy-paste should work ...
494 interprogram-paste-function ;; ...with...
495 'x-cut-buffer-or-selection-value) ;; ...other X clients
499 *** Global keyboard changes not directly related to a mode
500 Disable /suspend_frame/ function, I dislike it.
501 #+BEGIN_SRC emacs-lisp tangle:yes
502 (global-unset-key [(control z)])
503 (global-unset-key [(control x) (control z)])
506 Default of *C-k* is to kill from the point to the end of line. If
507 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
508 set, including newline. But to kill the entire line, one still needs a
509 *C-a* in front of it. So I change it, by defining a function to do just this for
511 #+BEGIN_SRC emacs-lisp tangle:yes
512 (defun kill-entire-line ()
513 "Kill this entire line (including newline), regardless of where point is within the line."
517 (back-to-indentation))
519 (global-unset-key [(control k)])
520 (global-set-key [(control k)] 'kill-entire-line)
521 (global-set-key [remap kill-whole-line] 'kill-entire-line)
524 And the same is true when I'm in org-mode, which has an own kill function...
525 (the keybinding happens later, after org-mode is loaded fully)
526 #+BEGIN_SRC emacs-lisp tangle:yes
527 (defun jj-org-kill-line (&optional arg)
528 "Kill the entire line, regardless of where point is within the line, org-mode-version"
532 (back-to-indentation)
536 I really hate tabs, so I don't want any indentation to try using them.
537 And in case a project really needs them, I can change it just for that
538 file/project, but luckily none of those I work in is as broken.
539 #+BEGIN_SRC emacs-lisp tangle:yes
540 (setq-default indent-tabs-mode nil)
543 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
544 #+BEGIN_SRC emacs-lisp tangle:yes
545 (global-set-key "\M-5" 'match-paren)
548 Instead of the default "mark-defun" I want a more readline-like setting.
549 #+begin_src emacs-lisp
550 (global-set-key (kbd "C-M-h") 'backward-kill-word)
553 Align whatever with a regexp.
554 #+begin_src emacs-lisp
555 (global-set-key (kbd "C-x \\") 'align-regexp)
559 #+begin_src emacs-lisp
560 (global-set-key (kbd "C-+") 'text-scale-increase)
561 (global-set-key (kbd "C--") 'text-scale-decrease)
564 Regexes are too useful, so use the regex search by default.
565 #+begin_src emacs-lisp
566 (global-set-key (kbd "C-s") 'isearch-forward-regexp)
567 (global-set-key (kbd "\C-r") 'isearch-backward-regexp)
568 (global-set-key (kbd "C-M-s") 'isearch-forward)
569 (global-set-key (kbd "C-M-r") 'isearch-backward)
572 Rgrep is infinitely useful in multi-file projects.
573 #+begin_src emacs-lisp
574 (define-key global-map "\C-x\C-g" 'rgrep)
577 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
579 #+BEGIN_SRC emacs-lisp tangle:yes
580 (global-set-key [(meta shift up)] 'move-line-up)
581 (global-set-key [(meta shift down)] 'move-line-down)
584 "Pull" lines up, join them
585 #+BEGIN_SRC emacs-lisp tangle:yes
586 (global-set-key (kbd "M-j")
592 When I press Enter I almost always want to go to the right indentation on the next line.
593 #+BEGIN_SRC emacs-lisp tangle:yes
594 (global-set-key (kbd "RET") 'newline-and-indent)
597 Easier undo, and i don't need suspend-frame
598 #+BEGIN_SRC emacs-lisp tangle:yes
599 (global-set-key (kbd "C-z") 'undo)
602 Window switching, go backwards. (C-x o goes to the next window)
603 #+BEGIN_SRC emacs-lisp tangle:yes
604 (global-set-key (kbd "C-x O") (lambda ()
610 #+BEGIN_SRC emacs-lisp tangle:yes
611 (global-set-key (kbd "C-x C-r") 'prelude-sudo-edit)
614 M-space is bound to just-one-space, which is great for programming. What
615 it does is remove all spaces around the cursor, except for one. But to
616 be really useful, it also should include newlines. It doesn’t do this by
617 default. Rather, you have to call it with a negative argument. Sure
619 #+BEGIN_SRC emacs-lisp tangle:yes
620 (global-set-key (kbd "M-SPC") 'just-one-space-with-newline)
623 Count which commands I use how often.
624 #+BEGIN_SRC emacs-lisp tangle:yes
626 (expand-file-name "keyfreq" jj-cache-dir)
627 "Keyfreq cache file")
628 (defvar keyfreq-file-lock
629 (expand-file-name "keyfreq.lock" jj-cache-dir)
630 "Keyfreq cache file")
633 (keyfreq-autosave-mode 1)
636 Duplicate current line
637 #+BEGIN_SRC emacs-lisp tangle:yes
638 (defun duplicate-line ()
639 "Insert a copy of the current line after the current line."
642 (let ((line-text (buffer-substring-no-properties
643 (line-beginning-position)
644 (line-end-position))))
647 (insert line-text))))
649 (global-set-key (kbd "C-c p") 'duplicate-line)
652 Smarter move to the beginning of the line. That is, it first moves to
653 the beginning of the line - and on second keypress it goes to the
654 first character on line.
655 #+BEGIN_SRC emacs-lisp tangle:yes
656 (defun smarter-move-beginning-of-line (arg)
657 "Move point back to indentation of beginning of line.
659 Move point to the first non-whitespace character on this line.
660 If point is already there, move to the beginning of the line.
661 Effectively toggle between the first non-whitespace character and
662 the beginning of the line.
664 If ARG is not nil or 1, move forward ARG - 1 lines first. If
665 point reaches the beginning or end of the buffer, stop there."
667 (setq arg (or arg 1))
671 (let ((line-move-visual nil))
672 (forward-line (1- arg))))
674 (let ((orig-point (point)))
675 (back-to-indentation)
676 (when (= orig-point (point))
677 (move-beginning-of-line 1))))
679 ;; remap C-a to `smarter-move-beginning-of-line'
680 (global-set-key [remap move-beginning-of-line]
681 'smarter-move-beginning-of-line)
685 [2013-04-28 So 11:26]
687 Quickly move around in buffers.
688 #+BEGIN_SRC emacs-lisp tangle:yes
689 (autoload 'ace-jump-mode "ace-jump-mode" "Emacs quick move minor mode" t)
690 (define-key global-map (kbd "H-SPC") 'ace-jump-mode)
691 ;; enable a more powerful jump back function from ace jump mode
692 (autoload 'ace-jump-mode-pop-mark "ace-jump-mode" "Ace jump back :-)" t)
693 (eval-after-load "ace-jump-mode" '(ace-jump-mode-enable-mark-sync))
694 (define-key global-map (kbd "H-c SPC") 'ace-jump-mode-pop-mark)
697 Usually you can press the *Ins*ert key, to get into overwrite mode. I
698 don't like that, have broken much with it and so just forbid it by
700 #+BEGIN_SRC emacs-lisp tangle:yes
701 (global-unset-key [insert])
702 (global-unset-key [kp-insert])
705 ** Miscellaneous stuff
706 Emacs should keep backup copies of files I edit, but I do not want them
707 to clutter up the filesystem everywhere. So I put them into one defined
708 place, backup-directory, which even contains my username (for systems
709 where =temporary-file-directory= is not inside my home).
710 #+BEGIN_SRC emacs-lisp tangle:yes
711 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
712 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
714 (setq version-control t) ;; Use version numbers for backups
715 (setq kept-new-versions 10) ;; Number of newest versions to keep
716 (setq kept-old-versions 2) ;; Number of oldest versions to keep
717 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
719 (add-hook 'before-save-hook 'force-backup-of-buffer)
721 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
722 (setq backup-by-copying t)
723 (setq make-backup-files t)
725 (setq backup-enable-predicate
727 (and (normal-backup-enable-predicate name)
729 (let ((method (file-remote-p name 'method)))
730 (when (stringp method)
731 (member method '("su" "sudo"))))))))
735 Weeks start on Monday, not sunday.
736 #+BEGIN_SRC emacs-lisp tangle:yes
737 (setq calendar-week-start-day 1)
740 Searches and matches should ignore case.
741 #+BEGIN_SRC emacs-lisp tangle:yes
742 (setq-default case-fold-search t)
745 Which buffers to get rid off at midnight.
746 #+BEGIN_SRC emacs-lisp tangle:yes
747 (setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
748 "*Man " "*Buffer List*"
754 "*magit" "*Calendar")))
757 Don't display a cursor in non-selected windows.
758 #+BEGIN_SRC emacs-lisp tangle:yes
759 (setq-default cursor-in-non-selected-windows nil)
762 What should be displayed in the mode-line for files with those types
764 #+BEGIN_SRC emacs-lisp tangle:yes
765 (setq eol-mnemonic-dos "(DOS)")
766 (setq eol-mnemonic-mac "(Mac)")
769 Much larger threshold for garbage collection prevents it to run too often.
770 #+BEGIN_SRC emacs-lisp tangle:yes
771 (setq gc-cons-threshold 48000000)
774 #+BEGIN_SRC emacs-lisp tangle:yes
775 (setq max-lisp-eval-depth 1000)
776 (setq max-specpdl-size 3000)
780 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
781 #+BEGIN_SRC emacs-lisp tangle:yes
782 (defun unfill-paragraph ()
783 "Takes a multi-line paragraph and makes it into a single line of text."
785 (let ((fill-column (point-max)))
786 (fill-paragraph nil)))
789 #+BEGIN_SRC emacs-lisp tangle:yes
790 (setq-default indicate-empty-lines t)
793 #+BEGIN_SRC emacs-lisp tangle:yes
794 (setq browse-url-browser-function (quote browse-url-generic))
795 (setq browse-url-generic-program "/usr/bin/x-www-browser")
798 *** When saving a script - make it executable
799 #+BEGIN_SRC emacs-lisp tangle:yes
800 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
804 #+BEGIN_SRC emacs-lisp tangle:yes
806 (unless (server-running-p)
810 ** Customized variables
811 [2013-05-02 Thu 22:14]
812 The following contains a set of variables i may reasonably want to
813 change on other systems - which don't affect the init file loading
814 process. So I *can* use the customization interface for it...
815 #+BEGIN_SRC emacs-lisp tangle:yes
816 (defgroup ganneff nil
817 "Modify ganneffs settings"
820 (defgroup ganneff-org-mode nil
821 "Ganneffs org-mode settings"
822 :tag "Ganneffs org-mode settings"
824 :link '(custom-group-link "ganneff"))
826 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
827 "ID of the organization task."
828 :tag "Organization Task ID"
830 :group 'ganneff-org-mode)
832 (defcustom org-my-archive-expiry-days 2
833 "The number of days after which a completed task should be auto-archived.
834 This can be 0 for immediate, or a floating point value."
835 :tag "Archive expiry days"
837 :group 'ganneff-org-mode)
842 [2013-05-21 Tue 23:22]
843 Restore removed var alias, used by ruby-electric-brace and others
844 #+BEGIN_SRC emacs-lisp tangle:yes
845 (unless (boundp 'last-command-char)
846 (defvaralias 'last-command-char 'last-command-event))
849 * Customized variables
851 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
853 Of course I want to be able to use the customize interface, and some
854 things can only be set via it (or so they say). I usually prefer to put
855 things I keep for a long while into statements somewhere else, not just
856 custom-set here, but we need it anyways.
858 #+BEGIN_SRC emacs-lisp tangle:yes
859 (setq custom-file jj-custom-file)
860 (safe-load custom-file)
863 The source of this is:
864 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
867 * Extra modes and their configuration
869 For some file endings we need to tell emacs what mode we want for them.
870 I only list modes here where I don't have any other special
873 - Some extras for ruby, used with ruby on rails for example
874 #+BEGIN_SRC emacs-lisp tangle:yes
875 (add-to-list 'auto-mode-alist '("\\.rxml$" . ruby-mode))
876 (add-to-list 'auto-mode-alist '("\\.rjs$" . ruby-mode))
877 (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
878 (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
879 (add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
883 #+BEGIN_SRC emacs-lisp tangle:yes
884 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
888 #+BEGIN_SRC emacs-lisp tangle:yes
889 (add-to-list 'auto-mode-alist '("COMMIT_EDITMSG$" . diff-mode))
893 #+BEGIN_SRC emacs-lisp tangle:yes
894 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
895 (add-to-list 'auto-mode-alist '("\\.pod$" . pod-mode))
896 (add-to-list 'auto-mode-alist '("\\.tt$" . tt-mode))
897 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
898 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
899 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
903 #+BEGIN_SRC emacs-lisp tangle:yes
904 (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
905 (add-to-list 'auto-mode-alist '("\\.py$" . python-mode))
906 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
909 ** Region bindings mode
910 [2013-05-01 Wed 22:51]
911 This mode allows to have keybindings that are only alive when the
912 region is active. Helpful for things that only do any useful action
913 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
914 #+BEGIN_SRC emacs-lisp tangle:yes
915 (require 'region-bindings-mode)
916 (region-bindings-mode-enable)
919 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
920 #+BEGIN_SRC emacs-lisp tangle:yes
922 (setq tramp-default-method "ssh")
923 (setq tramp-persistency-file-name (expand-file-name "tramp" jj-cache-dir))
924 (setq shell-prompt-pattern "^[^a-zA-Z].*[#$%>] *")
925 (add-to-list 'tramp-default-method-alist
926 '("\\`localhost\\'" "\\`root\\'" "su")
928 (setq tramp-debug-buffer nil)
929 (setq tramp-default-method "sshx")
930 (setq tramp-verbose 5)
934 We configure only a bit of the tiny-tools to load when I should need
935 them. I don't need much actually, but these things are nice to have.
937 #+BEGIN_SRC emacs-lisp tangle:yes
938 (autoload 'turn-on-tinyperl-mode "tinyperl" "" t)
939 (add-hook 'perl-mode-hook 'turn-on-tinyperl-mode)
940 (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode)
942 (autoload 'tinycomment-indent-for-comment "tinycomment" "" t)
943 (autoload 'tinyeat-forward-preserve "tinyeat" "" t)
944 (autoload 'tinyeat-backward-preserve "tinyeat" "" t)
945 (autoload 'tinyeat-delete-paragraph "tinyeat" "" t)
946 (autoload 'tinyeat-kill-line "tinyeat" "" t)
947 (autoload 'tinyeat-zap-line "tinyeat" "" t)
948 (autoload 'tinyeat-kill-line-backward "tinyeat" "" t)
949 (autoload 'tinyeat-kill-buffer-lines-point-max "tinyeat" "" t)
950 (autoload 'tinyeat-kill-buffer-lines-point-min "tinyeat" "" t)
952 *** Keyboard changes for tiny-tools
953 #+BEGIN_SRC emacs-lisp tangle:yes
954 (global-set-key "\M-;" 'tinycomment-indent-for-comment)
956 (global-set-key (kbd "ESC C-k") 'tinyeat-kill-line-backward)
957 (global-set-key (kbd "ESC d") 'tinyeat-forward-preserve)
958 (global-set-key (kbd "ESC z") 'tinyeat-kill-buffer-lines-main)
959 (global-set-key (kbd "<M-backspace>") 'tinyeat-backward-preserve)
960 (global-set-key (kbd "<C-delete>") 'tinyeat-forward-preserve)
961 (global-set-key (kbd "<S-backspace>") 'tinyeat-delete-whole-word)
965 I like dired and work a lot with it, but it tends to leave lots of
967 dired-single to the rescue.
968 #+BEGIN_SRC emacs-lisp tangle:yes
969 (autoload 'dired-single-buffer "dired-single" "" t)
970 (autoload 'dired-single-buffer-mouse "dired-single" "" t)
971 (autoload 'dired-single-magic-buffer "dired-single" "" t)
972 (autoload 'dired-single-toggle-buffer-name "dired-single" "" t)
975 We want some extra key bindings loaded. In case we haven't loaded dired
976 yet, there won't be a keymap to add to, so add our setup function to the
977 load hook only. Otherwise just bind the keys.
978 #+BEGIN_SRC emacs-lisp tangle:yes
979 (if (boundp 'dired-mode-map)
980 ;; we're good to go; just add our bindings
982 ;; it's not loaded yet, so add our bindings to the load-hook
983 (add-hook 'dired-load-hook 'my-dired-init))
987 #+BEGIN_SRC emacs-lisp tangle:yes
988 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
989 (setq dired-dwim-target t)
990 (setq dired-listing-switches "-alh")
991 (setq dired-recursive-copies (quote top))
992 (setq dired-recursive-deletes (quote top))
996 #+BEGIN_SRC emacs-lisp tangle:yes
997 (setq wdired-allow-to-change-permissions t)
1000 [2013-05-02 Thu 00:04]
1001 #+BEGIN_SRC emacs-lisp tangle:yes
1002 (require 'filladapt)
1003 (eval-after-load "filladapt" '(diminish 'filladapt-mode))
1004 (setq-default filladapt-mode t)
1007 [2013-05-03 Fri 16:09]
1008 Replace default find-file with find-file-at-point, which tries to
1009 guess the default file/URL from text around the point.
1010 #+BEGIN_SRC emacs-lisp tangle:yes
1014 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
1015 ‘TAB’ completion is to typing things manually every time.”]]
1016 #+BEGIN_SRC emacs-lisp tangle:yes
1021 Always have unique buffernames. See [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html][Uniquify - GNU Emacs Manual]]
1022 #+BEGIN_SRC emacs-lisp tangle:yes
1024 (setq uniquify-buffer-name-style 'post-forward)
1025 (setq uniquify-after-kill-buffer-p t)
1026 (setq uniquify-ignore-buffers-re "^\\*")
1030 A defined abbrev is a word which expands, if you insert it, into some
1031 different text. Abbrevs are defined by the user to expand in specific
1033 #+BEGIN_SRC emacs-lisp tangle:yes
1034 (setq save-abbrevs 'silently)
1035 (setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
1036 (if (file-exists-p abbrev-file-name)
1037 (quietly-read-abbrev-file))
1042 Obviously emacs can do syntax hilighting. For more things than you ever
1044 And I want to have it everywhere.
1045 #+BEGIN_SRC emacs-lisp tangle:yes
1046 (require 'font-lock)
1047 (global-font-lock-mode 1)
1048 (setq font-lock-maximum-decoration t)
1051 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
1052 #+BEGIN_SRC emacs-lisp tangle:yes
1058 By default, Emacs can update the time stamp for the following two
1059 formats if one exists in the first 8 lines of the file.
1062 #+BEGIN_SRC emacs-lisp tangle:yes
1063 (require 'time-stamp)
1064 (setq time-stamp-active t)
1065 (setq time-stamp-format "%02H:%02M:%02S (%z) - %02d.%02m.%:y from %u (%U) on %s")
1066 (setq time-stamp-old-format-warn nil)
1067 (setq time-stamp-time-zone nil)
1068 (add-hook 'write-file-hooks 'time-stamp)
1072 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
1074 #+BEGIN_SRC emacs-lisp tangle:yes
1075 (autoload 'cperl-mode "cperl-mode" )
1076 (defalias 'perl-mode 'cperl-mode)
1077 (setq cperl-hairy t)
1078 (setq cperl-electric-keywords t)
1079 (setq cperl-electric-lbrace-space t)
1080 (setq cperl-electric-parens nil)
1081 (setq cperl-highlight-variables-indiscriminately t)
1082 (setq cperl-imenu-addback t)
1083 (setq cperl-invalid-face (quote underline))
1084 (setq cperl-lazy-help-time 5)
1085 (setq cperl-mode-hook (quote (turn-on-tinyperl-mode)))
1086 (setq cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$")
1087 (setq cperl-syntaxify-by-font-lock t)
1088 (setq cperl-use-syntax-table-text-property-for-tags t)
1091 And have cperl mode give ElDoc a useful string
1092 #+BEGIN_SRC emacs-lisp tangle:yes
1093 (defun my-cperl-eldoc-documentation-function ()
1094 "Return meaningful doc string for `eldoc-mode'."
1096 (let ((cperl-message-on-help-error nil))
1098 (add-hook 'cperl-mode-hook
1100 (set (make-local-variable 'eldoc-documentation-function)
1101 'my-cperl-eldoc-documentation-function)
1106 #+BEGIN_SRC emacs-lisp tangle:yes
1107 (autoload 'python-mode "python-mode" "Python Mode." t)
1108 (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
1109 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
1110 (setq interpreter-mode-alist
1111 (cons '("python" . python-mode)
1112 interpreter-mode-alist)
1115 (set-variable 'py-indent-offset 4)
1116 (set-variable 'py-smart-indentation nil)
1117 (set-variable 'indent-tabs-mode nil)
1118 (define-key python-mode-map "\C-m" 'newline-and-indent)
1119 (turn-on-eldoc-mode)
1121 (defun python-auto-fill-comments-only ()
1123 (set (make-local-variable 'fill-nobreak-predicate)
1125 (not (python-in-string/comment)))))
1126 (add-hook 'python-mode-hook
1128 (python-auto-fill-comments-only)))
1130 (autoload 'pymacs-apply "pymacs")
1131 (autoload 'pymacs-call "pymacs")
1132 (autoload 'pymacs-eval "pymacs" nil t)
1133 (autoload 'pymacs-exec "pymacs" nil t)
1134 (autoload 'pymacs-load "pymacs" nil t)
1138 If an =ipython= executable is on the path, then assume that IPython is
1139 the preferred method python evaluation.
1140 #+BEGIN_SRC emacs-lisp tangle:yes
1141 (when (executable-find "ipython")
1143 (setq org-babel-python-mode 'python-mode))
1145 (setq python-shell-interpreter "ipython")
1146 (setq python-shell-interpreter-args "")
1147 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
1148 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
1149 (setq python-shell-completion-setup-code
1150 "from IPython.core.completerlib import module_completion")
1151 (setq python-shell-completion-module-string-code
1152 "';'.join(module_completion('''%s'''))\n")
1153 (setq python-shell-completion-string-code
1154 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
1158 I prefer comments to be indented too
1159 #+BEGIN_SRC emacs-lisp tangle:yes
1160 (setq sh-indent-comment t)
1164 When files change outside emacs for whatever reason I want emacs to deal
1165 with it. Not to have to revert buffers myself
1166 #+BEGIN_SRC emacs-lisp tangle:yes
1167 (require 'autorevert)
1168 (setq global-auto-revert-mode t)
1169 (global-auto-revert-mode)
1172 ** linum (line number)
1173 Various modes should have line numbers in front of each line.
1175 But then there are some where it would just be deadly - like org-mode,
1176 gnus, so we have a list of modes where we don't want to see it.
1177 #+BEGIN_SRC emacs-lisp tangle:yes
1179 (setq linum-format "%3d ")
1180 (setq linum-mode-inhibit-modes-list '(org-mode
1187 (defadvice linum-on (around linum-on-inhibit-for-modes)
1188 "Stop the load of linum-mode for some major modes."
1189 (unless (member major-mode linum-mode-inhibit-modes-list)
1192 (ad-activate 'linum-on)
1193 (global-linum-mode 1)
1197 #+BEGIN_SRC emacs-lisp tangle:yes
1198 (autoload 'css-mode "css-mode")
1199 (add-auto-mode 'css-mode "\\.css")
1201 (require 'flymake-css)
1202 (defun maybe-flymake-css-load ()
1203 "Activate flymake-css as necessary, but not in derived modes."
1204 (when (eq major-mode 'css-mode)
1205 (flymake-css-load)))
1206 (add-hook 'css-mode-hook 'maybe-flymake-css-load)
1207 ;;; Auto-complete CSS keywords
1208 (eval-after-load 'auto-complete
1210 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
1211 (add-hook hook 'ac-css-mode-setup))))
1215 [2013-05-21 Tue 23:39]
1216 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
1217 coexist in one buffer.
1218 #+BEGIN_SRC emacs-lisp tangle:yes
1220 (setq mmm-global-mode 'buffers-with-submode-classes)
1221 (setq mmm-submode-decoration-level 2)
1222 (eval-after-load 'mmm-vars
1228 :face mmm-code-submode-face
1229 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
1230 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
1231 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
1232 @ "\n" _ "\n" @ "</script>" @)))
1235 :face mmm-code-submode-face
1236 :front "<style[^>]*>[ \t]*\n?"
1237 :back "[ \t]*</style>"
1238 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
1239 @ "\n" _ "\n" @ "</style>" @)))
1242 :face mmm-code-submode-face
1245 (dolist (mode (list 'html-mode 'nxml-mode))
1246 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
1247 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
1253 Instead of default /html-mode/ I use /html-helper-mode/.
1254 #+BEGIN_SRC emacs-lisp tangle:yes
1255 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
1256 (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
1257 (setq auto-mode-alist (cons '("\\.asp$" . html-helper-mode) auto-mode-alist))
1258 (setq auto-mode-alist (cons '("\\.phtml$" . html-helper-mode) auto-mode-alist))
1259 (defalias 'html-mode 'html-helper-mode)
1263 #+BEGIN_SRC emacs-lisp tangle:yes
1264 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
1265 (setq TeX-auto-save t)
1266 (setq TeX-parse-self t)
1267 (setq TeX-PDF-mode t)
1271 #+BEGIN_SRC emacs-lisp tangle:yes
1272 (require 'dpkg-dev-el-loaddefs nil 'noerror)
1273 (require 'debian-el-loaddefs nil 'noerror)
1275 (setq debian-changelog-full-name "Joerg Jaspert")
1276 (setq debian-changelog-mailing-address "joerg@debian.org")
1280 *** General settings
1281 [2013-04-28 So 17:06]
1283 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
1284 it is quite extensive. Nevertheless, it starts out small, loading it.
1285 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1289 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
1290 that we need org-protocol.
1291 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1292 (require 'org-protocol)
1297 My current =org-agenda-files= variable only includes a set of
1299 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1300 (setq org-agenda-files (quote ("~/org/"
1306 (setq org-default-notes-file "~/org/notes.org")
1308 =org-mode= manages the =org-agenda-files= variable automatically using
1309 =C-c [= and =C-c ]= to add and remove files respectively. However,
1310 this replaces my directory list with a list of explicit filenames
1311 instead and is not what I want. If this occurs then adding a new org
1312 file to any of the above directories will not contribute to my agenda
1313 and I will probably miss something important.
1315 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
1316 prevent messing up my list of directories in the =org-agenda-files=
1317 variable. I just add and remove directories manually here. Changing
1318 the list of directories in =org-agenda-files= happens very rarely
1319 since new files in existing directories are automatically picked up.
1321 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1322 ;; Keep tasks with dates on the global todo lists
1323 (setq org-agenda-todo-ignore-with-date nil)
1325 ;; Keep tasks with deadlines on the global todo lists
1326 (setq org-agenda-todo-ignore-deadlines nil)
1328 ;; Keep tasks with scheduled dates on the global todo lists
1329 (setq org-agenda-todo-ignore-scheduled nil)
1331 ;; Keep tasks with timestamps on the global todo lists
1332 (setq org-agenda-todo-ignore-timestamp nil)
1334 ;; Remove completed deadline tasks from the agenda view
1335 (setq org-agenda-skip-deadline-if-done t)
1337 ;; Remove completed scheduled tasks from the agenda view
1338 (setq org-agenda-skip-scheduled-if-done t)
1340 ;; Remove completed items from search results
1341 (setq org-agenda-skip-timestamp-if-done t)
1343 ;; Include agenda archive files when searching for things
1344 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
1346 ;; Show all future entries for repeating tasks
1347 (setq org-agenda-repeating-timestamp-show-all t)
1349 ;; Show all agenda dates - even if they are empty
1350 (setq org-agenda-show-all-dates t)
1352 ;; Sorting order for tasks on the agenda
1353 (setq org-agenda-sorting-strategy
1354 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
1355 (todo category-up priority-down effort-up)
1356 (tags category-up priority-down effort-up)
1357 (search category-up))))
1359 ;; Start the weekly agenda on Monday
1360 (setq org-agenda-start-on-weekday 1)
1362 ;; Enable display of the time grid so we can see the marker for the current time
1363 (setq org-agenda-time-grid (quote ((daily today remove-match)
1364 #("----------------" 0 16 (org-heading t))
1365 (0800 1000 1200 1400 1500 1700 1900 2100))))
1367 ;; Display tags farther right
1368 (setq org-agenda-tags-column -102)
1370 ; position the habit graph on the agenda to the right of the default
1371 (setq org-habit-graph-column 50)
1373 ; turn habits back on
1374 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
1377 ;; Agenda sorting functions
1379 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
1382 (setq org-deadline-warning-days 30)
1384 ;; Always hilight the current agenda line
1385 (add-hook 'org-agenda-mode-hook
1386 '(lambda () (hl-line-mode 1))
1390 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1391 (setq org-agenda-persistent-filter t)
1392 (add-hook 'org-agenda-mode-hook
1393 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
1396 (add-hook 'org-agenda-mode-hook
1397 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
1400 (add-hook 'org-agenda-mode-hook
1401 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
1404 (add-hook 'org-agenda-mode-hook
1405 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
1408 (add-hook 'org-agenda-mode-hook
1409 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
1412 ; Rebuild the reminders everytime the agenda is displayed
1413 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
1415 ;(if (file-exists-p "~/org/refile.org")
1416 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
1418 ; Activate appointments so we get notifications
1421 (setq org-agenda-log-mode-items (quote (closed clock state)))
1422 (if (> emacs-major-version 23)
1423 (setq org-agenda-span 3)
1424 (setq org-agenda-ndays 3))
1426 (setq org-agenda-show-all-dates t)
1427 (setq org-agenda-start-on-weekday nil)
1428 (setq org-deadline-warning-days 14)
1431 *** Global keybindings.
1432 Start off by defining a series of keybindings.
1434 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
1435 setup manually, not by org-mode. Also turn off =C-c ;=, which
1436 comments headlines - a function never used.
1437 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1438 (add-hook 'org-mode-hook
1440 (org-defkey org-mode-map "\C-c[" 'undefined)
1441 (org-defkey org-mode-map "\C-c]" 'undefined)
1442 (org-defkey org-mode-map "\C-c;" 'undefined))
1446 And now a largish set of keybindings...
1447 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1448 (global-set-key "\C-cl" 'org-store-link)
1449 (global-set-key "\C-ca" 'org-agenda)
1450 (global-set-key "\C-cb" 'org-iswitchb)
1451 (define-key mode-specific-map [?a] 'org-agenda)
1453 (global-set-key (kbd "<f12>") 'org-agenda)
1454 (global-set-key (kbd "<f5>") 'bh/org-todo)
1455 (global-set-key (kbd "<S-f5>") 'bh/widen)
1456 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
1457 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
1459 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
1460 (global-set-key (kbd "<f9> b") 'bbdb)
1461 (global-set-key (kbd "<f9> c") 'calendar)
1462 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
1463 (global-set-key (kbd "<f9> h") 'bh/hide-other)
1464 (global-set-key (kbd "<f9> n") 'org-narrow-to-subtree)
1465 (global-set-key (kbd "<f9> w") 'widen)
1466 (global-set-key (kbd "<f9> u") 'bh/narrow-up-one-level)
1467 (global-set-key (kbd "<f9> I") 'bh/punch-in)
1468 (global-set-key (kbd "<f9> O") 'bh/punch-out)
1469 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
1470 (global-set-key (kbd "<f9> p") 'bh/phone-call)
1471 (global-set-key (kbd "<f9> r") 'boxquote-region)
1472 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
1473 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
1474 (global-set-key (kbd "<f9> T") 'tabify)
1475 (global-set-key (kbd "<f9> U") 'untabify)
1476 (global-set-key (kbd "<f9> v") 'visible-mode)
1477 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
1478 (global-set-key (kbd "C-<f9>") 'previous-buffer)
1479 (global-set-key (kbd "C-<f10>") 'next-buffer)
1480 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
1481 (global-set-key (kbd "C-x n r") 'narrow-to-region)
1482 (global-set-key (kbd "<f11>") 'org-clock-goto)
1483 (global-set-key (kbd "C-<f11>") 'org-clock-in)
1484 (global-set-key (kbd "C-M-r") 'org-capture)
1485 (global-set-key (kbd "C-c r") 'org-capture)
1486 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
1488 (define-key org-mode-map [(control k)] 'jj-org-kill-line)
1491 *** Tasks, States, Todo fun
1493 First we define the global todo keywords.
1494 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1495 (setq org-todo-keywords
1496 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
1497 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
1499 (setq org-todo-keyword-faces
1500 (quote (("TODO" :foreground "red" :weight bold)
1501 ("NEXT" :foreground "light blue" :weight bold)
1502 ("DONE" :foreground "forest green" :weight bold)
1503 ("WAITING" :foreground "orange" :weight bold)
1504 ("HOLD" :foreground "orange" :weight bold)
1505 ("DELEGATED" :foreground "yellow" :weight bold)
1506 ("CANCELLED" :foreground "dark green" :weight bold)
1507 ("PHONE" :foreground "dark green" :weight bold))))
1510 **** Fast Todo Selection
1511 Fast todo selection allows changing from any task todo state to any
1512 other state directly by selecting the appropriate key from the fast
1513 todo selection key menu.
1514 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1515 (setq org-use-fast-todo-selection t)
1517 Changing a task state is done with =C-c C-t KEY=
1519 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
1522 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1523 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1525 allows changing todo states with S-left and S-right skipping all of
1526 the normal processing when entering or leaving a todo state. This
1527 cycles through the todo states but skips setting timestamps and
1528 entering notes which is very convenient when all you want to do is fix
1529 up the status of an entry.
1531 **** Todo State Triggers
1532 I have a few triggers that automatically assign tags to tasks based on
1533 state changes. If a task moves to =CANCELLED= state then it gets a
1534 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
1535 =CANCELLED= tag. These are used for filtering tasks in agenda views
1536 which I'll talk about later.
1538 The triggers break down to the following rules:
1540 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
1541 - Moving a task to =WAITING= adds a =WAITING= tag
1542 - Moving a task to =HOLD= adds a =WAITING= tag
1543 - Moving a task to a done state removes a =WAITING= tag
1544 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
1545 - Moving a task to =NEXT= removes a =WAITING= tag
1546 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
1548 The tags are used to filter tasks in the agenda views conveniently.
1549 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1550 (setq org-todo-state-tags-triggers
1551 (quote (("CANCELLED" ("CANCELLED" . t))
1552 ("WAITING" ("WAITING" . t))
1553 ("HOLD" ("WAITING" . t) ("HOLD" . t))
1554 (done ("WAITING") ("HOLD"))
1555 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1556 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1557 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1560 *** Capturing new tasks
1561 Org capture replaces the old remember mode.
1562 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1563 (setq org-directory "~/org")
1564 (setq org-default-notes-file "~/org/refile.org")
1566 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
1567 ;; see http://orgmode.org/manual/Template-elements.html
1568 (setq org-capture-templates
1569 (quote (("t" "todo" entry (file "~/org/refile.org")
1570 "* TODO %?\nAdded: %U\n"
1571 :clock-in t :clock-resume t)
1572 ("l" "linktodo" entry (file "~/org/refile.org")
1573 "* TODO %?\nAdded: %U\n%a\n"
1574 :clock-in t :clock-resume t)
1575 ("r" "respond" entry (file "~/org/refile.org")
1576 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
1577 :clock-in t :clock-resume t :immediate-finish t)
1578 ("n" "note" entry (file "~/org/refile.org")
1579 "* %? :NOTE:\nAdded: %U\n%a\n"
1580 :clock-in t :clock-resume t)
1581 ("d" "Delegated" entry (file "~/org/refile.org")
1582 "* DELEGATED %?\nAdded: %U\n%a\n"
1583 :clock-in t :clock-resume t)
1584 ("j" "Journal" entry (file+datetree "~/org/diary.org")
1586 :clock-in t :clock-resume t)
1587 ("w" "org-protocol" entry (file "~/org/refile.org")
1588 "* TODO Review %c\nAdded: %U\n"
1589 :immediate-finish t)
1590 ("p" "Phone call" entry (file "~/org/refile.org")
1591 "* PHONE %? :PHONE:\nAdded: %U"
1592 :clock-in t :clock-resume t)
1593 ("f" "Firewall request" entry (file+headline "~/org/nsb/dlh.org" "Firewall")
1594 "* TODO Firewall Request, RT: %?\nAdded: %U"
1595 :clock-in t :clock-resume t)
1596 ("i" "Ticket" entry (file+headline "~/org/nsb/dlh.org" "RT Ticket")
1597 "* TODO RT: %a\nAdded: %U\n\n%?"
1598 :clock-in t :clock-resume t :jump-to-captured t)
1599 ("x" "Bookmark link" entry (file "~/org/refile.org")
1600 "* Bookmark: %c\n%i\nAdded: %U\n"
1601 :immediate-finish t)
1602 ("h" "Habit" entry (file "~/org/refile.org")
1603 "* NEXT %?\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\nAdded: %U\nSCHEDULED: %(format-time-string \"<%Y-%m-%d %a .+1d/3d>\")\n")
1607 Capture mode now handles automatically clocking in and out of a
1608 capture task. This all works out of the box now without special hooks.
1609 When I start a capture mode task the task is clocked in as specified
1610 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
1611 resumes on the original clocking task.
1613 The quick clocking in and out of capture mode tasks (often it takes
1614 less than a minute to capture some new task details) can leave
1615 empty clock drawers in my tasks which aren't really useful.
1616 The following prevents this.
1617 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1618 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1622 All my newly captured entries end up in =refile.org= and want to be
1623 moved over to the right place. The following is the setup for it.
1624 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1625 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1626 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1627 (org-agenda-files :maxlevel . 9))))
1629 ; Use full outline paths for refile targets - we file directly with IDO
1630 (setq org-refile-use-outline-path t)
1632 ; Targets complete directly with IDO
1633 (setq org-outline-path-complete-in-steps nil)
1635 ; Allow refile to create parent tasks with confirmation
1636 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1638 ; Use IDO for both buffer and file completion and ido-everywhere to t
1639 (setq org-completion-use-ido t)
1640 (setq org-completion-use-iswitchb nil)
1641 :; Use IDO for both buffer and file completion and ido-everywhere to t
1642 ;(setq ido-everywhere t)
1643 ;(setq ido-max-directory-size 100000)
1644 ;(ido-mode (quote both))
1645 ; Use the current window when visiting files and buffers with ido
1646 (setq ido-default-file-method 'selected-window)
1647 (setq ido-default-buffer-method 'selected-window)
1649 ;;;; Refile settings
1650 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1654 Agenda view is the central place for org-mode interaction...
1655 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1656 ;; Do not dim blocked tasks
1657 (setq org-agenda-dim-blocked-tasks nil)
1658 ;; Compact the block agenda view
1659 (setq org-agenda-compact-blocks t)
1661 ;; Custom agenda command definitions
1662 (setq org-agenda-custom-commands
1663 (quote (("N" "Notes" tags "NOTE"
1664 ((org-agenda-overriding-header "Notes")
1665 (org-tags-match-list-sublevels t)))
1666 ("h" "Habits" tags-todo "STYLE=\"habit\""
1667 ((org-agenda-overriding-header "Habits")
1668 (org-agenda-sorting-strategy
1669 '(todo-state-down effort-up category-keep))))
1673 ((org-agenda-overriding-header "Tasks to Refile")
1674 (org-tags-match-list-sublevels nil)))
1675 (tags-todo "-HOLD-CANCELLED/!"
1676 ((org-agenda-overriding-header "Projects")
1677 (org-agenda-skip-function 'bh/skip-non-projects)
1678 (org-agenda-sorting-strategy
1680 (tags-todo "-CANCELLED/!"
1681 ((org-agenda-overriding-header "Stuck Projects")
1682 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
1683 (tags-todo "-WAITING-CANCELLED/!NEXT"
1684 ((org-agenda-overriding-header "Next Tasks")
1685 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1686 (org-agenda-todo-ignore-scheduled t)
1687 (org-agenda-todo-ignore-deadlines t)
1688 (org-agenda-todo-ignore-with-date t)
1689 (org-tags-match-list-sublevels t)
1690 (org-agenda-sorting-strategy
1691 '(todo-state-down effort-up category-keep))))
1692 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
1693 ((org-agenda-overriding-header "Tasks")
1694 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
1695 (org-agenda-todo-ignore-scheduled t)
1696 (org-agenda-todo-ignore-deadlines t)
1697 (org-agenda-todo-ignore-with-date t)
1698 (org-agenda-sorting-strategy
1700 (tags-todo "-CANCELLED+WAITING/!"
1701 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1702 (org-agenda-skip-function 'bh/skip-stuck-projects)
1703 (org-tags-match-list-sublevels nil)
1704 (org-agenda-todo-ignore-scheduled 'future)
1705 (org-agenda-todo-ignore-deadlines 'future)))
1707 ((org-agenda-overriding-header "Tasks to Archive")
1708 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1709 (org-tags-match-list-sublevels nil))))
1711 ("r" "Tasks to Refile" tags "REFILE"
1712 ((org-agenda-overriding-header "Tasks to Refile")
1713 (org-tags-match-list-sublevels nil)))
1714 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
1715 ((org-agenda-overriding-header "Stuck Projects")
1716 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
1717 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
1718 ((org-agenda-overriding-header "Next Tasks")
1719 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1720 (org-agenda-todo-ignore-scheduled t)
1721 (org-agenda-todo-ignore-deadlines t)
1722 (org-agenda-todo-ignore-with-date t)
1723 (org-tags-match-list-sublevels t)
1724 (org-agenda-sorting-strategy
1725 '(todo-state-down effort-up category-keep))))
1726 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
1727 ((org-agenda-overriding-header "Tasks")
1728 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
1729 (org-agenda-sorting-strategy
1731 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
1732 ((org-agenda-overriding-header "Projects")
1733 (org-agenda-skip-function 'bh/skip-non-projects)
1734 (org-agenda-sorting-strategy
1736 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
1737 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
1738 (org-tags-match-list-sublevels nil))
1739 ("A" "Tasks to Archive" tags "-REFILE/"
1740 ((org-agenda-overriding-header "Tasks to Archive")
1741 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1742 (org-tags-match-list-sublevels nil))))))
1744 ; Overwrite the current window with the agenda
1745 (setq org-agenda-window-setup 'current-window)
1750 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1752 ;; Resume clocking task when emacs is restarted
1753 (org-clock-persistence-insinuate)
1755 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
1756 (setq org-clock-history-length 36)
1757 ;; Resume clocking task on clock-in if the clock is open
1758 (setq org-clock-in-resume t)
1759 ;; Change tasks to NEXT when clocking in
1760 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1761 ;; Separate drawers for clocking and logs
1762 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1763 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1764 (setq org-clock-into-drawer t)
1765 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1766 (setq org-clock-out-remove-zero-time-clocks t)
1767 ;; Clock out when moving task to a done state
1768 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
1769 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1770 (setq org-clock-persist t)
1771 ;; Do not prompt to resume an active clock
1772 (setq org-clock-persist-query-resume nil)
1773 ;; Enable auto clock resolution for finding open clocks
1774 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1775 ;; Include current clocking task in clock reports
1776 (setq org-clock-report-include-clocking-task t)
1778 ; use discrete minute intervals (no rounding) increments
1779 (setq org-time-stamp-rounding-minutes (quote (1 1)))
1781 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1783 (setq bh/keep-clock-running nil)
1785 (setq org-agenda-clock-consistency-checks
1786 (quote (:max-duration "4:00"
1789 :gap-ok-around ("4:00"))))
1793 **** Setting a default clock task
1794 Per default the =** Organization= task in my tasks.org file receives
1795 misc clock time. This is the task I clock in on when I punch in at the
1796 start of my work day with =F9-I=. Punching-in anywhere clocks in this
1797 Organization task as the default task.
1799 If I want to change the default clocking task I just visit the
1800 new task in any org buffer and clock it in with =C-u C-u C-c C-x
1801 C-i=. Now this new task that collects miscellaneous clock
1802 minutes when the clock would normally stop.
1804 You can quickly clock in the default clocking task with =C-u C-c
1805 C-x C-i d=. Another option is to repeatedly clock out so the
1806 clock moves up the project tree until you clock out the
1807 top-level task and the clock moves to the default task.
1810 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1811 ;; Agenda clock report parameters
1812 (setq org-agenda-clockreport-parameter-plist
1813 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
1815 ;; Agenda log mode items to display (closed and state changes by default)
1816 (setq org-agenda-log-mode-items (quote (closed state)))
1818 **** Task estimates, column view
1819 Setup column view globally with the following headlines
1820 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1821 ; Set default column view headings: Task Effort Clock_Summary
1822 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
1824 Setup the estimate for effort values.
1825 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1826 ; global Effort estimate values
1827 ; global STYLE property values for completion
1828 (setq org-global-properties (quote (("Effort_ALL" . "0:15 0:30 0:45 1:00 2:00 3:00 4:00 5:00 6:00 0:00")
1829 ("STYLE_ALL" . "habit"))))
1833 Tags are mostly used for filtering inside the agenda.
1834 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1835 ; Tags with fast selection keys
1836 (setq org-tag-alist (quote ((:startgroup)
1854 ; Allow setting single tags without the menu
1855 (setq org-fast-tag-selection-single-key (quote expert))
1857 ; For tag searches ignore tasks with scheduled and deadline dates
1858 (setq org-agenda-tags-todo-honor-ignore-options t)
1862 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1863 (setq org-archive-mark-done nil)
1864 (setq org-archive-location "%s_archive::* Archived Tasks")
1868 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1869 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
1870 (setq org-plantuml-jar-path "~/java/plantuml.jar")
1872 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
1874 ; Make babel results blocks lowercase
1875 (setq org-babel-results-keyword "results")
1877 (org-babel-do-load-languages
1878 (quote org-babel-load-languages)
1879 (quote ((emacs-lisp . t)
1898 ; Do not prompt to confirm evaluation
1899 ; This may be dangerous - make sure you understand the consequences
1900 ; of setting this -- see the docstring for details
1901 (setq org-confirm-babel-evaluate nil)
1903 ; Use fundamental mode when editing plantuml blocks with C-c '
1904 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
1907 #+BEGIN_SRC emacs-lisp tangle:yes
1908 ;; Don't have images visible on startup, breaks on console
1909 (setq org-startup-with-inline-images nil)
1912 **** ditaa, graphviz, etc
1913 Those are all nice tools. Look at
1914 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
1917 *** Publishing and exporting
1920 Org-mode can export to a variety of publishing formats including (but not limited to)
1923 (plain text - but not the original org-mode file)
1927 which enables getting to lots of other formats like ODF, XML, etc
1929 via LaTeX or Docbook
1932 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
1934 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1935 ;; Explicitly load required exporters
1939 ;; FIXME, check the following two
1940 ;(require 'ox-icalendar)
1943 ; experimenting with docbook exports - not finished
1944 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
1945 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
1947 ;; define categories that should be excluded
1948 (setq org-export-exclude-category (list "google" "google"))
1949 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1951 ; define how the date strings look
1952 (setq org-export-date-timestamp-format "%Y-%m-%d")
1953 ; Inline images in HTML instead of producting links to the image
1954 (setq org-html-inline-images t)
1955 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
1956 (setq org-export-with-sub-superscripts nil)
1958 (setq org-html-head-extra (concat
1959 "<link rel=\"stylesheet\" href=\"http://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
1961 (setq org-html-head-include-default-style nil)
1962 ; Do not generate internal css formatting for HTML exports
1963 (setq org-export-htmlize-output-type (quote css))
1964 ; Export with LaTeX fragments
1965 (setq org-export-with-LaTeX-fragments t)
1966 ; Increase default number of headings to export
1967 (setq org-export-headline-levels 6)
1970 (setq org-publish-project-alist
1973 :base-directory "~/.emacs.d/"
1974 :base-extension "org"
1976 :publishing-directory "/develop/www/emacs"
1978 :publishing-function org-html-publish-to-html
1979 :headline-levels 4 ; Just the default for this project.
1985 :base-directory "~/.emacs.d/"
1986 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
1987 :publishing-directory "/develop/www/emacs"
1988 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
1990 :publishing-function org-publish-attachment
1992 ("inherit-org-info-js"
1993 :base-directory "/develop/vcs/org-info-js/"
1995 :base-extension "js"
1996 :publishing-directory "/develop/www/"
1997 :publishing-function org-publish-attachment
1999 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
2004 (setq org-export-with-timestamps nil)
2009 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2010 (setq org-latex-to-pdf-process
2011 '("xelatex -interaction nonstopmode %f"
2012 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
2013 (setq org-export-latex-listings 'minted)
2014 (setq org-latex-listings t)
2016 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
2017 ;; but adapted to use latexmk 4.20 or higher.
2018 (defun my-auto-tex-cmd ()
2019 "When exporting from .org with latex, automatically run latex,
2020 pdflatex, or xelatex as appropriate, using latexmk."
2022 ;; default command: oldstyle latex via dvi
2023 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
2025 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
2026 (setq texcmd "latexmk -pdf -quiet %f"))
2028 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
2029 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
2030 ;; LaTeX compilation command
2031 (setq org-latex-to-pdf-process (list texcmd)))
2033 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
2035 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
2036 (setq org-export-latex-packages-alist
2038 ("" "longtable" nil)
2043 (defun my-auto-tex-parameters ()
2044 "Automatically select the tex packages to include."
2045 ;; default packages for ordinary latex or pdflatex export
2046 (setq org-export-latex-default-packages-alist
2047 '(("AUTO" "inputenc" t)
2057 ("" "hyperref" nil)))
2059 ;; Packages to include when xelatex is used
2060 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
2061 (setq org-export-latex-default-packages-alist
2066 ("german" "babel" t)
2067 ("babel" "csquotes" t)
2069 ("xetex" "hyperref" nil)
2072 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
2073 (setq org-export-latex-classes
2075 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
2076 ("\\section{%s}" . "\\section*{%s}")
2077 ("\\subsection{%s}" . "\\subsection*{%s}")
2078 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2079 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2080 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
2081 org-export-latex-classes))))
2083 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
2086 *** Prevent editing invisible text
2087 The following setting prevents accidentally editing hidden text when
2088 the point is inside a folded region. This can happen if you are in
2089 the body of a heading and globally fold the org-file with =S-TAB=
2091 I find invisible edits (and undo's) hard to deal with so now I can't
2092 edit invisible text. =C-c C-r= (org-reveal) will display where the
2093 point is if it is buried in invisible text to allow editing again.
2095 #+BEGIN_SRC emacs-lisp tangle:yes :tangle yes
2096 (setq org-catch-invisible-edits 'error)
2100 #+BEGIN_SRC emacs-lisp tangle:yes :tangle yes
2101 ;; disable the default org-mode stuck projects agenda view
2102 (setq org-stuck-projects (quote ("" nil nil "")))
2104 ; force showing the next headline.
2105 (setq org-show-entry-below (quote ((default))))
2107 (setq org-show-following-heading t)
2108 (setq org-show-hierarchy-above t)
2109 (setq org-show-siblings (quote ((default))))
2111 (setq org-special-ctrl-a/e t)
2112 (setq org-special-ctrl-k t)
2113 (setq org-yank-adjusted-subtrees t)
2115 (setq org-table-export-default-format "orgtbl-to-csv")
2119 The following setting adds alphabetical lists like
2123 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2124 (setq org-alphabetical-lists t)
2127 #+BEGIN_SRC emacs-lisp tangle:yes :tangle yes
2128 (setq org-remove-highlights-with-change nil)
2130 (setq org-list-demote-modify-bullet (quote (("+" . "-")
2137 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
2140 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
2141 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
2146 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2147 ;; Enable abbrev-mode
2148 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
2149 (setq org-startup-indented t)
2150 (setq org-startup-folded t)
2151 (setq org-cycle-separator-lines 0)
2154 I find extra blank lines in lists and headings a bit of a nuisance.
2155 To get a body after a list you need to include a blank line between
2156 the list entry and the body -- and indent the body appropriately.
2157 Most of my lists have no body detail so I like the look of collapsed
2158 lists with no blank lines better.
2160 The following setting prevents creating blank lines before headings
2161 but allows list items to adapt to existing blank lines around the items:
2162 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2163 (setq org-blank-before-new-entry (quote ((heading)
2164 (plain-list-item . auto))))
2167 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2168 (setq org-reverse-note-order nil)
2169 (setq org-default-notes-file "~/notes.org")
2172 Enforce task blocking. Tasks can't go done when there is any subtask
2173 still open. Unless they have a property of =NOBLOCKING: t=
2174 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2175 (setq org-enforce-todo-checkbox-dependencies t)
2176 (setq org-enforce-todo-dependencies t)
2179 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2180 (setq org-fast-tag-selection-single-key (quote expert))
2181 (setq org-footnote-auto-adjust t)
2182 (setq org-hide-block-startup t)
2183 (setq org-icalendar-alarm-time 15)
2184 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
2185 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
2186 (setq org-icalendar-honor-noexport-tag t)
2187 (setq org-icalendar-include-bbdb-anniversaries nil)
2188 (setq org-icalendar-include-body 200)
2189 (setq org-icalendar-include-todo nil)
2190 (setq org-icalendar-store-UID t)
2191 (setq org-icalendar-timezone "Europe/Berlin")
2192 (setq org-insert-mode-line-in-empty-file t)
2193 (setq org-log-done (quote note))
2194 (setq org-log-into-drawer t)
2195 (setq org-log-state-notes-insert-after-drawers nil)
2196 (setq org-log-reschedule (quote time))
2197 (setq org-log-states-order-reversed t)
2198 (setq org-mobile-agendas (quote all))
2199 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
2200 (setq org-mobile-inbox-for-pull "~/org/refile.org")
2201 (setq org-remember-store-without-prompt t)
2202 (setq org-return-follows-link t)
2203 (setq org-reverse-note-order t)
2205 ; regularly save our org-mode buffers
2206 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
2208 (setq org-log-done t)
2210 (setq org-enable-priority-commands t)
2211 (setq org-default-priority ?E)
2212 (setq org-lowest-priority ?E)
2217 Speed commands enable single-letter commands in Org-mode files when
2218 the point is at the beginning of a headline, or at the beginning of a
2221 See the `=org-speed-commands-default=' variable for a list of the keys
2222 and commands enabled at the beginning of headlines. All code blocks
2223 are available at the beginning of a code block, the following key
2224 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
2225 display a list of the code blocks commands and their related keys.
2227 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2228 (setq org-use-speed-commands t)
2229 (setq org-speed-commands-user (quote (("0" . ignore)
2242 ("h" . bh/hide-other)
2245 (call-interactively 'org-insert-heading-respect-content))
2246 ("k" . org-kill-note-or-show-branches)
2249 ("q" . bh/show-org-agenda)
2251 ("s" . org-save-all-org-buffers)
2255 ("z" . org-add-note)
2260 ("F" . bh/restrict-to-file-or-follow)
2263 ("J" . org-clock-goto)
2267 ("N" . bh/narrow-to-org-subtree)
2268 ("P" . bh/narrow-to-org-project)
2273 ("U" . bh/narrow-up-one-org-level)
2280 (add-hook 'org-agenda-mode-hook
2282 (define-key org-agenda-mode-map "q" 'bury-buffer))
2285 (defvar bh/current-view-project nil)
2286 (add-hook 'org-agenda-mode-hook
2287 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
2291 The following displays the contents of code blocks in Org-mode files
2292 using the major-mode of the code. It also changes the behavior of
2293 =TAB= to as if it were used in the appropriate major mode. This means
2294 that reading and editing code form inside of your Org-mode files is
2295 much more like reading and editing of code using its major mode.
2297 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2298 (setq org-src-fontify-natively t)
2299 (setq org-src-tab-acts-natively t)
2302 #+BEGIN_SRC emacs-lisp tangle:yes :tangle yes
2303 (setq org-src-preserve-indentation nil)
2304 (setq org-edit-src-content-indentation 0)
2308 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2309 (setq org-attach-directory "~/org/data/")
2311 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2312 (setq org-agenda-sticky t)
2315 **** Checklist handling
2316 [2013-05-11 Sat 22:15]
2318 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2319 (require 'org-checklist)
2323 For some reason I prefer this mode more than the way without. I want to
2324 see the marked region.
2325 #+BEGIN_SRC emacs-lisp tangle:yes
2326 (transient-mark-mode 1)
2329 I know that this lets it look "more like windows", but I don't much care
2330 about its paste/copy/cut keybindings, the really nice part is the great
2331 support for rectangular regions, which I started to use a lot since I
2332 know this mode. The normal keybindings for those are just to useless.
2333 #+BEGIN_SRC emacs-lisp tangle:yes
2335 (setq cua-enable-cua-keys (quote shift))
2338 Luckily cua-mode easily supports this, with the following line I just
2339 get the CUA selection and rectangle stuff, not the keybindings. Yes,
2340 even though the above =cua-enable-cua-keys= setting would only enable
2341 them if the selection is done when the region was marked with a shifted
2343 #+BEGIN_SRC emacs-lisp tangle:yes
2344 (cua-selection-mode t)
2348 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2351 #+BEGIN_SRC emacs-lisp tangle:yes
2352 (autoload 'mo-git-blame-file "mo-git-blame" nil t)
2353 (autoload 'mo-git-blame-current "mo-git-blame" nil t)
2357 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2359 I want to access it from anywhere using =F6=.
2360 #+BEGIN_SRC emacs-lisp tangle:yes
2361 (autoload 'mingus "mingus-stays-home" nil t)
2362 (global-set-key (kbd "<f6>") 'mingus)
2363 (setq mingus-dired-add-keys t)
2364 (setq mingus-mode-always-modeline nil)
2365 (setq mingus-mode-line-show-elapsed-percentage nil)
2366 (setq mingus-mode-line-show-volume nil)
2367 (setq mingus-mpd-config-file "/etc/mpd.conf")
2368 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2369 (setq mingus-mpd-root "/share/music/")
2373 [2013-05-22 Wed 22:40]
2374 Save and restore the desktop
2375 #+BEGIN_SRC emacs-lisp tangle:yes
2376 (setq desktop-path (list jj-cache-dir))
2377 (desktop-save-mode 1)
2378 (defadvice desktop-read (around trace-desktop-errors activate)
2379 (let ((debug-on-error t))
2383 ;;----------------------------------------------------------------------------
2384 ;; Restore histories and registers after saving
2385 ;;----------------------------------------------------------------------------
2388 (setq session-save-file (expand-file-name "session" jj-cache-dir))
2389 (add-hook 'after-init-hook 'session-initialize)
2391 ;; save a bunch of variables to the desktop file
2392 ;; for lists specify the len of the maximal saved data also
2393 (setq desktop-globals-to-save
2394 (append '((extended-command-history . 30)
2395 (file-name-history . 100)
2397 (compile-history . 30)
2398 (minibuffer-history . 50)
2399 (query-replace-history . 60)
2400 (read-expression-history . 60)
2401 (regexp-history . 60)
2402 (regexp-search-ring . 20)
2404 (comint-input-ring . 50)
2405 (shell-command-history . 50)
2407 desktop-missing-file-warning
2413 [2013-04-21 So 20:25]
2414 Save a bit of history
2415 #+BEGIN_SRC emacs-lisp tangle no
2417 (setq savehist-additional-variables
2418 '(search ring regexp-search-ring kill-ring compile-history))
2419 ;; save every minute
2420 (setq savehist-autosave-interval 60)
2421 (setq savehist-file (expand-file-name "savehist" jj-cache-dir))
2426 Store at which point I have been in files.
2427 #+BEGIN_SRC emacs-lisp tangle:yes
2428 (setq-default save-place t)
2429 (require 'saveplace)
2430 (setq save-place-file (expand-file-name "saved-places" jj-cache-dir))
2433 EasyPG is a GnuPG interface for Emacs.
2434 #+BEGIN_SRC emacs-lisp tangle:yes
2439 I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
2440 #+BEGIN_SRC emacs-lisp tangle:yes
2441 (defadvice epg--start (around advice-epg-disable-agent disable)
2442 "Don't allow epg--start to use gpg-agent in plain text
2444 (if (display-graphic-p)
2446 (let ((agent (getenv "GPG_AGENT_INFO")))
2447 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
2449 (setenv "GPG_AGENT_INFO" agent))))
2450 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
2451 (ad-activate 'epg--start)
2454 #+BEGIN_SRC emacs-lisp tangle:yes
2456 (setq message-kill-buffer-on-exit t)
2459 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
2460 what I want every emacs to know.
2462 #+BEGIN_SRC emacs-lisp tangle:yes
2463 ;;*** Keyboardmacros
2464 (global-unset-key "\M-n")
2465 (global-set-key "\M-n" 'gnus) ; Start gnus with M-n
2469 url contains code to parse and handle URLs - who would have thought? I
2470 set it to send Accept-language header and tell it to not send email,
2471 operating system or location info.
2472 #+BEGIN_SRC emacs-lisp tangle:yes
2473 (setq url-mime-language-string "de,en")
2474 (setq url-privacy-level (quote (email os lastloc)))
2477 Crazy way of completion. It looks at the word before point and then
2478 tries to expand it in various ways.
2479 #+BEGIN_SRC emacs-lisp tangle:yes
2480 (require 'hippie-exp)
2481 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
2482 try-expand-dabbrev-all-buffers
2483 try-expand-dabbrev-from-kill
2484 try-complete-file-name-partially
2485 try-complete-file-name
2486 try-expand-all-abbrevs try-expand-list
2488 try-complete-lisp-symbol-partially
2489 try-complete-lisp-symbol))
2490 (global-set-key (kbd "M-/") 'hippie-expand)
2493 [2013-04-27 Sa 23:16]
2494 Yasnippet is a template system. Type an abbreviation, expand it into
2495 whatever the snippet holds.
2496 #+BEGIN_SRC emacs-lisp tangle:yes
2497 (setq yas-snippet-dirs (expand-file-name "yasnippet/snippets" jj-elisp-dir))
2498 (require 'yasnippet)
2501 ;; Integrate hippie-expand with ya-snippet
2502 (add-to-list 'hippie-expand-try-functions-list
2503 'yas-hippie-try-expand)
2506 The Emacs Lisp Package Archive (may) contain(s) some things I
2507 want. Even though I usually only use it to get the package, then when I
2508 like it move it into my own space. My elpa subdir stays empty.
2509 #+BEGIN_SRC emacs-lisp tangle:yes
2510 (when (> emacs-major-version 23)
2512 (setq package-user-dir (expand-file-name "elpa" jj-cache-dir))
2513 (package-initialize)
2514 (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
2515 (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
2519 [2013-04-08 Mon 23:57]
2520 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2521 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2522 #+BEGIN_SRC emacs-lisp tangle:yes
2523 (require 'multiple-cursors)
2524 (define-key region-bindings-mode-map "a" 'mc/mark-all-like-this)
2526 (define-key region-bindings-mode-map "p" 'mc/mark-previous-like-this)
2527 (define-key region-bindings-mode-map "n" 'mc/mark-next-like-this)
2528 (define-key region-bindings-mode-map "l" 'mc/edit-lines)
2529 (define-key region-bindings-mode-map "m" 'mc/mark-more-like-this-extended)
2530 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))
2532 ** rainbow-delimiters
2533 [2013-04-09 Di 23:38]
2534 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
2535 which highlights parens, brackets, and braces according to their
2536 depth. Each successive level is highlighted a different color. This
2537 makes it easy to spot matching delimiters, orient yourself in the code,
2538 and tell which statements are at the same depth.
2539 #+BEGIN_SRC emacs-lisp tangle:yes
2540 (when (require 'rainbow-delimiters nil 'noerror)
2541 (global-rainbow-delimiters-mode))
2544 [2013-04-21 So 11:07]
2545 Emacs undo is pretty powerful - but can also be confusing. There are
2546 tons of modes available to change it, even downgrade it to the very
2547 crappy ways one usually knows from other systems which lose
2548 information. undo-tree is different - it helps keeping you sane while
2549 keeping the full power of emacs undo/redo.
2550 #+BEGIN_SRC emacs-lisp tangle:yes
2551 (require 'undo-tree)
2552 (global-undo-tree-mode)
2553 (diminish 'undo-tree-mode)
2556 Additionally I would like to keep the region active should I undo
2559 #+BEGIN_SRC emacs-lisp tangle:yes
2560 ;; Keep region when undoing in region
2561 (defadvice undo-tree-undo (around keep-region activate)
2563 (let ((m (set-marker (make-marker) (mark)))
2564 (p (set-marker (make-marker) (point))))
2573 [2013-04-21 So 20:27]
2574 Use shift + arrow keys to switch between visible buffers
2575 #+BEGIN_SRC emacs-lisp tangle:yes
2577 (windmove-default-keybindings 'hyper)
2578 (setq windmove-wrap-around t)
2580 ** volatile highlights
2581 [2013-04-21 So 20:31]
2582 VolatileHighlights highlights changes to the buffer caused by commands
2583 such as ‘undo’, ‘yank’/’yank-pop’, etc. The highlight disappears at the
2584 next command. The highlighting gives useful visual feedback for what
2585 your operation actually changed in the buffer.
2586 #+BEGIN_SRC emacs-lisp tangle:yes
2587 (require 'volatile-highlights)
2588 (volatile-highlights-mode t)
2589 (diminish 'volatile-highlights-mode)
2592 [2013-04-21 So 20:36]
2593 ediff - don't start another frame
2596 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
2600 #+BEGIN_SRC emacs-lisp tangle:yes
2601 (require 're-builder)
2602 (setq reb-re-syntax 'string)
2605 [2013-04-21 So 20:39]
2608 [2013-04-21 So 20:48]
2609 magit is a mode for interacting with git.
2610 #+BEGIN_SRC emacs-lisp tangle:yes
2611 (require 'magitload)
2612 (require 'magit-svn)
2613 (global-set-key (kbd "C-x g") 'magit-status)
2614 (setq magit-commit-signoff t)
2617 ** lisp editing stuff
2618 [2013-04-21 So 21:00]
2619 I'm not doing much of it, except for my emacs and gnus configs, but
2620 then I like it nice too...
2621 #+BEGIN_SRC emacs-lisp tangle:yes
2622 (define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
2625 (setq lisp-coding-hook 'lisp-coding-defaults)
2626 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2628 (eval-after-load "paredit"
2629 '(diminish 'paredit-mode " π"))
2631 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2632 (add-hook 'emacs-lisp-mode-hook (lambda ()
2633 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2635 (define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
2637 (eval-after-load "elisp-slime-nav"
2638 '(diminish 'elisp-slime-nav-mode))
2639 (eval-after-load "rainbow-mode"
2640 '(diminish 'rainbow-mode))
2641 (eval-after-load "eldoc"
2642 '(diminish 'eldoc-mode))
2646 This highlights some /weaselwords/, a mode to /aid in finding common
2647 writing problems/...
2648 [2013-04-27 Sa 23:29]
2649 #+BEGIN_SRC emacs-lisp tangle:yes
2650 (require 'writegood-mode)
2651 (global-set-key "\C-cg" 'writegood-mode)
2653 ** auto-complete mode
2654 [2013-04-27 Sa 16:33]
2655 And aren't we all lazy? I definitely am, and I like my emacs doing as
2656 much possible work for me as it can.
2657 So here, auto-complete-mode, which lets emacs do this, based on what I
2659 #+BEGIN_SRC emacs-lisp tangle:yes
2660 (require 'auto-complete)
2661 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
2662 (global-auto-complete-mode t)
2664 (setq ac-expand-on-auto-complete nil)
2666 (setq ac-auto-start t)
2668 ;;----------------------------------------------------------------------------
2669 ;; Use Emacs' built-in TAB completion hooks to trigger AC (Emacs >= 23.2)
2670 ;;----------------------------------------------------------------------------
2671 (setq tab-always-indent 'complete) ;; use 't when auto-complete is disabled
2672 (add-to-list 'completion-styles 'initials t)
2674 ;; hook AC into completion-at-point
2675 (defun sanityinc/auto-complete-at-point ()
2676 (when (and (not (minibufferp))
2677 (fboundp 'auto-complete-mode)
2681 (defun set-auto-complete-as-completion-at-point-function ()
2682 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
2684 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
2686 (require 'ac-dabbrev)
2687 (set-default 'ac-sources
2689 ac-source-dictionary
2690 ac-source-words-in-buffer
2691 ac-source-words-in-same-mode-buffers
2692 ac-source-words-in-all-buffer
2695 (dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
2696 sass-mode yaml-mode csv-mode espresso-mode haskell-mode
2697 html-mode nxml-mode sh-mode smarty-mode clojure-mode
2698 lisp-mode textile-mode markdown-mode tuareg-mode
2699 js3-mode css-mode less-css-mode sql-mode ielm-mode))
2700 (add-to-list 'ac-modes mode))
2702 ;; Exclude very large buffers from dabbrev
2703 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
2704 (< (buffer-size other-buffer) (* 1 1024 1024)))
2706 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
2709 ;; custom keybindings to use tab, enter and up and down arrows
2710 (define-key ac-complete-mode-map "\t" 'ac-expand)
2711 (define-key ac-complete-mode-map "\r" 'ac-complete)
2712 (define-key ac-complete-mode-map "\M-n" 'ac-next)
2713 (define-key ac-complete-mode-map "\M-p" 'ac-previous)
2714 (define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
2716 (setq auto-completion-syntax-alist (quote (global accept . word))) ;; Use space and punctuation to accept the current the most likely completion.
2717 (setq auto-completion-min-chars (quote (global . 3))) ;; Avoid completion for short trivial words.
2718 (setq completion-use-dynamic t)
2720 (add-hook 'latex-mode-hook 'auto-complete-mode)
2721 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
2722 (add-hook 'prog-mode-hook 'auto-complete-mode)
2723 (add-hook 'org-mode-hook 'auto-complete-mode)
2726 [2013-04-28 So 01:13]
2727 YAML is a nice format for data, which is both, human and machine
2728 readable/editable without getting a big headache.
2729 #+BEGIN_SRC emacs-lisp tangle:yes
2730 (require 'yaml-mode)
2731 (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
2732 (add-hook 'yaml-mode-hook
2734 (define-key yaml-mode-map "\C-m" 'newline-and-indent)))
2738 [2013-04-28 So 22:21]
2739 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
2740 As the one time I tried Flymake i wasn't happy, thats easy to
2742 #+BEGIN_SRC emacs-lisp tangle:yes
2743 (when (> emacs-major-version 23)
2745 (add-hook 'after-init-hook #'global-flycheck-mode))
2748 [2013-05-21 Tue 23:18]
2749 #+BEGIN_SRC emacs-lisp tangle:yes
2750 (require 'crontab-mode)
2751 (add-auto-mode 'crontab-mode "\\.?cron\\(tab\\)?\\'")
2755 [2013-05-22 Wed 22:02]
2757 nxml-mode is a major mode for editing XML.
2758 #+BEGIN_SRC emacs-lisp tangle:yes
2763 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2766 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2767 (fset 'xml-mode 'nxml-mode)
2768 (setq nxml-slash-auto-complete-flag t)
2771 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2772 (defun pp-xml-region (begin end)
2773 "Pretty format XML markup in region. The function inserts
2774 linebreaks to separate tags that have nothing but whitespace
2775 between them. It then indents the markup by using nxml's
2781 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2782 (backward-char) (insert "\n"))
2783 (indent-region begin end)))
2785 ;;----------------------------------------------------------------------------
2786 ;; Integration with tidy for html + xml
2787 ;;----------------------------------------------------------------------------
2788 ;; tidy is autoloaded
2789 (eval-after-load 'tidy
2791 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2792 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2794 (add-auto-mode 'html-mode "\\.(jsp|tmpl)\\'")
2798 [2013-05-22 Wed 22:33]
2799 Programming in ruby...
2801 #+BEGIN_SRC emacs-lisp tangle:yes
2802 (add-auto-mode 'ruby-mode
2803 "Rakefile\\'" "\\.rake\\'" "\.rxml\\'"
2804 "\\.rjs\\'" ".irbrc\\'" "\.builder\\'" "\\.ru\\'"
2805 "\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
2807 (setq ruby-use-encoding-map nil)
2809 (eval-after-load 'ruby-mode
2811 (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
2812 (define-key ruby-mode-map (kbd "TAB") 'indent-for-tab-command)))
2814 ;; Stupidly the non-bundled ruby-mode isn't a derived mode of
2815 ;; prog-mode: we run the latter's hooks anyway in that case.
2816 (add-hook 'ruby-mode-hook
2818 (unless (derived-mode-p 'prog-mode)
2819 (run-hooks 'prog-mode-hook))))
2822 (defun sanityinc/ensure-mmm-erb-loaded ()
2827 (defun sanityinc/set-up-mode-for-erb (mode)
2828 (add-hook (derived-mode-hook-name mode) 'sanityinc/ensure-mmm-erb-loaded)
2829 (mmm-add-mode-ext-class mode "\\.erb\\'" 'erb))
2831 (let ((html-erb-modes '(html-mode html-erb-mode nxml-mode)))
2832 (dolist (mode html-erb-modes)
2833 (sanityinc/set-up-mode-for-erb mode)
2834 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-js)
2835 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css)))
2837 (mapc 'sanityinc/set-up-mode-for-erb
2838 '(coffee-mode js-mode js2-mode js3-mode markdown-mode textile-mode))
2840 (mmm-add-mode-ext-class 'html-erb-mode "\\.jst\\.ejs\\'" 'ejs)
2842 (add-auto-mode 'html-erb-mode "\\.rhtml\\'" "\\.html\\.erb\\'")
2843 (add-to-list 'auto-mode-alist '("\\.jst\\.ejs\\'" . html-erb-mode))
2844 (mmm-add-mode-ext-class 'yaml-mode "\\.yaml\\'" 'erb)
2846 (dolist (mode (list 'js-mode 'js2-mode 'js3-mode))
2847 (mmm-add-mode-ext-class mode "\\.js\\.erb\\'" 'erb))
2851 And thats it for this file, control passes "back" to [[file:../initjj.org][initjj.org/el]]
2852 which then may load more files.