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 I have some stuff put away in my local dir. I don't want to load it all
42 at startup time, so it is using the autoload feature. For that to work
43 load the loaddefs, so autoload knows where to grab stuff
44 #+BEGIN_SRC emacs-lisp tangle:yes
45 (safe-load (concat jj-elisp-dir "/tiny/loaddefs.el"))
46 (safe-load (concat jj-elisp-local-dir "/loaddefs.el"))
49 Always ensure to have a scratch buffer around.
50 #+BEGIN_SRC emacs-lisp tangle:yes
52 (set-buffer (get-buffer-create "*scratch*"))
53 (lisp-interaction-mode)
54 (make-local-variable 'kill-buffer-query-functions)
55 (add-hook 'kill-buffer-query-functions 'kill-scratch-buffer))
58 Handier way to add modes to auto-mode-alist
59 #+BEGIN_SRC emacs-lisp tangle:yes
60 (defun add-auto-mode (mode &rest patterns)
61 "Add entries to `auto-mode-alist' to use `MODE' for all given file `PATTERNS'."
62 (dolist (pattern patterns)
63 (add-to-list 'auto-mode-alist (cons pattern mode))))
66 Helpers for the config
67 #+BEGIN_SRC emacs-lisp tangle:yes
68 (require 'use-package)
74 We need to define the load-path. As I have lots of things I add
75 locally, its getting a few entries. I only leave out org-mode here, as
76 that is already done in =init.el=.
78 I also disliked the repeated /add-to-list/ lines, so I now just have
79 one variable and go over that in a loop.
80 #+BEGIN_SRC emacs-lisp tangle:yes
81 (defvar jj-elisp-subdirs '(local gnus icicle org/contrib tiny mo-git-blame cedet
82 cedet/eieio ecb jdee/lisp sunrise multiple-cursors
83 auto-complete yasnippet magit mmm emms/lisp)
84 "List of subdirectories in jj-elisp-dir to add to load-path")
87 (dolist (dirval jj-elisp-subdirs)
88 (let ((name (expand-file-name (symbol-name dirval) jj-elisp-dir)))
89 (when (file-exists-p name)
90 (add-to-list 'load-path name)))))
91 ;; For older emacsen we need an extra directory, which should be at
92 ;; THE END of the load path
93 (when (version< emacs-version "24")
94 (add-to-list 'load-path (expand-file-name "emacs23" jj-elisp-dir) t))
99 Help emacs to find the info files
100 #+BEGIN_SRC emacs-lisp tangle:yes
101 (setq Info-directory-list '("~/emacs/info"
102 "/usr/local/share/info/"
104 "/usr/local/gnu/info/"
105 "/usr/local/gnu/lib/info/"
106 "/usr/local/gnu/lib/emacs/info/"
107 "/usr/local/emacs/info/"
108 "/usr/local/lib/info/"
109 "/usr/local/lib/emacs/info/"
110 "/usr/share/info/emacs-23"
113 (setq Info-default-directory-list
114 (cons "~/emacs/info" Info-default-directory-list))
120 :ID: 0a1560d9-7e55-47ab-be52-b3a8b8eea4aa
122 I dislike the startup message
123 #+BEGIN_SRC emacs-lisp tangle:yes
124 (setq inhibit-splash-screen t)
125 (setq inhibit-startup-message t)
128 Usually I want the lines to break at 72 characters.
129 #+BEGIN_SRC emacs-lisp tangle:yes
130 (if (version<= emacs-version "22")
131 (setq default-fill-column 72)
132 (setq fill-column 72))
135 And it is nice to have a final newline in files.
136 #+BEGIN_SRC emacs-lisp tangle:yes
137 (setq require-final-newline t)
140 After I typed 300 characters or took a break for more than a minute it
141 would be nice of emacs to save whatever I am on in one of its auto-save
142 backups. See [[info:emacs#Auto%20Save%20Control][info:emacs#Auto Save Control]] for more details.
143 #+BEGIN_SRC emacs-lisp tangle:yes
144 (setq auto-save-interval 300)
145 (setq auto-save-timeout 60)
148 Set my full name and my default mail address - for whatever wants to use
149 it later. Also, I am using gnus.
150 #+BEGIN_SRC emacs-lisp tangle:yes
151 (setq user-full-name "Joerg Jaspert")
152 (setq user-mail-address "joerg@ganneff.de")
153 (setq mail-user-agent (quote gnus-user-agent))
156 My default mail server. Well, simply a localhost, I have a forwarder that
157 puts mail off the right way, no need for emacs to have any further
159 #+BEGIN_SRC emacs-lisp tangle:yes
160 (setq smtpmail-default-smtp-server "localhost")
161 (setq smtpmail-smtp-server "localhost")
164 Enable automatic handling of compressed files.
165 #+BEGIN_SRC emacs-lisp tangle:yes
166 (auto-compression-mode 1)
169 Emacs forbids a certain set of commands, as they can be very confusing
170 for new users. Enable them.
171 #+BEGIN_SRC emacs-lisp tangle:yes
172 (put 'narrow-to-region 'disabled nil)
173 (put 'narrow-to-page 'disabled nil)
174 (put 'narrow-to-defun 'disabled nil)
175 (put 'upcase-region 'disabled nil)
176 (put 'downcase-region 'disabled nil)
180 I've tried various different fonts and while I like the Terminus font
181 most for my shells, in Emacs Inconsolata clearly wins.
182 #+BEGIN_SRC emacs-lisp tangle:yes
183 (if (version<= emacs-version "22")
184 (set-default-font "Inconsolata-14")
185 (set-frame-font "Inconsolata-14"))
188 I always use dark backgrounds, so tell Emacs about it. No need to
190 #+BEGIN_SRC emacs-lisp tangle:yes
191 (setq-default frame-background-mode jj-color-style)
194 And I always liked dark backgrounds with colors setup for them. So I
195 switched through multiple themes doing it in emacs too, but never
196 entirely liked it. Until I found solarized, which is now not only my
197 emacs theme, but also for most of my other software too, especially my
198 shell. Consistent look is great.
199 #+BEGIN_SRC emacs-lisp tangle:yes
200 (if (or (> emacs-major-version 23) (boundp 'custom-theme-load-path))
202 (defun jj-init-theme ()
204 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
205 (load-theme 'solarized-light t))
206 (set-face-attribute 'org-date nil :underline nil)
207 (message "Initializing theme solarized-dark")
209 (add-to-list 'custom-theme-load-path jj-theme-dir)
210 (add-hook 'after-init-hook 'jj-init-theme)
212 (add-to-list 'load-path (expand-file-name "emacs-color-theme-solarized" jj-elisp-dir))
213 (require 'color-theme-solarized)
214 (color-theme-solarized-dark)
218 Make the fringe (gutter) smaller, the argument is a width in pixels (the default is 8)
219 #+BEGIN_SRC emacs-lisp tangle:yes
220 (if (fboundp 'fringe-mode)
224 A bit more spacing between buffer lines
225 #+BEGIN_SRC emacs-lisp tangle:yes
226 (setq-default line-spacing 0.1)
229 [2013-04-21 So 20:54]
230 I do not want my cursor to blink.
231 #+BEGIN_SRC emacs-lisp tangle:yes
232 (blink-cursor-mode -1)
234 *** Menu, Tool and Scrollbar
235 I don't want to see the menu-bar, tool-bar or scrollbar.
236 #+BEGIN_SRC emacs-lisp tangle:yes
240 (set-scroll-bar-mode nil))
242 **** When using emacs in daemon mode
243 Emacs has a very nice mode where it detaches itself and runs as daemon -
244 and you can just open /frames/ (windows) from it by using [[http://www.emacswiki.org/emacs/EmacsClient][Emacs
245 Client]]. It's fast, it's nice, it's convinient.
247 Except that Emacs behaves stupid when you do that and ignores your
248 menu/tool/scrollbar settings. Sucks.
250 For them to work even then, we have to do two things.
251 1. We have to set the frame alist. We simple set both,
252 =initial-frame-alist= and =default-frame-alist= to the same value here.
253 #+BEGIN_SRC emacs-lisp tangle:yes
254 (setq initial-frame-alist '(
255 (horizontal-scroll-bars . nil)
256 (vertical-scroll-bars . nil)
259 (setq default-frame-alist (copy-alist initial-frame-alist))
261 2. We have to disable the toolbar using the customize interface, so you
262 can find that in the [[id:0102208d-fdf6-4928-9e40-7e341bd3aa3a][Customized variables]] section.
264 *** Hilight current line in buffer
265 As it says, it does a hilight of the current line.
266 #+BEGIN_SRC emacs-lisp tangle:yes
267 (global-hl-line-mode +1)
269 *** Allow recursive minibuffers
270 This allows (additional) minibuffer commands while in the minibuffer.
271 #+BEGIN_SRC emacs-lisp tangle:yes
272 (setq enable-recursive-minibuffers 't)
275 *** Modeline related changes
276 I want to see line and column numbers, so turn them on.
277 Size indication lets me know how far I am in a buffer.
279 And modeline-posn is great. It will hilight the column number in the
280 modeline in red as soon as you are over the defined limit.
282 #+BEGIN_SRC emacs-lisp tangle:yes
284 (column-number-mode 1)
285 (size-indication-mode 1)
286 (display-time-mode 1)
287 (setq display-time-day-and-date nil)
288 (setq display-time-24hr-format t)
289 (setq modelinepos-column-limit 72)
291 (require 'modeline-posn)
292 (set-face-foreground 'modelinepos-column-warning "grey20")
293 (set-face-background 'modelinepos-column-warning "red")
296 [2013-04-22 Mon 11:27]
297 The modeline is easily cluttered up with stuff I don't really need to
298 see. So lets hide those. There are two ways, one of them uses diminish
299 to get entirely rid of some modes, the other is a function taken from
300 "Mastering Emacs" which replaces the modes text with an own (set of)
302 #+BEGIN_SRC emacs-lisp tangle:yes
304 (diminish 'auto-fill-function)
305 (defvar mode-line-cleaner-alist
306 `((auto-complete-mode . " α")
307 (yas-minor-mode . " y")
308 (paredit-mode . " π")
312 (lisp-interaction-mode . "λ")
315 (emacs-lisp-mode . "EL")
317 (org-indent-mode . "")
319 (nxhtml-mode . "nx"))
321 "Alist for `clean-mode-line'.
323 When you add a new element to the alist, keep in mind that you
324 must pass the correct minor/major mode symbol and a string you
325 want to use in the modeline *in lieu of* the original.
327 Want some symbols? Go:
329 ;ςερτζθιοπασδφγηξκλυχψωβνμ
330 :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
331 @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
335 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
338 Unfortunately icicles breaks this with the way it adds/removes itself,
339 so take it our for now...
342 Back when I started with text-mode. But nowadays I want default mode to
343 be org-mode - it is just so much better to use. And does sensible things
344 with many README files out there, and various other "crap" you get to
346 #+BEGIN_SRC emacs-lisp tangle:yes
347 (if (> emacs-major-version 22)
348 (setq major-mode 'org-mode)
349 (setq default-major-mode 'org-mode))
350 (setq initial-major-mode 'org-mode)
354 [2013-04-23 Tue 16:43]
355 Shell. zsh in my case.
356 #+BEGIN_SRC emacs-lisp tangle:yes
357 (setq shell-file-name "zsh")
358 (setq shell-command-switch "-c")
359 (setq explicit-shell-file-name shell-file-name)
360 (setenv "SHELL" shell-file-name)
361 (setq explicit-sh-args '("-login" "-i"))
362 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
363 (setq comint-scroll-to-bottom-on-input t) ; always insert at the bottom
364 (setq comint-scroll-to-bottom-on-output t) ; always add output at the bottom
365 (setq comint-scroll-show-maximum-output t) ; scroll to show max possible output
366 (setq comint-completion-autolist t) ; show completion list when ambiguous
367 (setq comint-input-ignoredups t) ; no duplicates in command history
368 (setq comint-completion-addsuffix t) ; insert space/slash after file completion
372 Basic settings for emacs integrated shell
373 #+BEGIN_SRC emacs-lisp tangle:yes
374 (setq eshell-cmpl-cycle-completions nil
375 eshell-save-history-on-exit t
376 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
377 (eval-after-load 'esh-opt
382 ;; TODO: for some reason requiring this here breaks it, but
383 ;; requiring it after an eshell session is started works fine.
384 ;; (require 'eshell-vc)
385 (setenv "PAGER" "cat")
386 ; (set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
387 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
388 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
389 (add-hook 'eshell-preoutput-filter-functions
390 'ansi-color-filter-apply)
391 (add-to-list 'eshell-visual-commands "ssh")
392 (add-to-list 'eshell-visual-commands "tail")
393 (add-to-list 'eshell-command-completions-alist
395 (add-to-list 'eshell-command-completions-alist
396 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))))
401 Incremental search is great, but annoyingly you need to type whatever
402 you want. If you want to search for just the next (or previous)
403 occurence of what is at your cursor position use the following.
404 *C-x* will insert the current word while *M-up* and *M-down* will just
405 jump to the next/previous occurence of it.
406 #+BEGIN_SRC emacs-lisp tangle:yes
407 (define-key isearch-mode-map (kbd "C-x") 'sacha/isearch-yank-current-word)
408 (global-set-key '[M-up] 'sacha/search-word-backward)
409 (global-set-key '[M-down] 'sacha/search-word-forward)
412 *** Frame configuration
413 I want to see the buffername and its size, not the host I am on in my
415 #+BEGIN_SRC emacs-lisp tangle:yes
416 (setq frame-title-format "%b (%i)")
419 *** Protect some buffers
420 I don't want some buffers to be killed, **scratch** for example.
421 In the past I had a long function that just recreated them, but the
422 =keep-buffers= package is easier.
423 #+BEGIN_SRC emacs-lisp tangle:yes
424 (require 'keep-buffers)
425 (keep-buffers-mode 1)
426 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
427 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
428 (push '("\\`*Group" . nil) keep-buffers-protected-alist)
432 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
434 #+BEGIN_SRC emacs-lisp tangle:yes
435 (defalias 'yes-or-no-p 'y-or-n-p)
438 *** Language/i18n stuff
439 In this day and age, UTF-8 is the way to go.
440 #+BEGIN_SRC emacs-lisp tangle:yes
441 (set-language-environment 'utf-8)
442 (set-default-coding-systems 'utf-8)
443 (set-terminal-coding-system 'utf-8)
444 (set-keyboard-coding-system 'utf-8)
445 (set-clipboard-coding-system 'utf-8)
446 (prefer-coding-system 'utf-8)
447 (set-charset-priority 'unicode)
448 (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
451 *** Hilight matching parentheses
452 While I do have the nifty shortcut to jump to the other parentheses,
453 hilighting them makes it obvious where they are.
454 #+BEGIN_SRC emacs-lisp tangle:yes
456 (setq show-paren-style 'parenthesis)
459 *** Kill other buffers
460 While many editors allow you to close "all the other files, not the one
461 you are in", emacs doesn't have this... Except, now it will.
462 #+BEGIN_SRC emacs-lisp tangle:yes
463 (global-set-key (kbd "C-c k") 'prelude-kill-other-buffers)
466 Default scrolling behaviour in emacs is a bit annoying, who wants to
468 #+BEGIN_SRC emacs-lisp tangle:yes
469 (setq scroll-margin 0)
470 (setq scroll-conservatively 100000)
471 (setq scroll-up-aggressively 0.0)
472 (setq scroll-down-aggressively 0.0)
473 (setq scroll-preserve-screen-position t)
476 *** Copy/Paste with X
477 [2013-04-09 Di 23:31]
478 The default how emacs handles cutting/pasting with the primary selection
479 changed in emacs24. I am used to the old way, so get it back.
480 #+BEGIN_SRC emacs-lisp tangle:yes
481 (setq x-select-enable-primary t)
482 (setq x-select-enable-clipboard t ;; copy-paste should work ...
483 interprogram-paste-function ;; ...with...
484 'x-cut-buffer-or-selection-value) ;; ...other X clients
488 *** Global keyboard changes not directly related to a mode
489 Disable /suspend_frame/ function, I dislike it.
490 #+BEGIN_SRC emacs-lisp tangle:yes
491 (global-unset-key [(control z)])
492 (global-unset-key [(control x) (control z)])
495 Default of *C-k* is to kill from the point to the end of line. If
496 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
497 set, including newline. But to kill the entire line, one still needs a
498 *C-a* in front of it. So I change it, by defining a function to do just this for
500 #+BEGIN_SRC emacs-lisp tangle:yes
501 (defun kill-entire-line ()
502 "Kill this entire line (including newline), regardless of where point is within the line."
506 (back-to-indentation))
508 (global-unset-key [(control k)])
509 (global-set-key [(control k)] 'kill-entire-line)
510 (global-set-key [remap kill-whole-line] 'kill-entire-line)
513 And the same is true when I'm in org-mode, which has an own kill function...
514 (the keybinding happens later, after org-mode is loaded fully)
515 #+BEGIN_SRC emacs-lisp tangle:yes
516 (defun jj-org-kill-line (&optional arg)
517 "Kill the entire line, regardless of where point is within the line, org-mode-version"
521 (back-to-indentation)
525 I really hate tabs, so I don't want any indentation to try using them.
526 And in case a project really needs them, I can change it just for that
527 file/project, but luckily none of those I work in is as broken.
528 #+BEGIN_SRC emacs-lisp tangle:yes
529 (setq-default indent-tabs-mode nil)
532 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
533 #+BEGIN_SRC emacs-lisp tangle:yes
534 (global-set-key "\M-5" 'match-paren)
537 Instead of the default "mark-defun" I want a more readline-like setting.
538 #+begin_src emacs-lisp
539 (global-set-key (kbd "C-M-h") 'backward-kill-word)
542 Align whatever with a regexp.
543 #+begin_src emacs-lisp
544 (global-set-key (kbd "C-x \\") 'align-regexp)
548 #+begin_src emacs-lisp
549 (global-set-key (kbd "C-+") 'text-scale-increase)
550 (global-set-key (kbd "C--") 'text-scale-decrease)
553 Regexes are too useful, so use the regex search by default.
554 #+begin_src emacs-lisp
555 (global-set-key (kbd "C-s") 'isearch-forward-regexp)
556 (global-set-key (kbd "\C-r") 'isearch-backward-regexp)
557 (global-set-key (kbd "C-M-s") 'isearch-forward)
558 (global-set-key (kbd "C-M-r") 'isearch-backward)
561 Rgrep is infinitely useful in multi-file projects.
562 #+begin_src emacs-lisp
563 (define-key global-map "\C-x\C-g" 'rgrep)
566 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
568 #+BEGIN_SRC emacs-lisp tangle:yes
569 (global-set-key [(meta shift up)] 'move-line-up)
570 (global-set-key [(meta shift down)] 'move-line-down)
573 "Pull" lines up, join them
574 #+BEGIN_SRC emacs-lisp tangle:yes
575 (global-set-key (kbd "M-j")
581 When I press Enter I almost always want to go to the right indentation on the next line.
582 #+BEGIN_SRC emacs-lisp tangle:yes
583 (global-set-key (kbd "RET") 'newline-and-indent)
586 Easier undo, and i don't need suspend-frame
587 #+BEGIN_SRC emacs-lisp tangle:yes
588 (global-set-key (kbd "C-z") 'undo)
591 Window switching, go backwards. (C-x o goes to the next window)
592 #+BEGIN_SRC emacs-lisp tangle:yes
593 (global-set-key (kbd "C-x O") (lambda ()
599 #+BEGIN_SRC emacs-lisp tangle:yes
600 (global-set-key (kbd "C-x C-r") 'prelude-sudo-edit)
603 M-space is bound to just-one-space, which is great for programming. What
604 it does is remove all spaces around the cursor, except for one. But to
605 be really useful, it also should include newlines. It doesn’t do this by
606 default. Rather, you have to call it with a negative argument. Sure
608 #+BEGIN_SRC emacs-lisp tangle:yes
609 (global-set-key (kbd "M-SPC") 'just-one-space-with-newline)
612 Count which commands I use how often.
613 #+BEGIN_SRC emacs-lisp tangle:yes
615 (expand-file-name "keyfreq" jj-cache-dir)
616 "Keyfreq cache file")
617 (defvar keyfreq-file-lock
618 (expand-file-name "keyfreq.lock" jj-cache-dir)
619 "Keyfreq cache file")
622 (keyfreq-autosave-mode 1)
625 Duplicate current line
626 #+BEGIN_SRC emacs-lisp tangle:yes
627 (defun duplicate-line ()
628 "Insert a copy of the current line after the current line."
631 (let ((line-text (buffer-substring-no-properties
632 (line-beginning-position)
633 (line-end-position))))
636 (insert line-text))))
638 (global-set-key (kbd "C-c p") 'duplicate-line)
641 Smarter move to the beginning of the line. That is, it first moves to
642 the beginning of the line - and on second keypress it goes to the
643 first character on line.
644 #+BEGIN_SRC emacs-lisp tangle:yes
645 (defun smarter-move-beginning-of-line (arg)
646 "Move point back to indentation of beginning of line.
648 Move point to the first non-whitespace character on this line.
649 If point is already there, move to the beginning of the line.
650 Effectively toggle between the first non-whitespace character and
651 the beginning of the line.
653 If ARG is not nil or 1, move forward ARG - 1 lines first. If
654 point reaches the beginning or end of the buffer, stop there."
656 (setq arg (or arg 1))
660 (let ((line-move-visual nil))
661 (forward-line (1- arg))))
663 (let ((orig-point (point)))
664 (back-to-indentation)
665 (when (= orig-point (point))
666 (move-beginning-of-line 1))))
668 ;; remap C-a to `smarter-move-beginning-of-line'
669 (global-set-key [remap move-beginning-of-line]
670 'smarter-move-beginning-of-line)
674 Easily copy characters from the previous nonblank line, starting just
675 above point. With a prefix argument, only copy ARG characters (never
676 past EOL), no argument copies rest of line.
677 #+BEGIN_SRC emacs-lisp tangle:yes
679 (global-set-key (kbd "H-y") 'copy-from-above-command)
682 Open a new X Terminal pointing to the directory of the current
684 #+BEGIN_SRC emacs-lisp tangle:yes
685 (global-set-key (kbd "H-t") 'jj-open-shell)
688 [2013-04-28 So 11:26]
690 Quickly move around in buffers.
691 #+BEGIN_SRC emacs-lisp tangle:yes
692 (autoload 'ace-jump-mode "ace-jump-mode" "Emacs quick move minor mode" t)
693 (define-key global-map (kbd "H-SPC") 'ace-jump-mode)
694 ;; enable a more powerful jump back function from ace jump mode
695 (autoload 'ace-jump-mode-pop-mark "ace-jump-mode" "Ace jump back :-)" t)
696 (eval-after-load "ace-jump-mode" '(ace-jump-mode-enable-mark-sync))
697 (define-key global-map (kbd "H-c SPC") 'ace-jump-mode-pop-mark)
700 Usually you can press the *Ins*ert key, to get into overwrite mode. I
701 don't like that, have broken much with it and so just forbid it by
703 #+BEGIN_SRC emacs-lisp tangle:yes
704 (global-unset-key [insert])
705 (global-unset-key [kp-insert])
708 ** Miscellaneous stuff
709 Emacs should keep backup copies of files I edit, but I do not want them
710 to clutter up the filesystem everywhere. So I put them into one defined
711 place, backup-directory, which even contains my username (for systems
712 where =temporary-file-directory= is not inside my home).
713 #+BEGIN_SRC emacs-lisp tangle:yes
714 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
715 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
717 (setq version-control t) ;; Use version numbers for backups
718 (setq kept-new-versions 10) ;; Number of newest versions to keep
719 (setq kept-old-versions 2) ;; Number of oldest versions to keep
720 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
722 (add-hook 'before-save-hook 'force-backup-of-buffer)
724 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
725 (setq backup-by-copying t)
726 (setq make-backup-files t)
728 (setq backup-enable-predicate
730 (and (normal-backup-enable-predicate name)
732 (let ((method (file-remote-p name 'method)))
733 (when (stringp method)
734 (member method '("su" "sudo"))))))))
738 Weeks start on Monday, not sunday.
739 #+BEGIN_SRC emacs-lisp tangle:yes
740 (setq calendar-week-start-day 1)
743 Searches and matches should ignore case.
744 #+BEGIN_SRC emacs-lisp tangle:yes
745 (setq-default case-fold-search t)
748 Which buffers to get rid off at midnight.
749 #+BEGIN_SRC emacs-lisp tangle:yes
750 (setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
751 "*Man " "*Buffer List*"
757 "*magit" "*Calendar")))
760 Don't display a cursor in non-selected windows.
761 #+BEGIN_SRC emacs-lisp tangle:yes
762 (setq-default cursor-in-non-selected-windows nil)
765 What should be displayed in the mode-line for files with those types
767 #+BEGIN_SRC emacs-lisp tangle:yes
768 (setq eol-mnemonic-dos "(DOS)")
769 (setq eol-mnemonic-mac "(Mac)")
772 Much larger threshold for garbage collection prevents it to run too often.
773 #+BEGIN_SRC emacs-lisp tangle:yes
774 (setq gc-cons-threshold 48000000)
777 #+BEGIN_SRC emacs-lisp tangle:yes
778 (setq max-lisp-eval-depth 1000)
779 (setq max-specpdl-size 3000)
783 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
784 #+BEGIN_SRC emacs-lisp tangle:yes
785 (defun unfill-paragraph ()
786 "Takes a multi-line paragraph and makes it into a single line of text."
788 (let ((fill-column (point-max)))
789 (fill-paragraph nil)))
792 #+BEGIN_SRC emacs-lisp tangle:yes
793 (setq-default indicate-empty-lines t)
796 Hilight annotations in comments, like FIXME/TODO/...
797 #+BEGIN_SRC emacs-lisp tangle:yes
798 (add-hook 'prog-mode-hook 'font-lock-comment-annotations)
802 #+BEGIN_SRC emacs-lisp tangle:yes
803 (setq browse-url-browser-function (quote browse-url-generic))
804 (setq browse-url-generic-program "/usr/bin/x-www-browser")
807 *** When saving a script - make it executable
808 #+BEGIN_SRC emacs-lisp tangle:yes
809 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
813 #+BEGIN_SRC emacs-lisp tangle:yes
815 (unless (server-running-p)
819 ** Customized variables
820 [2013-05-02 Thu 22:14]
821 The following contains a set of variables i may reasonably want to
822 change on other systems - which don't affect the init file loading
823 process. So I *can* use the customization interface for it...
824 #+BEGIN_SRC emacs-lisp tangle:yes
825 (defgroup ganneff nil
826 "Modify ganneffs settings"
829 (defgroup ganneff-org-mode nil
830 "Ganneffs org-mode settings"
831 :tag "Ganneffs org-mode settings"
833 :link '(custom-group-link "ganneff"))
835 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
836 "ID of the organization task."
837 :tag "Organization Task ID"
839 :group 'ganneff-org-mode)
841 (defcustom org-my-archive-expiry-days 2
842 "The number of days after which a completed task should be auto-archived.
843 This can be 0 for immediate, or a floating point value."
844 :tag "Archive expiry days"
846 :group 'ganneff-org-mode)
851 [2013-05-21 Tue 23:22]
852 Restore removed var alias, used by ruby-electric-brace and others
853 #+BEGIN_SRC emacs-lisp tangle:yes
854 (unless (boundp 'last-command-char)
855 (defvaralias 'last-command-char 'last-command-event))
858 * Customized variables
860 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
862 Of course I want to be able to use the customize interface, and some
863 things can only be set via it (or so they say). I usually prefer to put
864 things I keep for a long while into statements somewhere else, not just
865 custom-set here, but we need it anyways.
867 #+BEGIN_SRC emacs-lisp tangle:yes
868 (setq custom-file jj-custom-file)
869 (safe-load custom-file)
872 The source of this is:
873 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
876 * Extra modes and their configuration
878 For some file endings we need to tell emacs what mode we want for them.
879 I only list modes here where I don't have any other special
883 #+BEGIN_SRC emacs-lisp tangle:yes
884 (add-auto-mode 'markdown-mode "\\.mdwn$")
888 #+BEGIN_SRC emacs-lisp tangle:yes
889 (add-auto-mode 'diff-mode "COMMIT_EDITMSG$")
892 ** Region bindings mode
893 [2013-05-01 Wed 22:51]
894 This mode allows to have keybindings that are only alive when the
895 region is active. Helpful for things that only do any useful action
896 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
897 #+BEGIN_SRC emacs-lisp tangle:yes
898 (require 'region-bindings-mode)
899 (region-bindings-mode-enable)
902 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
903 #+BEGIN_SRC emacs-lisp tangle:yes
905 (setq tramp-default-method "ssh")
906 (setq tramp-persistency-file-name (expand-file-name "tramp" jj-cache-dir))
907 (setq shell-prompt-pattern "^[^a-zA-Z].*[#$%>] *")
908 (add-to-list 'tramp-default-method-alist
909 '("\\`localhost\\'" "\\`root\\'" "su")
911 (setq tramp-debug-buffer nil)
912 (setq tramp-default-method "sshx")
913 (setq tramp-verbose 5)
917 We configure only a bit of the tiny-tools to load when I should need
918 them. I don't need much actually, but these things are nice to have.
920 #+BEGIN_SRC emacs-lisp tangle:yes
921 (autoload 'turn-on-tinyperl-mode "tinyperl" "" t)
922 (add-hook 'perl-mode-hook 'turn-on-tinyperl-mode)
923 (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode)
925 (autoload 'tinycomment-indent-for-comment "tinycomment" "" t)
926 (autoload 'tinyeat-forward-preserve "tinyeat" "" t)
927 (autoload 'tinyeat-backward-preserve "tinyeat" "" t)
928 (autoload 'tinyeat-delete-paragraph "tinyeat" "" t)
929 (autoload 'tinyeat-kill-line "tinyeat" "" t)
930 (autoload 'tinyeat-zap-line "tinyeat" "" t)
931 (autoload 'tinyeat-kill-line-backward "tinyeat" "" t)
932 (autoload 'tinyeat-kill-buffer-lines-point-max "tinyeat" "" t)
933 (autoload 'tinyeat-kill-buffer-lines-point-min "tinyeat" "" t)
935 *** Keyboard changes for tiny-tools
936 #+BEGIN_SRC emacs-lisp tangle:yes
937 (global-set-key "\M-;" 'tinycomment-indent-for-comment)
939 (global-set-key (kbd "ESC C-k") 'tinyeat-kill-line-backward)
940 (global-set-key (kbd "ESC d") 'tinyeat-forward-preserve)
941 (global-set-key (kbd "ESC z") 'tinyeat-kill-buffer-lines-main)
942 (global-set-key (kbd "<M-backspace>") 'tinyeat-backward-preserve)
943 (global-set-key (kbd "<C-delete>") 'tinyeat-forward-preserve)
944 (global-set-key (kbd "<S-backspace>") 'tinyeat-delete-whole-word)
948 I like dired and work a lot with it, but it tends to leave lots of
950 dired-single to the rescue.
951 #+BEGIN_SRC emacs-lisp tangle:yes
952 (autoload 'dired-single-buffer "dired-single" "" t)
953 (autoload 'dired-single-buffer-mouse "dired-single" "" t)
954 (autoload 'dired-single-magic-buffer "dired-single" "" t)
955 (autoload 'dired-single-toggle-buffer-name "dired-single" "" t)
958 We want some extra key bindings loaded. In case we haven't loaded dired
959 yet, there won't be a keymap to add to, so add our setup function to the
960 load hook only. Otherwise just bind the keys.
961 #+BEGIN_SRC emacs-lisp tangle:yes
962 (if (boundp 'dired-mode-map)
963 ;; we're good to go; just add our bindings
965 ;; it's not loaded yet, so add our bindings to the load-hook
966 (add-hook 'dired-load-hook 'my-dired-init))
970 #+BEGIN_SRC emacs-lisp tangle:yes
971 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
972 (setq dired-dwim-target t)
973 (setq dired-listing-switches "-alh")
974 (setq dired-recursive-copies (quote top))
975 (setq dired-recursive-deletes (quote top))
979 #+BEGIN_SRC emacs-lisp tangle:yes
980 (setq wdired-allow-to-change-permissions t)
983 [2013-05-02 Thu 00:04]
984 #+BEGIN_SRC emacs-lisp tangle:yes
986 (eval-after-load "filladapt" '(diminish 'filladapt-mode))
987 (setq-default filladapt-mode t)
990 [2013-05-03 Fri 16:09]
991 Replace default find-file with find-file-at-point, which tries to
992 guess the default file/URL from text around the point.
993 #+BEGIN_SRC emacs-lisp tangle:yes
997 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
998 ‘TAB’ completion is to typing things manually every time.”]]
999 #+BEGIN_SRC emacs-lisp tangle:yes
1004 Always have unique buffernames. See [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html][Uniquify - GNU Emacs Manual]]
1005 #+BEGIN_SRC emacs-lisp tangle:yes
1007 (setq uniquify-buffer-name-style 'post-forward)
1008 (setq uniquify-after-kill-buffer-p t)
1009 (setq uniquify-ignore-buffers-re "^\\*")
1013 A defined abbrev is a word which expands, if you insert it, into some
1014 different text. Abbrevs are defined by the user to expand in specific
1016 #+BEGIN_SRC emacs-lisp tangle:yes
1017 (setq save-abbrevs 'silently)
1018 (setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
1019 (if (file-exists-p abbrev-file-name)
1020 (quietly-read-abbrev-file))
1025 Obviously emacs can do syntax hilighting. For more things than you ever
1027 And I want to have it everywhere.
1028 #+BEGIN_SRC emacs-lisp tangle:yes
1029 (require 'font-lock)
1030 (global-font-lock-mode 1)
1031 (setq font-lock-maximum-decoration t)
1034 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
1035 #+BEGIN_SRC emacs-lisp tangle:yes
1041 By default, Emacs can update the time stamp for the following two
1042 formats if one exists in the first 8 lines of the file.
1045 #+BEGIN_SRC emacs-lisp tangle:yes
1046 (require 'time-stamp)
1047 (setq time-stamp-active t)
1048 (setq time-stamp-format "%02H:%02M:%02S (%z) - %02d.%02m.%:y from %u (%U) on %s")
1049 (setq time-stamp-old-format-warn nil)
1050 (setq time-stamp-time-zone nil)
1051 (add-hook 'write-file-hooks 'time-stamp)
1055 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
1057 #+BEGIN_SRC emacs-lisp tangle:yes
1058 (autoload 'cperl-mode "cperl-mode" )
1059 (defalias 'perl-mode 'cperl-mode)
1060 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
1061 (add-auto-mode 'pod-mode "\\.pod$")
1062 (add-auto-mode 'tt-mode "\\.tt$")
1063 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
1064 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
1065 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
1068 (setq cperl-hairy t)
1069 (setq cperl-electric-keywords t)
1070 (setq cperl-electric-lbrace-space t)
1071 (setq cperl-electric-parens nil)
1072 (setq cperl-highlight-variables-indiscriminately t)
1073 (setq cperl-imenu-addback t)
1074 (setq cperl-invalid-face (quote underline))
1075 (setq cperl-lazy-help-time 5)
1076 (setq cperl-mode-hook (quote (turn-on-tinyperl-mode)))
1077 (setq cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$")
1078 (setq cperl-syntaxify-by-font-lock t)
1079 (setq cperl-use-syntax-table-text-property-for-tags t)
1081 ;; And have cperl mode give ElDoc a useful string
1082 (defun my-cperl-eldoc-documentation-function ()
1083 "Return meaningful doc string for `eldoc-mode'."
1085 (let ((cperl-message-on-help-error nil))
1088 (add-hook 'cperl-mode-hook
1090 (set (make-local-variable 'eldoc-documentation-function)
1091 'my-cperl-eldoc-documentation-function)
1096 #+BEGIN_SRC emacs-lisp tangle:yes
1097 (autoload 'python-mode "python-mode" "Python Mode." t)
1098 (add-auto-mode 'python-mode "\\.py\\'")
1099 (add-auto-mode 'python-mode "\\.py$")
1100 (add-auto-mode 'python-mode "SConstruct\\'")
1101 (add-auto-mode 'python-mode "SConscript\\'")
1102 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
1105 (set-variable 'py-indent-offset 4)
1106 (set-variable 'py-smart-indentation nil)
1107 (set-variable 'indent-tabs-mode nil)
1108 (define-key python-mode-map "\C-m" 'newline-and-indent)
1109 (turn-on-eldoc-mode)
1110 (defun python-auto-fill-comments-only ()
1112 (set (make-local-variable 'fill-nobreak-predicate)
1114 (not (python-in-string/comment)))))
1115 (add-hook 'python-mode-hook
1117 (python-auto-fill-comments-only)))
1119 (autoload 'pymacs-apply "pymacs")
1120 (autoload 'pymacs-call "pymacs")
1121 (autoload 'pymacs-eval "pymacs" nil t)
1122 (autoload 'pymacs-exec "pymacs" nil t)
1123 (autoload 'pymacs-load "pymacs" nil t))
1126 If an =ipython= executable is on the path, then assume that IPython is
1127 the preferred method python evaluation.
1128 #+BEGIN_SRC emacs-lisp tangle:yes
1129 (when (executable-find "ipython")
1131 (setq org-babel-python-mode 'python-mode))
1133 (setq python-shell-interpreter "ipython")
1134 (setq python-shell-interpreter-args "")
1135 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
1136 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
1137 (setq python-shell-completion-setup-code
1138 "from IPython.core.completerlib import module_completion")
1139 (setq python-shell-completion-module-string-code
1140 "';'.join(module_completion('''%s'''))\n")
1141 (setq python-shell-completion-string-code
1142 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
1146 I prefer comments to be indented too
1147 #+BEGIN_SRC emacs-lisp tangle:yes
1148 (setq sh-indent-comment t)
1152 When files change outside emacs for whatever reason I want emacs to deal
1153 with it. Not to have to revert buffers myself
1154 #+BEGIN_SRC emacs-lisp tangle:yes
1155 (require 'autorevert)
1156 (setq global-auto-revert-mode t)
1157 (global-auto-revert-mode)
1160 ** linum (line number)
1161 Various modes should have line numbers in front of each line.
1163 But then there are some where it would just be deadly - like org-mode,
1164 gnus, so we have a list of modes where we don't want to see it.
1165 #+BEGIN_SRC emacs-lisp tangle:yes
1167 (setq linum-format "%3d ")
1168 (setq linum-mode-inhibit-modes-list '(org-mode
1175 (defadvice linum-on (around linum-on-inhibit-for-modes)
1176 "Stop the load of linum-mode for some major modes."
1177 (unless (member major-mode linum-mode-inhibit-modes-list)
1180 (ad-activate 'linum-on)
1181 (global-linum-mode 1)
1185 #+BEGIN_SRC emacs-lisp tangle:yes
1186 (autoload 'css-mode "css-mode")
1187 (add-auto-mode 'css-mode "\\.css")
1191 (require 'flymake-css)
1192 (defun maybe-flymake-css-load ()
1193 "Activate flymake-css as necessary, but not in derived modes."
1194 (when (eq major-mode 'css-mode)
1195 (flymake-css-load)))
1196 (add-hook 'css-mode-hook 'maybe-flymake-css-load)
1197 ;;; Auto-complete CSS keywords
1198 (eval-after-load 'auto-complete
1200 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
1201 (add-hook hook 'ac-css-mode-setup)))))
1205 [2013-05-21 Tue 23:39]
1206 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
1207 coexist in one buffer.
1208 #+BEGIN_SRC emacs-lisp tangle:yes
1210 (setq mmm-global-mode 'buffers-with-submode-classes)
1211 (setq mmm-submode-decoration-level 2)
1212 (eval-after-load 'mmm-vars
1218 :face mmm-code-submode-face
1219 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
1220 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
1221 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
1222 @ "\n" _ "\n" @ "</script>" @)))
1225 :face mmm-code-submode-face
1226 :front "<style[^>]*>[ \t]*\n?"
1227 :back "[ \t]*</style>"
1228 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
1229 @ "\n" _ "\n" @ "</style>" @)))
1232 :face mmm-code-submode-face
1235 (dolist (mode (list 'html-mode 'nxml-mode))
1236 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
1237 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
1243 Instead of default /html-mode/ I use /html-helper-mode/.
1244 #+BEGIN_SRC emacs-lisp tangle:yes
1245 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
1246 (add-auto-mode 'html-helper-mode "\\.html$")
1247 (add-auto-mode 'html-helper-mode "\\.asp$")
1248 (add-auto-mode 'html-helper-mode "\\.phtml$")
1249 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
1250 (defalias 'html-mode 'html-helper-mode)
1254 #+BEGIN_SRC emacs-lisp tangle:yes
1255 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
1256 (setq TeX-auto-save t)
1257 (setq TeX-parse-self t)
1258 (setq TeX-PDF-mode t)
1262 #+BEGIN_SRC emacs-lisp tangle:yes
1263 (require 'dpkg-dev-el-loaddefs nil 'noerror)
1264 (require 'debian-el-loaddefs nil 'noerror)
1266 (setq debian-changelog-full-name "Joerg Jaspert")
1267 (setq debian-changelog-mailing-address "joerg@debian.org")
1271 *** General settings
1272 [2013-04-28 So 17:06]
1274 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
1275 it is quite extensive. Nevertheless, it starts out small, loading it.
1276 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1280 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
1281 that we need org-protocol.
1282 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1283 (require 'org-protocol)
1288 My current =org-agenda-files= variable only includes a set of
1290 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1291 (setq org-agenda-files (quote ("~/org/"
1297 (setq org-default-notes-file "~/org/notes.org")
1299 =org-mode= manages the =org-agenda-files= variable automatically using
1300 =C-c [= and =C-c ]= to add and remove files respectively. However,
1301 this replaces my directory list with a list of explicit filenames
1302 instead and is not what I want. If this occurs then adding a new org
1303 file to any of the above directories will not contribute to my agenda
1304 and I will probably miss something important.
1306 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
1307 prevent messing up my list of directories in the =org-agenda-files=
1308 variable. I just add and remove directories manually here. Changing
1309 the list of directories in =org-agenda-files= happens very rarely
1310 since new files in existing directories are automatically picked up.
1312 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1313 ;; Keep tasks with dates on the global todo lists
1314 (setq org-agenda-todo-ignore-with-date nil)
1316 ;; Keep tasks with deadlines on the global todo lists
1317 (setq org-agenda-todo-ignore-deadlines nil)
1319 ;; Keep tasks with scheduled dates on the global todo lists
1320 (setq org-agenda-todo-ignore-scheduled nil)
1322 ;; Keep tasks with timestamps on the global todo lists
1323 (setq org-agenda-todo-ignore-timestamp nil)
1325 ;; Remove completed deadline tasks from the agenda view
1326 (setq org-agenda-skip-deadline-if-done t)
1328 ;; Remove completed scheduled tasks from the agenda view
1329 (setq org-agenda-skip-scheduled-if-done t)
1331 ;; Remove completed items from search results
1332 (setq org-agenda-skip-timestamp-if-done t)
1334 ;; Include agenda archive files when searching for things
1335 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
1337 ;; Show all future entries for repeating tasks
1338 (setq org-agenda-repeating-timestamp-show-all t)
1340 ;; Show all agenda dates - even if they are empty
1341 (setq org-agenda-show-all-dates t)
1343 ;; Sorting order for tasks on the agenda
1344 (setq org-agenda-sorting-strategy
1345 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
1346 (todo category-up priority-down effort-up)
1347 (tags category-up priority-down effort-up)
1348 (search category-up))))
1350 ;; Start the weekly agenda on Monday
1351 (setq org-agenda-start-on-weekday 1)
1353 ;; Enable display of the time grid so we can see the marker for the current time
1354 (setq org-agenda-time-grid (quote ((daily today remove-match)
1355 #("----------------" 0 16 (org-heading t))
1356 (0800 1000 1200 1400 1500 1700 1900 2100))))
1358 ;; Display tags farther right
1359 (setq org-agenda-tags-column -102)
1361 ; position the habit graph on the agenda to the right of the default
1362 (setq org-habit-graph-column 50)
1364 ; turn habits back on
1365 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
1368 ;; Agenda sorting functions
1370 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
1373 (setq org-deadline-warning-days 30)
1375 ;; Always hilight the current agenda line
1376 (add-hook 'org-agenda-mode-hook
1377 '(lambda () (hl-line-mode 1))
1381 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1382 (setq org-agenda-persistent-filter t)
1383 (add-hook 'org-agenda-mode-hook
1384 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
1387 (add-hook 'org-agenda-mode-hook
1388 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
1391 (add-hook 'org-agenda-mode-hook
1392 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
1395 (add-hook 'org-agenda-mode-hook
1396 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
1399 (add-hook 'org-agenda-mode-hook
1400 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
1403 ; Rebuild the reminders everytime the agenda is displayed
1404 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
1406 ;(if (file-exists-p "~/org/refile.org")
1407 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
1409 ; Activate appointments so we get notifications
1412 (setq org-agenda-log-mode-items (quote (closed clock state)))
1413 (if (> emacs-major-version 23)
1414 (setq org-agenda-span 3)
1415 (setq org-agenda-ndays 3))
1417 (setq org-agenda-show-all-dates t)
1418 (setq org-agenda-start-on-weekday nil)
1419 (setq org-deadline-warning-days 14)
1422 *** Global keybindings.
1423 Start off by defining a series of keybindings.
1425 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
1426 setup manually, not by org-mode. Also turn off =C-c ;=, which
1427 comments headlines - a function never used.
1428 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1429 (add-hook 'org-mode-hook
1431 (org-defkey org-mode-map "\C-c[" 'undefined)
1432 (org-defkey org-mode-map "\C-c]" 'undefined)
1433 (org-defkey org-mode-map "\C-c;" 'undefined))
1437 And now a largish set of keybindings...
1438 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1439 (global-set-key "\C-cl" 'org-store-link)
1440 (global-set-key "\C-ca" 'org-agenda)
1441 (global-set-key "\C-cb" 'org-iswitchb)
1442 (define-key mode-specific-map [?a] 'org-agenda)
1444 (global-set-key (kbd "<f12>") 'org-agenda)
1445 (global-set-key (kbd "<f5>") 'bh/org-todo)
1446 (global-set-key (kbd "<S-f5>") 'bh/widen)
1447 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
1448 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
1450 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
1451 (global-set-key (kbd "<f9> b") 'bbdb)
1452 (global-set-key (kbd "<f9> c") 'calendar)
1453 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
1454 (global-set-key (kbd "<f9> h") 'bh/hide-other)
1455 (global-set-key (kbd "<f9> n") 'org-narrow-to-subtree)
1456 (global-set-key (kbd "<f9> w") 'widen)
1457 (global-set-key (kbd "<f9> u") 'bh/narrow-up-one-level)
1458 (global-set-key (kbd "<f9> I") 'bh/punch-in)
1459 (global-set-key (kbd "<f9> O") 'bh/punch-out)
1460 (global-set-key (kbd "<f9> H") 'jj/punch-in-hw)
1461 (global-set-key (kbd "<f9> W") 'jj/punch-out-hw)
1462 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
1463 (global-set-key (kbd "<f9> p") 'bh/phone-call)
1464 (global-set-key (kbd "<f9> r") 'boxquote-region)
1465 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
1466 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
1467 (global-set-key (kbd "<f9> T") 'tabify)
1468 (global-set-key (kbd "<f9> U") 'untabify)
1469 (global-set-key (kbd "<f9> v") 'visible-mode)
1470 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
1471 (global-set-key (kbd "C-<f9>") 'previous-buffer)
1472 (global-set-key (kbd "C-<f10>") 'next-buffer)
1473 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
1474 (global-set-key (kbd "C-x n r") 'narrow-to-region)
1475 (global-set-key (kbd "<f11>") 'org-clock-goto)
1476 (global-set-key (kbd "C-<f11>") 'org-clock-in)
1477 (global-set-key (kbd "C-M-r") 'org-capture)
1478 (global-set-key (kbd "C-c r") 'org-capture)
1479 (global-set-key (kbd "C-S-<f12>") 'bh/save-then-publish)
1481 (define-key org-mode-map [(control k)] 'jj-org-kill-line)
1484 *** Tasks, States, Todo fun
1486 First we define the global todo keywords.
1487 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1488 (setq org-todo-keywords
1489 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
1490 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
1492 (setq org-todo-keyword-faces
1493 (quote (("TODO" :foreground "red" :weight bold)
1494 ("NEXT" :foreground "light blue" :weight bold)
1495 ("DONE" :foreground "forest green" :weight bold)
1496 ("WAITING" :foreground "orange" :weight bold)
1497 ("HOLD" :foreground "orange" :weight bold)
1498 ("DELEGATED" :foreground "yellow" :weight bold)
1499 ("CANCELLED" :foreground "dark green" :weight bold)
1500 ("PHONE" :foreground "dark green" :weight bold))))
1503 **** Fast Todo Selection
1504 Fast todo selection allows changing from any task todo state to any
1505 other state directly by selecting the appropriate key from the fast
1506 todo selection key menu.
1507 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1508 (setq org-use-fast-todo-selection t)
1510 Changing a task state is done with =C-c C-t KEY=
1512 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
1515 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1516 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1518 allows changing todo states with S-left and S-right skipping all of
1519 the normal processing when entering or leaving a todo state. This
1520 cycles through the todo states but skips setting timestamps and
1521 entering notes which is very convenient when all you want to do is fix
1522 up the status of an entry.
1524 **** Todo State Triggers
1525 I have a few triggers that automatically assign tags to tasks based on
1526 state changes. If a task moves to =CANCELLED= state then it gets a
1527 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
1528 =CANCELLED= tag. These are used for filtering tasks in agenda views
1529 which I'll talk about later.
1531 The triggers break down to the following rules:
1533 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
1534 - Moving a task to =WAITING= adds a =WAITING= tag
1535 - Moving a task to =HOLD= adds a =WAITING= tag
1536 - Moving a task to a done state removes a =WAITING= tag
1537 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
1538 - Moving a task to =NEXT= removes a =WAITING= tag
1539 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
1541 The tags are used to filter tasks in the agenda views conveniently.
1542 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1543 (setq org-todo-state-tags-triggers
1544 (quote (("CANCELLED" ("CANCELLED" . t))
1545 ("WAITING" ("WAITING" . t))
1546 ("HOLD" ("WAITING" . t) ("HOLD" . t))
1547 (done ("WAITING") ("HOLD"))
1548 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1549 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1550 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1553 *** Capturing new tasks
1554 Org capture replaces the old remember mode.
1555 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1556 (setq org-directory "~/org")
1557 (setq org-default-notes-file "~/org/refile.org")
1559 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
1560 ;; see http://orgmode.org/manual/Template-elements.html
1561 (setq org-capture-templates
1562 (quote (("t" "todo" entry (file "~/org/refile.org")
1563 "* TODO %?\nAdded: %U\n"
1564 :clock-in t :clock-resume t)
1565 ("l" "linktodo" entry (file "~/org/refile.org")
1566 "* TODO %?\nAdded: %U\n%a\n"
1567 :clock-in t :clock-resume t)
1568 ("r" "respond" entry (file "~/org/refile.org")
1569 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
1570 :clock-in t :clock-resume t :immediate-finish t)
1571 ("n" "note" entry (file "~/org/refile.org")
1572 "* %? :NOTE:\nAdded: %U\n%a\n"
1573 :clock-in t :clock-resume t)
1574 ("d" "Delegated" entry (file "~/org/refile.org")
1575 "* DELEGATED %?\nAdded: %U\n%a\n"
1576 :clock-in t :clock-resume t)
1577 ("j" "Journal" entry (file+datetree "~/org/diary.org")
1579 :clock-in t :clock-resume t)
1580 ("w" "org-protocol" entry (file "~/org/refile.org")
1581 "* TODO Review %c\nAdded: %U\n"
1582 :immediate-finish t)
1583 ("p" "Phone call" entry (file "~/org/refile.org")
1584 "* PHONE %? :PHONE:\nAdded: %U"
1585 :clock-in t :clock-resume t)
1586 ("x" "Bookmark link" entry (file "~/org/refile.org")
1587 "* Bookmark: %c\n%i\nAdded: %U\n"
1588 :immediate-finish t)
1589 ("h" "Habit" entry (file "~/org/refile.org")
1590 "* 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")
1594 Capture mode now handles automatically clocking in and out of a
1595 capture task. This all works out of the box now without special hooks.
1596 When I start a capture mode task the task is clocked in as specified
1597 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
1598 resumes on the original clocking task.
1600 The quick clocking in and out of capture mode tasks (often it takes
1601 less than a minute to capture some new task details) can leave
1602 empty clock drawers in my tasks which aren't really useful.
1603 The following prevents this.
1604 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1605 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1609 All my newly captured entries end up in =refile.org= and want to be
1610 moved over to the right place. The following is the setup for it.
1611 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1612 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1613 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1614 (org-agenda-files :maxlevel . 9))))
1616 ; Use full outline paths for refile targets - we file directly with IDO
1617 (setq org-refile-use-outline-path t)
1619 ; Targets complete directly with IDO
1620 (setq org-outline-path-complete-in-steps nil)
1622 ; Allow refile to create parent tasks with confirmation
1623 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1625 ; Use IDO for both buffer and file completion and ido-everywhere to t
1626 (setq org-completion-use-ido t)
1627 (setq org-completion-use-iswitchb nil)
1628 :; Use IDO for both buffer and file completion and ido-everywhere to t
1629 ;(setq ido-everywhere t)
1630 ;(setq ido-max-directory-size 100000)
1631 ;(ido-mode (quote both))
1632 ; Use the current window when visiting files and buffers with ido
1633 (setq ido-default-file-method 'selected-window)
1634 (setq ido-default-buffer-method 'selected-window)
1636 ;;;; Refile settings
1637 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1641 Agenda view is the central place for org-mode interaction...
1642 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1643 ;; Do not dim blocked tasks
1644 (setq org-agenda-dim-blocked-tasks nil)
1645 ;; Compact the block agenda view
1646 (setq org-agenda-compact-blocks t)
1648 ;; Custom agenda command definitions
1649 (setq org-agenda-custom-commands
1650 (quote (("N" "Notes" tags "NOTE"
1651 ((org-agenda-overriding-header "Notes")
1652 (org-tags-match-list-sublevels t)))
1653 ("h" "Habits" tags-todo "STYLE=\"habit\""
1654 ((org-agenda-overriding-header "Habits")
1655 (org-agenda-sorting-strategy
1656 '(todo-state-down effort-up category-keep))))
1660 ((org-agenda-overriding-header "Tasks to Refile")
1661 (org-tags-match-list-sublevels nil)))
1662 (tags-todo "-HOLD-CANCELLED/!"
1663 ((org-agenda-overriding-header "Projects")
1664 (org-agenda-skip-function 'bh/skip-non-projects)
1665 (org-agenda-sorting-strategy
1667 (tags-todo "-CANCELLED/!"
1668 ((org-agenda-overriding-header "Stuck Projects")
1669 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
1670 (tags-todo "-WAITING-CANCELLED/!NEXT"
1671 ((org-agenda-overriding-header "Next Tasks")
1672 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1673 (org-agenda-todo-ignore-scheduled t)
1674 (org-agenda-todo-ignore-deadlines t)
1675 (org-agenda-todo-ignore-with-date t)
1676 (org-tags-match-list-sublevels t)
1677 (org-agenda-sorting-strategy
1678 '(todo-state-down effort-up category-keep))))
1679 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
1680 ((org-agenda-overriding-header "Tasks")
1681 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
1682 (org-agenda-todo-ignore-scheduled t)
1683 (org-agenda-todo-ignore-deadlines t)
1684 (org-agenda-todo-ignore-with-date t)
1685 (org-agenda-sorting-strategy
1687 (tags-todo "-CANCELLED+WAITING/!"
1688 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1689 (org-agenda-skip-function 'bh/skip-stuck-projects)
1690 (org-tags-match-list-sublevels nil)
1691 (org-agenda-todo-ignore-scheduled 'future)
1692 (org-agenda-todo-ignore-deadlines 'future)))
1694 ((org-agenda-overriding-header "Tasks to Archive")
1695 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1696 (org-tags-match-list-sublevels nil))))
1698 ("r" "Tasks to Refile" tags "REFILE"
1699 ((org-agenda-overriding-header "Tasks to Refile")
1700 (org-tags-match-list-sublevels nil)))
1701 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
1702 ((org-agenda-overriding-header "Stuck Projects")
1703 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
1704 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
1705 ((org-agenda-overriding-header "Next Tasks")
1706 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1707 (org-agenda-todo-ignore-scheduled t)
1708 (org-agenda-todo-ignore-deadlines t)
1709 (org-agenda-todo-ignore-with-date t)
1710 (org-tags-match-list-sublevels t)
1711 (org-agenda-sorting-strategy
1712 '(todo-state-down effort-up category-keep))))
1713 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
1714 ((org-agenda-overriding-header "Tasks")
1715 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
1716 (org-agenda-sorting-strategy
1718 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
1719 ((org-agenda-overriding-header "Projects")
1720 (org-agenda-skip-function 'bh/skip-non-projects)
1721 (org-agenda-sorting-strategy
1723 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
1724 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
1725 (org-tags-match-list-sublevels nil))
1726 ("A" "Tasks to Archive" tags "-REFILE/"
1727 ((org-agenda-overriding-header "Tasks to Archive")
1728 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1729 (org-tags-match-list-sublevels nil))))))
1731 ; Overwrite the current window with the agenda
1732 (setq org-agenda-window-setup 'current-window)
1737 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1739 ;; Resume clocking task when emacs is restarted
1740 (org-clock-persistence-insinuate)
1742 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
1743 (setq org-clock-history-length 36)
1744 ;; Resume clocking task on clock-in if the clock is open
1745 (setq org-clock-in-resume t)
1746 ;; Change tasks to NEXT when clocking in
1747 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1748 ;; Separate drawers for clocking and logs
1749 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1750 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1751 (setq org-clock-into-drawer t)
1752 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1753 (setq org-clock-out-remove-zero-time-clocks t)
1754 ;; Clock out when moving task to a done state
1755 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
1756 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1757 (setq org-clock-persist t)
1758 ;; Do not prompt to resume an active clock
1759 (setq org-clock-persist-query-resume nil)
1760 ;; Enable auto clock resolution for finding open clocks
1761 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1762 ;; Include current clocking task in clock reports
1763 (setq org-clock-report-include-clocking-task t)
1765 ; use discrete minute intervals (no rounding) increments
1766 (setq org-time-stamp-rounding-minutes (quote (1 1)))
1768 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1770 (setq bh/keep-clock-running nil)
1772 (setq org-agenda-clock-consistency-checks
1773 (quote (:max-duration "4:00"
1776 :gap-ok-around ("4:00"))))
1780 **** Setting a default clock task
1781 Per default the =** Organization= task in my tasks.org file receives
1782 misc clock time. This is the task I clock in on when I punch in at the
1783 start of my work day with =F9-I=. Punching-in anywhere clocks in this
1784 Organization task as the default task.
1786 If I want to change the default clocking task I just visit the
1787 new task in any org buffer and clock it in with =C-u C-u C-c C-x
1788 C-i=. Now this new task that collects miscellaneous clock
1789 minutes when the clock would normally stop.
1791 You can quickly clock in the default clocking task with =C-u C-c
1792 C-x C-i d=. Another option is to repeatedly clock out so the
1793 clock moves up the project tree until you clock out the
1794 top-level task and the clock moves to the default task.
1797 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1798 ;; Agenda clock report parameters
1799 (setq org-agenda-clockreport-parameter-plist
1800 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
1802 ;; Agenda log mode items to display (closed and state changes by default)
1803 (setq org-agenda-log-mode-items (quote (closed state)))
1805 **** Task estimates, column view
1806 Setup column view globally with the following headlines
1807 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1808 ; Set default column view headings: Task Effort Clock_Summary
1809 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
1811 Setup the estimate for effort values.
1812 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1813 ; global Effort estimate values
1814 ; global STYLE property values for completion
1815 (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")
1816 ("STYLE_ALL" . "habit"))))
1820 Tags are mostly used for filtering inside the agenda.
1821 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1822 ; Tags with fast selection keys
1823 (setq org-tag-alist (quote ((:startgroup)
1841 ; Allow setting single tags without the menu
1842 (setq org-fast-tag-selection-single-key (quote expert))
1844 ; For tag searches ignore tasks with scheduled and deadline dates
1845 (setq org-agenda-tags-todo-honor-ignore-options t)
1849 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1850 (setq org-archive-mark-done nil)
1851 (setq org-archive-location "%s_archive::* Archived Tasks")
1855 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1856 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
1857 (setq org-plantuml-jar-path "~/java/plantuml.jar")
1859 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
1861 ; Make babel results blocks lowercase
1862 (setq org-babel-results-keyword "results")
1864 (org-babel-do-load-languages
1865 (quote org-babel-load-languages)
1866 (quote ((emacs-lisp . t)
1885 ; Do not prompt to confirm evaluation
1886 ; This may be dangerous - make sure you understand the consequences
1887 ; of setting this -- see the docstring for details
1888 (setq org-confirm-babel-evaluate nil)
1890 ; Use fundamental mode when editing plantuml blocks with C-c '
1891 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
1894 #+BEGIN_SRC emacs-lisp tangle:yes
1895 ;; Don't have images visible on startup, breaks on console
1896 (setq org-startup-with-inline-images nil)
1899 #+BEGIN_SRC emacs-lisp tangle:yes
1900 (add-to-list 'org-structure-template-alist
1901 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
1902 "<comment>\n?\n</comment>"))
1904 **** ditaa, graphviz, etc
1905 Those are all nice tools. Look at
1906 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
1909 *** Publishing and exporting
1912 Org-mode can export to a variety of publishing formats including (but not limited to)
1915 (plain text - but not the original org-mode file)
1919 which enables getting to lots of other formats like ODF, XML, etc
1921 via LaTeX or Docbook
1924 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
1926 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1927 ;; Explicitly load required exporters
1931 ;; FIXME, check the following two
1932 ;(require 'ox-icalendar)
1935 ; experimenting with docbook exports - not finished
1936 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
1937 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
1939 ;; define categories that should be excluded
1940 (setq org-export-exclude-category (list "google" "google"))
1941 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1943 ; define how the date strings look
1944 (setq org-export-date-timestamp-format "%Y-%m-%d")
1945 ; Inline images in HTML instead of producting links to the image
1946 (setq org-html-inline-images t)
1947 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
1948 (setq org-export-with-sub-superscripts nil)
1950 (setq org-html-head-extra (concat
1951 "<link rel=\"stylesheet\" href=\"http://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
1953 (setq org-html-head-include-default-style nil)
1954 ; Do not generate internal css formatting for HTML exports
1955 (setq org-export-htmlize-output-type (quote css))
1956 ; Export with LaTeX fragments
1957 (setq org-export-with-LaTeX-fragments t)
1958 ; Increase default number of headings to export
1959 (setq org-export-headline-levels 6)
1962 (setq org-publish-project-alist
1965 :base-directory "~/.emacs.d/"
1966 :base-extension "org"
1968 :publishing-directory "/develop/www/emacs"
1970 :publishing-function org-html-publish-to-html
1971 :headline-levels 4 ; Just the default for this project.
1977 :base-directory "~/.emacs.d/"
1978 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
1979 :publishing-directory "/develop/www/emacs"
1980 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
1982 :publishing-function org-publish-attachment
1984 ("inherit-org-info-js"
1985 :base-directory "/develop/vcs/org-info-js/"
1987 :base-extension "js"
1988 :publishing-directory "/develop/www/"
1989 :publishing-function org-publish-attachment
1991 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
1996 (setq org-export-with-timestamps nil)
2001 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2002 (setq org-latex-to-pdf-process
2003 '("xelatex -interaction nonstopmode %f"
2004 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
2005 (setq org-export-latex-listings 'minted)
2006 (setq org-latex-listings t)
2008 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
2009 ;; but adapted to use latexmk 4.20 or higher.
2010 (defun my-auto-tex-cmd ()
2011 "When exporting from .org with latex, automatically run latex,
2012 pdflatex, or xelatex as appropriate, using latexmk."
2014 ;; default command: oldstyle latex via dvi
2015 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
2017 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
2018 (setq texcmd "latexmk -pdf -quiet %f"))
2020 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
2021 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
2022 ;; LaTeX compilation command
2023 (setq org-latex-to-pdf-process (list texcmd)))
2025 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
2027 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
2028 (setq org-export-latex-packages-alist
2030 ("" "longtable" nil)
2035 (defun my-auto-tex-parameters ()
2036 "Automatically select the tex packages to include."
2037 ;; default packages for ordinary latex or pdflatex export
2038 (setq org-export-latex-default-packages-alist
2039 '(("AUTO" "inputenc" t)
2049 ("" "hyperref" nil)))
2051 ;; Packages to include when xelatex is used
2052 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
2053 (setq org-export-latex-default-packages-alist
2058 ("german" "babel" t)
2059 ("babel" "csquotes" t)
2061 ("xetex" "hyperref" nil)
2064 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
2065 (setq org-export-latex-classes
2067 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
2068 ("\\section{%s}" . "\\section*{%s}")
2069 ("\\subsection{%s}" . "\\subsection*{%s}")
2070 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2071 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2072 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
2073 org-export-latex-classes))))
2075 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
2078 *** Prevent editing invisible text
2079 The following setting prevents accidentally editing hidden text when
2080 the point is inside a folded region. This can happen if you are in
2081 the body of a heading and globally fold the org-file with =S-TAB=
2083 I find invisible edits (and undo's) hard to deal with so now I can't
2084 edit invisible text. =C-c C-r= (org-reveal) will display where the
2085 point is if it is buried in invisible text to allow editing again.
2087 #+BEGIN_SRC emacs-lisp tangle:yes :tangle yes
2088 (setq org-catch-invisible-edits 'error)
2092 #+BEGIN_SRC emacs-lisp tangle:yes :tangle yes
2093 ;; disable the default org-mode stuck projects agenda view
2094 (setq org-stuck-projects (quote ("" nil nil "")))
2096 ; force showing the next headline.
2097 (setq org-show-entry-below (quote ((default))))
2099 (setq org-show-following-heading t)
2100 (setq org-show-hierarchy-above t)
2101 (setq org-show-siblings (quote ((default))))
2103 (setq org-special-ctrl-a/e t)
2104 (setq org-special-ctrl-k t)
2105 (setq org-yank-adjusted-subtrees t)
2107 (setq org-table-export-default-format "orgtbl-to-csv")
2111 The following setting adds alphabetical lists like
2115 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2116 (setq org-alphabetical-lists t)
2119 #+BEGIN_SRC emacs-lisp tangle:yes :tangle yes
2120 (setq org-remove-highlights-with-change nil)
2122 (setq org-list-demote-modify-bullet (quote (("+" . "-")
2129 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
2132 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
2133 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
2138 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2139 ;; Enable abbrev-mode
2140 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
2141 (setq org-startup-indented t)
2142 (setq org-startup-folded t)
2143 (setq org-cycle-separator-lines 0)
2146 I find extra blank lines in lists and headings a bit of a nuisance.
2147 To get a body after a list you need to include a blank line between
2148 the list entry and the body -- and indent the body appropriately.
2149 Most of my lists have no body detail so I like the look of collapsed
2150 lists with no blank lines better.
2152 The following setting prevents creating blank lines before headings
2153 but allows list items to adapt to existing blank lines around the items:
2154 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2155 (setq org-blank-before-new-entry (quote ((heading)
2156 (plain-list-item . auto))))
2159 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2160 (setq org-reverse-note-order nil)
2161 (setq org-default-notes-file "~/notes.org")
2164 Enforce task blocking. Tasks can't go done when there is any subtask
2165 still open. Unless they have a property of =NOBLOCKING: t=
2166 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2167 (setq org-enforce-todo-checkbox-dependencies t)
2168 (setq org-enforce-todo-dependencies t)
2171 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2172 (setq org-fast-tag-selection-single-key (quote expert))
2173 (setq org-footnote-auto-adjust t)
2174 (setq org-hide-block-startup t)
2175 (setq org-icalendar-alarm-time 15)
2176 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
2177 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
2178 (setq org-icalendar-honor-noexport-tag t)
2179 (setq org-icalendar-include-bbdb-anniversaries nil)
2180 (setq org-icalendar-include-body 200)
2181 (setq org-icalendar-include-todo nil)
2182 (setq org-icalendar-store-UID t)
2183 (setq org-icalendar-timezone "Europe/Berlin")
2184 (setq org-insert-mode-line-in-empty-file t)
2185 (setq org-log-done (quote note))
2186 (setq org-log-into-drawer t)
2187 (setq org-log-state-notes-insert-after-drawers nil)
2188 (setq org-log-reschedule (quote time))
2189 (setq org-log-states-order-reversed t)
2190 (setq org-mobile-agendas (quote all))
2191 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
2192 (setq org-mobile-inbox-for-pull "~/org/refile.org")
2193 (setq org-remember-store-without-prompt t)
2194 (setq org-return-follows-link t)
2195 (setq org-reverse-note-order t)
2197 ; regularly save our org-mode buffers
2198 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
2200 (setq org-log-done t)
2202 (setq org-enable-priority-commands t)
2203 (setq org-default-priority ?E)
2204 (setq org-lowest-priority ?E)
2209 Speed commands enable single-letter commands in Org-mode files when
2210 the point is at the beginning of a headline, or at the beginning of a
2213 See the `=org-speed-commands-default=' variable for a list of the keys
2214 and commands enabled at the beginning of headlines. All code blocks
2215 are available at the beginning of a code block, the following key
2216 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
2217 display a list of the code blocks commands and their related keys.
2219 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2220 (setq org-use-speed-commands t)
2221 (setq org-speed-commands-user (quote (("0" . ignore)
2234 ("h" . bh/hide-other)
2237 (call-interactively 'org-insert-heading-respect-content))
2238 ("k" . org-kill-note-or-show-branches)
2241 ("q" . bh/show-org-agenda)
2243 ("s" . org-save-all-org-buffers)
2247 ("z" . org-add-note)
2252 ("F" . bh/restrict-to-file-or-follow)
2255 ("J" . org-clock-goto)
2259 ("N" . bh/narrow-to-org-subtree)
2260 ("P" . bh/narrow-to-org-project)
2265 ("U" . bh/narrow-up-one-org-level)
2272 (add-hook 'org-agenda-mode-hook
2274 (define-key org-agenda-mode-map "q" 'bury-buffer))
2277 (defvar bh/current-view-project nil)
2278 (add-hook 'org-agenda-mode-hook
2279 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
2283 The following displays the contents of code blocks in Org-mode files
2284 using the major-mode of the code. It also changes the behavior of
2285 =TAB= to as if it were used in the appropriate major mode. This means
2286 that reading and editing code form inside of your Org-mode files is
2287 much more like reading and editing of code using its major mode.
2289 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2290 (setq org-src-fontify-natively t)
2291 (setq org-src-tab-acts-natively t)
2294 #+BEGIN_SRC emacs-lisp tangle:yes :tangle yes
2295 (setq org-src-preserve-indentation nil)
2296 (setq org-edit-src-content-indentation 0)
2300 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2301 (setq org-attach-directory "~/org/data/")
2303 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2304 (setq org-agenda-sticky t)
2307 **** Checklist handling
2308 [2013-05-11 Sat 22:15]
2310 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2311 (require 'org-checklist)
2315 For some reason I prefer this mode more than the way without. I want to
2316 see the marked region.
2317 #+BEGIN_SRC emacs-lisp tangle:yes
2318 (transient-mark-mode 1)
2321 I know that this lets it look "more like windows", but I don't much care
2322 about its paste/copy/cut keybindings, the really nice part is the great
2323 support for rectangular regions, which I started to use a lot since I
2324 know this mode. The normal keybindings for those are just to useless.
2325 #+BEGIN_SRC emacs-lisp tangle:yes
2327 (setq cua-enable-cua-keys (quote shift))
2330 Luckily cua-mode easily supports this, with the following line I just
2331 get the CUA selection and rectangle stuff, not the keybindings. Yes,
2332 even though the above =cua-enable-cua-keys= setting would only enable
2333 them if the selection is done when the region was marked with a shifted
2335 #+BEGIN_SRC emacs-lisp tangle:yes
2336 (cua-selection-mode t)
2340 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2343 #+BEGIN_SRC emacs-lisp tangle:yes
2344 (autoload 'mo-git-blame-file "mo-git-blame" nil t)
2345 (autoload 'mo-git-blame-current "mo-git-blame" nil t)
2349 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2351 I want to access it from anywhere using =F6=.
2352 #+BEGIN_SRC emacs-lisp tangle:yes
2353 (autoload 'mingus "mingus-stays-home" nil t)
2354 (global-set-key (kbd "<f6>") 'mingus)
2356 (setq mingus-dired-add-keys t)
2357 (setq mingus-mode-always-modeline nil)
2358 (setq mingus-mode-line-show-elapsed-percentage nil)
2359 (setq mingus-mode-line-show-volume nil)
2360 (setq mingus-mpd-config-file "/etc/mpd.conf")
2361 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2362 (setq mingus-mpd-root "/share/music/"))
2366 [2013-05-22 Wed 22:40]
2367 Save and restore the desktop
2368 #+BEGIN_SRC emacs-lisp tangle:yes
2369 (setq desktop-path (list jj-cache-dir))
2370 (desktop-save-mode 1)
2371 (defadvice desktop-read (around trace-desktop-errors activate)
2372 (let ((debug-on-error t))
2376 ;;----------------------------------------------------------------------------
2377 ;; Restore histories and registers after saving
2378 ;;----------------------------------------------------------------------------
2381 (setq session-save-file (expand-file-name "session" jj-cache-dir))
2382 (add-hook 'after-init-hook 'session-initialize)
2384 ;; save a bunch of variables to the desktop file
2385 ;; for lists specify the len of the maximal saved data also
2386 (setq desktop-globals-to-save
2387 (append '((extended-command-history . 30)
2388 (file-name-history . 100)
2390 (compile-history . 30)
2391 (minibuffer-history . 50)
2392 (query-replace-history . 60)
2393 (read-expression-history . 60)
2394 (regexp-history . 60)
2395 (regexp-search-ring . 20)
2397 (comint-input-ring . 50)
2398 (shell-command-history . 50)
2400 desktop-missing-file-warning
2406 [2013-04-21 So 20:25]
2407 Save a bit of history
2408 #+BEGIN_SRC emacs-lisp tangle no
2410 (setq savehist-additional-variables
2411 '(search ring regexp-search-ring kill-ring compile-history))
2412 ;; save every minute
2413 (setq savehist-autosave-interval 60)
2414 (setq savehist-file (expand-file-name "savehist" jj-cache-dir))
2419 Store at which point I have been in files.
2420 #+BEGIN_SRC emacs-lisp tangle:yes
2421 (setq-default save-place t)
2422 (require 'saveplace)
2423 (setq save-place-file (expand-file-name "saved-places" jj-cache-dir))
2426 EasyPG is a GnuPG interface for Emacs.
2427 #+BEGIN_SRC emacs-lisp tangle:yes
2432 I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
2433 #+BEGIN_SRC emacs-lisp tangle:yes
2434 (defadvice epg--start (around advice-epg-disable-agent disable)
2435 "Don't allow epg--start to use gpg-agent in plain text
2437 (if (display-graphic-p)
2439 (let ((agent (getenv "GPG_AGENT_INFO")))
2440 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
2442 (setenv "GPG_AGENT_INFO" agent))))
2443 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
2444 (ad-activate 'epg--start)
2447 #+BEGIN_SRC emacs-lisp tangle:yes
2449 (setq message-kill-buffer-on-exit t)
2452 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
2453 what I want every emacs to know.
2454 #+BEGIN_SRC emacs-lisp tangle:yes
2455 ;;*** Keyboardmacros
2456 (global-unset-key "\M-n")
2457 (global-set-key "\M-n" 'gnus) ; Start gnus with M-n
2464 url contains code to parse and handle URLs - who would have thought? I
2465 set it to send Accept-language header and tell it to not send email,
2466 operating system or location info.
2467 #+BEGIN_SRC emacs-lisp tangle:yes
2468 (setq url-mime-language-string "de,en")
2469 (setq url-privacy-level (quote (email os lastloc)))
2472 Crazy way of completion. It looks at the word before point and then
2473 tries to expand it in various ways.
2474 #+BEGIN_SRC emacs-lisp tangle:yes
2475 (require 'hippie-exp)
2476 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
2477 try-expand-dabbrev-all-buffers
2478 try-expand-dabbrev-from-kill
2479 try-complete-file-name-partially
2480 try-complete-file-name
2481 try-expand-all-abbrevs try-expand-list
2483 try-complete-lisp-symbol-partially
2484 try-complete-lisp-symbol))
2485 (global-set-key (kbd "M-/") 'hippie-expand)
2488 [2013-04-27 Sa 23:16]
2489 Yasnippet is a template system. Type an abbreviation, expand it into
2490 whatever the snippet holds.
2491 #+BEGIN_SRC emacs-lisp tangle:yes
2492 (setq yas-snippet-dirs (expand-file-name "yasnippet/snippets" jj-elisp-dir))
2493 (require 'yasnippet)
2496 ;; Integrate hippie-expand with ya-snippet
2497 (add-to-list 'hippie-expand-try-functions-list
2498 'yas-hippie-try-expand)
2501 The Emacs Lisp Package Archive (may) contain(s) some things I
2502 want. Even though I usually only use it to get the package, then when I
2503 like it move it into my own space. My elpa subdir stays empty.
2504 #+BEGIN_SRC emacs-lisp tangle:yes
2505 (when (> emacs-major-version 23)
2507 (setq package-user-dir (expand-file-name "elpa" jj-cache-dir))
2508 (package-initialize)
2509 (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
2510 (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
2514 [2013-04-08 Mon 23:57]
2515 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2516 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2517 #+BEGIN_SRC emacs-lisp tangle:yes
2518 (safe-load (concat jj-elisp-dir "/multiple-cursors/multiple-cursors-autoloads.el"))
2519 (define-key region-bindings-mode-map "a" 'mc/mark-all-like-this)
2520 (define-key region-bindings-mode-map "p" 'mc/mark-previous-like-this)
2521 (define-key region-bindings-mode-map "n" 'mc/mark-next-like-this)
2522 (define-key region-bindings-mode-map "l" 'mc/edit-lines)
2523 (define-key region-bindings-mode-map "m" 'mc/mark-more-like-this-extended)
2524 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))
2526 ** rainbow-delimiters
2527 [2013-04-09 Di 23:38]
2528 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
2529 which highlights parens, brackets, and braces according to their
2530 depth. Each successive level is highlighted a different color. This
2531 makes it easy to spot matching delimiters, orient yourself in the code,
2532 and tell which statements are at the same depth.
2533 #+BEGIN_SRC emacs-lisp tangle:yes
2534 (when (require 'rainbow-delimiters nil 'noerror)
2535 (global-rainbow-delimiters-mode))
2538 [2013-04-21 So 11:07]
2539 Emacs undo is pretty powerful - but can also be confusing. There are
2540 tons of modes available to change it, even downgrade it to the very
2541 crappy ways one usually knows from other systems which lose
2542 information. undo-tree is different - it helps keeping you sane while
2543 keeping the full power of emacs undo/redo.
2544 #+BEGIN_SRC emacs-lisp tangle:yes
2545 (require 'undo-tree)
2546 (global-undo-tree-mode)
2547 (diminish 'undo-tree-mode)
2550 Additionally I would like to keep the region active should I undo
2553 #+BEGIN_SRC emacs-lisp tangle:yes
2554 ;; Keep region when undoing in region
2555 (defadvice undo-tree-undo (around keep-region activate)
2557 (let ((m (set-marker (make-marker) (mark)))
2558 (p (set-marker (make-marker) (point))))
2567 [2013-04-21 So 20:27]
2568 Use hyper + arrow keys to switch between visible buffers
2569 #+BEGIN_SRC emacs-lisp tangle:yes
2571 (windmove-default-keybindings 'hyper)
2572 (setq windmove-wrap-around t)
2574 ** volatile highlights
2575 [2013-04-21 So 20:31]
2576 VolatileHighlights highlights changes to the buffer caused by commands
2577 such as ‘undo’, ‘yank’/’yank-pop’, etc. The highlight disappears at the
2578 next command. The highlighting gives useful visual feedback for what
2579 your operation actually changed in the buffer.
2580 #+BEGIN_SRC emacs-lisp tangle:yes
2581 (require 'volatile-highlights)
2582 (volatile-highlights-mode t)
2583 (diminish 'volatile-highlights-mode)
2586 [2013-04-21 So 20:36]
2587 ediff - don't start another frame
2590 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
2594 #+BEGIN_SRC emacs-lisp tangle:yes
2595 (require 're-builder)
2596 (setq reb-re-syntax 'string)
2599 [2013-04-21 So 20:48]
2600 magit is a mode for interacting with git.
2601 #+BEGIN_SRC emacs-lisp tangle:yes
2602 (require 'magitload)
2603 ;(require 'magit-svn)
2604 (global-set-key (kbd "C-x g") 'magit-status)
2605 (setq magit-commit-signoff t)
2608 ** lisp editing stuff
2609 [2013-04-21 So 21:00]
2610 I'm not doing much of it, except for my emacs and gnus configs, but
2611 then I like it nice too...
2612 #+BEGIN_SRC emacs-lisp tangle:yes
2613 (define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
2616 (setq lisp-coding-hook 'lisp-coding-defaults)
2617 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2620 '(diminish 'paredit-mode " π"))
2622 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2623 (add-hook 'emacs-lisp-mode-hook (lambda ()
2624 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2626 (define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
2628 (after "elisp-slime-nav"
2629 '(diminish 'elisp-slime-nav-mode))
2630 (after "rainbow-mode"
2631 '(diminish 'rainbow-mode))
2633 '(diminish 'eldoc-mode))
2637 This highlights some /weaselwords/, a mode to /aid in finding common
2638 writing problems/...
2639 [2013-04-27 Sa 23:29]
2640 #+BEGIN_SRC emacs-lisp tangle:yes
2641 (require 'writegood-mode)
2642 (global-set-key "\C-cg" 'writegood-mode)
2644 ** auto-complete mode
2645 [2013-04-27 Sa 16:33]
2646 And aren't we all lazy? I definitely am, and I like my emacs doing as
2647 much possible work for me as it can.
2648 So here, auto-complete-mode, which lets emacs do this, based on what I
2650 #+BEGIN_SRC emacs-lisp tangle:yes
2651 (require 'auto-complete)
2652 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
2653 (global-auto-complete-mode t)
2655 (setq ac-expand-on-auto-complete nil)
2657 (setq ac-auto-start t)
2659 ;;----------------------------------------------------------------------------
2660 ;; Use Emacs' built-in TAB completion hooks to trigger AC (Emacs >= 23.2)
2661 ;;----------------------------------------------------------------------------
2662 (setq tab-always-indent 'complete) ;; use 't when auto-complete is disabled
2663 (add-to-list 'completion-styles 'initials t)
2665 ;; hook AC into completion-at-point
2666 (defun sanityinc/auto-complete-at-point ()
2667 (when (and (not (minibufferp))
2668 (fboundp 'auto-complete-mode)
2672 (defun set-auto-complete-as-completion-at-point-function ()
2673 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
2675 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
2677 (require 'ac-dabbrev)
2678 (set-default 'ac-sources
2680 ac-source-dictionary
2681 ac-source-words-in-buffer
2682 ac-source-words-in-same-mode-buffers
2683 ac-source-words-in-all-buffer
2686 (dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
2687 sass-mode yaml-mode csv-mode espresso-mode haskell-mode
2688 html-mode nxml-mode sh-mode smarty-mode clojure-mode
2689 lisp-mode textile-mode markdown-mode tuareg-mode
2690 js3-mode css-mode less-css-mode sql-mode ielm-mode))
2691 (add-to-list 'ac-modes mode))
2693 ;; Exclude very large buffers from dabbrev
2694 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
2695 (< (buffer-size other-buffer) (* 1 1024 1024)))
2697 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
2700 ;; custom keybindings to use tab, enter and up and down arrows
2701 (define-key ac-complete-mode-map "\t" 'ac-expand)
2702 (define-key ac-complete-mode-map "\r" 'ac-complete)
2703 (define-key ac-complete-mode-map "\M-n" 'ac-next)
2704 (define-key ac-complete-mode-map "\M-p" 'ac-previous)
2705 (define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
2707 (setq auto-completion-syntax-alist (quote (global accept . word))) ;; Use space and punctuation to accept the current the most likely completion.
2708 (setq auto-completion-min-chars (quote (global . 3))) ;; Avoid completion for short trivial words.
2709 (setq completion-use-dynamic t)
2711 (add-hook 'latex-mode-hook 'auto-complete-mode)
2712 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
2713 (add-hook 'prog-mode-hook 'auto-complete-mode)
2714 (add-hook 'org-mode-hook 'auto-complete-mode)
2717 [2013-04-28 So 01:13]
2718 YAML is a nice format for data, which is both, human and machine
2719 readable/editable without getting a big headache.
2720 #+BEGIN_SRC emacs-lisp tangle:yes
2721 (require 'yaml-mode)
2722 (add-auto-mode 'yaml-mode "\\.yml$")
2723 (add-auto-mode 'yaml-mode "\\.yaml$")
2724 (add-hook 'yaml-mode-hook
2726 (define-key yaml-mode-map "\C-m" 'newline-and-indent)))
2730 [2013-04-28 So 22:21]
2731 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
2732 As the one time I tried Flymake i wasn't happy, thats easy to
2734 #+BEGIN_SRC emacs-lisp tangle:yes
2735 (when (> emacs-major-version 23)
2737 (add-hook 'after-init-hook #'global-flycheck-mode))
2740 [2013-05-21 Tue 23:18]
2741 #+BEGIN_SRC emacs-lisp tangle:yes
2742 (require 'crontab-mode)
2743 (add-auto-mode 'crontab-mode "\\.?cron\\(tab\\)?\\'")
2747 [2013-05-22 Wed 22:02]
2748 nxml-mode is a major mode for editing XML.
2749 #+BEGIN_SRC emacs-lisp tangle:yes
2754 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2757 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2758 (fset 'xml-mode 'nxml-mode)
2759 (setq nxml-slash-auto-complete-flag t)
2761 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2762 (defun pp-xml-region (begin end)
2763 "Pretty format XML markup in region. The function inserts
2764 linebreaks to separate tags that have nothing but whitespace
2765 between them. It then indents the markup by using nxml's
2771 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2772 (backward-char) (insert "\n"))
2773 (indent-region begin end)))
2775 ;;----------------------------------------------------------------------------
2776 ;; Integration with tidy for html + xml
2777 ;;----------------------------------------------------------------------------
2778 ;; tidy is autoloaded
2779 (eval-after-load 'tidy
2781 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2782 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2787 [2013-05-22 Wed 22:33]
2788 Programming in ruby...
2791 #+BEGIN_SRC emacs-lisp tangle:yes
2792 (add-auto-mode 'ruby-mode
2793 "Rakefile\\'" "\\.rake\\'" "\.rxml\\'"
2794 "\\.rjs\\'" ".irbrc\\'" "\.builder\\'" "\\.ru\\'"
2795 "\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
2799 #+BEGIN_SRC emacs-lisp tangle:yes
2801 (message "ruby has been loaded")
2802 (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
2803 (define-key ruby-mode-map (kbd "TAB") 'indent-for-tab-command)
2805 (require 'ruby-hash-syntax)
2807 (setq ruby-use-encoding-map nil)
2808 ;; Stupidly the non-bundled ruby-mode isn't a derived mode of
2809 ;; prog-mode: we run the latter's hooks anyway in that case.
2810 (add-hook 'ruby-mode-hook
2812 (unless (derived-mode-p 'prog-mode)
2813 (run-hooks 'prog-mode-hook))))
2818 EMMS is the Emacs Multimedia System.
2819 #+BEGIN_SRC emacs-lisp tangle:no
2820 (require 'emms-source-file)
2821 (require 'emms-source-playlist)
2822 (require 'emms-info)
2823 (require 'emms-cache)
2824 (require 'emms-playlist-mode)
2825 (require 'emms-playing-time)
2826 (require 'emms-player-mpd)
2827 (require 'emms-playlist-sort)
2828 (require 'emms-mark)
2829 (require 'emms-browser)
2830 (require 'emms-lyrics)
2831 (require 'emms-last-played)
2832 (require 'emms-score)
2833 (require 'emms-tag-editor)
2834 (require 'emms-history)
2835 (require 'emms-i18n)
2837 (setq emms-playlist-default-major-mode 'emms-playlist-mode)
2838 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
2839 (emms-playing-time 1)
2841 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
2842 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
2844 (when (fboundp 'emms-cache) ; work around compiler warning
2846 (setq emms-score-default-score 3)
2848 (defun emms-mpd-init ()
2849 "Connect Emms to mpd."
2851 (emms-player-mpd-connect))
2854 (require 'emms-player-mpd)
2855 (setq emms-player-mpd-server-name "localhost")
2856 (setq emms-player-mpd-server-port "6600")
2857 (add-to-list 'emms-info-functions 'emms-info-mpd)
2858 (add-to-list 'emms-player-list 'emms-player-mpd)
2859 (setq emms-volume-change-function 'emms-volume-mpd-change)
2860 (setq emms-player-mpd-sync-playlist t)
2862 (setq emms-source-file-default-directory "/var/lib/mpd/music")
2863 (setq emms-player-mpd-music-directory "/var/lib/mpd/music")
2864 (setq emms-info-auto-update t)
2865 (setq emms-lyrics-scroll-p t)
2866 (setq emms-lyrics-display-on-minibuffer t)
2867 (setq emms-lyrics-display-on-modeline nil)
2868 (setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
2870 (setq emms-last-played-format-alist
2871 '(((emms-last-played-seconds-today) . "%H:%M")
2872 (604800 . "%a %H:%M") ; this week
2873 ((emms-last-played-seconds-month) . "%d.%m.%Y")
2874 ((emms-last-played-seconds-year) . "%d.%m.%Y")
2875 (t . "Never played")))
2878 (defun my-describe (track)
2879 (let* ((empty "...")
2880 (name (emms-track-name track))
2881 (type (emms-track-type track))
2882 (short-name (file-name-nondirectory name))
2883 (play-count (or (emms-track-get track 'play-count) 0))
2884 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
2885 (artist (or (emms-track-get track 'info-artist) empty))
2886 (year (emms-track-get track 'info-year))
2887 (playing-time (or (emms-track-get track 'info-playing-time) 0))
2888 (min (/ playing-time 60))
2889 (sec (% playing-time 60))
2890 (album (or (emms-track-get track 'info-album) empty))
2891 (tracknumber (emms-track-get track 'info-tracknumber))
2892 (short-name (file-name-sans-extension
2893 (file-name-nondirectory name)))
2894 (title (or (emms-track-get track 'info-title) short-name))
2895 (rating (emms-score-get-score name))
2898 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
2899 (emms-last-played-format-date last-played)
2903 (if (and tracknumber ; tracknumber
2904 (not (zerop (string-to-number tracknumber))))
2905 (format "%02d" (string-to-number tracknumber))
2909 (make-string rating rate-char)))
2912 (setq emms-track-description-function 'my-describe)
2914 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
2915 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
2916 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
2917 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
2918 (global-set-key (kbd "H-<f9> x") 'emms-start)
2919 (global-set-key (kbd "H-<f9> v") 'emms-stop)
2920 (global-set-key (kbd "H-<f9> n") 'emms-next)
2921 (global-set-key (kbd "H-<f9> p") 'emms-previous)
2922 (global-set-key (kbd "H-<f9> o") 'emms-show)
2923 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
2924 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
2925 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
2926 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
2927 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
2929 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
2930 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
2931 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
2932 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
2934 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
2935 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
2936 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
2937 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
2939 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
2940 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
2941 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
2942 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
2944 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
2945 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
2946 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
2947 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
2948 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
2949 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
2951 (define-key emms-playlist-mode-map "x" 'emms-start)
2952 (define-key emms-playlist-mode-map "v" 'emms-stop)
2953 (define-key emms-playlist-mode-map "n" 'emms-next)
2954 (define-key emms-playlist-mode-map "p" 'emms-previous)
2956 (setq emms-playlist-buffer-name "*EMMS Playlist*"
2957 emms-playlist-mode-open-playlists t)
2963 'emms-browser-artist-face nil
2968 (setq emms-player-mpd-supported-regexp
2969 (or (emms-player-mpd-get-supported-regexp)
2970 (concat "\\`http://\\|"
2971 (emms-player-simple-regexp
2972 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
2973 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
2977 Yet another folding extension for the Emacs editor. Unlike many
2978 others, this one works by just using the existing indentation of the
2979 file, so basically works in every halfway structured file.
2980 #+BEGIN_SRC emacs-lisp tangle:yes
2981 (define-key global-map (kbd "C-#") 'yafolding)
2982 ;;(define-key global-map (kbd "C-c C-f") 'yafolding-toggle-all)
2983 (define-key global-map (kbd "C-c C-f") 'yafolding-toggle-all-by-current-level)
2986 Incremental mini-buffer completion preview: Type in the minibuffer,
2987 list of matching commands is echoed
2988 #+BEGIN_SRC emacs-lisp tangle:yes
2993 And thats it for this file, control passes "back" to [[file:../initjj.org][initjj.org/el]]
2994 which then may load more files.