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
19 (defvar safe-load-error-list ""
20 "*List of files that reported errors when loaded via safe-load")
22 (defun safe-load (file &optional noerror nomessage nosuffix)
23 "Load a file. If error on load, report back, wait for
24 a key stroke then continue on"
26 (condition-case nil (load file noerror nomessage nosuffix)
29 (setq safe-load-error-list (concat safe-load-error-list " " file))
30 (message "****** [Return to continue] Error loading %s" safe-load-error-list )
34 (defun safe-load-check ()
35 "Check for any previous safe-load loading errors. (safe-load.el)"
37 (if (string-equal safe-load-error-list "") ()
38 (message (concat "****** error loading: " safe-load-error-list))))
41 match-paren will either jump to the "other" paren or simply insert %
42 #+BEGIN_SRC emacs-lisp
43 (defun match-paren (arg)
44 "Go to the matching parenthesis if on parenthesis otherwise insert %."
46 (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
47 ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
48 (t (self-insert-command (or arg 1)))))
51 I have some stuff put away in my local dir. I don't want to load it all
52 at startup time, so it is using the autoload feature. For that to work
53 load the loaddefs, so autoload knows where to grab stuff
54 #+BEGIN_SRC emacs-lisp
55 (load-file (concat jj-elisp-dir "/tiny/loaddefs.el"))
56 (load-file (concat jj-elisp-local-dir "/loaddefs.el"))
60 Always ensure to have a scratch buffer around.
61 #+BEGIN_SRC emacs-lisp
63 (set-buffer (get-buffer-create "*scratch*"))
64 (lisp-interaction-mode)
65 (make-local-variable 'kill-buffer-query-functions)
66 (add-hook 'kill-buffer-query-functions 'kill-scratch-buffer))
69 Helpers for the config
70 #+BEGIN_SRC emacs-lisp
71 (require 'use-package)
77 We need to define the load-path. As I have lots of things I add
78 locally, its getting a few entries. I only leave out org-mode here, as
79 that is already done in =init.el=.
81 I also disliked the repeated /add-to-list/ lines, so I now just have
82 one variable and go over that in a loop.
83 #+BEGIN_SRC emacs-lisp
84 (defvar jj-elisp-subdirs '(local gnus icicle org/contrib tiny mo-git-blame cedet
85 cedet/eieio ecb jdee/lisp sunrise multiple-cursors
86 auto-complete yasnippet magit)
87 "List of subdirectories in jj-elisp-dir to add to load-path")
90 (dolist (dirval jj-elisp-subdirs)
91 (let ((name (expand-file-name (symbol-name dirval) jj-elisp-dir)))
92 (when (file-exists-p name)
93 (add-to-list 'load-path name)))))
94 ;; For older emacsen we need an extra directory, which should be at
95 ;; THE END of the load path
96 (when (< emacs-major-version 24)
97 (add-to-list 'load-path (expand-file-name "emacs23" jj-elisp-dir) t))
102 Help emacs to find the info files
103 #+BEGIN_SRC emacs-lisp
104 (setq Info-directory-list '("~/emacs/info"
105 "/usr/local/share/info/"
107 "/usr/local/gnu/info/"
108 "/usr/local/gnu/lib/info/"
109 "/usr/local/gnu/lib/emacs/info/"
110 "/usr/local/emacs/info/"
111 "/usr/local/lib/info/"
112 "/usr/local/lib/emacs/info/"
113 "/usr/share/info/emacs-23"
116 (setq Info-default-directory-list
117 (cons "~/emacs/info" Info-default-directory-list))
123 :ID: 0a1560d9-7e55-47ab-be52-b3a8b8eea4aa
125 I dislike the startup message
126 #+BEGIN_SRC emacs-lisp
127 (setq inhibit-splash-screen t)
128 (setq inhibit-startup-message t)
131 Usually I want the lines to break at 72 characters.
132 #+BEGIN_SRC emacs-lisp
133 (if (> emacs-major-version 22)
134 (setq fill-column 72)
135 (setq default-fill-column 72))
138 And it is nice to have a final newline in files.
139 #+BEGIN_SRC emacs-lisp
140 (setq require-final-newline t)
143 After I typed 300 characters or took a break for more than a minute it
144 would be nice of emacs to save whatever I am on in one of its auto-save
145 backups. See [[info:emacs#Auto%20Save%20Control][info:emacs#Auto Save Control]] for more details.
146 #+BEGIN_SRC emacs-lisp
147 (setq auto-save-interval 300)
148 (setq auto-save-timeout 60)
151 Set my full name and my default mail address - for whatever wants to use
152 it later. Also, I am using gnus.
153 #+BEGIN_SRC emacs-lisp
154 (setq user-full-name "Joerg Jaspert")
155 (setq user-mail-address "joerg@ganneff.de")
156 (setq mail-user-agent (quote gnus-user-agent))
159 My default mail server. Well, simply a localhost, I have a forwarder that
160 puts mail off the right way, no need for emacs to have any further
162 #+BEGIN_SRC emacs-lisp
163 (setq smtpmail-default-smtp-server "localhost")
164 (setq smtpmail-smtp-server "localhost")
167 Enable automatic handling of compressed files.
168 #+BEGIN_SRC emacs-lisp
169 (auto-compression-mode 1)
172 Emacs forbids a certain set of commands, as they can be very confusing
173 for new users. Enable them.
174 #+BEGIN_SRC emacs-lisp
175 (put 'narrow-to-region 'disabled nil)
176 (put 'narrow-to-page 'disabled nil)
177 (put 'narrow-to-defun 'disabled nil)
178 (put 'upcase-region 'disabled nil)
179 (put 'downcase-region 'disabled nil)
183 I've tried various different fonts and while I like the Terminus font
184 most for my shells, in Emacs Inconsolata clearly wins.
185 #+BEGIN_SRC emacs-lisp
186 (if (> emacs-major-version 22)
187 (set-frame-font "Inconsolata-14")
188 (set-default-font "Inconsolata-14"))
191 I always use dark backgrounds, so tell Emacs about it. No need to
193 #+BEGIN_SRC emacs-lisp
194 (setq-default frame-background-mode 'dark)
197 And I always liked dark backgrounds with colors setup for them. So I
198 switched through multiple themes doing it in emacs too, but never
199 entirely liked it. Until I found solarized, which is now not only my
200 emacs theme, but also for most of my other software too, especially my
201 shell. Consistent look is great.
202 #+BEGIN_SRC emacs-lisp
203 (if (boundp 'custom-theme-load-path)
205 (defun jj-init-theme ()
207 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
208 (load-theme 'solarized-light t))
209 (set-face-attribute 'org-date nil :underline nil)
210 (message "Initializing theme solarized-dark")
212 (add-to-list 'custom-theme-load-path jj-theme-dir)
213 (add-hook 'after-init-hook 'jj-init-theme)
215 (message "Emacs version too old, using non-solarize theme")
216 (defvar custom-theme-load-path jj-theme-dir)
217 (require 'naquadah-theme))
220 Make the fringe (gutter) smaller, the argument is a width in pixels (the default is 8)
221 #+BEGIN_SRC emacs-lisp
222 (if (fboundp 'fringe-mode)
227 [2013-04-21 So 20:54]
228 I do not want my cursor to blink.
229 #+BEGIN_SRC emacs-lisp
230 (blink-cursor-mode -1)
232 *** Menu, Tool and Scrollbar
233 I don't want to see the menu-bar, tool-bar or scrollbar.
234 #+BEGIN_SRC emacs-lisp
238 (set-scroll-bar-mode nil))
240 **** When using emacs in daemon mode
241 Emacs has a very nice mode where it detaches itself and runs as daemon -
242 and you can just open /frames/ (windows) from it by using [[http://www.emacswiki.org/emacs/EmacsClient][Emacs
243 Client]]. It's fast, it's nice, it's convinient.
245 Except that Emacs behaves stupid when you do that and ignores your
246 menu/tool/scrollbar settings. Sucks.
248 For them to work even then, we have to do two things.
249 1. We have to set the frame alist. We simple set both,
250 =initial-frame-alist= and =default-frame-alist= to the same value here.
251 #+BEGIN_SRC emacs-lisp
252 (setq initial-frame-alist '(
253 (horizontal-scroll-bars . nil)
254 (vertical-scroll-bars . nil)
257 (setq default-frame-alist (copy-alist initial-frame-alist))
259 2. We have to disable the toolbar using the customize interface, so you
260 can find that in the [[id:0102208d-fdf6-4928-9e40-7e341bd3aa3a][Customized variables]] section.
262 *** Hilight current line in buffer
263 As it says, it does a hilight of the current line.
264 #+BEGIN_SRC emacs-lisp
265 (global-hl-line-mode +1)
267 *** Allow recursive minibuffers
268 This allows (additional) minibuffer commands while in the minibuffer.
269 #+BEGIN_SRC emacs-lisp
270 (setq enable-recursive-minibuffers 't)
273 *** Modeline related changes
274 I want to see line and column numbers, so turn them on.
275 Size indication lets me know how far I am in a buffer.
277 And modeline-posn is great. It will hilight the column number in the
278 modeline in red as soon as you are over the defined limit.
280 #+BEGIN_SRC emacs-lisp
282 (column-number-mode 1)
283 (size-indication-mode 1)
284 (display-time-mode 1)
285 (setq display-time-day-and-date nil)
286 (setq display-time-24hr-format t)
287 (setq modelinepos-column-limit 72)
289 (require 'modeline-posn)
290 (set-face-foreground 'modelinepos-column-warning "grey20")
291 (set-face-background 'modelinepos-column-warning "red")
294 [2013-04-22 Mon 11:27]
295 The modeline is easily cluttered up with stuff I don't really need to
296 see. So lets hide those. There are two ways, one of them uses diminish
297 to get entirely rid of some modes, the other is a function taken from
298 "Mastering Emacs" which replaces the modes text with an own (set of)
300 #+BEGIN_SRC emacs-lisp
302 (diminish 'auto-fill-function)
303 (defvar mode-line-cleaner-alist
304 `((auto-complete-mode . " α")
305 (yas-minor-mode . " y")
306 (paredit-mode . " π")
310 (lisp-interaction-mode . "λ")
313 (emacs-lisp-mode . "EL")
315 (org-indent-mode . "")
317 (nxhtml-mode . "nx"))
319 "Alist for `clean-mode-line'.
321 When you add a new element to the alist, keep in mind that you
322 must pass the correct minor/major mode symbol and a string you
323 want to use in the modeline *in lieu of* the original.
325 Want some symbols? Go:
327 ;ςερτζθιοπασδφγηξκλυχψωβνμ
328 :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
329 @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
333 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
336 Unfortunately icicles breaks this with the way it adds/removes itself,
337 so take it our for now...
340 Back when I started with text-mode. But nowadays I want default mode to
341 be org-mode - it is just so much better to use. And does sensible things
342 with many README files out there, and various other "crap" you get to
344 #+BEGIN_SRC emacs-lisp
345 (if (> emacs-major-version 22)
346 (setq major-mode 'org-mode)
347 (setq default-major-mode 'org-mode))
348 (setq initial-major-mode 'org-mode)
352 [2013-04-23 Tue 16:43]
353 Shell. zsh in my case.
354 #+BEGIN_SRC emacs-lisp
355 (setq shell-file-name "zsh")
356 (setq shell-command-switch "-c")
357 (setq explicit-shell-file-name shell-file-name)
358 (setenv "SHELL" shell-file-name)
359 (setq explicit-sh-args '("-login" "-i"))
360 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
361 (setq comint-scroll-to-bottom-on-input t) ; always insert at the bottom
362 (setq comint-scroll-to-bottom-on-output t) ; always add output at the bottom
363 (setq comint-scroll-show-maximum-output t) ; scroll to show max possible output
364 (setq comint-completion-autolist t) ; show completion list when ambiguous
365 (setq comint-input-ignoredups t) ; no duplicates in command history
366 (setq comint-completion-addsuffix t) ; insert space/slash after file completion
370 Basic settings for emacs integrated shell
371 #+BEGIN_SRC emacs-lisp
372 (setq eshell-cmpl-cycle-completions nil
373 eshell-save-history-on-exit t
374 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
375 (eval-after-load 'esh-opt
380 ;; TODO: for some reason requiring this here breaks it, but
381 ;; requiring it after an eshell session is started works fine.
382 ;; (require 'eshell-vc)
383 (setenv "PAGER" "cat")
384 ; (set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
385 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
386 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
387 (add-hook 'eshell-preoutput-filter-functions
388 'ansi-color-filter-apply)
389 (add-to-list 'eshell-visual-commands "ssh")
390 (add-to-list 'eshell-visual-commands "tail")
391 (add-to-list 'eshell-command-completions-alist
393 (add-to-list 'eshell-command-completions-alist
394 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))))
399 Incremental search is great, but annoyingly you need to type whatever
400 you want. If you want to search for just the next (or previous)
401 occurence of what is at your cursor position use the following.
402 *C-x* will insert the current word while *M-up* and *M-down* will just
403 jump to the next/previous occurence of it.
404 #+BEGIN_SRC emacs-lisp
405 (define-key isearch-mode-map (kbd "C-x") 'sacha/isearch-yank-current-word)
406 (global-set-key '[M-up] 'sacha/search-word-backward)
407 (global-set-key '[M-down] 'sacha/search-word-forward)
410 *** Frame configuration
411 I want to see the buffername and its size, not the host I am on in my
413 #+BEGIN_SRC emacs-lisp
414 (setq frame-title-format "%b (%i)")
417 *** Protect some buffers
418 I don't want some buffers to be killed, **scratch** for example.
419 In the past I had a long function that just recreated them, but the
420 =keep-buffers= package is easier.
421 #+BEGIN_SRC emacs-lisp
422 (require 'keep-buffers)
423 (keep-buffers-mode 1)
424 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
425 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
426 (push '("\\`*Group" . nil) keep-buffers-protected-alist)
430 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
432 #+BEGIN_SRC emacs-lisp
433 (defalias 'yes-or-no-p 'y-or-n-p)
436 *** Language/i18n stuff
437 In this day and age, UTF-8 is the way to go.
438 #+BEGIN_SRC emacs-lisp
439 (set-language-environment 'utf-8)
440 (set-default-coding-systems 'utf-8)
441 (set-terminal-coding-system 'utf-8)
442 (set-keyboard-coding-system 'utf-8)
443 (set-clipboard-coding-system 'utf-8)
444 (prefer-coding-system 'utf-8)
445 (set-charset-priority 'unicode)
446 (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
449 *** Hilight matching parentheses
450 While I do have the nifty shortcut to jump to the other parentheses,
451 hilighting them makes it obvious where they are.
452 #+BEGIN_SRC emacs-lisp
454 (setq show-paren-style 'parenthesis)
457 *** Kill other buffers
458 While many editors allow you to close "all the other files, not the one
459 you are in", emacs doesn't have this... Except, now it will.
460 #+BEGIN_SRC emacs-lisp
461 (global-set-key (kbd "C-c k") 'prelude-kill-other-buffers)
464 Default scrolling behaviour in emacs is a bit annoying, who wants to
466 #+BEGIN_SRC emacs-lisp
467 (setq scroll-margin 0)
468 (setq scroll-conservatively 100000)
469 (setq scroll-up-aggressively 0.0)
470 (setq scroll-down-aggressively 0.0)
471 (setq scroll-preserve-screen-position t)
474 *** Copy/Paste with X
475 [2013-04-09 Di 23:31]
476 The default how emacs handles cutting/pasting with the primary selection
477 changed in emacs24. I am used to the old way, so get it back.
478 #+BEGIN_SRC emacs-lisp
479 (setq x-select-enable-primary t)
480 (setq x-select-enable-clipboard t ;; copy-paste should work ...
481 interprogram-paste-function ;; ...with...
482 'x-cut-buffer-or-selection-value) ;; ...other X clients
486 *** Global keyboard changes not directly related to a mode
487 Disable /suspend_frame/ function, I dislike it.
488 #+BEGIN_SRC emacs-lisp
489 (global-unset-key [(control z)])
490 (global-unset-key [(control x) (control z)])
493 Default of *C-k* is to kill from the point to the end of line. If
494 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
495 set, including newline. But to kill the entire line, one still needs a
496 *C-a* in front of it. So I change it, by defining a function to do just this for
498 #+BEGIN_SRC emacs-lisp
499 (defun kill-entire-line ()
500 "Kill this entire line (including newline), regardless of where point is within the line."
504 (back-to-indentation))
506 (global-unset-key [(control k)])
507 (global-set-key [(control k)] 'kill-entire-line)
508 (global-set-key [remap kill-whole-line] 'kill-entire-line)
511 And the same is true when I'm in org-mode, which has an own kill function...
512 (the keybinding happens later, after org-mode is loaded fully)
513 #+BEGIN_SRC emacs-lisp
514 (defun jj-org-kill-line (&optional arg)
515 "Kill the entire line, regardless of where point is within the line, org-mode-version"
519 (back-to-indentation)
523 I really hate tabs, so I don't want any indentation to try using them.
524 And in case a project really needs them, I can change it just for that
525 file/project, but luckily none of those I work in is as broken.
526 #+BEGIN_SRC emacs-lisp
527 (setq-default indent-tabs-mode nil)
530 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
531 #+BEGIN_SRC emacs-lisp
532 (global-set-key "\M-5" 'match-paren)
535 Instead of the default "mark-defun" I want a more readline-like setting.
536 #+begin_src emacs-lisp
537 (global-set-key (kbd "C-M-h") 'backward-kill-word)
540 Align whatever with a regexp.
541 #+begin_src emacs-lisp
542 (global-set-key (kbd "C-x \\") 'align-regexp)
546 #+begin_src emacs-lisp
547 (global-set-key (kbd "C-+") 'text-scale-increase)
548 (global-set-key (kbd "C--") 'text-scale-decrease)
551 Regexes are too useful, so use the regex search by default.
552 #+begin_src emacs-lisp
553 (global-set-key (kbd "C-s") 'isearch-forward-regexp)
554 (global-set-key (kbd "\C-r") 'isearch-backward-regexp)
555 (global-set-key (kbd "C-M-s") 'isearch-forward)
556 (global-set-key (kbd "C-M-r") 'isearch-backward)
559 Rgrep is infinitely useful in multi-file projects.
560 #+begin_src emacs-lisp
561 (define-key global-map "\C-x\C-g" 'rgrep)
564 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
566 #+BEGIN_SRC emacs-lisp
567 (global-set-key [(meta shift up)] 'move-line-up)
568 (global-set-key [(meta shift down)] 'move-line-down)
571 "Pull" lines up, join them
572 #+BEGIN_SRC emacs-lisp
573 (global-set-key (kbd "M-j")
579 When I press Enter I almost always want to go to the right indentation on the next line.
580 #+BEGIN_SRC emacs-lisp
581 (global-set-key (kbd "RET") 'newline-and-indent)
584 Easier undo, and i don't need suspend-frame
585 #+BEGIN_SRC emacs-lisp
586 (global-set-key (kbd "C-z") 'undo)
589 Window switching, go backwards. (C-x o goes to the next window)
590 #+BEGIN_SRC emacs-lisp
591 (global-set-key (kbd "C-x O") (lambda ()
597 #+BEGIN_SRC emacs-lisp
598 (global-set-key (kbd "C-x C-r") 'prelude-sudo-edit)
601 M-space is bound to just-one-space, which is great for programming. What
602 it does is remove all spaces around the cursor, except for one. But to
603 be really useful, it also should include newlines. It doesn’t do this by
604 default. Rather, you have to call it with a negative argument. Sure
606 #+BEGIN_SRC emacs-lisp
607 (global-set-key (kbd "M-SPC") 'just-one-space-with-newline)
610 Count which commands I use how often.
611 #+BEGIN_SRC emacs-lisp
613 (expand-file-name "keyfreq" jj-cache-dir)
614 "Keyfreq cache file")
615 (defvar keyfreq-file-lock
616 (expand-file-name "keyfreq.lock" jj-cache-dir)
617 "Keyfreq cache file")
620 (keyfreq-autosave-mode 1)
624 [2013-04-28 So 11:26]
625 #+BEGIN_SRC emacs-lisp
626 (autoload 'ace-jump-mode "ace-jump-mode" "Emacs quick move minor mode" t)
627 (define-key global-map (kbd "H-SPC") 'ace-jump-mode)
628 ;; enable a more powerful jump back function from ace jump mode
629 (autoload 'ace-jump-mode-pop-mark "ace-jump-mode" "Ace jump back :-)" t)
630 (eval-after-load "ace-jump-mode" '(ace-jump-mode-enable-mark-sync))
631 (define-key global-map (kbd "H-c SPC") 'ace-jump-mode-pop-mark)
634 Usually you can press the *Ins*ert key, to get into overwrite mode. I
635 don't like that, have broken much with it and so just forbid it by
637 #+BEGIN_SRC emacs-lisp
638 (global-unset-key [insert])
639 (global-unset-key [kp-insert])
642 ** Miscellaneous stuff
643 Emacs should keep backup copies of files I edit, but I do not want them
644 to clutter up the filesystem everywhere. So I put them into one defined
645 place, backup-directory, which even contains my username (for systems
646 where =temporary-file-directory= is not inside my home).
647 #+BEGIN_SRC emacs-lisp
648 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
649 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
651 (setq version-control t) ;; Use version numbers for backups
652 (setq kept-new-versions 10) ;; Number of newest versions to keep
653 (setq kept-old-versions 2) ;; Number of oldest versions to keep
654 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
656 (add-hook 'before-save-hook 'force-backup-of-buffer)
658 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
659 (setq backup-by-copying t)
660 (setq make-backup-files t)
662 (setq backup-enable-predicate
664 (and (normal-backup-enable-predicate name)
666 (let ((method (file-remote-p name 'method)))
667 (when (stringp method)
668 (member method '("su" "sudo"))))))))
672 Weeks start on Monday, not sunday.
673 #+BEGIN_SRC emacs-lisp
674 (setq calendar-week-start-day 1)
677 Searches and matches should ignore case.
678 #+BEGIN_SRC emacs-lisp
679 (setq-default case-fold-search t)
682 Which buffers to get rid off at midnight.
683 #+BEGIN_SRC emacs-lisp
684 (setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
685 "*Man " "*Buffer List*"
691 "*magit" "*Calendar")))
694 Don't display a cursor in non-selected windows.
695 #+BEGIN_SRC emacs-lisp
696 (setq-default cursor-in-non-selected-windows nil)
699 What should be displayed in the mode-line for files with those types
701 #+BEGIN_SRC emacs-lisp
702 (setq eol-mnemonic-dos "(DOS)")
703 (setq eol-mnemonic-mac "(Mac)")
706 Much larger threshold for garbage collection prevents it to run too often.
707 #+BEGIN_SRC emacs-lisp
708 (setq gc-cons-threshold 48000000)
711 #+BEGIN_SRC emacs-lisp
712 (setq max-lisp-eval-depth 1000)
713 (setq max-specpdl-size 3000)
717 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
718 #+BEGIN_SRC emacs-lisp
719 (defun unfill-paragraph ()
720 "Takes a multi-line paragraph and makes it into a single line of text."
722 (let ((fill-column (point-max)))
723 (fill-paragraph nil)))
726 #+BEGIN_SRC emacs-lisp
727 (setq-default indicate-empty-lines t)
730 #+BEGIN_SRC emacs-lisp
731 (setq browse-url-browser-function (quote browse-url-generic))
732 (setq browse-url-generic-program "/usr/bin/x-www-browser")
735 *** When saving a script - make it executable
736 #+BEGIN_SRC emacs-lisp
737 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
741 #+BEGIN_SRC emacs-lisp
745 ** Customized variables
746 [2013-05-02 Thu 22:14]
747 The following contains a set of variables i may reasonably want to
748 change on other systems - which don't affect the init file loading
749 process. So I *can* use the customization interface for it...
750 #+BEGIN_SRC emacs-lisp
751 (defgroup ganneff nil
752 "Modify ganneffs settings"
755 (defgroup ganneff-org-mode nil
756 "Ganneffs org-mode settings"
757 :tag "Ganneffs org-mode settings"
759 :link '(custom-group-link "ganneff"))
761 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
762 "ID of the organization task."
763 :tag "Organization Task ID"
765 :group 'ganneff-org-mode)
767 (defcustom org-my-archive-expiry-days 2
768 "The number of days after which a completed task should be auto-archived.
769 This can be 0 for immediate, or a floating point value."
770 :tag "Archive expiry days"
772 :group 'ganneff-org-mode)
776 * Customized variables
778 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
780 Of course I want to be able to use the customize interface, and some
781 things can only be set via it (or so they say). I usually prefer to put
782 things I keep for a long while into statements somewhere else, not just
783 custom-set here, but we need it anyways.
785 #+BEGIN_SRC emacs-lisp
786 (setq custom-file jj-custom-file)
787 (safe-load custom-file)
790 The source of this is:
791 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
794 * Extra modes and their configuration
796 For some file endings we need to tell emacs what mode we want for them.
797 I only list modes here where I don't have any other special
800 - Some extras for ruby, used with ruby on rails for example
801 #+BEGIN_SRC emacs-lisp
802 (add-to-list 'auto-mode-alist '("\\.rxml$" . ruby-mode))
803 (add-to-list 'auto-mode-alist '("\\.rjs$" . ruby-mode))
804 (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
805 (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
806 (add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
810 #+BEGIN_SRC emacs-lisp
811 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
815 #+BEGIN_SRC emacs-lisp
816 (add-to-list 'auto-mode-alist '("COMMIT_EDITMSG$" . diff-mode))
820 #+BEGIN_SRC emacs-lisp
821 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
822 (add-to-list 'auto-mode-alist '("\\.pod$" . pod-mode))
823 (add-to-list 'auto-mode-alist '("\\.tt$" . tt-mode))
824 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
825 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
826 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
830 #+BEGIN_SRC emacs-lisp
831 (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
832 (add-to-list 'auto-mode-alist '("\\.py$" . python-mode))
833 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
836 ** Region bindings mode
837 [2013-05-01 Wed 22:51]
838 This mode allows to have keybindings that are only alive when the
839 region is active. Helpful for things that only do any useful action
840 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
841 #+BEGIN_SRC emacs-lisp
842 (require 'region-bindings-mode)
843 (region-bindings-mode-enable)
846 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
847 #+BEGIN_SRC emacs-lisp
849 (setq tramp-default-method "ssh")
850 (setq tramp-persistency-file-name (expand-file-name "tramp" jj-cache-dir))
851 (setq shell-prompt-pattern "^[^a-zA-Z].*[#$%>] *")
852 (add-to-list 'tramp-default-method-alist
853 '("\\`localhost\\'" "\\`root\\'" "su")
855 (setq tramp-debug-buffer nil)
856 (setq tramp-default-method "sshx")
857 (setq tramp-verbose 5)
861 We configure only a bit of the tiny-tools to load when I should need
862 them. I don't need much actually, but these things are nice to have.
864 #+BEGIN_SRC emacs-lisp
865 (autoload 'turn-on-tinyperl-mode "tinyperl" "" t)
866 (add-hook 'perl-mode-hook 'turn-on-tinyperl-mode)
867 (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode)
869 (autoload 'tinycomment-indent-for-comment "tinycomment" "" t)
870 (autoload 'tinyeat-forward-preserve "tinyeat" "" t)
871 (autoload 'tinyeat-backward-preserve "tinyeat" "" t)
872 (autoload 'tinyeat-delete-paragraph "tinyeat" "" t)
873 (autoload 'tinyeat-kill-line "tinyeat" "" t)
874 (autoload 'tinyeat-zap-line "tinyeat" "" t)
875 (autoload 'tinyeat-kill-line-backward "tinyeat" "" t)
876 (autoload 'tinyeat-kill-buffer-lines-point-max "tinyeat" "" t)
877 (autoload 'tinyeat-kill-buffer-lines-point-min "tinyeat" "" t)
879 *** Keyboard changes for tiny-tools
880 #+BEGIN_SRC emacs-lisp
881 (global-set-key "\M-;" 'tinycomment-indent-for-comment)
883 (global-set-key (kbd "ESC C-k") 'tinyeat-kill-line-backward)
884 (global-set-key (kbd "ESC d") 'tinyeat-forward-preserve)
885 (global-set-key (kbd "ESC z") 'tinyeat-kill-buffer-lines-main)
886 (global-set-key (kbd "<M-backspace>") 'tinyeat-backward-preserve)
887 (global-set-key (kbd "<C-delete>") 'tinyeat-forward-preserve)
888 (global-set-key (kbd "<S-backspace>") 'tinyeat-delete-whole-word)
892 I like dired and work a lot with it, but it tends to leave lots of
894 dired-single to the rescue.
895 #+BEGIN_SRC emacs-lisp
896 (autoload 'dired-single-buffer "dired-single" "" t)
897 (autoload 'dired-single-buffer-mouse "dired-single" "" t)
898 (autoload 'dired-single-magic-buffer "dired-single" "" t)
899 (autoload 'dired-single-toggle-buffer-name "dired-single" "" t)
902 We want some extra key bindings loaded. In case we haven't loaded dired
903 yet, there won't be a keymap to add to, so add our setup function to the
904 load hook only. Otherwise just bind the keys.
905 #+BEGIN_SRC emacs-lisp
906 (if (boundp 'dired-mode-map)
907 ;; we're good to go; just add our bindings
909 ;; it's not loaded yet, so add our bindings to the load-hook
910 (add-hook 'dired-load-hook 'my-dired-init))
914 #+BEGIN_SRC emacs-lisp
915 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
916 (setq dired-dwim-target t)
917 (setq dired-listing-switches "-alh")
918 (setq dired-recursive-copies (quote top))
919 (setq dired-recursive-deletes (quote top))
923 #+BEGIN_SRC emacs-lisp
924 (setq wdired-allow-to-change-permissions t)
927 [2013-05-02 Thu 00:04]
928 #+BEGIN_SRC emacs-lisp
930 (eval-after-load "filladapt" '(diminish 'filladapt-mode))
931 (setq-default filladapt-mode t)
934 [2013-05-03 Fri 16:09]
935 Replace default find-file with find-file-at-point, which tries to
936 guess the default file/URL from text around the point.
937 #+BEGIN_SRC emacs-lisp
941 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
942 ‘TAB’ completion is to typing things manually every time.”]]
943 #+BEGIN_SRC emacs-lisp
948 Always have unique buffernames. See [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html][Uniquify - GNU Emacs Manual]]
949 #+BEGIN_SRC emacs-lisp
951 (setq uniquify-buffer-name-style 'post-forward)
952 (setq uniquify-after-kill-buffer-p t)
953 (setq uniquify-ignore-buffers-re "^\\*")
957 A defined abbrev is a word which expands, if you insert it, into some
958 different text. Abbrevs are defined by the user to expand in specific
960 #+BEGIN_SRC emacs-lisp
961 (setq save-abbrevs 'silently)
962 (setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
963 (if (file-exists-p abbrev-file-name)
964 (quietly-read-abbrev-file))
969 Obviously emacs can do syntax hilighting. For more things than you ever
971 And I want to have it everywhere.
972 #+BEGIN_SRC emacs-lisp
974 (global-font-lock-mode 1)
975 (setq font-lock-maximum-decoration t)
978 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
979 #+BEGIN_SRC emacs-lisp
985 By default, Emacs can update the time stamp for the following two
986 formats if one exists in the first 8 lines of the file.
989 #+BEGIN_SRC emacs-lisp
990 (require 'time-stamp)
991 (setq time-stamp-active t)
992 (setq time-stamp-format "%02H:%02M:%02S (%z) - %02d.%02m.%:y from %u (%U) on %s")
993 (setq time-stamp-old-format-warn nil)
994 (setq time-stamp-time-zone nil)
995 (add-hook 'write-file-hooks 'time-stamp)
999 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
1001 #+BEGIN_SRC emacs-lisp
1002 (autoload 'cperl-mode "cperl-mode" )
1003 (defalias 'perl-mode 'cperl-mode)
1004 (setq cperl-hairy t)
1005 (setq cperl-electric-keywords t)
1006 (setq cperl-electric-lbrace-space t)
1007 (setq cperl-electric-parens nil)
1008 (setq cperl-highlight-variables-indiscriminately t)
1009 (setq cperl-imenu-addback t)
1010 (setq cperl-invalid-face (quote underline))
1011 (setq cperl-lazy-help-time 5)
1012 (setq cperl-mode-hook (quote (turn-on-tinyperl-mode)))
1013 (setq cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$")
1014 (setq cperl-syntaxify-by-font-lock t)
1015 (setq cperl-use-syntax-table-text-property-for-tags t)
1018 And have cperl mode give ElDoc a useful string
1019 #+BEGIN_SRC emacs-lisp
1020 (defun my-cperl-eldoc-documentation-function ()
1021 "Return meaningful doc string for `eldoc-mode'."
1023 (let ((cperl-message-on-help-error nil))
1025 (add-hook 'cperl-mode-hook
1027 (set (make-local-variable 'eldoc-documentation-function)
1028 'my-cperl-eldoc-documentation-function)
1033 #+BEGIN_SRC emacs-lisp
1034 (autoload 'python-mode "python-mode" "Python Mode." t)
1035 (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
1036 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
1037 (setq interpreter-mode-alist
1038 (cons '("python" . python-mode)
1039 interpreter-mode-alist)
1042 (set-variable 'py-indent-offset 4)
1043 (set-variable 'py-smart-indentation nil)
1044 (set-variable 'indent-tabs-mode nil)
1045 (define-key python-mode-map "\C-m" 'newline-and-indent)
1046 (turn-on-eldoc-mode)
1048 (defun python-auto-fill-comments-only ()
1050 (set (make-local-variable 'fill-nobreak-predicate)
1052 (not (python-in-string/comment)))))
1053 (add-hook 'python-mode-hook
1055 (python-auto-fill-comments-only)))
1057 (autoload 'pymacs-apply "pymacs")
1058 (autoload 'pymacs-call "pymacs")
1059 (autoload 'pymacs-eval "pymacs" nil t)
1060 (autoload 'pymacs-exec "pymacs" nil t)
1061 (autoload 'pymacs-load "pymacs" nil t)
1065 If an =ipython= executable is on the path, then assume that IPython is
1066 the preferred method python evaluation.
1067 #+BEGIN_SRC emacs-lisp
1068 (when (executable-find "ipython")
1070 (setq org-babel-python-mode 'python-mode))
1072 (setq python-shell-interpreter "ipython")
1073 (setq python-shell-interpreter-args "")
1074 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
1075 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
1076 (setq python-shell-completion-setup-code
1077 "from IPython.core.completerlib import module_completion")
1078 (setq python-shell-completion-module-string-code
1079 "';'.join(module_completion('''%s'''))\n")
1080 (setq python-shell-completion-string-code
1081 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
1085 I prefer comments to be indented too
1086 #+BEGIN_SRC emacs-lisp
1087 (setq sh-indent-comment t)
1091 When files change outside emacs for whatever reason I want emacs to deal
1092 with it. Not to have to revert buffers myself
1093 #+BEGIN_SRC emacs-lisp
1094 (require 'autorevert)
1095 (setq global-auto-revert-mode t)
1096 (global-auto-revert-mode)
1099 ** linum (line number)
1100 Various modes should have line numbers in front of each line.
1102 But then there are some where it would just be deadly - like org-mode,
1103 gnus, so we have a list of modes where we don't want to see it.
1104 #+BEGIN_SRC emacs-lisp
1106 (setq linum-format "%3d ")
1107 (setq linum-mode-inhibit-modes-list '(org-mode
1114 (defadvice linum-on (around linum-on-inhibit-for-modes)
1115 "Stop the load of linum-mode for some major modes."
1116 (unless (member major-mode linum-mode-inhibit-modes-list)
1119 (ad-activate 'linum-on)
1120 (global-linum-mode 1)
1124 #+BEGIN_SRC emacs-lisp
1125 (autoload 'css-mode "css-mode")
1126 (setq auto-mode-alist (cons '("\\.css\\'" . css-mode) auto-mode-alist))
1130 Instead of default /html-mode/ I use /html-helper-mode/.
1131 #+BEGIN_SRC emacs-lisp
1132 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
1133 (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
1134 (setq auto-mode-alist (cons '("\\.asp$" . html-helper-mode) auto-mode-alist))
1135 (setq auto-mode-alist (cons '("\\.phtml$" . html-helper-mode) auto-mode-alist))
1136 (defalias 'html-mode 'html-helper-mode)
1140 #+BEGIN_SRC emacs-lisp
1141 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
1142 (setq TeX-auto-save t)
1143 (setq TeX-parse-self t)
1144 (setq TeX-PDF-mode t)
1148 #+BEGIN_SRC emacs-lisp
1149 (require 'dpkg-dev-el-loaddefs nil 'noerror)
1150 (require 'debian-el-loaddefs nil 'noerror)
1152 (setq debian-changelog-full-name "Joerg Jaspert")
1153 (setq debian-changelog-mailing-address "joerg@debian.org")
1157 *** General settings
1158 [2013-04-28 So 17:06]
1160 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
1161 it is quite extensive. Nevertheless, it starts out small, loading it.
1162 #+BEGIN_SRC emacs-lisp tangle:yes
1166 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
1167 that we need org-protocol.
1168 #+BEGIN_SRC emacs-lisp tangle:yes
1169 (require 'org-protocol)
1174 My current =org-agenda-files= variable only includes a set of
1176 #+BEGIN_SRC emacs-lisp tangle:yes
1177 (setq org-agenda-files (quote ("~/org/"
1183 (setq org-default-notes-file "~/org/notes.org")
1185 =org-mode= manages the =org-agenda-files= variable automatically using
1186 =C-c [= and =C-c ]= to add and remove files respectively. However,
1187 this replaces my directory list with a list of explicit filenames
1188 instead and is not what I want. If this occurs then adding a new org
1189 file to any of the above directories will not contribute to my agenda
1190 and I will probably miss something important.
1192 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
1193 prevent messing up my list of directories in the =org-agenda-files=
1194 variable. I just add and remove directories manually here. Changing
1195 the list of directories in =org-agenda-files= happens very rarely
1196 since new files in existing directories are automatically picked up.
1198 #+BEGIN_SRC emacs-lisp tangle:yes
1199 ;; Keep tasks with dates on the global todo lists
1200 (setq org-agenda-todo-ignore-with-date nil)
1202 ;; Keep tasks with deadlines on the global todo lists
1203 (setq org-agenda-todo-ignore-deadlines nil)
1205 ;; Keep tasks with scheduled dates on the global todo lists
1206 (setq org-agenda-todo-ignore-scheduled nil)
1208 ;; Keep tasks with timestamps on the global todo lists
1209 (setq org-agenda-todo-ignore-timestamp nil)
1211 ;; Remove completed deadline tasks from the agenda view
1212 (setq org-agenda-skip-deadline-if-done t)
1214 ;; Remove completed scheduled tasks from the agenda view
1215 (setq org-agenda-skip-scheduled-if-done t)
1217 ;; Remove completed items from search results
1218 (setq org-agenda-skip-timestamp-if-done t)
1220 ;; Include agenda archive files when searching for things
1221 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
1223 ;; Show all future entries for repeating tasks
1224 (setq org-agenda-repeating-timestamp-show-all t)
1226 ;; Show all agenda dates - even if they are empty
1227 (setq org-agenda-show-all-dates t)
1229 ;; Sorting order for tasks on the agenda
1230 (setq org-agenda-sorting-strategy
1231 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
1232 (todo category-up priority-down effort-up)
1233 (tags category-up priority-down effort-up)
1234 (search category-up))))
1236 ;; Start the weekly agenda on Monday
1237 (setq org-agenda-start-on-weekday 1)
1239 ;; Enable display of the time grid so we can see the marker for the current time
1240 (setq org-agenda-time-grid (quote ((daily today remove-match)
1241 #("----------------" 0 16 (org-heading t))
1242 (0800 1000 1200 1400 1500 1700 1900 2100))))
1244 ;; Display tags farther right
1245 (setq org-agenda-tags-column -102)
1247 ; position the habit graph on the agenda to the right of the default
1248 (setq org-habit-graph-column 50)
1250 ; turn habits back on
1251 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
1254 ;; Agenda sorting functions
1256 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
1259 (setq org-deadline-warning-days 30)
1261 ;; Always hilight the current agenda line
1262 (add-hook 'org-agenda-mode-hook
1263 '(lambda () (hl-line-mode 1))
1267 #+BEGIN_SRC emacs-lisp tangle:yes
1268 (setq org-agenda-persistent-filter t)
1269 (add-hook 'org-agenda-mode-hook
1270 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
1273 (add-hook 'org-agenda-mode-hook
1274 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
1277 (add-hook 'org-agenda-mode-hook
1278 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
1281 (add-hook 'org-agenda-mode-hook
1282 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
1285 (add-hook 'org-agenda-mode-hook
1286 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
1289 ; Rebuild the reminders everytime the agenda is displayed
1290 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
1292 ;(if (file-exists-p "~/org/refile.org")
1293 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
1295 ; Activate appointments so we get notifications
1298 (setq org-agenda-log-mode-items (quote (closed clock state)))
1299 (if (> emacs-major-version 23)
1300 (setq org-agenda-span 3)
1301 (setq org-agenda-ndays 3))
1303 (setq org-agenda-show-all-dates t)
1304 (setq org-agenda-start-on-weekday nil)
1305 (setq org-deadline-warning-days 14)
1308 *** Global keybindings.
1309 Start off by defining a series of keybindings.
1311 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
1312 setup manually, not by org-mode. Also turn off =C-c ;=, which
1313 comments headlines - a function never used.
1314 #+BEGIN_SRC emacs-lisp tangle:yes
1315 (add-hook 'org-mode-hook
1317 (org-defkey org-mode-map "\C-c[" 'undefined)
1318 (org-defkey org-mode-map "\C-c]" 'undefined)
1319 (org-defkey org-mode-map "\C-c;" 'undefined))
1323 And now a largish set of keybindings...
1324 #+BEGIN_SRC emacs-lisp tangle:yes
1325 (global-set-key "\C-cl" 'org-store-link)
1326 (global-set-key "\C-ca" 'org-agenda)
1327 (global-set-key "\C-cb" 'org-iswitchb)
1328 (define-key mode-specific-map [?a] 'org-agenda)
1330 (global-set-key (kbd "<f12>") 'org-agenda)
1331 (global-set-key (kbd "<f5>") 'bh/org-todo)
1332 (global-set-key (kbd "<S-f5>") 'bh/widen)
1333 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
1334 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
1336 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
1337 (global-set-key (kbd "<f9> b") 'bbdb)
1338 (global-set-key (kbd "<f9> c") 'calendar)
1339 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
1340 (global-set-key (kbd "<f9> h") 'bh/hide-other)
1341 (global-set-key (kbd "<f9> n") 'org-narrow-to-subtree)
1342 (global-set-key (kbd "<f9> w") 'widen)
1343 (global-set-key (kbd "<f9> u") 'bh/narrow-up-one-level)
1344 (global-set-key (kbd "<f9> I") 'bh/punch-in)
1345 (global-set-key (kbd "<f9> O") 'bh/punch-out)
1346 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
1347 (global-set-key (kbd "<f9> p") 'bh/phone-call)
1348 (global-set-key (kbd "<f9> r") 'boxquote-region)
1349 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
1350 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
1351 (global-set-key (kbd "<f9> T") 'tabify)
1352 (global-set-key (kbd "<f9> U") 'untabify)
1353 (global-set-key (kbd "<f9> v") 'visible-mode)
1354 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
1355 (global-set-key (kbd "C-<f9>") 'previous-buffer)
1356 (global-set-key (kbd "C-<f10>") 'next-buffer)
1357 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
1358 (global-set-key (kbd "C-x n r") 'narrow-to-region)
1359 (global-set-key (kbd "<f11>") 'org-clock-goto)
1360 (global-set-key (kbd "C-<f11>") 'org-clock-in)
1361 (global-set-key (kbd "C-M-r") 'org-capture)
1362 (global-set-key (kbd "C-c r") 'org-capture)
1363 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
1365 (define-key org-mode-map [(control k)] 'jj-org-kill-line)
1368 *** Tasks, States, Todo fun
1370 First we define the global todo keywords.
1371 #+BEGIN_SRC emacs-lisp tangle:yes
1372 (setq org-todo-keywords
1373 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
1374 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
1376 (setq org-todo-keyword-faces
1377 (quote (("TODO" :foreground "red" :weight bold)
1378 ("NEXT" :foreground "light blue" :weight bold)
1379 ("DONE" :foreground "forest green" :weight bold)
1380 ("WAITING" :foreground "orange" :weight bold)
1381 ("HOLD" :foreground "orange" :weight bold)
1382 ("DELEGATED" :foreground "yellow" :weight bold)
1383 ("CANCELLED" :foreground "dark green" :weight bold)
1384 ("PHONE" :foreground "dark green" :weight bold))))
1387 **** Fast Todo Selection
1388 Fast todo selection allows changing from any task todo state to any
1389 other state directly by selecting the appropriate key from the fast
1390 todo selection key menu.
1391 #+BEGIN_SRC emacs-lisp tangle:yes
1392 (setq org-use-fast-todo-selection t)
1394 Changing a task state is done with =C-c C-t KEY=
1396 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
1399 #+BEGIN_SRC emacs-lisp tangle:yes
1400 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1402 allows changing todo states with S-left and S-right skipping all of
1403 the normal processing when entering or leaving a todo state. This
1404 cycles through the todo states but skips setting timestamps and
1405 entering notes which is very convenient when all you want to do is fix
1406 up the status of an entry.
1408 **** Todo State Triggers
1409 I have a few triggers that automatically assign tags to tasks based on
1410 state changes. If a task moves to =CANCELLED= state then it gets a
1411 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
1412 =CANCELLED= tag. These are used for filtering tasks in agenda views
1413 which I'll talk about later.
1415 The triggers break down to the following rules:
1417 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
1418 - Moving a task to =WAITING= adds a =WAITING= tag
1419 - Moving a task to =HOLD= adds a =WAITING= tag
1420 - Moving a task to a done state removes a =WAITING= tag
1421 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
1422 - Moving a task to =NEXT= removes a =WAITING= tag
1423 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
1425 The tags are used to filter tasks in the agenda views conveniently.
1426 #+BEGIN_SRC emacs-lisp tangle:yes
1427 (setq org-todo-state-tags-triggers
1428 (quote (("CANCELLED" ("CANCELLED" . t))
1429 ("WAITING" ("WAITING" . t))
1430 ("HOLD" ("WAITING" . t) ("HOLD" . t))
1431 (done ("WAITING") ("HOLD"))
1432 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1433 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1434 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1437 *** Capturing new tasks
1438 Org capture replaces the old remember mode.
1439 #+BEGIN_SRC emacs-lisp tangle:yes
1440 (setq org-directory "~/org")
1441 (setq org-default-notes-file "~/org/refile.org")
1443 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
1444 ;; see http://orgmode.org/manual/Template-elements.html
1445 (setq org-capture-templates
1446 (quote (("t" "todo" entry (file "~/org/refile.org")
1447 "* TODO %?\nAdded: %U\n"
1448 :clock-in t :clock-resume t)
1449 ("l" "linktodo" entry (file "~/org/refile.org")
1450 "* TODO %?\nAdded: %U\n%a\n"
1451 :clock-in t :clock-resume t)
1452 ("r" "respond" entry (file "~/org/refile.org")
1453 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
1454 :clock-in t :clock-resume t :immediate-finish t)
1455 ("n" "note" entry (file "~/org/refile.org")
1456 "* %? :NOTE:\nAdded: %U\n%a\n"
1457 :clock-in t :clock-resume t)
1458 ("d" "Delegated" entry (file "~/org/refile.org")
1459 "* DELEGATED %?\nAdded: %U\n%a\n"
1460 :clock-in t :clock-resume t)
1461 ("j" "Journal" entry (file+datetree "~/org/diary.org")
1463 :clock-in t :clock-resume t)
1464 ("w" "org-protocol" entry (file "~/org/refile.org")
1465 "* TODO Review %c\nAdded: %U\n"
1466 :immediate-finish t)
1467 ("p" "Phone call" entry (file "~/org/refile.org")
1468 "* PHONE %? :PHONE:\nAdded: %U"
1469 :clock-in t :clock-resume t)
1470 ("f" "Firewall request" entry (file+headline "~/org/nsb/dlh.org" "Firewall")
1471 "* TODO Firewall Request, RT: %?\nAdded: %U"
1472 :clock-in t :clock-resume t)
1473 ("i" "Ticket" entry (file+headline "~/org/nsb/dlh.org" "RT Ticket")
1474 "* TODO RT: %a\nAdded: %U\n\n%?"
1475 :clock-in t :clock-resume t :jump-to-captured t)
1476 ("x" "Bookmark link" entry (file "~/org/refile.org")
1477 "* Bookmark: %c\n%i\nAdded: %U\n"
1478 :immediate-finish t)
1479 ("h" "Habit" entry (file "~/org/refile.org")
1480 "* 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")
1484 Capture mode now handles automatically clocking in and out of a
1485 capture task. This all works out of the box now without special hooks.
1486 When I start a capture mode task the task is clocked in as specified
1487 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
1488 resumes on the original clocking task.
1490 The quick clocking in and out of capture mode tasks (often it takes
1491 less than a minute to capture some new task details) can leave
1492 empty clock drawers in my tasks which aren't really useful.
1493 The following prevents this.
1494 #+BEGIN_SRC emacs-lisp tangle:yes
1495 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1499 All my newly captured entries end up in =refile.org= and want to be
1500 moved over to the right place. The following is the setup for it.
1501 #+BEGIN_SRC emacs-lisp tangle:yes
1502 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1503 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1504 (org-agenda-files :maxlevel . 9))))
1506 ; Use full outline paths for refile targets - we file directly with IDO
1507 (setq org-refile-use-outline-path t)
1509 ; Targets complete directly with IDO
1510 (setq org-outline-path-complete-in-steps nil)
1512 ; Allow refile to create parent tasks with confirmation
1513 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1515 ; Use IDO for both buffer and file completion and ido-everywhere to t
1516 (setq org-completion-use-ido t)
1517 (setq org-completion-use-iswitchb nil)
1518 :; Use IDO for both buffer and file completion and ido-everywhere to t
1519 ;(setq ido-everywhere t)
1520 ;(setq ido-max-directory-size 100000)
1521 ;(ido-mode (quote both))
1522 ; Use the current window when visiting files and buffers with ido
1523 (setq ido-default-file-method 'selected-window)
1524 (setq ido-default-buffer-method 'selected-window)
1526 ;;;; Refile settings
1527 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1531 Agenda view is the central place for org-mode interaction...
1532 #+BEGIN_SRC emacs-lisp tangle:yes
1533 ;; Do not dim blocked tasks
1534 (setq org-agenda-dim-blocked-tasks nil)
1535 ;; Compact the block agenda view
1536 (setq org-agenda-compact-blocks t)
1538 ;; Custom agenda command definitions
1539 (setq org-agenda-custom-commands
1540 (quote (("N" "Notes" tags "NOTE"
1541 ((org-agenda-overriding-header "Notes")
1542 (org-tags-match-list-sublevels t)))
1543 ("h" "Habits" tags-todo "STYLE=\"habit\""
1544 ((org-agenda-overriding-header "Habits")
1545 (org-agenda-sorting-strategy
1546 '(todo-state-down effort-up category-keep))))
1550 ((org-agenda-overriding-header "Tasks to Refile")
1551 (org-tags-match-list-sublevels nil)))
1552 (tags-todo "-HOLD-CANCELLED/!"
1553 ((org-agenda-overriding-header "Projects")
1554 (org-agenda-skip-function 'bh/skip-non-projects)
1555 (org-agenda-sorting-strategy
1557 (tags-todo "-CANCELLED/!"
1558 ((org-agenda-overriding-header "Stuck Projects")
1559 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
1560 (tags-todo "-WAITING-CANCELLED/!NEXT"
1561 ((org-agenda-overriding-header "Next Tasks")
1562 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1563 (org-agenda-todo-ignore-scheduled t)
1564 (org-agenda-todo-ignore-deadlines t)
1565 (org-agenda-todo-ignore-with-date t)
1566 (org-tags-match-list-sublevels t)
1567 (org-agenda-sorting-strategy
1568 '(todo-state-down effort-up category-keep))))
1569 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
1570 ((org-agenda-overriding-header "Tasks")
1571 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
1572 (org-agenda-todo-ignore-scheduled t)
1573 (org-agenda-todo-ignore-deadlines t)
1574 (org-agenda-todo-ignore-with-date t)
1575 (org-agenda-sorting-strategy
1577 (tags-todo "-CANCELLED+WAITING/!"
1578 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1579 (org-agenda-skip-function 'bh/skip-stuck-projects)
1580 (org-tags-match-list-sublevels nil)
1581 (org-agenda-todo-ignore-scheduled 'future)
1582 (org-agenda-todo-ignore-deadlines 'future)))
1584 ((org-agenda-overriding-header "Tasks to Archive")
1585 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1586 (org-tags-match-list-sublevels nil))))
1588 ("r" "Tasks to Refile" tags "REFILE"
1589 ((org-agenda-overriding-header "Tasks to Refile")
1590 (org-tags-match-list-sublevels nil)))
1591 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
1592 ((org-agenda-overriding-header "Stuck Projects")
1593 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
1594 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
1595 ((org-agenda-overriding-header "Next Tasks")
1596 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1597 (org-agenda-todo-ignore-scheduled t)
1598 (org-agenda-todo-ignore-deadlines t)
1599 (org-agenda-todo-ignore-with-date t)
1600 (org-tags-match-list-sublevels t)
1601 (org-agenda-sorting-strategy
1602 '(todo-state-down effort-up category-keep))))
1603 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
1604 ((org-agenda-overriding-header "Tasks")
1605 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
1606 (org-agenda-sorting-strategy
1608 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
1609 ((org-agenda-overriding-header "Projects")
1610 (org-agenda-skip-function 'bh/skip-non-projects)
1611 (org-agenda-sorting-strategy
1613 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
1614 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
1615 (org-tags-match-list-sublevels nil))
1616 ("A" "Tasks to Archive" tags "-REFILE/"
1617 ((org-agenda-overriding-header "Tasks to Archive")
1618 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1619 (org-tags-match-list-sublevels nil))))))
1621 ; Overwrite the current window with the agenda
1622 (setq org-agenda-window-setup 'current-window)
1627 #+BEGIN_SRC emacs-lisp tangle:yes
1629 ;; Resume clocking task when emacs is restarted
1630 (org-clock-persistence-insinuate)
1632 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
1633 (setq org-clock-history-length 36)
1634 ;; Resume clocking task on clock-in if the clock is open
1635 (setq org-clock-in-resume t)
1636 ;; Change tasks to NEXT when clocking in
1637 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1638 ;; Separate drawers for clocking and logs
1639 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1640 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1641 (setq org-clock-into-drawer t)
1642 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1643 (setq org-clock-out-remove-zero-time-clocks t)
1644 ;; Clock out when moving task to a done state
1645 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
1646 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1647 (setq org-clock-persist t)
1648 ;; Do not prompt to resume an active clock
1649 (setq org-clock-persist-query-resume nil)
1650 ;; Enable auto clock resolution for finding open clocks
1651 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1652 ;; Include current clocking task in clock reports
1653 (setq org-clock-report-include-clocking-task t)
1655 ; use discrete minute intervals (no rounding) increments
1656 (setq org-time-stamp-rounding-minutes (quote (1 1)))
1658 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1660 (setq bh/keep-clock-running nil)
1662 (setq org-agenda-clock-consistency-checks
1663 (quote (:max-duration "4:00"
1666 :gap-ok-around ("4:00"))))
1670 **** Setting a default clock task
1671 Per default the =** Organization= task in my tasks.org file receives
1672 misc clock time. This is the task I clock in on when I punch in at the
1673 start of my work day with =F9-I=. Punching-in anywhere clocks in this
1674 Organization task as the default task.
1676 If I want to change the default clocking task I just visit the
1677 new task in any org buffer and clock it in with =C-u C-u C-c C-x
1678 C-i=. Now this new task that collects miscellaneous clock
1679 minutes when the clock would normally stop.
1681 You can quickly clock in the default clocking task with =C-u C-c
1682 C-x C-i d=. Another option is to repeatedly clock out so the
1683 clock moves up the project tree until you clock out the
1684 top-level task and the clock moves to the default task.
1687 #+BEGIN_SRC emacs-lisp tangle:yes
1688 ;; Agenda clock report parameters
1689 (setq org-agenda-clockreport-parameter-plist
1690 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
1692 ;; Agenda log mode items to display (closed and state changes by default)
1693 (setq org-agenda-log-mode-items (quote (closed state)))
1695 **** Task estimates, column view
1696 Setup column view globally with the following headlines
1697 #+BEGIN_SRC emacs-lisp tangle:yes
1698 ; Set default column view headings: Task Effort Clock_Summary
1699 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
1701 Setup the estimate for effort values.
1702 #+BEGIN_SRC emacs-lisp tangle:yes
1703 ; global Effort estimate values
1704 ; global STYLE property values for completion
1705 (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")
1706 ("STYLE_ALL" . "habit"))))
1710 Tags are mostly used for filtering inside the agenda.
1711 #+BEGIN_SRC emacs-lisp tangle:yes
1712 ; Tags with fast selection keys
1713 (setq org-tag-alist (quote ((:startgroup)
1731 ; Allow setting single tags without the menu
1732 (setq org-fast-tag-selection-single-key (quote expert))
1734 ; For tag searches ignore tasks with scheduled and deadline dates
1735 (setq org-agenda-tags-todo-honor-ignore-options t)
1739 #+BEGIN_SRC emacs-lisp tangle:yes
1740 (setq org-archive-mark-done nil)
1741 (setq org-archive-location "%s_archive::* Archived Tasks")
1745 #+BEGIN_SRC emacs-lisp tangle:yes
1746 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
1747 (setq org-plantuml-jar-path "~/java/plantuml.jar")
1749 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
1751 ; Make babel results blocks lowercase
1752 (setq org-babel-results-keyword "results")
1754 (org-babel-do-load-languages
1755 (quote org-babel-load-languages)
1756 (quote ((emacs-lisp . t)
1775 ; Do not prompt to confirm evaluation
1776 ; This may be dangerous - make sure you understand the consequences
1777 ; of setting this -- see the docstring for details
1778 (setq org-confirm-babel-evaluate nil)
1780 ; Use fundamental mode when editing plantuml blocks with C-c '
1781 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
1784 #+BEGIN_SRC emacs-lisp
1785 ;; Don't have images visible on startup, breaks on console
1786 (setq org-startup-with-inline-images nil)
1789 **** ditaa, graphviz, etc
1790 Those are all nice tools. Look at
1791 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
1794 *** Publishing and exporting
1797 Org-mode can export to a variety of publishing formats including (but not limited to)
1800 (plain text - but not the original org-mode file)
1804 which enables getting to lots of other formats like ODF, XML, etc
1806 via LaTeX or Docbook
1809 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
1811 #+BEGIN_SRC emacs-lisp tangle:yes
1812 ;; Explicitly load required exporters
1816 ;; FIXME, check the following two
1817 ;(require 'ox-icalendar)
1820 ; experimenting with docbook exports - not finished
1821 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
1822 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
1824 ;; define categories that should be excluded
1825 (setq org-export-exclude-category (list "google" "google"))
1826 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1828 ; define how the date strings look
1829 (setq org-export-date-timestamp-format "%Y-%m-%d")
1830 ; Inline images in HTML instead of producting links to the image
1831 (setq org-html-inline-images t)
1832 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
1833 (setq org-export-with-sub-superscripts nil)
1835 (setq org-html-head-extra (concat
1836 "<link rel=\"stylesheet\" href=\"http://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
1838 (setq org-html-head-include-default-style nil)
1839 ; Do not generate internal css formatting for HTML exports
1840 (setq org-export-htmlize-output-type (quote css))
1841 ; Export with LaTeX fragments
1842 (setq org-export-with-LaTeX-fragments t)
1843 ; Increase default number of headings to export
1844 (setq org-export-headline-levels 6)
1847 (setq org-publish-project-alist
1850 :base-directory "~/.emacs.d/"
1851 :base-extension "org"
1853 :publishing-directory "/develop/www/emacs"
1855 :publishing-function org-html-publish-to-html
1856 :headline-levels 4 ; Just the default for this project.
1862 :base-directory "~/.emacs.d/"
1863 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
1864 :publishing-directory "/develop/www/emacs"
1865 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
1867 :publishing-function org-publish-attachment
1869 ("inherit-org-info-js"
1870 :base-directory "/develop/vcs/org-info-js/"
1872 :base-extension "js"
1873 :publishing-directory "/develop/www/"
1874 :publishing-function org-publish-attachment
1876 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
1881 (setq org-export-with-timestamps nil)
1886 #+BEGIN_SRC emacs-lisp tangle:yes
1887 (setq org-latex-to-pdf-process
1888 '("xelatex -interaction nonstopmode %f"
1889 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
1890 (setq org-export-latex-listings 'minted)
1891 (setq org-latex-listings t)
1893 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1894 ;; but adapted to use latexmk 4.20 or higher.
1895 (defun my-auto-tex-cmd ()
1896 "When exporting from .org with latex, automatically run latex,
1897 pdflatex, or xelatex as appropriate, using latexmk."
1899 ;; default command: oldstyle latex via dvi
1900 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
1902 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
1903 (setq texcmd "latexmk -pdf -quiet %f"))
1905 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
1906 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
1907 ;; LaTeX compilation command
1908 (setq org-latex-to-pdf-process (list texcmd)))
1910 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
1912 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
1913 (setq org-export-latex-packages-alist
1915 ("" "longtable" nil)
1920 (defun my-auto-tex-parameters ()
1921 "Automatically select the tex packages to include."
1922 ;; default packages for ordinary latex or pdflatex export
1923 (setq org-export-latex-default-packages-alist
1924 '(("AUTO" "inputenc" t)
1934 ("" "hyperref" nil)))
1936 ;; Packages to include when xelatex is used
1937 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
1938 (setq org-export-latex-default-packages-alist
1943 ("german" "babel" t)
1944 ("babel" "csquotes" t)
1946 ("xetex" "hyperref" nil)
1949 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
1950 (setq org-export-latex-classes
1952 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
1953 ("\\section{%s}" . "\\section*{%s}")
1954 ("\\subsection{%s}" . "\\subsection*{%s}")
1955 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1956 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1957 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
1958 org-export-latex-classes))))
1960 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
1963 *** Prevent editing invisible text
1964 The following setting prevents accidentally editing hidden text when
1965 the point is inside a folded region. This can happen if you are in
1966 the body of a heading and globally fold the org-file with =S-TAB=
1968 I find invisible edits (and undo's) hard to deal with so now I can't
1969 edit invisible text. =C-c C-r= (org-reveal) will display where the
1970 point is if it is buried in invisible text to allow editing again.
1972 #+BEGIN_SRC emacs-lisp :tangle yes
1973 (setq org-catch-invisible-edits 'error)
1977 #+BEGIN_SRC emacs-lisp :tangle yes
1978 ;; disable the default org-mode stuck projects agenda view
1979 (setq org-stuck-projects (quote ("" nil nil "")))
1981 ; force showing the next headline.
1982 (setq org-show-entry-below (quote ((default))))
1984 (setq org-show-following-heading t)
1985 (setq org-show-hierarchy-above t)
1986 (setq org-show-siblings (quote ((default))))
1988 (setq org-special-ctrl-a/e t)
1989 (setq org-special-ctrl-k t)
1990 (setq org-yank-adjusted-subtrees t)
1992 (setq org-table-export-default-format "orgtbl-to-csv")
1996 The following setting adds alphabetical lists like
2000 #+BEGIN_SRC emacs-lisp tangle:yes
2001 (setq org-alphabetical-lists t)
2004 #+BEGIN_SRC emacs-lisp :tangle yes
2005 (setq org-remove-highlights-with-change nil)
2007 (setq org-list-demote-modify-bullet (quote (("+" . "-")
2014 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
2017 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
2018 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
2023 #+BEGIN_SRC emacs-lisp tangle:yes
2024 ;; Enable abbrev-mode
2025 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
2026 (setq org-startup-indented t)
2027 (setq org-startup-folded t)
2028 (setq org-cycle-separator-lines 0)
2031 I find extra blank lines in lists and headings a bit of a nuisance.
2032 To get a body after a list you need to include a blank line between
2033 the list entry and the body -- and indent the body appropriately.
2034 Most of my lists have no body detail so I like the look of collapsed
2035 lists with no blank lines better.
2037 The following setting prevents creating blank lines before headings
2038 but allows list items to adapt to existing blank lines around the items:
2039 #+BEGIN_SRC emacs-lisp tangle:yes
2040 (setq org-blank-before-new-entry (quote ((heading)
2041 (plain-list-item . auto))))
2044 #+BEGIN_SRC emacs-lisp tangle:yes
2045 (setq org-reverse-note-order nil)
2046 (setq org-default-notes-file "~/notes.org")
2049 Enforce task blocking. Tasks can't go done when there is any subtask
2050 still open. Unless they have a property of =NOBLOCKING: t=
2051 #+BEGIN_SRC emacs-lisp tangle:yes
2052 (setq org-enforce-todo-checkbox-dependencies t)
2053 (setq org-enforce-todo-dependencies t)
2056 #+BEGIN_SRC emacs-lisp tangle:yes
2057 (setq org-fast-tag-selection-single-key (quote expert))
2058 (setq org-footnote-auto-adjust t)
2059 (setq org-hide-block-startup t)
2060 (setq org-icalendar-alarm-time 15)
2061 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
2062 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
2063 (setq org-icalendar-honor-noexport-tag t)
2064 (setq org-icalendar-include-bbdb-anniversaries nil)
2065 (setq org-icalendar-include-body 200)
2066 (setq org-icalendar-include-todo nil)
2067 (setq org-icalendar-store-UID t)
2068 (setq org-icalendar-timezone "Europe/Berlin")
2069 (setq org-insert-mode-line-in-empty-file t)
2070 (setq org-log-done (quote note))
2071 (setq org-log-into-drawer t)
2072 (setq org-log-state-notes-insert-after-drawers nil)
2073 (setq org-log-reschedule (quote time))
2074 (setq org-log-states-order-reversed t)
2075 (setq org-mobile-agendas (quote all))
2076 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
2077 (setq org-mobile-inbox-for-pull "~/org/refile.org")
2078 (setq org-remember-store-without-prompt t)
2079 (setq org-return-follows-link t)
2080 (setq org-reverse-note-order t)
2082 ; regularly save our org-mode buffers
2083 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
2085 (setq org-log-done t)
2087 (setq org-enable-priority-commands t)
2088 (setq org-default-priority ?E)
2089 (setq org-lowest-priority ?E)
2094 Speed commands enable single-letter commands in Org-mode files when
2095 the point is at the beginning of a headline, or at the beginning of a
2098 See the `=org-speed-commands-default=' variable for a list of the keys
2099 and commands enabled at the beginning of headlines. All code blocks
2100 are available at the beginning of a code block, the following key
2101 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
2102 display a list of the code blocks commands and their related keys.
2104 #+BEGIN_SRC emacs-lisp tangle:yes
2105 (setq org-use-speed-commands t)
2106 (setq org-speed-commands-user (quote (("0" . ignore)
2119 ("h" . bh/hide-other)
2122 (call-interactively 'org-insert-heading-respect-content))
2123 ("k" . org-kill-note-or-show-branches)
2126 ("q" . bh/show-org-agenda)
2128 ("s" . org-save-all-org-buffers)
2132 ("z" . org-add-note)
2137 ("F" . bh/restrict-to-file-or-follow)
2140 ("J" . org-clock-goto)
2144 ("N" . bh/narrow-to-org-subtree)
2145 ("P" . bh/narrow-to-org-project)
2150 ("U" . bh/narrow-up-one-org-level)
2157 (add-hook 'org-agenda-mode-hook
2159 (define-key org-agenda-mode-map "q" 'bury-buffer))
2162 (defvar bh/current-view-project nil)
2163 (add-hook 'org-agenda-mode-hook
2164 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
2168 The following displays the contents of code blocks in Org-mode files
2169 using the major-mode of the code. It also changes the behavior of
2170 =TAB= to as if it were used in the appropriate major mode. This means
2171 that reading and editing code form inside of your Org-mode files is
2172 much more like reading and editing of code using its major mode.
2174 #+BEGIN_SRC emacs-lisp tangle:yes
2175 (setq org-src-fontify-natively t)
2176 (setq org-src-tab-acts-natively t)
2179 #+BEGIN_SRC emacs-lisp :tangle yes
2180 (setq org-src-preserve-indentation nil)
2181 (setq org-edit-src-content-indentation 0)
2185 #+BEGIN_SRC emacs-lisp tangle:yes
2186 (setq org-attach-directory "~/org/data/")
2188 #+BEGIN_SRC emacs-lisp tangle:yes
2189 (setq org-agenda-sticky t)
2192 **** Checklist handling
2193 [2013-05-11 Sat 22:15]
2195 #+BEGIN_SRC emacs-lisp tangle:yes
2196 (require 'org-checklist)
2200 For some reason I prefer this mode more than the way without. I want to
2201 see the marked region.
2202 #+BEGIN_SRC emacs-lisp
2203 (transient-mark-mode 1)
2206 I know that this lets it look "more like windows", but I don't much care
2207 about its paste/copy/cut keybindings, the really nice part is the great
2208 support for rectangular regions, which I started to use a lot since I
2209 know this mode. The normal keybindings for those are just to useless.
2210 #+BEGIN_SRC emacs-lisp
2212 (setq cua-enable-cua-keys (quote shift))
2215 Luckily cua-mode easily supports this, with the following line I just
2216 get the CUA selection and rectangle stuff, not the keybindings. Yes,
2217 even though the above =cua-enable-cua-keys= setting would only enable
2218 them if the selection is done when the region was marked with a shifted
2220 #+BEGIN_SRC emacs-lisp
2221 (cua-selection-mode t)
2225 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2228 #+BEGIN_SRC emacs-lisp
2229 (autoload 'mo-git-blame-file "mo-git-blame" nil t)
2230 (autoload 'mo-git-blame-current "mo-git-blame" nil t)
2234 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2236 I want to access it from anywhere using =F6=.
2237 #+BEGIN_SRC emacs-lisp
2238 (autoload 'mingus "mingus-stays-home" nil t)
2239 (global-set-key (kbd "<f6>") 'mingus)
2240 (setq mingus-dired-add-keys t)
2241 (setq mingus-mode-always-modeline nil)
2242 (setq mingus-mode-line-show-elapsed-percentage nil)
2243 (setq mingus-mode-line-show-volume nil)
2244 (setq mingus-mpd-config-file "/etc/mpd.conf")
2245 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2246 (setq mingus-mpd-root "/share/music/")
2250 Store at which point I have been in files.
2251 #+BEGIN_SRC emacs-lisp
2252 (setq-default save-place t)
2253 (require 'saveplace)
2254 (setq save-place-file (expand-file-name "saved-places" jj-cache-dir))
2257 [2013-04-21 So 20:25]
2258 Save a bit of history
2259 #+BEGIN_SRC emacs-lisp
2261 (setq savehist-additional-variables
2262 '(search ring regexp-search-ring kill-ring compile-history))
2263 ;; save every minute
2264 (setq savehist-autosave-interval 60)
2265 (setq savehist-file (expand-file-name "savehist" jj-cache-dir))
2270 EasyPG is a GnuPG interface for Emacs.
2271 #+BEGIN_SRC emacs-lisp
2276 I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
2277 #+BEGIN_SRC emacs-lisp
2278 (defadvice epg--start (around advice-epg-disable-agent disable)
2279 "Don't allow epg--start to use gpg-agent in plain text
2281 (if (display-graphic-p)
2283 (let ((agent (getenv "GPG_AGENT_INFO")))
2284 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
2286 (setenv "GPG_AGENT_INFO" agent))))
2287 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
2288 (ad-activate 'epg--start)
2291 #+BEGIN_SRC emacs-lisp
2293 (setq message-kill-buffer-on-exit t)
2296 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
2297 what I want every emacs to know.
2299 #+BEGIN_SRC emacs-lisp
2300 ;;*** Keyboardmacros
2301 (global-unset-key "\M-n")
2302 (global-set-key "\M-n" 'gnus) ; Start gnus with M-n
2306 url contains code to parse and handle URLs - who would have thought? I
2307 set it to send Accept-language header and tell it to not send email,
2308 operating system or location info.
2309 #+BEGIN_SRC emacs-lisp
2310 (setq url-mime-language-string "de,en")
2311 (setq url-privacy-level (quote (email os lastloc)))
2314 Crazy way of completion. It looks at the word before point and then
2315 tries to expand it in various ways.
2316 #+BEGIN_SRC emacs-lisp
2317 (require 'hippie-exp)
2318 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
2319 try-expand-dabbrev-all-buffers
2320 try-expand-dabbrev-from-kill
2321 try-complete-file-name-partially
2322 try-complete-file-name
2323 try-expand-all-abbrevs try-expand-list
2325 try-complete-lisp-symbol-partially
2326 try-complete-lisp-symbol))
2327 (global-set-key (kbd "M-/") 'hippie-expand)
2330 [2013-04-27 Sa 23:16]
2331 Yasnippet is a template system. Type an abbreviation, expand it into
2332 whatever the snippet holds.
2333 #+BEGIN_SRC emacs-lisp
2334 (setq yas-snippet-dirs (expand-file-name "yasnippet/snippets" jj-elisp-dir))
2335 (require 'yasnippet)
2338 ;; Integrate hippie-expand with ya-snippet
2339 (add-to-list 'hippie-expand-try-functions-list
2340 'yas-hippie-try-expand)
2343 The Emacs Lisp Package Archive (may) contain(s) some things I
2344 want. Even though I usually only use it to get the package, then when I
2345 like it move it into my own space. My elpa subdir stays empty.
2346 #+BEGIN_SRC emacs-lisp
2347 (when (> emacs-major-version 23)
2349 (setq package-user-dir (expand-file-name "elpa" jj-cache-dir))
2350 (package-initialize)
2351 (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
2352 (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
2356 [2013-04-08 Mon 23:57]
2357 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2358 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2359 #+BEGIN_SRC emacs-lisp
2360 (require 'multiple-cursors)
2361 (define-key region-bindings-mode-map "a" 'mc/mark-all-like-this)
2363 (define-key region-bindings-mode-map "p" 'mc/mark-previous-like-this)
2364 (define-key region-bindings-mode-map "n" 'mc/mark-next-like-this)
2365 (define-key region-bindings-mode-map "l" 'mc/edit-lines)
2366 (define-key region-bindings-mode-map "m" 'mc/mark-more-like-this-extended)
2367 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))
2369 ** rainbow-delimiters
2370 [2013-04-09 Di 23:38]
2371 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
2372 which highlights parens, brackets, and braces according to their
2373 depth. Each successive level is highlighted a different color. This
2374 makes it easy to spot matching delimiters, orient yourself in the code,
2375 and tell which statements are at the same depth.
2376 #+BEGIN_SRC emacs-lisp
2377 (when (require 'rainbow-delimiters nil 'noerror)
2378 (global-rainbow-delimiters-mode))
2381 [2013-04-21 So 11:07]
2382 Emacs undo is pretty powerful - but can also be confusing. There are
2383 tons of modes available to change it, even downgrade it to the very
2384 crappy ways one usually knows from other systems which lose
2385 information. undo-tree is different - it helps keeping you sane while
2386 keeping the full power of emacs undo/redo.
2387 #+BEGIN_SRC emacs-lisp
2388 (require 'undo-tree)
2389 (global-undo-tree-mode)
2390 (diminish 'undo-tree-mode)
2393 Additionally I would like to keep the region active should I undo
2396 #+BEGIN_SRC emacs-lisp
2397 ;; Keep region when undoing in region
2398 (defadvice undo-tree-undo (around keep-region activate)
2400 (let ((m (set-marker (make-marker) (mark)))
2401 (p (set-marker (make-marker) (point))))
2410 [2013-04-21 So 20:27]
2411 Use shift + arrow keys to switch between visible buffers
2412 #+BEGIN_SRC emacs-lisp
2414 (windmove-default-keybindings 'hyper)
2415 (setq windmove-wrap-around t)
2417 ** volatile highlights
2418 [2013-04-21 So 20:31]
2419 VolatileHighlights highlights changes to the buffer caused by commands
2420 such as ‘undo’, ‘yank’/’yank-pop’, etc. The highlight disappears at the
2421 next command. The highlighting gives useful visual feedback for what
2422 your operation actually changed in the buffer.
2423 #+BEGIN_SRC emacs-lisp
2424 (require 'volatile-highlights)
2425 (volatile-highlights-mode t)
2426 (diminish 'volatile-highlights-mode)
2429 [2013-04-21 So 20:36]
2430 ediff - don't start another frame
2433 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
2437 #+BEGIN_SRC emacs-lisp
2438 (require 're-builder)
2439 (setq reb-re-syntax 'string)
2442 [2013-04-21 So 20:39]
2445 [2013-04-21 So 20:48]
2446 magit is a mode for interacting with git.
2447 #+BEGIN_SRC emacs-lisp
2448 (require 'magitload)
2449 (require 'magit-svn)
2450 (global-set-key (kbd "C-x g") 'magit-status)
2451 (setq magit-commit-signoff t)
2454 ** lisp editing stuff
2455 [2013-04-21 So 21:00]
2456 I'm not doing much of it, except for my emacs and gnus configs, but
2457 then I like it nice too...
2458 #+BEGIN_SRC emacs-lisp
2459 (define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
2461 (setq lisp-coding-hook 'lisp-coding-defaults)
2462 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2464 (eval-after-load "paredit"
2465 '(diminish 'paredit-mode " π"))
2467 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2468 (add-hook 'emacs-lisp-mode-hook (lambda ()
2469 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2471 (define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
2473 (eval-after-load "elisp-slime-nav"
2474 '(diminish 'elisp-slime-nav-mode))
2475 (eval-after-load "rainbow-mode"
2476 '(diminish 'rainbow-mode))
2477 (eval-after-load "eldoc"
2478 '(diminish 'eldoc-mode))
2482 This highlights some /weaselwords/, a mode to /aid in finding common
2483 writing problems/...
2484 [2013-04-27 Sa 23:29]
2485 #+BEGIN_SRC emacs-lisp
2486 (require 'writegood-mode)
2487 (global-set-key "\C-cg" 'writegood-mode)
2489 ** auto-complete mode
2490 [2013-04-27 Sa 16:33]
2491 And aren't we all lazy? I definitely am, and I like my emacs doing as
2492 much possible work for me as it can.
2493 So here, auto-complete-mode, which lets emacs do this, based on what I
2495 #+BEGIN_SRC emacs-lisp
2496 (require 'auto-complete)
2497 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
2499 (setq ac-auto-start t)
2501 ;; custom keybindings to use tab, enter and up and down arrows
2502 (define-key ac-complete-mode-map "\t" 'ac-expand)
2503 (define-key ac-complete-mode-map "\r" 'ac-complete)
2504 (define-key ac-complete-mode-map "\M-n" 'ac-next)
2505 (define-key ac-complete-mode-map "\M-p" 'ac-previous)
2506 (define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
2508 (require 'ac-dabbrev)
2509 (setq ac-sources (list ac-source-dabbrev))
2511 (setq auto-completion-syntax-alist (quote (global accept . word))) ;; Use space and punctuation to accept the current the most likely completion.
2512 (setq auto-completion-min-chars (quote (global . 2))) ;; Avoid completion for short trivial words.
2513 (setq completion-use-dynamic t)
2515 (add-hook 'latex-mode-hook 'auto-complete-mode)
2516 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
2517 (add-hook 'prog-mode-hook 'auto-complete-mode)
2518 (add-hook 'org-mode-hook 'auto-complete-mode)
2521 [2013-04-28 So 01:13]
2522 YAML is a nice format for data, which is both, human and machine
2523 readable/editable without getting a big headache.
2524 #+BEGIN_SRC emacs-lisp
2525 (require 'yaml-mode)
2526 (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
2527 (add-hook 'yaml-mode-hook
2529 (define-key yaml-mode-map "\C-m" 'newline-and-indent)))
2533 [2013-04-28 So 22:21]
2534 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
2535 As the one time I tried Flymake i wasn't happy, thats easy to
2537 #+BEGIN_SRC emacs-lisp
2538 (when (> emacs-major-version 23)
2540 (add-hook 'after-init-hook #'global-flycheck-mode))
2543 And thats it for this file, control passes "back" to [[file:../initjj.org][initjj.org/el]]
2544 which then may load more files.