update mc
[emacs.git] / .emacs.d / config / emacs.org
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
6 #+LATEX_CMD: xelatex
7
8 * Basic config
9 ** General functions
10 :PROPERTIES:
11 :ID: b6e6cf73-9802-4a7b-bd65-fdb6f9745319
12 :END:
13 The following functions are used throughout my config, and so I load
14 them first.
15
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")
21
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"
25 (interactive "f")
26 (condition-case nil (load file noerror nomessage nosuffix)
27 (error
28 (progn
29 (setq safe-load-error-list (concat safe-load-error-list " " file))
30 (message "****** [Return to continue] Error loading %s" safe-load-error-list )
31 (sleep-for 1)
32 nil))))
33
34 (defun safe-load-check ()
35 "Check for any previous safe-load loading errors. (safe-load.el)"
36 (interactive)
37 (if (string-equal safe-load-error-list "") ()
38 (message (concat "****** error loading: " safe-load-error-list))))
39 #+END_SRC
40
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"))
47 #+END_SRC
48
49 Always ensure to have a scratch buffer around.
50 #+BEGIN_SRC emacs-lisp tangle:yes
51 (save-excursion
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))
56 #+END_SRC
57
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))))
64 #+END_SRC
65
66 Helpers for the config
67 #+BEGIN_SRC emacs-lisp tangle:yes
68 (require 'use-package)
69 (require 'bind-key)
70 #+END_SRC
71
72 ** Path settings
73 *** Load path
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=.
77
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")
85
86 (let (dirval)
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))
95
96 #+END_SRC
97
98 *** Info path
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/"
103 "/usr/local/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"
111 "/usr/share/info/"
112 "/usr/share/info/"))
113 (setq Info-default-directory-list
114 (cons "~/emacs/info" Info-default-directory-list))
115 #+END_SRC
116
117 ** Interface related
118 *** General stuff
119 :PROPERTIES:
120 :ID: 0a1560d9-7e55-47ab-be52-b3a8b8eea4aa
121 :END:
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)
126 #+END_SRC
127
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))
133 #+END_SRC
134
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)
138 #+END_SRC
139
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)
146 #+END_SRC
147
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))
154 #+END_SRC
155
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
158 knowledge here.
159 #+BEGIN_SRC emacs-lisp tangle:yes
160 (setq smtpmail-default-smtp-server "localhost")
161 (setq smtpmail-smtp-server "localhost")
162 #+END_SRC
163
164 Enable automatic handling of compressed files.
165 #+BEGIN_SRC emacs-lisp tangle:yes
166 (auto-compression-mode 1)
167 #+END_SRC
168
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)
177 #+END_SRC
178
179 *** Look / Theme
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"))
186 #+END_SRC
187
188 I always use dark backgrounds, so tell Emacs about it. No need to
189 guess around.
190 #+BEGIN_SRC emacs-lisp tangle:yes
191 (setq-default frame-background-mode jj-color-style)
192 #+END_SRC
193
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))
201 (progn
202 (defun jj-init-theme ()
203 (interactive)
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")
208 )
209 (add-to-list 'custom-theme-load-path jj-theme-dir)
210 (add-hook 'after-init-hook 'jj-init-theme)
211 )
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)
215 )
216 #+END_SRC
217
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)
221 (fringe-mode 4))
222 #+END_SRC
223
224 A bit more spacing between buffer lines
225 #+BEGIN_SRC emacs-lisp tangle:yes
226 (setq-default line-spacing 0.1)
227 #+END_SRC
228 *** Cursor changes
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)
233 #+END_SRC
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
237 (when window-system
238 (menu-bar-mode -1)
239 (tool-bar-mode -1)
240 (set-scroll-bar-mode nil))
241 #+END_SRC
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.
246
247 Except that Emacs behaves stupid when you do that and ignores your
248 menu/tool/scrollbar settings. Sucks.
249
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)
257 (menu-bar-lines . 0)
258 ))
259 (setq default-frame-alist (copy-alist initial-frame-alist))
260 #+END_SRC
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.
263
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)
268 #+END_SRC
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)
273 #+END_SRC
274
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.
278
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.
281
282 #+BEGIN_SRC emacs-lisp tangle:yes
283 (line-number-mode 1)
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)
290
291 (require 'modeline-posn)
292 (set-face-foreground 'modelinepos-column-warning "grey20")
293 (set-face-background 'modelinepos-column-warning "red")
294 #+END_SRC
295 **** diminish
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)
301 character(s).
302 #+BEGIN_SRC emacs-lisp tangle:yes
303 (require 'diminish)
304 (diminish 'auto-fill-function)
305 (defvar mode-line-cleaner-alist
306 `((auto-complete-mode . " α")
307 (yas-minor-mode . " y")
308 (paredit-mode . " π")
309 (eldoc-mode . "")
310 (abbrev-mode . "")
311 ;; Major modes
312 (lisp-interaction-mode . "λ")
313 (hi-lock-mode . "")
314 (python-mode . "Py")
315 (emacs-lisp-mode . "EL")
316 (org-mode . "Ω")
317 (org-indent-mode . "")
318 (sh-mode . " Σ")
319 (nxhtml-mode . "nx"))
320
321 "Alist for `clean-mode-line'.
322
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.
326
327 Want some symbols? Go:
328
329 ;ςερτζθιοπασδφγηξκλυχψωβνμ
330 :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
331 @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
332 ☃⌕☥
333 ")
334
335 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
336
337 #+END_SRC
338 Unfortunately icicles breaks this with the way it adds/removes itself,
339 so take it our for now...
340
341 *** Default mode
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
345 read in emacs.
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)
351 #+END_SRC
352
353 *** Shell
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
369 #+END_SRC
370
371 *** Emacs shell
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
378 '(progn
379 (require 'em-cmpl)
380 (require 'em-prompt)
381 (require 'em-term)
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
394 '("gunzip" "gz\\'"))
395 (add-to-list 'eshell-command-completions-alist
396 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))))
397
398 #+END_SRC
399
400 *** Isearch related
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)
410 #+END_SRC
411
412 *** Frame configuration
413 I want to see the buffername and its size, not the host I am on in my
414 frame title.
415 #+BEGIN_SRC emacs-lisp tangle:yes
416 (setq frame-title-format "%b (%i)")
417 #+END_SRC
418
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)
429 #+END_SRC
430
431 *** yes-or-no-p
432 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
433 lazy.
434 #+BEGIN_SRC emacs-lisp tangle:yes
435 (defalias 'yes-or-no-p 'y-or-n-p)
436 #+END_SRC
437
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))
449 #+END_SRC
450
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
455 (require 'paren)
456 (setq show-paren-style 'parenthesis)
457 (show-paren-mode +1)
458 #+END_SRC
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)
464 #+END_SRC
465 *** Scrolling
466 Default scrolling behaviour in emacs is a bit annoying, who wants to
467 jump half-windows?
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)
474 #+END_SRC
475
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
485
486 #+END_SRC
487
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)])
493 #+END_SRC
494
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
499 me. Lazyness++.
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."
503 (interactive)
504 (beginning-of-line)
505 (kill-line)
506 (back-to-indentation))
507
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)
511 #+END_SRC
512
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"
518 (interactive "P")
519 (beginning-of-line)
520 (org-kill-line arg)
521 (back-to-indentation)
522 )
523 #+END_SRC
524
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)
530 #+END_SRC
531
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)
535 #+END_SRC
536
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)
540 #+end_src
541
542 Align whatever with a regexp.
543 #+begin_src emacs-lisp
544 (global-set-key (kbd "C-x \\") 'align-regexp)
545 #+end_src
546
547 Font size changes
548 #+begin_src emacs-lisp
549 (global-set-key (kbd "C-+") 'text-scale-increase)
550 (global-set-key (kbd "C--") 'text-scale-decrease)
551 #+end_src
552
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)
559 #+end_src
560
561 Rgrep is infinitely useful in multi-file projects.
562 #+begin_src emacs-lisp
563 (define-key global-map "\C-x\C-g" 'rgrep)
564 #+end_src
565
566 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
567 AKA transpose lines.
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)
571 #+END_SRC
572
573 "Pull" lines up, join them
574 #+BEGIN_SRC emacs-lisp tangle:yes
575 (global-set-key (kbd "M-j")
576 (lambda ()
577 (interactive)
578 (join-line -1)))
579 #+END_SRC
580
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)
584 #+END_SRC
585
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)
589 #+END_SRC
590
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 ()
594 (interactive)
595 (other-window -1)))
596 #+END_SRC
597
598 Edit file as root
599 #+BEGIN_SRC emacs-lisp tangle:yes
600 (global-set-key (kbd "C-x C-r") 'prelude-sudo-edit)
601 #+END_SRC
602
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
607 not, bad Emacs.
608 #+BEGIN_SRC emacs-lisp tangle:yes
609 (global-set-key (kbd "M-SPC") 'just-one-space-with-newline)
610 #+END_SRC
611
612 Count which commands I use how often.
613 #+BEGIN_SRC emacs-lisp tangle:yes
614 (defvar keyfreq-file
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")
620 (require 'keyfreq)
621 (keyfreq-mode 1)
622 (keyfreq-autosave-mode 1)
623 #+END_SRC
624
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."
629 (interactive)
630 (save-excursion
631 (let ((line-text (buffer-substring-no-properties
632 (line-beginning-position)
633 (line-end-position))))
634 (move-end-of-line 1)
635 (newline)
636 (insert line-text))))
637
638 (global-set-key (kbd "C-c p") 'duplicate-line)
639 #+END_SRC
640
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.
647
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.
652
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."
655 (interactive "^p")
656 (setq arg (or arg 1))
657
658 ;; Move lines first
659 (when (/= arg 1)
660 (let ((line-move-visual nil))
661 (forward-line (1- arg))))
662
663 (let ((orig-point (point)))
664 (back-to-indentation)
665 (when (= orig-point (point))
666 (move-beginning-of-line 1))))
667
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)
671
672 #+END_SRC
673
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
678 (require 'misc)
679 (global-set-key (kbd "H-y") 'copy-from-above-command)
680 #+END_SRC
681
682 Open a new X Terminal pointing to the directory of the current
683 buffers path.
684 #+BEGIN_SRC emacs-lisp tangle:yes
685 (global-set-key (kbd "H-t") 'jj-open-shell)
686 #+END_SRC
687 **** ace-jump-mode
688 [2013-04-28 So 11:26]
689
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)
698 #+END_SRC
699 **** Overwrite mode
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
702 disabling that.
703 #+BEGIN_SRC emacs-lisp tangle:yes
704 (global-unset-key [insert])
705 (global-unset-key [kp-insert])
706 #+END_SRC
707
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)))
716
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?
721
722 (add-hook 'before-save-hook 'force-backup-of-buffer)
723
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)
727
728 (setq backup-enable-predicate
729 (lambda (name)
730 (and (normal-backup-enable-predicate name)
731 (not
732 (let ((method (file-remote-p name 'method)))
733 (when (stringp method)
734 (member method '("su" "sudo"))))))))
735
736 #+END_SRC
737
738 Weeks start on Monday, not sunday.
739 #+BEGIN_SRC emacs-lisp tangle:yes
740 (setq calendar-week-start-day 1)
741 #+END_SRC
742
743 Searches and matches should ignore case.
744 #+BEGIN_SRC emacs-lisp tangle:yes
745 (setq-default case-fold-search t)
746 #+END_SRC
747
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*"
752 "*Compile-Log*"
753 "*info*" "*vc*"
754 "*vc-diff*" "*diff*"
755 "*Customize"
756 "*tramp/" "*debug "
757 "*magit" "*Calendar")))
758 #+END_SRC
759
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)
763 #+END_SRC
764
765 What should be displayed in the mode-line for files with those types
766 of line endings.
767 #+BEGIN_SRC emacs-lisp tangle:yes
768 (setq eol-mnemonic-dos "(DOS)")
769 (setq eol-mnemonic-mac "(Mac)")
770 #+END_SRC
771
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)
775 #+END_SRC
776
777 #+BEGIN_SRC emacs-lisp tangle:yes
778 (setq max-lisp-eval-depth 1000)
779 (setq max-specpdl-size 3000)
780 #+END_SRC
781
782 Unfill paragraph
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."
787 (interactive)
788 (let ((fill-column (point-max)))
789 (fill-paragraph nil)))
790 #+END_SRC
791
792 #+BEGIN_SRC emacs-lisp tangle:yes
793 (setq-default indicate-empty-lines t)
794 #+END_SRC
795
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)
799 #+END_SRC
800
801 *** Browser
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")
805 #+END_SRC
806
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)
810 #+END_SRC
811
812 *** Emacs Server
813 #+BEGIN_SRC emacs-lisp tangle:yes
814 (require 'server)
815 (unless (server-running-p)
816 (server-start))
817 #+END_SRC
818
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"
827 :group 'environment)
828
829 (defgroup ganneff-org-mode nil
830 "Ganneffs org-mode settings"
831 :tag "Ganneffs org-mode settings"
832 :group 'ganneff
833 :link '(custom-group-link "ganneff"))
834
835 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
836 "ID of the organization task."
837 :tag "Organization Task ID"
838 :type 'string
839 :group 'ganneff-org-mode)
840
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"
845 :type 'float
846 :group 'ganneff-org-mode)
847 #+END_SRC
848
849
850 ** Compatibility
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))
856 #+END_SRC
857
858 * Customized variables
859 :PROPERTIES:
860 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
861 :END:
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.
866
867 #+BEGIN_SRC emacs-lisp tangle:yes
868 (setq custom-file jj-custom-file)
869 (safe-load custom-file)
870 #+END_SRC
871
872 The source of this is:
873 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
874
875
876 * Extra modes and their configuration
877 ** mode alists
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
880 configuration.
881
882 - Markdown syntax
883 #+BEGIN_SRC emacs-lisp tangle:yes
884 (add-auto-mode 'markdown-mode "\\.mdwn$")
885 #+END_SRC
886
887 - diff
888 #+BEGIN_SRC emacs-lisp tangle:yes
889 (add-auto-mode 'diff-mode "COMMIT_EDITMSG$")
890 #+END_SRC
891
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)
900 #+END_SRC
901 ** tramp
902 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
903 #+BEGIN_SRC emacs-lisp tangle:yes
904 (require 'tramp)
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")
910 )
911 (setq tramp-debug-buffer nil)
912 (setq tramp-default-method "sshx")
913 (setq tramp-verbose 5)
914 #+END_SRC
915
916 ** tiny-tools
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.
919
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)
924
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)
934 #+END_SRC
935 *** Keyboard changes for tiny-tools
936 #+BEGIN_SRC emacs-lisp tangle:yes
937 (global-set-key "\M-;" 'tinycomment-indent-for-comment)
938
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)
945 #+END_SRC
946
947 ** dired & co
948 I like dired and work a lot with it, but it tends to leave lots of
949 windows around.
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)
956 #+END_SRC
957
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
964 (my-dired-init)
965 ;; it's not loaded yet, so add our bindings to the load-hook
966 (add-hook 'dired-load-hook 'my-dired-init))
967 #+END_SRC
968
969 A few settings
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))
976 #+END_SRC
977
978 wdired
979 #+BEGIN_SRC emacs-lisp tangle:yes
980 (setq wdired-allow-to-change-permissions t)
981 #+END_SRC
982 ** filladapt
983 [2013-05-02 Thu 00:04]
984 #+BEGIN_SRC emacs-lisp tangle:yes
985 (require 'filladapt)
986 (eval-after-load "filladapt" '(diminish 'filladapt-mode))
987 (setq-default filladapt-mode t)
988 #+END_SRC
989 ** ffap
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
994 (ffap-bindings)
995 #+END_SRC
996 ** icicles
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
1000 (require 'icicles)
1001 (icy-mode 1)
1002 #+END_SRC
1003 ** uniquify
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
1006 (require 'uniquify)
1007 (setq uniquify-buffer-name-style 'post-forward)
1008 (setq uniquify-after-kill-buffer-p t)
1009 (setq uniquify-ignore-buffers-re "^\\*")
1010 #+END_SRC
1011
1012 ** abbrev
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
1015 ways.
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))
1021 (abbrev-mode 1)
1022 #+END_SRC
1023
1024 ** font-lock
1025 Obviously emacs can do syntax hilighting. For more things than you ever
1026 heard about.
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)
1032 #+END_SRC
1033 ** miniedit
1034 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
1035 #+BEGIN_SRC emacs-lisp tangle:yes
1036 (require 'miniedit)
1037 (miniedit-install)
1038 #+END_SRC
1039
1040 ** timestamp
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.
1043 - Time-stamp: <>
1044 - Time-stamp: " "
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)
1052 #+END_SRC
1053
1054 ** perl / cperl
1055 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
1056 up here to be used.
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))
1066
1067 (after '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)
1080
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'."
1084 (car
1085 (let ((cperl-message-on-help-error nil))
1086 (cperl-get-help))))
1087
1088 (add-hook 'cperl-mode-hook
1089 (lambda ()
1090 (set (make-local-variable 'eldoc-documentation-function)
1091 'my-cperl-eldoc-documentation-function)
1092 (eldoc-mode))))
1093 #+END_SRC
1094
1095 ** python
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))
1103
1104 (after '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 ()
1111 (auto-fill-mode 1)
1112 (set (make-local-variable 'fill-nobreak-predicate)
1113 (lambda ()
1114 (not (python-in-string/comment)))))
1115 (add-hook 'python-mode-hook
1116 (lambda ()
1117 (python-auto-fill-comments-only)))
1118 ;; pymacs
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))
1124 #+END_SRC
1125
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")
1130 (require 'ipython)
1131 (setq org-babel-python-mode 'python-mode))
1132
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")
1143 #+END_SRC
1144
1145 ** sh
1146 I prefer comments to be indented too
1147 #+BEGIN_SRC emacs-lisp tangle:yes
1148 (setq sh-indent-comment t)
1149 #+END_SRC
1150
1151 ** auto-revert
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)
1158 #+END_SRC
1159
1160 ** linum (line number)
1161 Various modes should have line numbers in front of each line.
1162
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
1166 (require 'linum)
1167 (setq linum-format "%3d ")
1168 (setq linum-mode-inhibit-modes-list '(org-mode
1169 eshell-mode
1170 shell-mode
1171 gnus-group-mode
1172 gnus-summary-mode
1173 gnus-article-mode))
1174
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)
1178 ad-do-it))
1179
1180 (ad-activate 'linum-on)
1181 (global-linum-mode 1)
1182 #+END_SRC
1183
1184 ** css
1185 #+BEGIN_SRC emacs-lisp tangle:yes
1186 (autoload 'css-mode "css-mode")
1187 (add-auto-mode 'css-mode "\\.css")
1188
1189 (after 'css-mode
1190 ;;; CSS flymake
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
1199 '(progn
1200 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
1201 (add-hook hook 'ac-css-mode-setup)))))
1202 #+END_SRC
1203
1204 ** mmm-mode
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
1209 (require 'mmm-auto)
1210 (setq mmm-global-mode 'buffers-with-submode-classes)
1211 (setq mmm-submode-decoration-level 2)
1212 (eval-after-load 'mmm-vars
1213 '(progn
1214 (mmm-add-group
1215 'html-css
1216 '((css-cdata
1217 :submode css-mode
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>" @)))
1223 (css
1224 :submode css-mode
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>" @)))
1230 (css-inline
1231 :submode css-mode
1232 :face mmm-code-submode-face
1233 :front "style=\""
1234 :back "\"")))
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)
1238 ))
1239
1240 #+END_SRC
1241
1242 ** html-helper
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)
1251 #+END_SRC
1252
1253 ** auctex
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)
1259 #+END_SRC
1260
1261 ** Debian related
1262 #+BEGIN_SRC emacs-lisp tangle:yes
1263 (require 'dpkg-dev-el-loaddefs nil 'noerror)
1264 (require 'debian-el-loaddefs nil 'noerror)
1265
1266 (setq debian-changelog-full-name "Joerg Jaspert")
1267 (setq debian-changelog-mailing-address "joerg@debian.org")
1268 #+END_SRC
1269
1270 ** org :FIXME:
1271 *** General settings
1272 [2013-04-28 So 17:06]
1273
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
1277 (require 'org)
1278 #+END_SRC
1279
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)
1284 #+END_SRC
1285
1286 *** Agenda
1287
1288 My current =org-agenda-files= variable only includes a set of
1289 directories.
1290 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1291 (setq org-agenda-files (quote ("~/org/"
1292 "~/org/debian"
1293 "~/org/debconf"
1294 "~/org/spi"
1295 "~/org/nsb"
1296 )))
1297 (setq org-default-notes-file "~/org/notes.org")
1298 #+END_SRC
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.
1305
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.
1311
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)
1315
1316 ;; Keep tasks with deadlines on the global todo lists
1317 (setq org-agenda-todo-ignore-deadlines nil)
1318
1319 ;; Keep tasks with scheduled dates on the global todo lists
1320 (setq org-agenda-todo-ignore-scheduled nil)
1321
1322 ;; Keep tasks with timestamps on the global todo lists
1323 (setq org-agenda-todo-ignore-timestamp nil)
1324
1325 ;; Remove completed deadline tasks from the agenda view
1326 (setq org-agenda-skip-deadline-if-done t)
1327
1328 ;; Remove completed scheduled tasks from the agenda view
1329 (setq org-agenda-skip-scheduled-if-done t)
1330
1331 ;; Remove completed items from search results
1332 (setq org-agenda-skip-timestamp-if-done t)
1333
1334 ;; Include agenda archive files when searching for things
1335 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
1336
1337 ;; Show all future entries for repeating tasks
1338 (setq org-agenda-repeating-timestamp-show-all t)
1339
1340 ;; Show all agenda dates - even if they are empty
1341 (setq org-agenda-show-all-dates t)
1342
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))))
1349
1350 ;; Start the weekly agenda on Monday
1351 (setq org-agenda-start-on-weekday 1)
1352
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))))
1357
1358 ;; Display tags farther right
1359 (setq org-agenda-tags-column -102)
1360
1361 ; position the habit graph on the agenda to the right of the default
1362 (setq org-habit-graph-column 50)
1363
1364 ; turn habits back on
1365 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
1366
1367 ;;
1368 ;; Agenda sorting functions
1369 ;;
1370 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
1371
1372
1373 (setq org-deadline-warning-days 30)
1374
1375 ;; Always hilight the current agenda line
1376 (add-hook 'org-agenda-mode-hook
1377 '(lambda () (hl-line-mode 1))
1378 'append)
1379 #+END_SRC
1380
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))
1385 'append)
1386
1387 (add-hook 'org-agenda-mode-hook
1388 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
1389 'append)
1390
1391 (add-hook 'org-agenda-mode-hook
1392 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
1393 'append)
1394
1395 (add-hook 'org-agenda-mode-hook
1396 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
1397 'append)
1398
1399 (add-hook 'org-agenda-mode-hook
1400 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
1401 'append)
1402
1403 ; Rebuild the reminders everytime the agenda is displayed
1404 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
1405
1406 ;(if (file-exists-p "~/org/refile.org")
1407 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
1408
1409 ; Activate appointments so we get notifications
1410 (appt-activate t)
1411
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))
1416
1417 (setq org-agenda-show-all-dates t)
1418 (setq org-agenda-start-on-weekday nil)
1419 (setq org-deadline-warning-days 14)
1420
1421 #+END_SRC
1422 *** Global keybindings.
1423 Start off by defining a series of keybindings.
1424
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
1430 (lambda ()
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))
1434 'append)
1435 #+END_SRC
1436
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)
1443
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)
1449
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)
1480
1481 (define-key org-mode-map [(control k)] 'jj-org-kill-line)
1482 #+END_SRC
1483
1484 *** Tasks, States, Todo fun
1485
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"))))
1491
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))))
1501 #+END_SRC
1502
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)
1509 #+END_SRC
1510 Changing a task state is done with =C-c C-t KEY=
1511
1512 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
1513
1514 The setting
1515 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1516 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1517 #+END_SRC
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.
1523
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.
1530
1531 The triggers break down to the following rules:
1532
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
1540
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")))))
1551 #+END_SRC
1552
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")
1558
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")
1578 "* %?\nAdded: %U\n"
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")
1591 )))
1592 #+END_SRC
1593
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.
1599
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)
1606 #+END_SRC
1607
1608 *** Refiling
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))))
1615
1616 ; Use full outline paths for refile targets - we file directly with IDO
1617 (setq org-refile-use-outline-path t)
1618
1619 ; Targets complete directly with IDO
1620 (setq org-outline-path-complete-in-steps nil)
1621
1622 ; Allow refile to create parent tasks with confirmation
1623 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1624
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)
1635
1636 ;;;; Refile settings
1637 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1638 #+END_SRC
1639
1640 *** Custom agenda
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)
1647
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))))
1657 (" " "Agenda"
1658 ((agenda "" nil)
1659 (tags "REFILE"
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
1666 '(category-keep))))
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
1686 '(category-keep))))
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)))
1693 (tags "-REFILE/"
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))))
1697 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
1717 '(category-keep))))
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
1722 '(category-keep))))
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))))))
1730
1731 ; Overwrite the current window with the agenda
1732 (setq org-agenda-window-setup 'current-window)
1733
1734 #+END_SRC
1735
1736 *** Time
1737 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1738 ;;
1739 ;; Resume clocking task when emacs is restarted
1740 (org-clock-persistence-insinuate)
1741 ;;
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)
1764
1765 ; use discrete minute intervals (no rounding) increments
1766 (setq org-time-stamp-rounding-minutes (quote (1 1)))
1767
1768 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1769
1770 (setq bh/keep-clock-running nil)
1771
1772 (setq org-agenda-clock-consistency-checks
1773 (quote (:max-duration "4:00"
1774 :min-duration 0
1775 :max-gap 0
1776 :gap-ok-around ("4:00"))))
1777
1778 #+END_SRC
1779
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.
1785
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.
1790
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.
1795
1796 **** Reporting
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)))
1801
1802 ;; Agenda log mode items to display (closed and state changes by default)
1803 (setq org-agenda-log-mode-items (quote (closed state)))
1804 #+END_SRC
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")
1810 #+END_SRC
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"))))
1817 #+END_SRC
1818
1819 *** Tags
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)
1824 ("@errand" . ?e)
1825 ("@office" . ?o)
1826 ("@home" . ?H)
1827 (:endgroup)
1828 ("PHONE" . ?p)
1829 ("WAITING" . ?w)
1830 ("HOLD" . ?h)
1831 ("PERSONAL" . ?P)
1832 ("WORK" . ?W)
1833 ("ORG" . ?O)
1834 ("PRIVATE" . ?N)
1835 ("crypt" . ?E)
1836 ("MARK" . ?M)
1837 ("NOTE" . ?n)
1838 ("CANCELLED" . ?c)
1839 ("FLAGGED" . ??))))
1840
1841 ; Allow setting single tags without the menu
1842 (setq org-fast-tag-selection-single-key (quote expert))
1843
1844 ; For tag searches ignore tasks with scheduled and deadline dates
1845 (setq org-agenda-tags-todo-honor-ignore-options t)
1846 #+END_SRC
1847
1848 *** Archiving
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")
1852 #+END_SRC
1853
1854 *** org-babel
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")
1858
1859 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
1860
1861 ; Make babel results blocks lowercase
1862 (setq org-babel-results-keyword "results")
1863
1864 (org-babel-do-load-languages
1865 (quote org-babel-load-languages)
1866 (quote ((emacs-lisp . t)
1867 (awk . t)
1868 (css . t)
1869 (makefile . t)
1870 (perl . t)
1871 (ruby . t)
1872 (dot . t)
1873 (ditaa . t)
1874 (R . t)
1875 (python . t)
1876 (ruby . t)
1877 (gnuplot . t)
1878 (clojure . t)
1879 (sh . t)
1880 (ledger . t)
1881 (org . t)
1882 (plantuml . t)
1883 (latex . t))))
1884
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)
1889
1890 ; Use fundamental mode when editing plantuml blocks with C-c '
1891 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
1892 #+END_SRC
1893
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)
1897 #+END_SRC
1898
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>"))
1903 #+END_SRC
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
1907 to them.
1908
1909 *** Publishing and exporting
1910
1911
1912 Org-mode can export to a variety of publishing formats including (but not limited to)
1913
1914 - ASCII
1915 (plain text - but not the original org-mode file)
1916 - HTML
1917 - LaTeX
1918 - Docbook
1919 which enables getting to lots of other formats like ODF, XML, etc
1920 - PDF
1921 via LaTeX or Docbook
1922 - iCal
1923
1924 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
1925
1926 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
1927 ;; Explicitly load required exporters
1928 (require 'ox-html)
1929 (require 'ox-latex)
1930 (require 'ox-ascii)
1931 ;; FIXME, check the following two
1932 ;(require 'ox-icalendar)
1933 ;(require 'ox-odt)
1934
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")
1938
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))
1942
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)
1949
1950 (setq org-html-head-extra (concat
1951 "<link rel=\"stylesheet\" href=\"http://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
1952 ))
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)
1960
1961
1962 (setq org-publish-project-alist
1963 '(
1964 ("config-notes"
1965 :base-directory "~/.emacs.d/"
1966 :base-extension "org"
1967 :exclude "elisp"
1968 :publishing-directory "/develop/www/emacs"
1969 :recursive t
1970 :publishing-function org-html-publish-to-html
1971 :headline-levels 4 ; Just the default for this project.
1972 :auto-preamble t
1973 :auto-sitemap t
1974 :makeindex t
1975 )
1976 ("config-static"
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"
1981 :recursive t
1982 :publishing-function org-publish-attachment
1983 )
1984 ("inherit-org-info-js"
1985 :base-directory "/develop/vcs/org-info-js/"
1986 :recursive t
1987 :base-extension "js"
1988 :publishing-directory "/develop/www/"
1989 :publishing-function org-publish-attachment
1990 )
1991 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
1992 )
1993 )
1994 )
1995
1996 (setq org-export-with-timestamps nil)
1997 #+END_SRC
1998
1999 **** Latex export
2000
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)
2007
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."
2013 (let ((texcmd)))
2014 ;; default command: oldstyle latex via dvi
2015 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
2016 ;; pdflatex -> .pdf
2017 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
2018 (setq texcmd "latexmk -pdf -quiet %f"))
2019 ;; xelatex -> .pdf
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)))
2024
2025 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
2026
2027 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
2028 (setq org-export-latex-packages-alist
2029 '(("" "graphicx" t)
2030 ("" "longtable" nil)
2031 ("" "float" nil)
2032 ("" "minted" nil)
2033 ))
2034
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)
2040 ("T1" "fontenc" t)
2041 ("" "fixltx2e" nil)
2042 ("" "wrapfig" nil)
2043 ("" "soul" t)
2044 ("" "textcomp" t)
2045 ("" "marvosym" t)
2046 ("" "wasysym" t)
2047 ("" "latexsym" t)
2048 ("" "amssymb" t)
2049 ("" "hyperref" nil)))
2050
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
2054 '(("" "fontspec" t)
2055 ("" "xunicode" t)
2056 ("" "url" t)
2057 ("" "rotating" t)
2058 ("german" "babel" t)
2059 ("babel" "csquotes" t)
2060 ("" "soul" t)
2061 ("xetex" "hyperref" nil)
2062 )))
2063
2064 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
2065 (setq org-export-latex-classes
2066 (cons '("scrartcl"
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))))
2074
2075 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
2076 #+END_SRC
2077
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=
2082
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.
2086
2087 #+BEGIN_SRC emacs-lisp tangle:yes :tangle yes
2088 (setq org-catch-invisible-edits 'error)
2089 #+END_SRC
2090
2091 *** Whatever
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 "")))
2095
2096 ; force showing the next headline.
2097 (setq org-show-entry-below (quote ((default))))
2098
2099 (setq org-show-following-heading t)
2100 (setq org-show-hierarchy-above t)
2101 (setq org-show-siblings (quote ((default))))
2102
2103 (setq org-special-ctrl-a/e t)
2104 (setq org-special-ctrl-k t)
2105 (setq org-yank-adjusted-subtrees t)
2106
2107 (setq org-table-export-default-format "orgtbl-to-csv")
2108
2109 #+END_SRC
2110
2111 The following setting adds alphabetical lists like
2112 ,a. item one
2113 ,b. item two
2114
2115 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2116 (setq org-alphabetical-lists t)
2117 #+END_SRC
2118
2119 #+BEGIN_SRC emacs-lisp tangle:yes :tangle yes
2120 (setq org-remove-highlights-with-change nil)
2121
2122 (setq org-list-demote-modify-bullet (quote (("+" . "-")
2123 ("*" . "-")
2124 ("1." . "-")
2125 ("1)" . "-"))))
2126
2127
2128
2129 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
2130
2131
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)
2134
2135 #+END_SRC
2136
2137
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)
2144 #+END_SRC
2145
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.
2151
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))))
2157 #+END_SRC
2158
2159 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2160 (setq org-reverse-note-order nil)
2161 (setq org-default-notes-file "~/notes.org")
2162 #+END_SRC
2163
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)
2169 #+END_SRC
2170
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)
2196
2197 ; regularly save our org-mode buffers
2198 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
2199
2200 (setq org-log-done t)
2201
2202 (setq org-enable-priority-commands t)
2203 (setq org-default-priority ?E)
2204 (setq org-lowest-priority ?E)
2205
2206
2207 #+END_SRC
2208
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
2211 code block.
2212
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.
2218
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)
2222 ("1" . ignore)
2223 ("2" . ignore)
2224 ("3" . ignore)
2225 ("4" . ignore)
2226 ("5" . ignore)
2227 ("6" . ignore)
2228 ("7" . ignore)
2229 ("8" . ignore)
2230 ("9" . ignore)
2231
2232 ("a" . ignore)
2233 ("d" . ignore)
2234 ("h" . bh/hide-other)
2235 ("i" progn
2236 (forward-char 1)
2237 (call-interactively 'org-insert-heading-respect-content))
2238 ("k" . org-kill-note-or-show-branches)
2239 ("l" . ignore)
2240 ("m" . ignore)
2241 ("q" . bh/show-org-agenda)
2242 ("r" . ignore)
2243 ("s" . org-save-all-org-buffers)
2244 ("w" . org-refile)
2245 ("x" . ignore)
2246 ("y" . ignore)
2247 ("z" . org-add-note)
2248
2249 ("A" . ignore)
2250 ("B" . ignore)
2251 ("E" . ignore)
2252 ("F" . bh/restrict-to-file-or-follow)
2253 ("G" . ignore)
2254 ("H" . ignore)
2255 ("J" . org-clock-goto)
2256 ("K" . ignore)
2257 ("L" . ignore)
2258 ("M" . ignore)
2259 ("N" . bh/narrow-to-org-subtree)
2260 ("P" . bh/narrow-to-org-project)
2261 ("Q" . ignore)
2262 ("R" . ignore)
2263 ("S" . ignore)
2264 ("T" . bh/org-todo)
2265 ("U" . bh/narrow-up-one-org-level)
2266 ("V" . ignore)
2267 ("W" . bh/widen)
2268 ("X" . ignore)
2269 ("Y" . ignore)
2270 ("Z" . ignore))))
2271
2272 (add-hook 'org-agenda-mode-hook
2273 (lambda ()
2274 (define-key org-agenda-mode-map "q" 'bury-buffer))
2275 'append)
2276
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))
2280 'append)
2281 #+END_SRC
2282
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.
2288
2289 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2290 (setq org-src-fontify-natively t)
2291 (setq org-src-tab-acts-natively t)
2292 #+END_SRC
2293
2294 #+BEGIN_SRC emacs-lisp tangle:yes :tangle yes
2295 (setq org-src-preserve-indentation nil)
2296 (setq org-edit-src-content-indentation 0)
2297 #+END_SRC
2298
2299
2300 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2301 (setq org-attach-directory "~/org/data/")
2302 #+END_SRC
2303 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2304 (setq org-agenda-sticky t)
2305 #+END_SRC
2306
2307 **** Checklist handling
2308 [2013-05-11 Sat 22:15]
2309
2310 #+BEGIN_SRC emacs-lisp tangle:yes tangle:yes
2311 (require 'org-checklist)
2312 #+END_SRC
2313
2314 ** transient mark
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)
2319 #+END_SRC
2320 ** cua
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
2326 (cua-mode t)
2327 (setq cua-enable-cua-keys (quote shift))
2328 #+END_SRC
2329
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
2334 movement keys.
2335 #+BEGIN_SRC emacs-lisp tangle:yes
2336 (cua-selection-mode t)
2337 #+END_SRC
2338
2339 ** mo-git-blame
2340 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2341 Emacs]].
2342
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)
2346 #+END_SRC
2347
2348 ** mingus
2349 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2350
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)
2355 (after '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/"))
2363 #+END_SRC
2364
2365 ** sessions
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))
2373 ad-do-it))
2374
2375
2376 ;;----------------------------------------------------------------------------
2377 ;; Restore histories and registers after saving
2378 ;;----------------------------------------------------------------------------
2379 (require 'session)
2380
2381 (setq session-save-file (expand-file-name "session" jj-cache-dir))
2382 (add-hook 'after-init-hook 'session-initialize)
2383
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)
2389 (grep-history . 30)
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)
2396 (search-ring . 20)
2397 (comint-input-ring . 50)
2398 (shell-command-history . 50)
2399 kill-ring
2400 desktop-missing-file-warning
2401 tags-file-name
2402 register-alist)))
2403
2404 #+END_SRC
2405 *** savehist
2406 [2013-04-21 So 20:25]
2407 Save a bit of history
2408 #+BEGIN_SRC emacs-lisp tangle no
2409 (require 'savehist)
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))
2415 (savehist-mode +1)
2416 #+END_SRC
2417
2418 *** saveplace
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))
2424 #+END_SRC
2425 ** easypg
2426 EasyPG is a GnuPG interface for Emacs.
2427 #+BEGIN_SRC emacs-lisp tangle:yes
2428 (require 'epa-file)
2429 (epa-file-enable)
2430 #+END_SRC
2431
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
2436 terminals."
2437 (if (display-graphic-p)
2438 ad-do-it
2439 (let ((agent (getenv "GPG_AGENT_INFO")))
2440 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
2441 ad-do-it
2442 (setenv "GPG_AGENT_INFO" agent))))
2443 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
2444 (ad-activate 'epg--start)
2445 #+END_SRC
2446 ** message
2447 #+BEGIN_SRC emacs-lisp tangle:yes
2448 (require 'message)
2449 (setq message-kill-buffer-on-exit t)
2450 #+END_SRC
2451 ** gnus
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
2458 (after 'gnus
2459 (jj-init-theme)
2460 )
2461 #+END_SRC
2462
2463 ** url
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)))
2470 #+END_SRC
2471 ** hippie-exp
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
2482 try-expand-line
2483 try-complete-lisp-symbol-partially
2484 try-complete-lisp-symbol))
2485 (global-set-key (kbd "M-/") 'hippie-expand)
2486 #+END_SRC
2487 ** yasnippet
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)
2494 (yas-global-mode 1)
2495
2496 ;; Integrate hippie-expand with ya-snippet
2497 (add-to-list 'hippie-expand-try-functions-list
2498 'yas-hippie-try-expand)
2499 #+END_SRC
2500 ** elpa
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)
2506 (require 'package)
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/"))
2511 )
2512 #+END_SRC
2513 ** multiple cursors
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))
2525 #+END_SRC
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))
2536 #+END_SRC
2537 ** undo-tree
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)
2548 #+END_SRC
2549
2550 Additionally I would like to keep the region active should I undo
2551 while I have one.
2552
2553 #+BEGIN_SRC emacs-lisp tangle:yes
2554 ;; Keep region when undoing in region
2555 (defadvice undo-tree-undo (around keep-region activate)
2556 (if (use-region-p)
2557 (let ((m (set-marker (make-marker) (mark)))
2558 (p (set-marker (make-marker) (point))))
2559 ad-do-it
2560 (goto-char p)
2561 (set-mark m)
2562 (set-marker p nil)
2563 (set-marker m nil))
2564 ad-do-it))
2565 #+END_SRC
2566 ** windmove
2567 [2013-04-21 So 20:27]
2568 Use hyper + arrow keys to switch between visible buffers
2569 #+BEGIN_SRC emacs-lisp tangle:yes
2570 (require 'windmove)
2571 (windmove-default-keybindings 'hyper)
2572 (setq windmove-wrap-around t)
2573 #+END_SRC
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)
2584 #+END_SRC
2585 ** ediff
2586 [2013-04-21 So 20:36]
2587 ediff - don't start another frame
2588 #+BEGIN_SRC elisp
2589 (require 'ediff)
2590 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
2591 #+END_SRC
2592 ** re-builder
2593 Saner regex syntax
2594 #+BEGIN_SRC emacs-lisp tangle:yes
2595 (require 're-builder)
2596 (setq reb-re-syntax 'string)
2597 #+END_SRC
2598 ** magit
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)
2606 #+END_SRC
2607
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)
2614 (require 'paredit)
2615
2616 (setq lisp-coding-hook 'lisp-coding-defaults)
2617 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2618
2619 (after "paredit"
2620 '(diminish 'paredit-mode " π"))
2621
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)))
2625
2626 (define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
2627
2628 (after "elisp-slime-nav"
2629 '(diminish 'elisp-slime-nav-mode))
2630 (after "rainbow-mode"
2631 '(diminish 'rainbow-mode))
2632 (after "eldoc"
2633 '(diminish 'eldoc-mode))
2634 #+END_SRC
2635
2636 ** writegood
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)
2643 #+END_SRC
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
2649 already had typed.
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)
2654
2655 (setq ac-expand-on-auto-complete nil)
2656 (setq ac-dwim t)
2657 (setq ac-auto-start t)
2658
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)
2664
2665 ;; hook AC into completion-at-point
2666 (defun sanityinc/auto-complete-at-point ()
2667 (when (and (not (minibufferp))
2668 (fboundp 'auto-complete-mode)
2669 auto-complete-mode)
2670 (auto-complete)))
2671
2672 (defun set-auto-complete-as-completion-at-point-function ()
2673 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
2674
2675 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
2676
2677 (require 'ac-dabbrev)
2678 (set-default 'ac-sources
2679 '(ac-source-imenu
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
2684 ac-source-dabbrev))
2685
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))
2692
2693 ;; Exclude very large buffers from dabbrev
2694 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
2695 (< (buffer-size other-buffer) (* 1 1024 1024)))
2696
2697 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
2698
2699
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)
2706
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)
2710
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)
2715 #+END_SRC
2716 ** yaml-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
2725 '(lambda ()
2726 (define-key yaml-mode-map "\C-m" 'newline-and-indent)))
2727 #+END_SRC
2728
2729 ** flycheck
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
2733 understand for me.
2734 #+BEGIN_SRC emacs-lisp tangle:yes
2735 (when (> emacs-major-version 23)
2736 (require 'flycheck)
2737 (add-hook 'after-init-hook #'global-flycheck-mode))
2738 #+END_SRC
2739 ** crontab-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\\)?\\'")
2744 #+END_SRC
2745
2746 ** nxml
2747 [2013-05-22 Wed 22:02]
2748 nxml-mode is a major mode for editing XML.
2749 #+BEGIN_SRC emacs-lisp tangle:yes
2750 (add-auto-mode
2751 'nxml-mode
2752 (concat "\\."
2753 (regexp-opt
2754 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2755 "gpx" "tcx"))
2756 "\\'"))
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)
2760
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
2766 indentation rules."
2767 (interactive "r")
2768 (save-excursion
2769 (nxml-mode)
2770 (goto-char begin)
2771 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2772 (backward-char) (insert "\n"))
2773 (indent-region begin end)))
2774
2775 ;;----------------------------------------------------------------------------
2776 ;; Integration with tidy for html + xml
2777 ;;----------------------------------------------------------------------------
2778 ;; tidy is autoloaded
2779 (eval-after-load 'tidy
2780 '(progn
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)))
2783 ))
2784
2785 #+END_SRC
2786 ** ruby
2787 [2013-05-22 Wed 22:33]
2788 Programming in ruby...
2789
2790 *** Auto-modes
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\\'")
2796 #+END_SRC
2797
2798 *** Config
2799 #+BEGIN_SRC emacs-lisp tangle:yes
2800 (after 'ruby-mode
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)
2804
2805 (require 'ruby-hash-syntax)
2806 (require 'inf-ruby)
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
2811 (lambda ()
2812 (unless (derived-mode-p 'prog-mode)
2813 (run-hooks 'prog-mode-hook))))
2814
2815 )
2816 #+END_SRC
2817 ** emms
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)
2836
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)
2840 (emms-lyrics 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)
2843 (emms-score 1)
2844 (when (fboundp 'emms-cache) ; work around compiler warning
2845 (emms-cache 1))
2846 (setq emms-score-default-score 3)
2847
2848 (defun emms-mpd-init ()
2849 "Connect Emms to mpd."
2850 (interactive)
2851 (emms-player-mpd-connect))
2852
2853 ;; players
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)
2861
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")
2869
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")))
2876
2877 ;; Playlist format
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))
2896 (rate-char ?☭)
2897 )
2898 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
2899 (emms-last-played-format-date last-played)
2900 artist
2901 year
2902 album
2903 (if (and tracknumber ; tracknumber
2904 (not (zerop (string-to-number tracknumber))))
2905 (format "%02d" (string-to-number tracknumber))
2906 "")
2907 title
2908 play-count
2909 (make-string rating rate-char)))
2910 )
2911
2912 (setq emms-track-description-function 'my-describe)
2913
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)
2928
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)
2933
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)))
2938
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)
2943
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)
2950
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)
2955
2956 (setq emms-playlist-buffer-name "*EMMS Playlist*"
2957 emms-playlist-mode-open-playlists t)
2958
2959 ;; Faces
2960 (if (window-system)
2961 ((lambda ()
2962 (set-face-attribute
2963 'emms-browser-artist-face nil
2964 :family "Arno Pro")
2965 )
2966 ))
2967
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)
2974
2975 #+END_SRC
2976 ** yafolding
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)
2984 #+END_SRC
2985 ** icomplete
2986 Incremental mini-buffer completion preview: Type in the minibuffer,
2987 list of matching commands is echoed
2988 #+BEGIN_SRC emacs-lisp tangle:yes
2989 (icomplete-mode 99)
2990 #+END_SRC
2991
2992 * Thats it
2993 And thats it for this file, control passes "back" to [[file:../initjj.org][initjj.org/el]]
2994 which then may load more files.