1 #+TITLE: emacs.org - Ganneffs emacs configuration
2 #+DESCRIPTION: My current Emacs configuration
3 #+KEYWORDS: org-mode Emacs configuration
4 #+STARTUP: align fold nodlcheck hidestars oddeven lognotestate
5 #+SETUPFILE: ~/.emacs.d/elisp/org-templates/level-0.org
11 :ID: b6e6cf73-9802-4a7b-bd65-fdb6f9745319
13 The following functions are used throughout my config, and so I load
16 safe-load does not break emacs initialization, should a file be
17 unreadable while emacs boots up.
18 #+BEGIN_SRC emacs-lisp :tangle yes
19 (defvar safe-load-error-list ""
20 "*List of files that reported errors when loaded via safe-load")
22 (defun safe-load (file &optional noerror nomessage nosuffix)
23 "Load a file. If error on load, report back, wait for
24 a key stroke then continue on"
26 (condition-case nil (load file noerror nomessage nosuffix)
29 (setq safe-load-error-list (concat safe-load-error-list " " file))
30 (message "****** [Return to continue] Error loading %s" safe-load-error-list )
34 (defun safe-load-check ()
35 "Check for any previous safe-load loading errors. (safe-load.el)"
37 (if (string-equal safe-load-error-list "") ()
38 (message (concat "****** error loading: " safe-load-error-list))))
41 I have some stuff put away in my local dir. I don't want to load it all
42 at startup time, so it is using the autoload feature. For that to work
43 load the loaddefs, so autoload knows where to grab stuff
44 #+BEGIN_SRC emacs-lisp :tangle yes
45 (safe-load (concat jj-elisp-dir "/tiny/loaddefs.el"))
46 (safe-load (concat jj-elisp-local-dir "/loaddefs.el"))
48 *** Keep *scratch* around
49 Always ensure to have a scratch buffer around.
50 #+BEGIN_SRC emacs-lisp :tangle yes
51 (with-current-buffer (get-buffer-create "*scratch*")
52 (lisp-interaction-mode)
53 (make-local-variable 'kill-buffer-query-functions)
54 (add-hook 'kill-buffer-query-functions 'kill-scratch-buffer))
57 Handier way to add modes to auto-mode-alist
58 #+BEGIN_SRC emacs-lisp :tangle yes
59 (defun add-auto-mode (mode &rest patterns)
60 "Add entries to `auto-mode-alist' to use `MODE' for all given file `PATTERNS'."
61 (dolist (pattern patterns)
62 (add-to-list 'auto-mode-alist (cons pattern mode))))
64 *** config helpers use-package/bind-key
65 Helpers for the config
66 https://github.com/jwiegley/use-package
67 #+BEGIN_SRC emacs-lisp :tangle yes
68 (require 'use-package)
72 [2014-05-20 Tue 22:36]
73 #+BEGIN_SRC emacs-lisp :tangle yes
74 (defmacro hook-into-modes (func modes)
75 `(dolist (mode-hook ,modes)
76 (add-hook mode-hook ,func)))
80 The Emacs Lisp Package Archive contains things I want.
81 #+BEGIN_SRC emacs-lisp :tangle yes
82 (when (> emacs-major-version 23)
84 (setq package-user-dir (expand-file-name "elpa" jj-elisp-dir))
85 (dolist (source '(("melpa" . "http://melpa.milkbox.net/packages/")
86 ("melpa-stable" . "http://melpa-stable.milkbox.net/packages/")
87 ("marmalade" . "http://marmalade-repo.org/packages/")
88 ("elpy" . "http://jorgenschaefer.github.io/packages/")
89 ("elpa" . "http://tromey.com/elpa/")))
90 (add-to-list 'package-archives source t))
96 We need to define the load-path. As I have lots of things I add
97 locally, its getting a few entries. I disliked the repeated
98 /add-to-list/ lines, so I now just take all subdirectories of
99 jj-elisp-dir and add them.
100 #+BEGIN_SRC emacs-lisp :tangle yes
102 (project (directory-files jj-elisp-dir t "\\w+"))
103 (when (file-directory-p project)
104 (if (string= project "emacs23")
105 (when (version< emacs-version "24")
106 (add-to-list 'load-path project))
107 (add-to-list 'load-path project))))
111 Help emacs to find the info files
112 #+BEGIN_SRC emacs-lisp :tangle no
113 (setq Info-directory-list '("~/emacs/info"
114 "/usr/local/share/info/"
116 "/usr/local/gnu/info/"
117 "/usr/local/gnu/lib/info/"
118 "/usr/local/gnu/lib/emacs/info/"
119 "/usr/local/emacs/info/"
120 "/usr/local/lib/info/"
121 "/usr/local/lib/emacs/info/"
122 "/usr/share/info/emacs-23"
125 (setq Info-default-directory-list
126 (cons "~/emacs/info" Info-default-directory-list))
132 :ID: 0a1560d9-7e55-47ab-be52-b3a8b8eea4aa
134 I dislike the startup message
135 #+BEGIN_SRC emacs-lisp :tangle yes
136 (setq inhibit-splash-screen t)
137 (setq inhibit-startup-message t)
140 Usually I want the lines to break at 72 characters.
141 #+BEGIN_SRC emacs-lisp :tangle yes
142 (setq fill-column 72)
145 And it is nice to have a final newline in files.
146 (Now off, ethan-wspace is doing it better).
147 #+BEGIN_SRC emacs-lisp :tangle yes
148 (setq require-final-newline nil)
149 (setq mode-require-final-newline nil)
152 After I typed 300 characters or took a break for more than a minute it
153 would be nice of emacs to save whatever I am on in one of its auto-save
154 backups. See [[info:emacs#Auto%20Save%20Control][info:emacs#Auto Save Control]] for more details.
155 #+BEGIN_SRC emacs-lisp :tangle yes
156 (setq auto-save-interval 300)
157 (setq auto-save-timeout 60)
160 Set my full name and my default mail address - for whatever wants to use
161 it later. Also, I am using gnus.
162 #+BEGIN_SRC emacs-lisp :tangle yes
163 (setq user-full-name "Joerg Jaspert")
164 (setq user-mail-address "joerg@ganneff.de")
165 (setq mail-user-agent (quote gnus-user-agent))
168 My default mail server. Well, simply a localhost, I have a forwarder that
169 puts mail off the right way, no need for emacs to have any further
171 #+BEGIN_SRC emacs-lisp :tangle yes
172 (setq smtpmail-default-smtp-server "localhost")
173 (setq smtpmail-smtp-server "localhost")
176 Enable automatic handling of compressed files.
177 #+BEGIN_SRC emacs-lisp :tangle yes
178 (auto-compression-mode 1)
181 Emacs forbids a certain set of commands, as they can be very confusing
182 for new users. Enable them.
183 #+BEGIN_SRC emacs-lisp :tangle yes
184 (put 'narrow-to-region 'disabled nil)
185 (put 'narrow-to-page 'disabled nil)
186 (put 'narrow-to-defun 'disabled nil)
187 (put 'upcase-region 'disabled nil)
188 (put 'downcase-region 'disabled nil)
192 I've tried various different fonts and while I like the Terminus font
193 most for my shells, in Emacs Inconsolata clearly wins.
194 #+BEGIN_SRC emacs-lisp :tangle yes
195 (set-frame-font "Inconsolata-14")
198 I always use dark backgrounds, so tell Emacs about it. No need to
200 #+BEGIN_SRC emacs-lisp :tangle yes
201 (setq-default frame-background-mode jj-color-style)
204 And I always liked dark backgrounds with colors setup for them. So I
205 switched through multiple themes doing it in emacs too, but never
206 entirely liked it. Until I found solarized, which is now not only my
207 emacs theme, but also for most of my other software too, especially my
208 shell. Consistent look is great.
209 #+BEGIN_SRC emacs-lisp :tangle no
210 (if (or (> emacs-major-version 23) (boundp 'custom-theme-load-path))
212 (defun jj-init-theme ()
214 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
215 (load-theme 'solarized-light t))
216 (set-face-attribute 'org-date nil :underline nil)
217 (message "Initializing theme solarized-dark")
219 (add-to-list 'custom-theme-load-path jj-theme-dir)
220 (add-hook 'after-init-hook 'jj-init-theme)
222 (add-to-list 'load-path (expand-file-name "emacs-color-theme-solarized" jj-elisp-dir))
223 (require 'color-theme-solarized)
224 (color-theme-solarized-dark)
227 #+BEGIN_SRC emacs-lisp :tangle yes
228 (use-package solarized
229 :load-path "elisp/emacs-color-theme-solarized"
232 (defun jj-init-theme ()
234 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
235 (load-theme 'solarized-light t))
236 (set-face-attribute 'org-date nil :underline nil)
237 (message "Initializing theme solarized-dark")
239 (add-to-list 'custom-theme-load-path jj-theme-dir)
240 (add-hook 'after-init-hook 'jj-init-theme)
244 Make the fringe (gutter) smaller, the argument is a width in pixels (the default is 8)
245 #+BEGIN_SRC emacs-lisp :tangle yes
246 (if (fboundp 'fringe-mode)
250 A bit more spacing between buffer lines
251 #+BEGIN_SRC emacs-lisp :tangle yes
252 (setq-default line-spacing 0.1)
255 [2013-04-21 So 20:54]
256 I do not want my cursor to blink.
257 #+BEGIN_SRC emacs-lisp :tangle yes
258 (blink-cursor-mode -1)
260 *** Menu, Tool and Scrollbar
261 I don't want to see the menu-bar, tool-bar or scrollbar.
262 #+BEGIN_SRC emacs-lisp :tangle yes
264 (dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode))
265 (when (fboundp mode) (funcall mode -1))))
267 **** When using emacs in daemon mode
268 Emacs has a very nice mode where it detaches itself and runs as daemon -
269 and you can just open /frames/ (windows) from it by using [[http://www.emacswiki.org/emacs/EmacsClient][Emacs
270 Client]]. It's fast, it's nice, it's convinient.
272 Except that Emacs behaves stupid when you do that and ignores your
273 menu/tool/scrollbar settings. Sucks.
275 For them to work even then, we have to do two things.
276 1. We have to set the frame alist. We simple set both,
277 =initial-frame-alist= and =default-frame-alist= to the same value here.
278 #+BEGIN_SRC emacs-lisp :tangle yes
279 (setq initial-frame-alist '(
280 (horizontal-scroll-bars . nil)
281 (vertical-scroll-bars . nil)
284 (setq default-frame-alist (copy-alist initial-frame-alist))
286 2. We have to disable the toolbar using the customize interface, so you
287 can find that in the [[id:0102208d-fdf6-4928-9e40-7e341bd3aa3a][Customized variables]] section.
289 *** Hilight current line in buffer
290 As it says, it does a hilight of the current line.
291 #+BEGIN_SRC emacs-lisp :tangle yes
292 (global-hl-line-mode +1)
294 *** Allow recursive minibuffers
295 This allows (additional) minibuffer commands while in the minibuffer.
296 #+BEGIN_SRC emacs-lisp :tangle yes
297 (setq enable-recursive-minibuffers 't)
300 *** Modeline related changes
301 I want to see line and column numbers, so turn them on.
302 Size indication lets me know how far I am in a buffer.
304 And modeline-posn is great. It will hilight the column number in the
305 modeline in red as soon as you are over the defined limit.
307 #+BEGIN_SRC emacs-lisp :tangle yes
309 (column-number-mode 1)
310 (size-indication-mode 1)
311 (display-time-mode 1)
312 (setq display-time-day-and-date nil)
313 (setq display-time-24hr-format t)
314 (setq modelinepos-column-limit 72)
316 (use-package modeline-posn
317 :ensure modeline-posn
320 (set-face-foreground 'modelinepos-column-warning "grey20")
321 (set-face-background 'modelinepos-column-warning "red")
322 (setq modelinepos-column-limit 72))
327 [2013-04-22 Mon 11:27]
328 The modeline is easily cluttered up with stuff I don't really need to
329 see. So lets hide those. There are two ways, one of them uses diminish
330 to get entirely rid of some modes, the other is a function taken from
331 "Mastering Emacs" which replaces the modes text with an own (set of)
333 #+BEGIN_SRC emacs-lisp :tangle yes
335 (diminish 'auto-fill-function)
336 (defvar mode-line-cleaner-alist
337 `((auto-complete-mode . " α")
338 (yas-minor-mode . " y")
339 (paredit-mode . " π")
343 (lisp-interaction-mode . "λ")
346 (emacs-lisp-mode . "EL")
348 (org-indent-mode . "")
350 (nxhtml-mode . "nx"))
352 "Alist for `clean-mode-line'.
354 When you add a new element to the alist, keep in mind that you
355 must pass the correct minor/major mode symbol and a string you
356 want to use in the modeline *in lieu of* the original.
358 Want some symbols? Go:
360 ;ςερτζθιοπασδφγηξκλυχψωβνμ
361 :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
362 @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
366 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
369 Unfortunately icicles breaks this with the way it adds/removes itself,
370 so take it our for now...
373 Back when I started with text-mode. But nowadays I want default mode to
374 be org-mode - it is just so much better to use. And does sensible things
375 with many README files out there, and various other "crap" you get to
377 #+BEGIN_SRC emacs-lisp :tangle yes
378 (setq major-mode 'org-mode)
379 (setq initial-major-mode 'org-mode)
383 [2013-04-23 Tue 16:43]
384 Shell. zsh in my case.
385 #+BEGIN_SRC emacs-lisp :tangle yes
386 (setq shell-file-name "zsh")
387 (setq shell-command-switch "-c")
388 (setq explicit-shell-file-name shell-file-name)
389 (setenv "SHELL" shell-file-name)
390 (setq explicit-sh-args '("-login" "-i"))
391 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
392 (setq comint-scroll-to-bottom-on-input t) ; always insert at the bottom
393 (setq comint-scroll-to-bottom-on-output t) ; always add output at the bottom
394 (setq comint-scroll-show-maximum-output t) ; scroll to show max possible output
395 (setq comint-completion-autolist t) ; show completion list when ambiguous
396 (setq comint-input-ignoredups t) ; no duplicates in command history
397 (setq comint-completion-addsuffix t) ; insert space/slash after file completion
401 Basic settings for emacs integrated shell
402 #+BEGIN_SRC emacs-lisp :tangle yes
407 (defun eshell-initialize ()
408 (defun eshell-spawn-external-command (beg end)
409 "Parse and expand any history references in current input."
412 (when (looking-back "&!" beg)
413 (delete-region (match-beginning 0) (match-end 0))
416 (add-hook 'eshell-expand-input-functions 'eshell-spawn-external-command)
417 (eval-after-load "em-unix"
419 (unintern 'eshell/su)
420 (unintern 'eshell/sudo))))
421 (add-hook 'eshell-first-time-mode-hook 'eshell-initialize)
431 (setq eshell-cmpl-cycle-completions nil
432 eshell-save-history-on-exit t
433 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
434 (setenv "PAGER" "cat")
435 (setq eshell-visual-commands
436 '("less" "tmux" "htop" "top" "bash" "zsh" "tail"))
437 (setq eshell-visual-subcommands
438 '(("git" "log" "l" "diff" "show")))
440 (add-to-list 'eshell-command-completions-alist
442 (add-to-list 'eshell-command-completions-alist
443 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
445 ;(set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
446 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
447 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
448 (add-hook 'eshell-preoutput-filter-functions
449 'ansi-color-filter-apply)
450 ;; Prompt with a bit of help from http://www.emacswiki.org/emacs/EshellPrompt
452 (defmacro with-face (str &rest properties)
453 `(propertize ,str 'face (list ,@properties)))
455 (defun eshell/abbr-pwd ()
456 (let ((home (getenv "HOME"))
459 ((string-equal home path) "~")
460 ((f-ancestor-of? home path) (concat "~/" (f-relative path home)))
463 (defun eshell/my-prompt ()
464 (let ((header-bg "#161616"))
466 (with-face user-login-name :foreground "cyan")
467 (with-face (concat "@" hostname) :foreground "white")
469 (with-face (eshell/abbr-pwd) :foreground "#009900")
471 (with-face "#" :foreground "red")
472 (with-face "$" :foreground "#69b7f0"))
475 (setq eshell-prompt-function 'eshell/my-prompt)
476 (setq eshell-highlight-prompt nil)
477 (setq eshell-prompt-regexp "^[^#$\n]+[#$] ")))
481 Incremental search is great, but annoyingly you need to type whatever
482 you want. If you want to search for just the next (or previous)
483 occurence of what is at your cursor position use the following.
484 *C-x* will insert the current word while *M-up* and *M-down* will just
485 jump to the next/previous occurence of it.
486 #+BEGIN_SRC emacs-lisp :tangle yes
487 (bind-key "C-x" 'sacha/isearch-yank-current-word isearch-mode-map)
488 (bind-key* "<M-up>" 'sacha/search-word-backward)
489 (bind-key* "<M-down>" 'sacha/search-word-forward)
492 *** Frame configuration
493 I want to see the buffername and its size, not the host I am on in my
495 #+BEGIN_SRC emacs-lisp :tangle yes
496 (setq frame-title-format "%b (%i)")
499 *** Protect some buffers
500 I don't want some buffers to be killed, **scratch** for example.
501 In the past I had a long function that just recreated them, but the
502 =keep-buffers= package is easier.
503 #+BEGIN_SRC emacs-lisp :tangle yes
504 (use-package keep-buffers
507 (keep-buffers-mode 1)
508 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
509 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
510 (push '("\\`*Group" . nil) keep-buffers-protected-alist)
515 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
517 #+BEGIN_SRC emacs-lisp :tangle yes
518 (defalias 'yes-or-no-p 'y-or-n-p)
521 *** Language/i18n stuff
522 In this day and age, UTF-8 is the way to go.
523 #+BEGIN_SRC emacs-lisp :tangle yes
524 (set-language-environment 'utf-8)
525 (set-default-coding-systems 'utf-8)
526 (set-terminal-coding-system 'utf-8)
527 (set-keyboard-coding-system 'utf-8)
528 (set-clipboard-coding-system 'utf-8)
529 (prefer-coding-system 'utf-8)
530 (set-charset-priority 'unicode)
531 (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
534 *** Hilight matching parentheses
535 While I do have the nifty shortcut to jump to the other parentheses,
536 hilighting them makes it obvious where they are.
537 #+BEGIN_SRC emacs-lisp :tangle yes
539 (use-package mic-paren
547 (setq show-paren-style 'parenthesis)
552 *** Kill other buffers
553 While many editors allow you to close "all the other files, not the one
554 you are in", emacs doesn't have this... Except, now it will.
555 (Update 30.05.2014: Not used ever, deactivated)
556 #+BEGIN_SRC emacs-lisp :tangle no
557 (bind-key "C-c k" 'prelude-kill-other-buffers)
560 Default scrolling behaviour in emacs is a bit annoying, who wants to
562 #+BEGIN_SRC emacs-lisp :tangle yes
563 (setq scroll-margin 0)
564 (setq scroll-conservatively 100000)
565 (setq scroll-up-aggressively 0.0)
566 (setq scroll-down-aggressively 0.0)
567 (setq scroll-preserve-screen-position t)
570 *** Copy/Paste with X
571 [2013-04-09 Di 23:31]
572 The default how emacs handles cutting/pasting with the primary selection
573 changed in emacs24. I am used to the old way, so get it back.
574 #+BEGIN_SRC emacs-lisp :tangle yes
575 (setq x-select-enable-primary t)
576 (setq x-select-enable-clipboard t ;; copy-paste should work ...
577 interprogram-paste-function ;; ...with...
578 'x-cut-buffer-or-selection-value) ;; ...other X clients
582 *** Global keyboard changes not directly related to a mode
583 Disable /suspend_frame/ function, I dislike it.
584 #+BEGIN_SRC emacs-lisp :tangle yes
586 (unbind-key "C-x C-z")
589 Default of *C-k* is to kill from the point to the end of line. If
590 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
591 set, including newline. But to kill the entire line, one still needs a
592 *C-a* in front of it. So I change it, by defining a function to do just this for
594 #+BEGIN_SRC emacs-lisp :tangle yes
595 (defun kill-entire-line ()
596 "Kill this entire line (including newline), regardless of where point is within the line."
600 (back-to-indentation))
603 (bind-key* "C-k" 'kill-entire-line)
604 (global-set-key [remap kill-whole-line] 'kill-entire-line)
607 And the same is true when I'm in org-mode, which has an own kill function...
608 (the keybinding happens later, after org-mode is loaded fully)
609 #+BEGIN_SRC emacs-lisp :tangle yes
610 (defun jj-org-kill-line (&optional arg)
611 "Kill the entire line, regardless of where point is within the line, org-mode-version"
615 (back-to-indentation)
619 I really hate tabs, so I don't want any indentation to try using them.
620 And in case a project really needs them, I can change it just for that
621 file/project, but luckily none of those I work in is as broken.
622 #+BEGIN_SRC emacs-lisp :tangle yes
623 (setq-default indent-tabs-mode nil)
626 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
627 #+BEGIN_SRC emacs-lisp :tangle yes
628 (bind-key* "M-5" 'match-paren)
631 Instead of the default "mark-defun" I want a more readline-like setting.
632 #+BEGIN_SRC emacs-lisp :tangle yes
633 (bind-key "C-M-h" 'backward-kill-word)
636 Align whatever with a regexp.
637 #+BEGIN_SRC emacs-lisp :tangle yes
638 (bind-key "C-x \\" 'align-regexp)
642 #+BEGIN_SRC emacs-lisp :tangle yes
643 (bind-key "C-+" 'text-scale-increase)
644 (bind-key "C--" 'text-scale-decrease)
647 Regexes are too useful, so use the regex search by default.
648 #+begin_src emacs-lisp
649 (bind-key "C-s" 'isearch-forward-regexp)
650 (bind-key "C-r" 'isearch-backward-regexp)
651 (bind-key "C-M-s" 'isearch-forward)
652 (bind-key "C-M-r" 'isearch-backward)
655 Rgrep is infinitely useful in multi-file projects.
656 #+begin_src emacs-lisp
657 (bind-key "C-x C-g" 'rgrep)
660 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
662 #+BEGIN_SRC emacs-lisp :tangle yes
663 (bind-key "<M-S-up>" 'move-line-up)
664 (bind-key "<M-S-down>" 'move-line-down)
667 "Pull" lines up, join them
668 #+BEGIN_SRC emacs-lisp :tangle yes
669 (defun join-line-or-lines-in-region ()
670 "Join this line or the lines in the selected region.
671 Joins single lines in reverse order to the default, ie. pulls the next one up."
673 (cond ((region-active-p)
674 (let ((min (line-number-at-pos (region-beginning))))
675 (goto-char (region-end))
676 (while (> (line-number-at-pos) min)
678 (t (let ((current-prefix-arg '(4)))
679 (call-interactively 'join-line)))))
680 (bind-key "M-j" 'join-line-or-lines-in-region)
683 When I press Enter I almost always want to go to the right indentation on the next line.
684 #+BEGIN_SRC emacs-lisp :tangle yes
685 (bind-key "RET" 'newline-and-indent)
688 Easier undo, and i don't need suspend-frame
689 #+BEGIN_SRC emacs-lisp :tangle yes
690 (bind-key "C-z" 'undo)
693 Window switching, go backwards. (C-x o goes to the next window)
694 #+BEGIN_SRC emacs-lisp :tangle yes
695 (bind-key "C-x O" (lambda ()
701 #+BEGIN_SRC emacs-lisp :tangle yes
702 (bind-key "C-x C-r" 'prelude-sudo-edit)
705 M-space is bound to just-one-space, which is great for programming. What
706 it does is remove all spaces around the cursor, except for one. But to
707 be really useful, it also should include newlines. It doesn’t do this by
708 default. Rather, you have to call it with a negative argument. Sure
710 #+BEGIN_SRC emacs-lisp :tangle yes
711 (bind-key "M-SPC" 'just-one-space-with-newline)
714 Count which commands I use how often.
715 #+BEGIN_SRC emacs-lisp :tangle yes
720 (setq keyfreq-file (expand-file-name "keyfreq" jj-cache-dir))
721 (setq keyfreq-file-lock (expand-file-name "keyfreq.lock" jj-cache-dir))
723 (keyfreq-autosave-mode 1)))
726 Duplicate current line
727 #+BEGIN_SRC emacs-lisp :tangle yes
728 (defun duplicate-line ()
729 "Insert a copy of the current line after the current line."
732 (let ((line-text (buffer-substring-no-properties
733 (line-beginning-position)
734 (line-end-position))))
737 (insert line-text))))
739 (bind-key "C-c p" 'duplicate-line)
742 Smarter move to the beginning of the line. That is, it first moves to
743 the beginning of the line - and on second keypress it goes to the
744 first character on line.
745 #+BEGIN_SRC emacs-lisp :tangle yes
746 (defun smarter-move-beginning-of-line (arg)
747 "Move point back to indentation of beginning of line.
749 Move point to the first non-whitespace character on this line.
750 If point is already there, move to the beginning of the line.
751 Effectively toggle between the first non-whitespace character and
752 the beginning of the line.
754 If ARG is not nil or 1, move forward ARG - 1 lines first. If
755 point reaches the beginning or end of the buffer, stop there."
757 (setq arg (or arg 1))
761 (let ((line-move-visual nil))
762 (forward-line (1- arg))))
764 (let ((orig-point (point)))
765 (back-to-indentation)
766 (when (= orig-point (point))
767 (move-beginning-of-line 1))))
769 ;; remap C-a to `smarter-move-beginning-of-line'
770 (global-set-key [remap move-beginning-of-line]
771 'smarter-move-beginning-of-line)
775 Easily copy characters from the previous nonblank line, starting just
776 above point. With a prefix argument, only copy ARG characters (never
777 past EOL), no argument copies rest of line.
778 #+BEGIN_SRC emacs-lisp :tangle yes
780 (bind-key "H-y" 'copy-from-above-command)
783 Open a new X Terminal pointing to the directory of the current
785 #+BEGIN_SRC emacs-lisp :tangle yes
786 (bind-key "H-t" 'jj-open-shell)
790 #+BEGIN_SRC emacs-lisp :tangle yes
791 (bind-key "H-a" 'align-code)
795 #+BEGIN_SRC emacs-lisp :tangle yes
796 (bind-key "C-c d" 'insert-date)
799 Usually you can press the *Ins*ert key, to get into overwrite mode. I
800 don't like that, have broken much with it and so just forbid it by
802 #+BEGIN_SRC emacs-lisp :tangle yes
803 (unbind-key "<insert>")
804 (unbind-key "<kp-insert>")
807 ** Miscellaneous stuff
808 Weeks start on Monday, not sunday.
809 #+BEGIN_SRC emacs-lisp :tangle yes
810 (setq calendar-week-start-day 1)
813 Searches and matches should ignore case.
814 #+BEGIN_SRC emacs-lisp :tangle yes
815 (setq-default case-fold-search t)
818 Which buffers to get rid off at midnight.
819 #+BEGIN_SRC emacs-lisp :tangle yes
820 (setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
821 "*Man " "*Buffer List*"
827 "*magit" "*Calendar")))
830 Don't display a cursor in non-selected windows.
831 #+BEGIN_SRC emacs-lisp :tangle yes
832 (setq-default cursor-in-non-selected-windows nil)
835 What should be displayed in the mode-line for files with those types
837 #+BEGIN_SRC emacs-lisp :tangle yes
838 (setq eol-mnemonic-dos "(DOS)")
839 (setq eol-mnemonic-mac "(Mac)")
842 Much larger threshold for garbage collection prevents it to run too often.
843 #+BEGIN_SRC emacs-lisp :tangle yes
844 (setq gc-cons-threshold 48000000)
847 #+BEGIN_SRC emacs-lisp :tangle yes
848 (setq max-lisp-eval-depth 1000)
849 (setq max-specpdl-size 3000)
853 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
854 #+BEGIN_SRC emacs-lisp :tangle yes
855 (defun unfill-paragraph ()
856 "Takes a multi-line paragraph and makes it into a single line of text."
858 (let ((fill-column (point-max)))
859 (fill-paragraph nil)))
860 (bind-key "H-u" 'unfill-paragraph)
863 #+BEGIN_SRC emacs-lisp :tangle yes
864 (setq-default indicate-empty-lines t)
865 (setq sentence-end-double-space nil)
868 Hilight annotations in comments, like FIXME/TODO/...
869 #+BEGIN_SRC emacs-lisp :tangle yes
870 (add-hook 'prog-mode-hook 'font-lock-comment-annotations)
874 #+BEGIN_SRC emacs-lisp :tangle yes
875 (setq browse-url-browser-function (quote browse-url-generic))
876 (setq browse-url-generic-program "/usr/bin/x-www-browser")
879 *** When saving a script - make it executable
880 #+BEGIN_SRC emacs-lisp :tangle yes
881 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
885 #+BEGIN_SRC emacs-lisp :tangle yes
889 (add-hook 'after-init-hook 'server-start)))
892 ** Customized variables
893 [2013-05-02 Thu 22:14]
894 The following contains a set of variables i may reasonably want to
895 change on other systems - which don't affect the init file loading
896 process. So I *can* use the customization interface for it...
897 #+BEGIN_SRC emacs-lisp :tangle yes
898 (defgroup ganneff nil
899 "Modify ganneffs settings"
902 (defgroup ganneff-org-mode nil
903 "Ganneffs org-mode settings"
904 :tag "Ganneffs org-mode settings"
906 :link '(custom-group-link "ganneff"))
908 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
909 "ID of the organization task."
910 :tag "Organization Task ID"
912 :group 'ganneff-org-mode)
914 (defcustom org-my-archive-expiry-days 2
915 "The number of days after which a completed task should be auto-archived.
916 This can be 0 for immediate, or a floating point value."
917 :tag "Archive expiry days"
919 :group 'ganneff-org-mode)
924 [2013-05-21 Tue 23:22]
925 Restore removed var alias, used by ruby-electric-brace and others
926 #+BEGIN_SRC emacs-lisp :tangle yes
927 (unless (boundp 'last-command-char)
928 (defvaralias 'last-command-char 'last-command-event))
931 * Customized variables
933 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
935 Of course I want to be able to use the customize interface, and some
936 things can only be set via it (or so they say). I usually prefer to put
937 things I keep for a long while into statements somewhere else, not just
938 custom-set here, but we need it anyways.
940 #+BEGIN_SRC emacs-lisp :tangle yes
941 (setq custom-file jj-custom-file)
942 (safe-load custom-file)
945 The source of this is:
946 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
949 * Extra modes and their configuration
951 A defined abbrev is a word which expands, if you insert it, into some
952 different text. Abbrevs are defined by the user to expand in specific
954 #+BEGIN_SRC emacs-lisp :tangle yes
956 :commands abbrev-mode
957 :diminish abbrev-mode
959 (hook-into-modes #'abbrev-mode '(text-mode-hook))
963 (setq save-abbrevs 'silently)
964 (setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
965 (if (file-exists-p abbrev-file-name)
966 (quietly-read-abbrev-file))
968 (add-hook 'expand-load-hook
970 (add-hook 'expand-expand-hook 'indent-according-to-mode)
971 (add-hook 'expand-jump-hook 'indent-according-to-mode)))))
975 [2013-04-28 So 11:26]
976 Quickly move around in buffers.
977 #+BEGIN_SRC emacs-lisp :tangle yes
978 (use-package ace-jump-mode
979 :ensure ace-jump-mode
980 :commands ace-jump-mode
981 :bind ("H-SPC" . ace-jump-mode))
984 [2013-04-21 So 20:27]
985 Use H-w to switch windows
986 #+BEGIN_SRC emacs-lisp :tangle yes
987 (use-package ace-window
990 :bind ("H-w" . ace-window))
993 [2014-06-01 Sun 23:02]
994 #+BEGIN_SRC emacs-lisp :tangle yes
1000 (global-anzu-mode 1)
1001 (setq anzu-search-threshold 1000)
1002 (set-face-attribute 'anzu-mode-line nil :foreground "yellow" :weight 'bold)))
1005 [2014-05-21 Wed 00:33]
1006 #+BEGIN_SRC emacs-lisp :tangle yes
1008 :commands (ascii-on ascii-toggle)
1011 (defun ascii-toggle ()
1017 (bind-key "C-c e A" 'ascii-toggle)))
1020 #+BEGIN_SRC emacs-lisp :tangle yes
1021 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
1022 (setq TeX-auto-save t)
1023 (setq TeX-parse-self t)
1024 (setq TeX-PDF-mode t)
1027 ** auto-complete mode
1028 [2013-04-27 Sa 16:33]
1029 And aren't we all lazy? I definitely am, and I like my emacs doing as
1030 much possible work for me as it can.
1031 So here, auto-complete-mode, which lets emacs do this, based on what I
1033 #+BEGIN_SRC emacs-lisp :tangle yes
1034 (use-package auto-complete
1035 :ensure auto-complete
1038 (global-auto-complete-mode t)
1042 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
1044 (setq ac-expand-on-auto-complete nil)
1046 (setq ac-auto-start t)
1048 ;;----------------------------------------------------------------------------
1049 ;; Use Emacs' built-in TAB completion hooks to trigger AC (Emacs >= 23.2)
1050 ;;----------------------------------------------------------------------------
1051 (setq tab-always-indent 'complete) ;; use 't when auto-complete is disabled
1052 (add-to-list 'completion-styles 'initials t)
1054 ;; hook AC into completion-at-point
1055 (defun sanityinc/auto-complete-at-point ()
1056 (when (and (not (minibufferp))
1057 (fboundp 'auto-complete-mode)
1061 (defun set-auto-complete-as-completion-at-point-function ()
1062 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
1064 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
1066 ;(require 'ac-dabbrev)
1067 (set-default 'ac-sources
1069 ac-source-dictionary
1070 ac-source-words-in-buffer
1071 ac-source-words-in-same-mode-buffers
1072 ac-source-words-in-all-buffer))
1073 ; ac-source-dabbrev))
1075 (dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
1076 sass-mode yaml-mode csv-mode espresso-mode haskell-mode
1077 html-mode nxml-mode sh-mode smarty-mode clojure-mode
1078 lisp-mode textile-mode markdown-mode tuareg-mode python-mode
1079 js3-mode css-mode less-css-mode sql-mode ielm-mode))
1080 (add-to-list 'ac-modes mode))
1082 ;; Exclude very large buffers from dabbrev
1083 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
1084 (< (buffer-size other-buffer) (* 1 1024 1024)))
1086 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
1089 ;; custom keybindings to use tab, enter and up and down arrows
1090 (bind-key "\t" 'ac-expand ac-complete-mode-map)
1091 (bind-key "\r" 'ac-complete ac-complete-mode-map)
1092 (bind-key "M-n" 'ac-next ac-complete-mode-map)
1093 (bind-key "M-p" 'ac-previous ac-complete-mode-map)
1094 (bind-key "M-TAB" 'auto-complete ac-mode-map)
1096 (setq auto-completion-syntax-alist (quote (global accept . word))) ;; Use space and punctuation to accept the current the most likely completion.
1097 (setq auto-completion-min-chars (quote (global . 3))) ;; Avoid completion for short trivial words.
1098 (setq completion-use-dynamic t)
1100 (add-hook 'latex-mode-hook 'auto-complete-mode)
1101 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
1102 (add-hook 'prog-mode-hook 'auto-complete-mode)
1103 (add-hook 'org-mode-hook 'auto-complete-mode)))
1107 When files change outside emacs for whatever reason I want emacs to deal
1108 with it. Not to have to revert buffers myself
1109 #+BEGIN_SRC emacs-lisp :tangle yes
1110 (use-package autorevert
1111 :commands auto-revert-mode
1112 :diminish auto-revert-mode
1115 (setq global-auto-revert-mode t)
1116 (setq global-auto-revert-non-file-buffers t)
1117 (global-auto-revert-mode)))
1121 Emacs should keep backup copies of files I edit, but I do not want them
1122 to clutter up the filesystem everywhere. So I put them into one defined
1123 place, backup-directory, which even contains my username (for systems
1124 where =temporary-file-directory= is not inside my home).
1125 #+BEGIN_SRC emacs-lisp :tangle yes
1126 (use-package backups-mode
1127 :load-path "elisp/backups-mode"
1128 :bind (("\C-cv" . save-version)
1129 ("\C-cb" . list-backups)
1130 ("\C-ck" . kill-buffer-prompt)
1131 ("\C-cw" . backup-walker-start))
1134 (setq backup-directory jj-backup-directory)
1135 (setq tramp-backup-directory (concat jj-backup-directory "/tramp"))
1136 (if (not (file-exists-p tramp-backup-directory))
1137 (make-directory tramp-backup-directory))
1138 (setq tramp-backup-directory-alist `((".*" . ,tramp-backup-directory)))
1139 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
1140 (setq auto-save-list-file-prefix (concat jj-backup-directory ".auto-saves-"))
1141 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
1143 (setq version-control t) ;; Use version numbers for backups
1144 (setq kept-new-versions 10) ;; Number of newest versions to keep
1145 (setq kept-old-versions 2) ;; Number of oldest versions to keep
1146 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
1147 (setq backup-by-copying t)
1148 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
1149 (setq make-backup-files t)
1151 (defadvice kill-buffer (around kill-buffer)
1152 "Always save before killing a file buffer"
1153 (when (and (buffer-modified-p)
1155 (file-exists-p (buffer-file-name)))
1158 (ad-activate 'kill-buffer)
1160 (defadvice save-buffers-kill-emacs (around save-buffers-kill-emacs)
1161 "Always save before killing emacs"
1162 (save-some-buffers t)
1164 (ad-activate 'save-buffers-kill-emacs)
1166 (defun kill-buffer-prompt ()
1167 "Allows one to kill a buffer without saving it.
1168 This is necessary since once you start backups-mode all file based buffers
1169 are saved automatically when they are killed"
1171 (if (and (buffer-modified-p) (buffer-file-name) (file-exists-p (buffer-file-name)) (y-or-n-p "Save buffer?"))
1173 (set-buffer-modified-p nil))
1176 (setq backup-enable-predicate
1178 (and (normal-backup-enable-predicate name)
1180 (let ((method (file-remote-p name 'method)))
1181 (when (stringp method)
1182 (member method '("su" "sudo"))))))))))
1186 [2013-05-21 Tue 23:18]
1187 #+BEGIN_SRC emacs-lisp :tangle yes
1188 (use-package crontab-mode
1189 :ensure crontab-mode
1190 :commands crontab-mode
1191 :mode ("\\.?cron\\(tab\\)?\\'" . crontab-mode))
1195 #+BEGIN_SRC emacs-lisp :tangle yes
1196 (use-package css-mode
1197 :mode ("\\.css\\'" . css-mode)
1202 (use-package flymake-css
1206 (defun maybe-flymake-css-load ()
1207 "Activate flymake-css as necessary, but not in derived modes."
1208 (when (eq major-mode 'css-mode)
1209 (flymake-css-load)))
1210 (add-hook 'css-mode-hook 'maybe-flymake-css-load)))
1211 ;;; Auto-complete CSS keywords
1212 (eval-after-load 'auto-complete
1214 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
1215 (add-hook hook 'ac-css-mode-setup))))))
1219 I know that this lets it look "more like windows", but I don't much care
1220 about its paste/copy/cut keybindings, the really nice part is the great
1221 support for rectangular regions, which I started to use a lot since I
1222 know this mode. The normal keybindings for those are just to useless.
1223 #+BEGIN_SRC emacs-lisp :tangle yes
1225 (setq cua-enable-cua-keys (quote shift))
1228 Luckily cua-mode easily supports this, with the following line I just
1229 get the CUA selection and rectangle stuff, not the keybindings. Yes,
1230 even though the above =cua-enable-cua-keys= setting would only enable
1231 them if the selection is done when the region was marked with a shifted
1233 #+BEGIN_SRC emacs-lisp :tangle yes
1234 (cua-selection-mode t)
1238 #+BEGIN_SRC emacs-lisp :tangle yes
1239 (require 'dpkg-dev-el-loaddefs nil 'noerror)
1240 (require 'debian-el-loaddefs nil 'noerror)
1242 (setq debian-changelog-full-name "Joerg Jaspert")
1243 (setq debian-changelog-mailing-address "joerg@debian.org")
1247 #+BEGIN_SRC emacs-lisp :tangle yes
1248 (use-package diff-mode
1250 :mode ("COMMIT_EDITMSG$" . diff-mode)
1252 (use-package diff-mode-))
1254 For some file endings we need to tell emacs what mode we want for them.
1255 I only list modes here where I don't have any other special
1259 I like dired and work a lot with it, but it tends to leave lots of
1261 dired-single to the rescue.
1262 #+BEGIN_SRC emacs-lisp :tangle yes
1267 (defvar mark-files-cache (make-hash-table :test #'equal))
1269 (defun mark-similar-versions (name)
1271 (if (string-match "^\\(.+?\\)-[0-9._-]+$" pat)
1272 (setq pat (match-string 1 pat)))
1273 (or (gethash pat mark-files-cache)
1274 (ignore (puthash pat t mark-files-cache)))))
1276 (defun dired-mark-similar-version ()
1278 (setq mark-files-cache (make-hash-table :test #'equal))
1279 (dired-mark-sexp '(mark-similar-versions name))))
1282 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
1283 (setq dired-dwim-target t)
1284 (setq dired-listing-switches "-alh")
1285 (setq dired-recursive-copies (quote top))
1286 (setq dired-recursive-deletes (quote top))
1288 (defun dired-package-initialize ()
1289 (unless (featurep 'runner)
1290 (use-package dired-x)
1298 (setq diredp-hide-details-initially-flag nil)))
1300 (use-package dired-single
1301 :ensure dired-single
1304 (bind-key "<return>" 'dired-single-buffer dired-mode-map)
1305 (bind-key "<mouse-1>" 'dired-single-buffer-mouse dired-mode-map)
1308 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
1314 (setq wdired-allow-to-change-permissions t)
1315 (bind-key "r" 'wdired-change-to-wdired-mode dired-mode-map)))
1317 (use-package gnus-dired
1320 (require 'gnus-dired)
1321 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
1322 (bind-key "a" 'gnus-dired-attach dired-mode-map)))
1324 (bind-key "M-!" 'async-shell-command dired-mode-map)
1325 (unbind-key "M-s f" dired-mode-map)
1327 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1328 "Make sure to remove \"Omit\" from the modeline."
1329 (diminish 'dired-omit-mode) dired-mode-map)
1331 ;; Omit files that Git would ignore
1332 (defun dired-omit-regexp ()
1333 (let ((file (expand-file-name ".git"))
1335 (while (and (not (file-exists-p file))
1338 (file-name-directory
1339 (directory-file-name
1340 (file-name-directory file))))
1341 ;; Give up if we are already at the root dir.
1342 (not (string= (file-name-directory file)
1344 ;; Move up to the parent dir and try again.
1345 (setq file (expand-file-name ".git" parent-dir)))
1346 ;; If we found a change log in a parent, use that.
1347 (if (file-exists-p file)
1348 (let ((regexp (funcall dired-omit-regexp-orig))
1350 (shell-command-to-string "git clean -d -x -n")))
1351 (if (= 0 (length omitted-files))
1355 (if (> (length regexp) 0)
1364 (if (= ?/ (aref str (1- (length str))))
1368 (split-string omitted-files "\n" t)
1371 (funcall dired-omit-regexp-orig))))))
1373 (add-hook 'dired-mode-hook 'dired-package-initialize)
1375 (defun dired-double-jump (first-dir second-dir)
1377 (list (read-directory-name "First directory: "
1378 (expand-file-name "~")
1380 (read-directory-name "Second directory: "
1381 (expand-file-name "~")
1382 nil nil "Archives/")))
1384 (dired-other-window second-dir))
1385 (bind-key "C-c J" 'dired-double-jump)))
1388 ** discover-my-major
1389 [2014-06-01 Sun 23:32]
1390 Discover key bindings and their meaning for the current Emacs major mode.
1391 #+BEGIN_SRC emacs-lisp :tangle yes
1392 (use-package discover-my-major
1393 :ensure discover-my-major
1394 :bind ("C-h C-m" . discover-my-major))
1397 EasyPG is a GnuPG interface for Emacs.
1398 #+BEGIN_SRC emacs-lisp :tangle yes
1403 I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1404 #+BEGIN_SRC emacs-lisp :tangle yes
1405 (defadvice epg--start (around advice-epg-disable-agent disable)
1406 "Don't allow epg--start to use gpg-agent in plain text
1408 (if (display-graphic-p)
1410 (let ((agent (getenv "GPG_AGENT_INFO")))
1411 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
1413 (setenv "GPG_AGENT_INFO" agent))))
1414 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
1415 (ad-activate 'epg--start)
1418 [2013-04-21 So 20:36]
1419 ediff - don't start another frame
1424 (defvar ctl-period-equals-map)
1425 (define-prefix-command 'ctl-period-equals-map)
1426 (bind-key "C-. =" 'ctl-period-equals-map)
1428 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
1430 :bind (("C-. = b" . ediff-buffers)
1431 ("C-. = B" . ediff-buffers3)
1432 ("C-. = =" . ediff-files)
1433 ("C-. = f" . ediff-files)
1434 ("C-. = F" . ediff-files3)
1435 ("C-. = r" . ediff-revision)
1436 ("C-. = p" . ediff-patch-file)
1437 ("C-. = P" . ediff-patch-buffer)
1438 ("C-. = l" . ediff-regions-linewise)
1439 ("C-. = w" . ediff-regions-wordwise)))
1442 EMMS is the Emacs Multimedia System.
1443 #+BEGIN_SRC emacs-lisp :tangle no
1444 (require 'emms-source-file)
1445 (require 'emms-source-playlist)
1446 (require 'emms-info)
1447 (require 'emms-cache)
1448 (require 'emms-playlist-mode)
1449 (require 'emms-playing-time)
1450 (require 'emms-player-mpd)
1451 (require 'emms-playlist-sort)
1452 (require 'emms-mark)
1453 (require 'emms-browser)
1454 (require 'emms-lyrics)
1455 (require 'emms-last-played)
1456 (require 'emms-score)
1457 (require 'emms-tag-editor)
1458 (require 'emms-history)
1459 (require 'emms-i18n)
1461 (setq emms-playlist-default-major-mode 'emms-playlist-mode)
1462 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
1463 (emms-playing-time 1)
1465 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
1466 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
1468 (when (fboundp 'emms-cache) ; work around compiler warning
1470 (setq emms-score-default-score 3)
1472 (defun emms-mpd-init ()
1473 "Connect Emms to mpd."
1475 (emms-player-mpd-connect))
1478 (require 'emms-player-mpd)
1479 (setq emms-player-mpd-server-name "localhost")
1480 (setq emms-player-mpd-server-port "6600")
1481 (add-to-list 'emms-info-functions 'emms-info-mpd)
1482 (add-to-list 'emms-player-list 'emms-player-mpd)
1483 (setq emms-volume-change-function 'emms-volume-mpd-change)
1484 (setq emms-player-mpd-sync-playlist t)
1486 (setq emms-source-file-default-directory "/var/lib/mpd/music")
1487 (setq emms-player-mpd-music-directory "/var/lib/mpd/music")
1488 (setq emms-info-auto-update t)
1489 (setq emms-lyrics-scroll-p t)
1490 (setq emms-lyrics-display-on-minibuffer t)
1491 (setq emms-lyrics-display-on-modeline nil)
1492 (setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
1494 (setq emms-last-played-format-alist
1495 '(((emms-last-played-seconds-today) . "%H:%M")
1496 (604800 . "%a %H:%M") ; this week
1497 ((emms-last-played-seconds-month) . "%d.%m.%Y")
1498 ((emms-last-played-seconds-year) . "%d.%m.%Y")
1499 (t . "Never played")))
1502 (defun my-describe (track)
1503 (let* ((empty "...")
1504 (name (emms-track-name track))
1505 (type (emms-track-type track))
1506 (short-name (file-name-nondirectory name))
1507 (play-count (or (emms-track-get track 'play-count) 0))
1508 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
1509 (artist (or (emms-track-get track 'info-artist) empty))
1510 (year (emms-track-get track 'info-year))
1511 (playing-time (or (emms-track-get track 'info-playing-time) 0))
1512 (min (/ playing-time 60))
1513 (sec (% playing-time 60))
1514 (album (or (emms-track-get track 'info-album) empty))
1515 (tracknumber (emms-track-get track 'info-tracknumber))
1516 (short-name (file-name-sans-extension
1517 (file-name-nondirectory name)))
1518 (title (or (emms-track-get track 'info-title) short-name))
1519 (rating (emms-score-get-score name))
1522 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
1523 (emms-last-played-format-date last-played)
1527 (if (and tracknumber ; tracknumber
1528 (not (zerop (string-to-number tracknumber))))
1529 (format "%02d" (string-to-number tracknumber))
1533 (make-string rating rate-char)))
1536 (setq emms-track-description-function 'my-describe)
1538 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
1539 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
1540 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
1541 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
1542 (global-set-key (kbd "H-<f9> x") 'emms-start)
1543 (global-set-key (kbd "H-<f9> v") 'emms-stop)
1544 (global-set-key (kbd "H-<f9> n") 'emms-next)
1545 (global-set-key (kbd "H-<f9> p") 'emms-previous)
1546 (global-set-key (kbd "H-<f9> o") 'emms-show)
1547 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
1548 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
1549 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
1550 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
1551 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
1553 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
1554 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
1555 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
1556 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
1558 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
1559 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
1560 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
1561 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
1563 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
1564 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
1565 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
1566 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
1568 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
1569 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
1570 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
1571 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
1572 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
1573 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
1575 (define-key emms-playlist-mode-map "x" 'emms-start)
1576 (define-key emms-playlist-mode-map "v" 'emms-stop)
1577 (define-key emms-playlist-mode-map "n" 'emms-next)
1578 (define-key emms-playlist-mode-map "p" 'emms-previous)
1580 (setq emms-playlist-buffer-name "*EMMS Playlist*"
1581 emms-playlist-mode-open-playlists t)
1587 'emms-browser-artist-face nil
1592 (setq emms-player-mpd-supported-regexp
1593 (or (emms-player-mpd-get-supported-regexp)
1594 (concat "\\`http://\\|"
1595 (emms-player-simple-regexp
1596 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
1597 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
1601 [2014-06-01 Sun 15:00]
1602 Proper whitespace handling
1603 #+BEGIN_SRC emacs-lisp :tangle yes
1604 (use-package ethan-wspace
1605 :ensure ethan-wspace
1606 :diminish (ethan-wspace-mode . "ew")
1608 (global-ethan-wspace-mode 1))
1612 [2014-06-01 Sun 15:16]
1613 #+BEGIN_SRC emacs-lisp :tangle yes
1614 (use-package expand-region
1615 :ensure expand-region
1616 :bind ("C-M-+" . er/expand-region))
1619 [2013-05-02 Thu 00:04]
1620 #+BEGIN_SRC emacs-lisp :tangle yes
1621 (use-package filladapt
1622 :diminish filladapt-mode
1624 (setq-default filladapt-mode t))
1627 [2013-04-28 So 22:21]
1628 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
1629 As the one time I tried Flymake i wasn't happy, thats easy to
1631 #+BEGIN_SRC emacs-lisp :tangle yes
1632 (use-package flycheck
1634 :bind (("M-n" . next-error)
1635 ("M-p" . previous-error))
1638 (add-hook 'find-file-hook
1640 (when (not (equal 'emacs-lisp-mode major-mode))
1644 (use-package flycheck-color-mode-line
1645 :ensure flycheck-color-mode-line)
1646 (setq flycheck-highlighting-mode nil)
1647 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
1651 Obviously emacs can do syntax hilighting. For more things than you ever
1653 And I want to have it everywhere.
1654 #+BEGIN_SRC emacs-lisp :tangle yes
1655 (use-package font-lock
1658 (global-font-lock-mode 1)
1659 (setq font-lock-maximum-decoration t)))
1662 #+BEGIN_SRC emacs-lisp :tangle yes
1663 (use-package git-commit-mode
1664 :ensure git-commit-mode
1665 :commands git-commit-mode
1666 :mode ("COMMIT_EDITMSG" . git-commit-mode))
1670 #+BEGIN_SRC emacs-lisp :tangle yes
1671 (use-package git-rebase-mode
1672 :ensure git-rebase-mode
1673 :commands git-rebase-mode
1674 :mode ("git-rebase-todo" . git-rebase-mode))
1677 [2014-05-21 Wed 22:56]
1678 #+BEGIN_SRC emacs-lisp :tangle yes
1679 (use-package git-gutter+
1681 :diminish git-gutter+-mode
1682 :bind (("C-x n" . git-gutter+-next-hunk)
1683 ("C-x p" . git-gutter+-previous-hunk)
1684 ("C-x v =" . git-gutter+-show-hunk)
1685 ("C-x r" . git-gutter+-revert-hunks)
1686 ("C-x s" . git-gutter+-stage-hunks)
1687 ("C-x c" . git-gutter+-commit)
1691 (setq git-gutter+-disabled-modes '(org-mode)))
1694 (use-package git-gutter-fringe+
1695 :ensure git-gutter-fringe+
1698 (setq git-gutter-fr+-side 'right-fringe)
1699 ;(git-gutter-fr+-minimal)
1701 (global-git-gutter+-mode 1)))
1705 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
1706 what I want every emacs to know.
1707 #+BEGIN_SRC emacs-lisp :tangle yes
1708 (bind-key "C-c g" 'gnus) ; Start gnus with M-n
1715 [2014-05-21 Wed 23:51]
1716 #+BEGIN_SRC emacs-lisp :tangle yes
1717 (use-package hi-lock
1718 :bind (("M-o l" . highlight-lines-matching-regexp)
1719 ("M-o r" . highlight-regexp)
1720 ("M-o w" . highlight-phrase)))
1724 (use-package hilit-chg
1725 :bind ("M-o C" . highlight-changes-mode))
1729 Crazy way of completion. It looks at the word before point and then
1730 tries to expand it in various ways.
1731 #+BEGIN_SRC emacs-lisp :tangle yes
1732 (use-package hippie-exp
1734 :bind ("M-/" . hippie-expand)
1737 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
1738 try-expand-dabbrev-all-buffers
1739 try-expand-dabbrev-from-kill
1740 try-complete-file-name-partially
1741 try-complete-file-name
1742 try-expand-all-abbrevs try-expand-list
1744 try-complete-lisp-symbol-partially
1745 try-complete-lisp-symbol))))
1748 Instead of default /html-mode/ I use /html-helper-mode/.
1749 #+BEGIN_SRC emacs-lisp :tangle yes
1750 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
1751 (add-auto-mode 'html-helper-mode "\\.html$")
1752 (add-auto-mode 'html-helper-mode "\\.asp$")
1753 (add-auto-mode 'html-helper-mode "\\.phtml$")
1754 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
1755 (defalias 'html-mode 'html-helper-mode)
1759 [2014-05-21 Wed 23:54]
1760 #+BEGIN_SRC emacs-lisp :tangle yes
1761 (use-package ibuffer
1763 :bind (("C-h h" . ibuffer)
1764 ("C-x C-b" . ibuffer)
1765 ("<XF86WebCam>" . ibuffer)
1770 (defvar my-ibufffer-separator " • ")
1771 (setq ibuffer-filter-group-name-face 'variable-pitch
1772 ibuffer-use-header-line t
1773 ibuffer-old-time 12)
1774 (use-package ibuffer-vc
1777 (ibuffer-vc-set-filter-groups-by-vc-root
1778 ibuffer-vc-generate-filter-groups-by-vc-root))
1779 (use-package ibuffer-tramp
1781 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
1782 ibuffer-tramp-set-filter-groups-by-tramp-connection))
1783 ;; Switching to ibuffer puts the cursor on the most recent buffer
1784 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
1785 "Open ibuffer with cursor pointed to most recent buffer name"
1786 (let ((recent-buffer-name (buffer-name)))
1788 (ibuffer-update nil t)
1789 (unless (string= recent-buffer-name "*Ibuffer*")
1790 (ibuffer-jump-to-buffer recent-buffer-name)))))
1793 (unbind-key "M-o" ibuffer-mode-map)
1794 (bind-key "s" 'isearch-forward-regexp ibuffer-mode-map)
1795 (bind-key "." 'ibuffer-invert-sorting ibuffer-mode-map)
1797 (defun ibuffer-magit-status ()
1799 (--when-let (get-buffer "*Ibuffer*")
1800 (with-current-buffer it
1801 (let* ((selected-buffer (ibuffer-current-buffer))
1802 (buffer-path (with-current-buffer
1804 (or (buffer-file-name)
1805 list-buffers-directory
1806 default-directory)))
1808 (if (file-regular-p buffer-path)
1809 (file-name-directory buffer-path)
1811 (magit-status default-directory)))))
1812 (bind-key "i" 'ibuffer-magit-status ibuffer-mode-map)
1813 (bind-key "G" 'ibuffer-magit-status ibuffer-mode-map)
1815 (setq ibuffer-directory-abbrev-alist
1820 (cons (f-slash (f-expand (cdr it))) (concat (car it) my-ibufffer-separator))
1821 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
1824 ("dak" . "/develop/dak/")
1826 ("config" . "~/.emacs.d/config/")
1828 ("systmp" . "/tmp/")
1829 ("puppet" . "~/git/puppet")
1833 (use-package ibuffer-git
1835 (use-package ibuffer-vc
1838 (define-ibuffer-column size-h
1839 (:name "Size" :inline t)
1841 ((> (buffer-size) 1000)
1842 (format "%7.1fk" (/ (buffer-size) 1000.0)))
1843 ((> (buffer-size) 1000000)
1844 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
1846 (format "%8d" (buffer-size)))))
1849 (define-ibuffer-filter filename2
1850 "Toggle current view to buffers with filename matching QUALIFIER."
1851 (:description "filename2"
1852 :reader (read-from-minibuffer "Filter by filename (regexp): "))
1853 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
1854 (ibuffer-awhen (with-current-buffer buf
1855 (or buffer-file-name
1857 (string-match qualifier it)))
1859 (defvar ibuffer-magit-filter-groups nil)
1860 (defun ibuffer-magit-define-filter-groups ()
1861 (when (and (not ibuffer-magit-filter-groups)
1862 (boundp 'magit-repo-dirs))
1863 (setq ibuffer-magit-filter-groups
1866 (file-name-nondirectory (directory-file-name it)))
1868 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
1870 (defun ibuffer-set-filter-groups-by-root ()
1872 ;; (ibuffer-projectile-define-filter-groups)
1873 ;; (ibuffer-magit-define-filter-groups)
1874 (setq ibuffer-filter-groups
1876 ;; ibuffer-projectile-filter-groups
1877 ibuffer-magit-filter-groups
1880 (or (mode . magit-log-edit-mode)
1881 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
1882 (name . "^\\*Pymacs\\*$")
1883 (name . "^\\*helm.*\\*")
1884 (name . "^\\*Compile-log\\*$")
1885 (name . "^\\*Ido Completions\\*$")
1886 (name . "^\\*magit-\\(process\\)\\*$")
1890 (name . "^\\*scratch")
1891 (name . "^\\*Messages")
1894 (ibuffer-vc-generate-filter-groups-by-vc-root)
1895 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
1897 (defun toggle-ibuffer-filter-groups ()
1900 (let ((ibuf (get-buffer "*Ibuffer*")))
1902 (with-current-buffer ibuf
1903 (let ((selected-buffer (ibuffer-current-buffer)))
1904 (if (not ibuffer-filter-groups)
1905 (ibuffer-set-filter-groups-by-root)
1906 (setq ibuffer-filter-groups nil))
1907 (pop-to-buffer ibuf)
1908 (ibuffer-update nil t)
1909 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
1911 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
1913 (setq ibuffer-default-sorting-mode 'recency
1914 ibuffer-eliding-string "…"
1915 ibuffer-compile-formats t
1916 ibuffer-git-column-length 6
1917 ibuffer-show-empty-filter-groups nil
1918 ibuffer-default-directory "~/"
1920 (setq ibuffer-formats '((mark vc-status-mini
1922 (git-status 8 8 :left)
1926 (name 18 18 :left :elide)
1928 (size-h 9 -1 :right)
1930 (mode 16 16 :left :elide)
1931 " " filename-and-process)
1933 (git-status 8 8 :left)
1939 (setq ibuffer-saved-filter-groups
1942 ("dired" (mode . dired-mode))
1943 ("perl" (mode . cperl-mode))
1945 (mode . puppet-mode)
1946 (mode . yaml-mode)))
1947 ("ruby" (mode . ruby-mode))
1949 (name . "^\\*scratch\\*$")
1950 (name . "^\\*Compile-log\\*$")
1951 (name . "^\\*Completions\\*$")
1952 (name . "^\\*Messages\\*$")
1953 (name . "^\\*Backtrace\\*$")
1954 (name . "^\\*Packages*\\*$")
1955 (name . "^\\*Help*\\*$")
1958 (mode . message-mode)
1961 (mode . gnus-group-mode)
1962 (mode . gnus-summary-mode)
1963 (mode . gnus-article-mode)
1964 (name . "^\\.bbdb$")
1965 (name . "^\\.newsrc-dribble")))
1967 (filename . ".*/org/.*")
1968 (mode . org-agenda-mode)
1969 (name . "^diary$")))
1971 (mode . magit-log-edit-mode)
1972 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
1974 ;; -------------------------------------------------
1975 ;; programming languages #1
1977 (mode . emacs-lisp-mode)
1978 (mode . python-mode)
1980 (mode . coffee-mode)
1983 (mode . actionscript-mode)
1986 (mode . haskell-mode)
1992 ;; -------------------------------------------------
1993 ;; configuration/data files
1997 (mode . conf-mode)))
1998 ;; -------------------------------------------------
1999 ;; text/notetaking/org
2000 ("org agenda" (mode . org-agenda-mode))
2003 (name . "^\\*Calendar\\*$")
2004 (name . "^diary$")))
2008 (mode . markdown-mode)))
2009 ;; -------------------------------------------------
2012 (mode . image-mode)))
2013 ;; -------------------------------------------------
2015 ("w3m" (mode . w3m-mode))
2017 (mode . magit-status-mode)
2018 (mode . magit-log-mode)
2019 (mode . vc-annotate-mode)))
2020 ("dired" (mode . dired-mode))
2025 (name . "^\\*Personal Keybindings\\*$")))
2026 ;; -------------------------------------------------
2028 ("MORE" (or (mode . magit-log-edit-mode)
2029 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2030 (name . "^\\*Pymacs\\*$")
2031 (name . "^\\*Compile-log\\*$")
2032 (name . "^\\*Completions\\*$")
2033 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
2035 ("*buffer*" (name . "\\*.*\\*"))))))
2037 (add-hook 'ibuffer-mode-hook
2039 (ibuffer-auto-mode 1)
2040 (ibuffer-switch-to-saved-filter-groups "default")))
2042 ;; Unless you turn this variable on you will be prompted every time
2043 ;; you want to delete a buffer, even unmodified ones, which is way
2044 ;; too cautious for most people. You’ll still be prompted for
2045 ;; confirmation when deleting modified buffers after the option has
2047 (setq ibuffer-expert t)
2052 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
2053 ‘TAB’ completion is to typing things manually every time.”]]
2054 #+BEGIN_SRC emacs-lisp :tangle yes
2055 (use-package icicles
2056 :load-path "elisp/icicle/"
2061 Incremental mini-buffer completion preview: Type in the minibuffer,
2062 list of matching commands is echoed
2063 #+BEGIN_SRC emacs-lisp :tangle yes
2067 [2014-05-26 Mon 22:49]
2068 #+BEGIN_SRC emacs-lisp :tangle yes
2071 :commands (iedit-mode)
2073 :bind (("C-;" . iedit-mode)
2074 ("C-," . iedit-mode-toggle-on-function))
2079 [2014-05-20 Tue 23:35]
2080 #+BEGIN_SRC emacs-lisp :tangle yes
2082 :bind ("C-h C-i" . info-lookup-symbol)
2086 ;; (defadvice info-setup (after load-info+ activate)
2087 ;; (use-package info+))
2089 (defadvice Info-exit (after remove-info-window activate)
2090 "When info mode is quit, remove the window."
2091 (if (> (length (window-list)) 1)
2094 (use-package info-look
2095 :commands info-lookup-add-help)
2097 ** linum (line number)
2098 Various modes should have line numbers in front of each line.
2100 But then there are some where it would just be deadly - like org-mode,
2101 gnus, so we have a list of modes where we don't want to see it.
2102 #+BEGIN_SRC emacs-lisp :tangle yes
2104 :diminish linum-mode
2107 (setq linum-format "%3d ")
2108 (setq linum-mode-inhibit-modes-list '(org-mode
2115 (defadvice linum-on (around linum-on-inhibit-for-modes)
2116 "Stop the load of linum-mode for some major modes."
2117 (unless (member major-mode linum-mode-inhibit-modes-list)
2120 (ad-activate 'linum-on))
2122 (global-linum-mode 1))
2125 ** lisp editing stuff
2126 [2013-04-21 So 21:00]
2127 I'm not doing much of it, except for my emacs and gnus configs, but
2128 then I like it nice too...
2129 #+BEGIN_SRC emacs-lisp :tangle yes
2130 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
2132 (defun remove-elc-on-save ()
2133 "If you're saving an elisp file, likely the .elc is no longer valid."
2134 (make-local-variable 'after-save-hook)
2135 (add-hook 'after-save-hook
2137 (if (file-exists-p (concat buffer-file-name "c"))
2138 (delete-file (concat buffer-file-name "c"))))))
2140 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
2141 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
2143 (use-package paredit
2145 :diminish paredit-mode " π")
2147 (setq lisp-coding-hook 'lisp-coding-defaults)
2148 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2150 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2151 (add-hook 'emacs-lisp-mode-hook (lambda ()
2152 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2154 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
2156 (after "elisp-slime-nav"
2157 '(diminish 'elisp-slime-nav-mode))
2158 (after "rainbow-mode"
2159 '(diminish 'rainbow-mode))
2161 '(diminish 'eldoc-mode))
2165 [2013-04-21 So 20:48]
2166 magit is a mode for interacting with git.
2167 #+BEGIN_SRC emacs-lisp :tangle yes
2170 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
2171 magit-git-repo-p magit-list-repos)
2173 :bind (("C-x g" . magit-status)
2174 ("C-x G" . magit-status-with-prefix))
2177 (setq magit-commit-signoff t
2178 magit-repo-dirs '("~/git"
2182 magit-repo-dirs-depth 4
2183 magit-log-auto-more t)
2184 (use-package magit-blame
2185 :commands magit-blame-mode)
2187 (add-hook 'magit-mode-hook 'hl-line-mode)
2188 (defun magit-status-with-prefix ()
2190 (let ((current-prefix-arg '(4)))
2191 (call-interactively 'magit-status)))
2195 (setenv "GIT_PAGER" "")
2197 (unbind-key "M-h" magit-mode-map)
2198 (unbind-key "M-s" magit-mode-map)
2200 (add-hook 'magit-log-edit-mode-hook
2202 (set-fill-column 72)
2205 (use-package magit-filenotify
2206 :ensure magit-filenotify
2207 :diminish (magit-filenotify-mode "MF")
2208 :commands (magit-filenotify-mode)
2211 (add-hook 'magit-mode-hook 'magit-filenotify-mode))
2214 (use-package magit-svn
2216 :commands (magit-svn-mode
2219 (use-package magit-find-file
2220 :ensure magit-find-file
2224 (bind-key "C-x C-f" 'magit-find-file-completing-read magit-mode-map)))))
2227 [2014-05-20 Tue 23:04]
2228 #+BEGIN_SRC emacs-lisp :tangle yes
2229 (use-package markdown-mode
2230 :mode (("\\.md\\'" . markdown-mode)
2231 ("\\.mdwn\\'" . markdown-mode))
2235 #+BEGIN_SRC emacs-lisp :tangle yes
2237 (setq message-kill-buffer-on-exit t)
2240 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2242 I want to access it from anywhere using =F6=.
2243 #+BEGIN_SRC emacs-lisp :tangle yes
2244 (use-package mingus-stays-home
2245 :bind ( "<f6>" . mingus)
2249 (setq mingus-dired-add-keys t)
2250 (setq mingus-mode-always-modeline nil)
2251 (setq mingus-mode-line-show-elapsed-percentage nil)
2252 (setq mingus-mode-line-show-volume nil)
2253 (setq mingus-mpd-config-file "/etc/mpd.conf")
2254 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2255 (setq mingus-mpd-root "/share/music/")))
2259 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
2260 #+BEGIN_SRC emacs-lisp :tangle yes
2261 (use-package miniedit
2265 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
2266 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
2267 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
2268 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
2273 [2013-05-21 Tue 23:39]
2274 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
2275 coexist in one buffer.
2276 #+BEGIN_SRC emacs-lisp :tangle yes
2277 (use-package mmm-auto
2281 (setq mmm-global-mode 'buffers-with-submode-classes)
2282 (setq mmm-submode-decoration-level 2)
2283 (eval-after-load 'mmm-vars
2289 :face mmm-code-submode-face
2290 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
2291 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
2292 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2293 @ "\n" _ "\n" @ "</script>" @)))
2296 :face mmm-code-submode-face
2297 :front "<style[^>]*>[ \t]*\n?"
2298 :back "[ \t]*</style>"
2299 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2300 @ "\n" _ "\n" @ "</style>" @)))
2303 :face mmm-code-submode-face
2306 (dolist (mode (list 'html-mode 'nxml-mode))
2307 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
2308 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
2313 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2316 #+BEGIN_SRC emacs-lisp :tangle yes
2317 (use-package mo-git-blame
2318 :ensure mo-git-blame
2319 :commands (mo-git-blame-current
2323 (setq mo-git-blame-blame-window-width 25)))
2327 [2013-04-08 Mon 23:57]
2328 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2329 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2330 #+BEGIN_SRC emacs-lisp :tangle yes
2331 (use-package multiple-cursors
2332 :ensure multiple-cursors
2334 :commands (mc/remove-fake-cursors
2335 mc/create-fake-cursor-at-point
2336 mc/pop-state-from-overlay
2337 mc/maybe-multiple-cursors-mode)
2338 :bind (("C-S-c C-S-c" . mc/edit-lines)
2339 ("C->" . mc/mark-next-like-this)
2340 ("C-<" . mc/mark-previous-like-this)
2341 ("C-c C-<" . mc/mark-all-like-this))
2344 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
2345 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
2346 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
2347 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
2348 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
2349 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
2352 [2013-05-22 Wed 22:02]
2353 nxml-mode is a major mode for editing XML.
2354 #+BEGIN_SRC emacs-lisp :tangle yes
2359 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2362 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2363 (fset 'xml-mode 'nxml-mode)
2364 (setq nxml-slash-auto-complete-flag t)
2366 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2367 (defun pp-xml-region (begin end)
2368 "Pretty format XML markup in region. The function inserts
2369 linebreaks to separate tags that have nothing but whitespace
2370 between them. It then indents the markup by using nxml's
2376 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2377 (backward-char) (insert "\n"))
2378 (indent-region begin end)))
2380 ;;----------------------------------------------------------------------------
2381 ;; Integration with tidy for html + xml
2382 ;;----------------------------------------------------------------------------
2383 ;; tidy is autoloaded
2384 (eval-after-load 'tidy
2386 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2387 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2392 *** General settings
2393 [2013-04-28 So 17:06]
2395 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
2396 it is quite extensive. Nevertheless, it starts out small, loading it.
2397 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2401 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
2402 that we need org-protocol.
2403 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2404 (require 'org-protocol)
2409 My current =org-agenda-files= variable only includes a set of
2411 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2412 (setq org-agenda-files (quote ("~/org/"
2418 (setq org-default-notes-file "~/org/notes.org")
2420 =org-mode= manages the =org-agenda-files= variable automatically using
2421 =C-c [= and =C-c ]= to add and remove files respectively. However,
2422 this replaces my directory list with a list of explicit filenames
2423 instead and is not what I want. If this occurs then adding a new org
2424 file to any of the above directories will not contribute to my agenda
2425 and I will probably miss something important.
2427 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
2428 prevent messing up my list of directories in the =org-agenda-files=
2429 variable. I just add and remove directories manually here. Changing
2430 the list of directories in =org-agenda-files= happens very rarely
2431 since new files in existing directories are automatically picked up.
2433 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2434 ;; Keep tasks with dates on the global todo lists
2435 (setq org-agenda-todo-ignore-with-date nil)
2437 ;; Keep tasks with deadlines on the global todo lists
2438 (setq org-agenda-todo-ignore-deadlines nil)
2440 ;; Keep tasks with scheduled dates on the global todo lists
2441 (setq org-agenda-todo-ignore-scheduled nil)
2443 ;; Keep tasks with timestamps on the global todo lists
2444 (setq org-agenda-todo-ignore-timestamp nil)
2446 ;; Remove completed deadline tasks from the agenda view
2447 (setq org-agenda-skip-deadline-if-done t)
2449 ;; Remove completed scheduled tasks from the agenda view
2450 (setq org-agenda-skip-scheduled-if-done t)
2452 ;; Remove completed items from search results
2453 (setq org-agenda-skip-timestamp-if-done t)
2455 ;; Include agenda archive files when searching for things
2456 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
2458 ;; Show all future entries for repeating tasks
2459 (setq org-agenda-repeating-timestamp-show-all t)
2461 ;; Show all agenda dates - even if they are empty
2462 (setq org-agenda-show-all-dates t)
2464 ;; Sorting order for tasks on the agenda
2465 (setq org-agenda-sorting-strategy
2466 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
2467 (todo category-up priority-down effort-up)
2468 (tags category-up priority-down effort-up)
2469 (search category-up))))
2471 ;; Start the weekly agenda on Monday
2472 (setq org-agenda-start-on-weekday 1)
2474 ;; Enable display of the time grid so we can see the marker for the current time
2475 (setq org-agenda-time-grid (quote ((daily today remove-match)
2476 #("----------------" 0 16 (org-heading t))
2477 (0800 1000 1200 1400 1500 1700 1900 2100))))
2479 ;; Display tags farther right
2480 (setq org-agenda-tags-column -102)
2482 ; position the habit graph on the agenda to the right of the default
2483 (setq org-habit-graph-column 50)
2485 ; turn habits back on
2486 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
2489 ;; Agenda sorting functions
2491 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
2494 (setq org-deadline-warning-days 30)
2496 ;; Always hilight the current agenda line
2497 (add-hook 'org-agenda-mode-hook
2498 '(lambda () (hl-line-mode 1))
2502 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2503 (setq org-agenda-persistent-filter t)
2504 (add-hook 'org-agenda-mode-hook
2505 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
2508 (add-hook 'org-agenda-mode-hook
2509 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
2512 (add-hook 'org-agenda-mode-hook
2513 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
2516 (add-hook 'org-agenda-mode-hook
2517 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
2520 (add-hook 'org-agenda-mode-hook
2521 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
2524 ; Rebuild the reminders everytime the agenda is displayed
2525 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
2527 ;(if (file-exists-p "~/org/refile.org")
2528 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
2530 ; Activate appointments so we get notifications
2533 (setq org-agenda-log-mode-items (quote (closed clock state)))
2534 (if (> emacs-major-version 23)
2535 (setq org-agenda-span 3)
2536 (setq org-agenda-ndays 3))
2538 (setq org-agenda-show-all-dates t)
2539 (setq org-agenda-start-on-weekday nil)
2540 (setq org-deadline-warning-days 14)
2543 *** Global keybindings.
2544 Start off by defining a series of keybindings.
2546 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
2547 setup manually, not by org-mode. Also turn off =C-c ;=, which
2548 comments headlines - a function never used.
2549 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2550 (add-hook 'org-mode-hook
2552 (org-defkey org-mode-map "\C-c[" 'undefined)
2553 (org-defkey org-mode-map "\C-c]" 'undefined)
2554 (org-defkey org-mode-map "\C-c;" 'undefined))
2558 And now a largish set of keybindings...
2559 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2560 (bind-key "C-c l" 'org-store-link)
2561 (bind-key "C-c a" 'org-agenda)
2562 ;(bind-key "C-c b" 'org-iswitchb)
2563 (define-key mode-specific-map [?a] 'org-agenda)
2565 (bind-key "<f12>" 'org-agenda)
2566 (bind-key "<f5>" 'bh/org-todo)
2567 (bind-key "<S-f5>" 'bh/widen)
2568 (bind-key "<f7>" 'bh/set-truncate-lines)
2569 (bind-key "<f8>" 'org-cycle-agenda-files)
2571 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
2572 (bind-key "<f9> b" 'bbdb)
2573 (bind-key "<f9> c" 'calendar)
2574 (bind-key "<f9> f" 'boxquote-insert-file)
2575 (bind-key "<f9> h" 'bh/hide-other)
2576 (bind-key "<f9> n" 'org-narrow-to-subtree)
2577 (bind-key "<f9> w" 'widen)
2578 (bind-key "<f9> u" 'bh/narrow-up-one-level)
2579 (bind-key "<f9> I" 'bh/punch-in)
2580 (bind-key "<f9> O" 'bh/punch-out)
2581 (bind-key "<f9> H" 'jj/punch-in-hw)
2582 (bind-key "<f9> W" 'jj/punch-out-hw)
2583 (bind-key "<f9> o" 'bh/make-org-scratch)
2584 (bind-key "<f9> p" 'bh/phone-call)
2585 (bind-key "<f9> r" 'boxquote-region)
2586 (bind-key "<f9> s" 'bh/switch-to-scratch)
2587 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
2588 (bind-key "<f9> T" 'tabify)
2589 (bind-key "<f9> U" 'untabify)
2590 (bind-key "<f9> v" 'visible-mode)
2591 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
2592 (bind-key "C-<f9>" 'previous-buffer)
2593 (bind-key "C-<f10>" 'next-buffer)
2594 (bind-key "M-<f9>" 'org-toggle-inline-images)
2595 ;(bind-key "C-x n r" 'narrow-to-region)
2596 (bind-key "<f11>" 'org-clock-goto)
2597 (bind-key "C-<f11>" 'org-clock-in)
2598 (bind-key "C-M-r" 'org-capture)
2599 (bind-key "C-c r" 'org-capture)
2600 (bind-key "C-S-<f12>" 'bh/save-then-publish)
2601 (bind-key "C-k" 'jj-org-kill-line org-mode-map)
2605 *** Tasks, States, Todo fun
2607 First we define the global todo keywords.
2608 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2609 (setq org-todo-keywords
2610 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
2611 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
2613 (setq org-todo-keyword-faces
2614 (quote (("TODO" :foreground "red" :weight bold)
2615 ("NEXT" :foreground "light blue" :weight bold)
2616 ("DONE" :foreground "forest green" :weight bold)
2617 ("WAITING" :foreground "orange" :weight bold)
2618 ("HOLD" :foreground "orange" :weight bold)
2619 ("DELEGATED" :foreground "yellow" :weight bold)
2620 ("CANCELLED" :foreground "dark green" :weight bold)
2621 ("PHONE" :foreground "dark green" :weight bold))))
2624 **** Fast Todo Selection
2625 Fast todo selection allows changing from any task todo state to any
2626 other state directly by selecting the appropriate key from the fast
2627 todo selection key menu.
2628 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2629 (setq org-use-fast-todo-selection t)
2631 Changing a task state is done with =C-c C-t KEY=
2633 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
2636 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2637 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
2639 allows changing todo states with S-left and S-right skipping all of
2640 the normal processing when entering or leaving a todo state. This
2641 cycles through the todo states but skips setting timestamps and
2642 entering notes which is very convenient when all you want to do is fix
2643 up the status of an entry.
2645 **** Todo State Triggers
2646 I have a few triggers that automatically assign tags to tasks based on
2647 state changes. If a task moves to =CANCELLED= state then it gets a
2648 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
2649 =CANCELLED= tag. These are used for filtering tasks in agenda views
2650 which I'll talk about later.
2652 The triggers break down to the following rules:
2654 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
2655 - Moving a task to =WAITING= adds a =WAITING= tag
2656 - Moving a task to =HOLD= adds a =WAITING= tag
2657 - Moving a task to a done state removes a =WAITING= tag
2658 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
2659 - Moving a task to =NEXT= removes a =WAITING= tag
2660 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
2662 The tags are used to filter tasks in the agenda views conveniently.
2663 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2664 (setq org-todo-state-tags-triggers
2665 (quote (("CANCELLED" ("CANCELLED" . t))
2666 ("WAITING" ("WAITING" . t))
2667 ("HOLD" ("WAITING" . t) ("HOLD" . t))
2668 (done ("WAITING") ("HOLD"))
2669 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
2670 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
2671 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
2674 *** Capturing new tasks
2675 Org capture replaces the old remember mode.
2676 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2677 (setq org-directory "~/org")
2678 (setq org-default-notes-file "~/org/refile.org")
2680 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
2681 ;; see http://orgmode.org/manual/Template-elements.html
2682 (setq org-capture-templates
2683 (quote (("t" "todo" entry (file "~/org/refile.org")
2684 "* TODO %?\nAdded: %U\n"
2685 :clock-in t :clock-resume t)
2686 ("l" "linktodo" entry (file "~/org/refile.org")
2687 "* TODO %?\nAdded: %U\n%a\n"
2688 :clock-in t :clock-resume t)
2689 ("r" "respond" entry (file "~/org/refile.org")
2690 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
2691 :clock-in t :clock-resume t :immediate-finish t)
2692 ("n" "note" entry (file "~/org/refile.org")
2693 "* %? :NOTE:\nAdded: %U\n%a\n"
2694 :clock-in t :clock-resume t)
2695 ("d" "Delegated" entry (file "~/org/refile.org")
2696 "* DELEGATED %?\nAdded: %U\n%a\n"
2697 :clock-in t :clock-resume t)
2698 ("j" "Journal" entry (file+datetree "~/org/diary.org")
2700 :clock-in t :clock-resume t)
2701 ("w" "org-protocol" entry (file "~/org/refile.org")
2702 "* TODO Review %c\nAdded: %U\n"
2703 :immediate-finish t)
2704 ("p" "Phone call" entry (file "~/org/refile.org")
2705 "* PHONE %? :PHONE:\nAdded: %U"
2706 :clock-in t :clock-resume t)
2707 ("x" "Bookmark link" entry (file "~/org/refile.org")
2708 "* Bookmark: %c\n%i\nAdded: %U\n"
2709 :immediate-finish t)
2710 ("h" "Habit" entry (file "~/org/refile.org")
2711 "* 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")
2715 Capture mode now handles automatically clocking in and out of a
2716 capture task. This all works out of the box now without special hooks.
2717 When I start a capture mode task the task is clocked in as specified
2718 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
2719 resumes on the original clocking task.
2721 The quick clocking in and out of capture mode tasks (often it takes
2722 less than a minute to capture some new task details) can leave
2723 empty clock drawers in my tasks which aren't really useful.
2724 The following prevents this.
2725 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2726 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
2730 All my newly captured entries end up in =refile.org= and want to be
2731 moved over to the right place. The following is the setup for it.
2732 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2733 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
2734 (setq org-refile-targets (quote ((nil :maxlevel . 9)
2735 (org-agenda-files :maxlevel . 9))))
2737 ; Use full outline paths for refile targets - we file directly with IDO
2738 (setq org-refile-use-outline-path t)
2740 ; Targets complete directly with IDO
2741 (setq org-outline-path-complete-in-steps nil)
2743 ; Allow refile to create parent tasks with confirmation
2744 (setq org-refile-allow-creating-parent-nodes (quote confirm))
2746 ; Use IDO for both buffer and file completion and ido-everywhere to t
2747 (setq org-completion-use-ido t)
2748 (setq org-completion-use-iswitchb nil)
2749 :; Use IDO for both buffer and file completion and ido-everywhere to t
2750 ;(setq ido-everywhere t)
2751 ;(setq ido-max-directory-size 100000)
2752 ;(ido-mode (quote both))
2753 ; Use the current window when visiting files and buffers with ido
2754 (setq ido-default-file-method 'selected-window)
2755 (setq ido-default-buffer-method 'selected-window)
2757 ;;;; Refile settings
2758 (setq org-refile-target-verify-function 'bh/verify-refile-target)
2762 Agenda view is the central place for org-mode interaction...
2763 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2764 ;; Do not dim blocked tasks
2765 (setq org-agenda-dim-blocked-tasks nil)
2766 ;; Compact the block agenda view
2767 (setq org-agenda-compact-blocks t)
2769 ;; Custom agenda command definitions
2770 (setq org-agenda-custom-commands
2771 (quote (("N" "Notes" tags "NOTE"
2772 ((org-agenda-overriding-header "Notes")
2773 (org-tags-match-list-sublevels t)))
2774 ("h" "Habits" tags-todo "STYLE=\"habit\""
2775 ((org-agenda-overriding-header "Habits")
2776 (org-agenda-sorting-strategy
2777 '(todo-state-down effort-up category-keep))))
2781 ((org-agenda-overriding-header "Tasks to Refile")
2782 (org-tags-match-list-sublevels nil)))
2783 (tags-todo "-HOLD-CANCELLED/!"
2784 ((org-agenda-overriding-header "Projects")
2785 (org-agenda-skip-function 'bh/skip-non-projects)
2786 (org-agenda-sorting-strategy
2788 (tags-todo "-CANCELLED/!"
2789 ((org-agenda-overriding-header "Stuck Projects")
2790 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
2791 (tags-todo "-WAITING-CANCELLED/!NEXT"
2792 ((org-agenda-overriding-header "Next Tasks")
2793 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
2794 (org-agenda-todo-ignore-scheduled t)
2795 (org-agenda-todo-ignore-deadlines t)
2796 (org-agenda-todo-ignore-with-date t)
2797 (org-tags-match-list-sublevels t)
2798 (org-agenda-sorting-strategy
2799 '(todo-state-down effort-up category-keep))))
2800 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
2801 ((org-agenda-overriding-header "Tasks")
2802 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
2803 (org-agenda-todo-ignore-scheduled t)
2804 (org-agenda-todo-ignore-deadlines t)
2805 (org-agenda-todo-ignore-with-date t)
2806 (org-agenda-sorting-strategy
2808 (tags-todo "-CANCELLED+WAITING/!"
2809 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
2810 (org-agenda-skip-function 'bh/skip-stuck-projects)
2811 (org-tags-match-list-sublevels nil)
2812 (org-agenda-todo-ignore-scheduled 'future)
2813 (org-agenda-todo-ignore-deadlines 'future)))
2815 ((org-agenda-overriding-header "Tasks to Archive")
2816 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
2817 (org-tags-match-list-sublevels nil))))
2819 ("r" "Tasks to Refile" tags "REFILE"
2820 ((org-agenda-overriding-header "Tasks to Refile")
2821 (org-tags-match-list-sublevels nil)))
2822 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
2823 ((org-agenda-overriding-header "Stuck Projects")
2824 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
2825 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
2826 ((org-agenda-overriding-header "Next Tasks")
2827 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
2828 (org-agenda-todo-ignore-scheduled t)
2829 (org-agenda-todo-ignore-deadlines t)
2830 (org-agenda-todo-ignore-with-date t)
2831 (org-tags-match-list-sublevels t)
2832 (org-agenda-sorting-strategy
2833 '(todo-state-down effort-up category-keep))))
2834 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
2835 ((org-agenda-overriding-header "Tasks")
2836 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
2837 (org-agenda-sorting-strategy
2839 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
2840 ((org-agenda-overriding-header "Projects")
2841 (org-agenda-skip-function 'bh/skip-non-projects)
2842 (org-agenda-sorting-strategy
2844 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
2845 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
2846 (org-tags-match-list-sublevels nil))
2847 ("A" "Tasks to Archive" tags "-REFILE/"
2848 ((org-agenda-overriding-header "Tasks to Archive")
2849 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
2850 (org-tags-match-list-sublevels nil))))))
2852 ; Overwrite the current window with the agenda
2853 (setq org-agenda-window-setup 'current-window)
2858 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2860 ;; Resume clocking task when emacs is restarted
2861 (org-clock-persistence-insinuate)
2863 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
2864 (setq org-clock-history-length 36)
2865 ;; Resume clocking task on clock-in if the clock is open
2866 (setq org-clock-in-resume t)
2867 ;; Change tasks to NEXT when clocking in
2868 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
2869 ;; Separate drawers for clocking and logs
2870 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
2871 ;; Save clock data and state changes and notes in the LOGBOOK drawer
2872 (setq org-clock-into-drawer t)
2873 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
2874 (setq org-clock-out-remove-zero-time-clocks t)
2875 ;; Clock out when moving task to a done state
2876 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
2877 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
2878 (setq org-clock-persist t)
2879 ;; Do not prompt to resume an active clock
2880 (setq org-clock-persist-query-resume nil)
2881 ;; Enable auto clock resolution for finding open clocks
2882 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
2883 ;; Include current clocking task in clock reports
2884 (setq org-clock-report-include-clocking-task t)
2886 ; use discrete minute intervals (no rounding) increments
2887 (setq org-time-stamp-rounding-minutes (quote (1 1)))
2889 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
2891 (setq bh/keep-clock-running nil)
2893 (setq org-agenda-clock-consistency-checks
2894 (quote (:max-duration "4:00"
2897 :gap-ok-around ("4:00"))))
2901 **** Setting a default clock task
2902 Per default the =** Organization= task in my tasks.org file receives
2903 misc clock time. This is the task I clock in on when I punch in at the
2904 start of my work day with =F9-I=. Punching-in anywhere clocks in this
2905 Organization task as the default task.
2907 If I want to change the default clocking task I just visit the
2908 new task in any org buffer and clock it in with =C-u C-u C-c C-x
2909 C-i=. Now this new task that collects miscellaneous clock
2910 minutes when the clock would normally stop.
2912 You can quickly clock in the default clocking task with =C-u C-c
2913 C-x C-i d=. Another option is to repeatedly clock out so the
2914 clock moves up the project tree until you clock out the
2915 top-level task and the clock moves to the default task.
2918 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2919 ;; Agenda clock report parameters
2920 (setq org-agenda-clockreport-parameter-plist
2921 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
2923 ;; Agenda log mode items to display (closed and state changes by default)
2924 (setq org-agenda-log-mode-items (quote (closed state)))
2926 **** Task estimates, column view
2927 Setup column view globally with the following headlines
2928 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2929 ; Set default column view headings: Task Effort Clock_Summary
2930 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
2932 Setup the estimate for effort values.
2933 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2934 ; global Effort estimate values
2935 ; global STYLE property values for completion
2936 (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")
2937 ("STYLE_ALL" . "habit"))))
2941 Tags are mostly used for filtering inside the agenda.
2942 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2943 ; Tags with fast selection keys
2944 (setq org-tag-alist (quote ((:startgroup)
2962 ; Allow setting single tags without the menu
2963 (setq org-fast-tag-selection-single-key (quote expert))
2965 ; For tag searches ignore tasks with scheduled and deadline dates
2966 (setq org-agenda-tags-todo-honor-ignore-options t)
2970 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2971 (setq org-archive-mark-done nil)
2972 (setq org-archive-location "%s_archive::* Archived Tasks")
2976 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2977 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
2978 (setq org-plantuml-jar-path "~/java/plantuml.jar")
2980 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
2982 ; Make babel results blocks lowercase
2983 (setq org-babel-results-keyword "results")
2985 (org-babel-do-load-languages
2986 (quote org-babel-load-languages)
2987 (quote ((emacs-lisp . t)
3006 ; Do not prompt to confirm evaluation
3007 ; This may be dangerous - make sure you understand the consequences
3008 ; of setting this -- see the docstring for details
3009 (setq org-confirm-babel-evaluate nil)
3011 ; Use fundamental mode when editing plantuml blocks with C-c '
3012 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
3015 #+BEGIN_SRC emacs-lisp :tangle yes
3016 ;; Don't have images visible on startup, breaks on console
3017 (setq org-startup-with-inline-images nil)
3020 #+BEGIN_SRC emacs-lisp :tangle yes
3021 (add-to-list 'org-structure-template-alist
3022 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
3023 "<comment>\n?\n</comment>"))
3025 **** ditaa, graphviz, etc
3026 Those are all nice tools. Look at
3027 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
3030 *** Publishing and exporting
3033 Org-mode can export to a variety of publishing formats including (but not limited to)
3036 (plain text - but not the original org-mode file)
3040 which enables getting to lots of other formats like ODF, XML, etc
3042 via LaTeX or Docbook
3045 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
3047 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3048 ;; Explicitly load required exporters
3052 ;; FIXME, check the following two
3053 ;(require 'ox-icalendar)
3056 ; experimenting with docbook exports - not finished
3057 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
3058 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
3060 ;; define categories that should be excluded
3061 (setq org-export-exclude-category (list "google" "google"))
3062 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
3064 ; define how the date strings look
3065 (setq org-export-date-timestamp-format "%Y-%m-%d")
3066 ; Inline images in HTML instead of producting links to the image
3067 (setq org-html-inline-images t)
3068 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
3069 (setq org-export-with-sub-superscripts nil)
3071 (setq org-html-head-extra (concat
3072 "<link rel=\"stylesheet\" href=\"http://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
3074 (setq org-html-head-include-default-style nil)
3075 ; Do not generate internal css formatting for HTML exports
3076 (setq org-export-htmlize-output-type (quote css))
3077 ; Export with LaTeX fragments
3078 (setq org-export-with-LaTeX-fragments t)
3079 ; Increase default number of headings to export
3080 (setq org-export-headline-levels 6)
3083 (setq org-publish-project-alist
3086 :base-directory "~/.emacs.d/"
3087 :base-extension "org"
3089 :publishing-directory "/develop/www/emacs"
3091 :publishing-function org-html-publish-to-html
3092 :headline-levels 4 ; Just the default for this project.
3098 :base-directory "~/.emacs.d/"
3099 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
3100 :publishing-directory "/develop/www/emacs"
3101 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
3103 :publishing-function org-publish-attachment
3105 ("inherit-org-info-js"
3106 :base-directory "/develop/vcs/org-info-js/"
3108 :base-extension "js"
3109 :publishing-directory "/develop/www/"
3110 :publishing-function org-publish-attachment
3112 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
3117 (setq org-export-with-timestamps nil)
3122 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3123 (setq org-latex-to-pdf-process
3124 '("xelatex -interaction nonstopmode %f"
3125 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
3126 (setq org-export-latex-listings 'minted)
3127 (setq org-latex-listings t)
3129 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
3130 ;; but adapted to use latexmk 4.20 or higher.
3131 (defun my-auto-tex-cmd ()
3132 "When exporting from .org with latex, automatically run latex,
3133 pdflatex, or xelatex as appropriate, using latexmk."
3135 ;; default command: oldstyle latex via dvi
3136 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
3138 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
3139 (setq texcmd "latexmk -pdf -quiet %f"))
3141 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3142 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
3143 ;; LaTeX compilation command
3144 (setq org-latex-to-pdf-process (list texcmd)))
3146 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
3148 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
3149 (setq org-export-latex-packages-alist
3151 ("" "longtable" nil)
3156 (defun my-auto-tex-parameters ()
3157 "Automatically select the tex packages to include."
3158 ;; default packages for ordinary latex or pdflatex export
3159 (setq org-export-latex-default-packages-alist
3160 '(("AUTO" "inputenc" t)
3170 ("" "hyperref" nil)))
3172 ;; Packages to include when xelatex is used
3173 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3174 (setq org-export-latex-default-packages-alist
3179 ("german" "babel" t)
3180 ("babel" "csquotes" t)
3182 ("xetex" "hyperref" nil)
3185 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
3186 (setq org-export-latex-classes
3188 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
3189 ("\\section{%s}" . "\\section*{%s}")
3190 ("\\subsection{%s}" . "\\subsection*{%s}")
3191 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
3192 ("\\paragraph{%s}" . "\\paragraph*{%s}")
3193 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
3194 org-export-latex-classes))))
3196 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
3199 *** Prevent editing invisible text
3200 The following setting prevents accidentally editing hidden text when
3201 the point is inside a folded region. This can happen if you are in
3202 the body of a heading and globally fold the org-file with =S-TAB=
3204 I find invisible edits (and undo's) hard to deal with so now I can't
3205 edit invisible text. =C-c C-r= (org-reveal) will display where the
3206 point is if it is buried in invisible text to allow editing again.
3208 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3209 (setq org-catch-invisible-edits 'error)
3213 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3214 ;; disable the default org-mode stuck projects agenda view
3215 (setq org-stuck-projects (quote ("" nil nil "")))
3217 ; force showing the next headline.
3218 (setq org-show-entry-below (quote ((default))))
3220 (setq org-show-following-heading t)
3221 (setq org-show-hierarchy-above t)
3222 (setq org-show-siblings (quote ((default))))
3224 (setq org-special-ctrl-a/e t)
3225 (setq org-special-ctrl-k t)
3226 (setq org-yank-adjusted-subtrees t)
3228 (setq org-table-export-default-format "orgtbl-to-csv")
3232 The following setting adds alphabetical lists like
3236 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3237 (if (> emacs-major-version 23)
3238 (setq org-list-allow-alphabetical t)
3239 (setq org-alphabetical-lists t))
3242 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3243 (setq org-remove-highlights-with-change nil)
3245 (setq org-list-demote-modify-bullet (quote (("+" . "-")
3252 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
3255 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
3256 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
3261 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3262 ;; Enable abbrev-mode
3263 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
3264 (setq org-startup-indented t)
3265 (setq org-startup-folded t)
3266 (setq org-cycle-separator-lines 0)
3269 I find extra blank lines in lists and headings a bit of a nuisance.
3270 To get a body after a list you need to include a blank line between
3271 the list entry and the body -- and indent the body appropriately.
3272 Most of my lists have no body detail so I like the look of collapsed
3273 lists with no blank lines better.
3275 The following setting prevents creating blank lines before headings
3276 but allows list items to adapt to existing blank lines around the items:
3277 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3278 (setq org-blank-before-new-entry (quote ((heading)
3279 (plain-list-item . auto))))
3282 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3283 (setq org-reverse-note-order nil)
3284 (setq org-default-notes-file "~/notes.org")
3287 Enforce task blocking. Tasks can't go done when there is any subtask
3288 still open. Unless they have a property of =NOBLOCKING: t=
3289 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3290 (setq org-enforce-todo-checkbox-dependencies t)
3291 (setq org-enforce-todo-dependencies t)
3294 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3295 (setq org-fast-tag-selection-single-key (quote expert))
3296 (setq org-footnote-auto-adjust t)
3297 (setq org-hide-block-startup t)
3298 (setq org-icalendar-alarm-time 15)
3299 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
3300 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
3301 (setq org-icalendar-honor-noexport-tag t)
3302 (setq org-icalendar-include-bbdb-anniversaries nil)
3303 (setq org-icalendar-include-body 200)
3304 (setq org-icalendar-include-todo nil)
3305 (setq org-icalendar-store-UID t)
3306 (setq org-icalendar-timezone "Europe/Berlin")
3307 (setq org-insert-mode-line-in-empty-file t)
3308 (setq org-log-done (quote note))
3309 (setq org-log-into-drawer t)
3310 (setq org-log-state-notes-insert-after-drawers nil)
3311 (setq org-log-reschedule (quote time))
3312 (setq org-log-states-order-reversed t)
3313 (setq org-mobile-agendas (quote all))
3314 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
3315 (setq org-mobile-inbox-for-pull "~/org/refile.org")
3316 (setq org-remember-store-without-prompt t)
3317 (setq org-return-follows-link t)
3318 (setq org-reverse-note-order t)
3320 ; regularly save our org-mode buffers
3321 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
3323 (setq org-log-done t)
3325 (setq org-enable-priority-commands t)
3326 (setq org-default-priority ?E)
3327 (setq org-lowest-priority ?E)
3332 Speed commands enable single-letter commands in Org-mode files when
3333 the point is at the beginning of a headline, or at the beginning of a
3336 See the `=org-speed-commands-default=' variable for a list of the keys
3337 and commands enabled at the beginning of headlines. All code blocks
3338 are available at the beginning of a code block, the following key
3339 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
3340 display a list of the code blocks commands and their related keys.
3342 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3343 (setq org-use-speed-commands t)
3344 (setq org-speed-commands-user (quote (("0" . ignore)
3357 ("h" . bh/hide-other)
3360 (call-interactively 'org-insert-heading-respect-content))
3361 ("k" . org-kill-note-or-show-branches)
3364 ("q" . bh/show-org-agenda)
3366 ("s" . org-save-all-org-buffers)
3370 ("z" . org-add-note)
3375 ("F" . bh/restrict-to-file-or-follow)
3378 ("J" . org-clock-goto)
3382 ("N" . bh/narrow-to-org-subtree)
3383 ("P" . bh/narrow-to-org-project)
3388 ("U" . bh/narrow-up-one-org-level)
3395 (add-hook 'org-agenda-mode-hook
3397 (define-key org-agenda-mode-map "q" 'bury-buffer))
3400 (defvar bh/current-view-project nil)
3401 (add-hook 'org-agenda-mode-hook
3402 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
3406 The following displays the contents of code blocks in Org-mode files
3407 using the major-mode of the code. It also changes the behavior of
3408 =TAB= to as if it were used in the appropriate major mode. This means
3409 that reading and editing code form inside of your Org-mode files is
3410 much more like reading and editing of code using its major mode.
3412 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3413 (setq org-src-fontify-natively t)
3414 (setq org-src-tab-acts-natively t)
3417 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3418 (setq org-src-preserve-indentation nil)
3419 (setq org-edit-src-content-indentation 0)
3423 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3424 (setq org-attach-directory "~/org/data/")
3426 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3427 (setq org-agenda-sticky t)
3430 **** Checklist handling
3431 [2013-05-11 Sat 22:15]
3433 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3434 (require 'org-checklist)
3438 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
3440 #+BEGIN_SRC emacs-lisp :tangle yes
3441 (use-package cperl-mode
3442 :commands cperl-mode
3445 (defalias 'perl-mode 'cperl-mode)
3446 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
3447 (add-auto-mode 'pod-mode "\\.pod$")
3448 (add-auto-mode 'tt-mode "\\.tt$")
3449 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
3450 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
3451 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
3455 (setq cperl-invalid-face nil
3456 cperl-close-paren-offset -4
3457 cperl-continued-statement-offset 0
3458 cperl-indent-level 4
3459 cperl-indent-parens-as-block t
3461 cperl-electric-keywords t
3462 cperl-electric-lbrace-space t
3463 cperl-electric-parens nil
3464 cperl-highlight-variables-indiscriminately t
3465 cperl-imenu-addback t
3466 cperl-invalid-face (quote underline)
3467 cperl-lazy-help-time 5
3468 cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$"
3469 cperl-syntaxify-by-font-lock t
3470 cperl-use-syntax-table-text-property-for-tags t)
3472 ;; And have cperl mode give ElDoc a useful string
3473 (defun my-cperl-eldoc-documentation-function ()
3474 "Return meaningful doc string for `eldoc-mode'."
3476 (let ((cperl-message-on-help-error nil))
3478 (add-hook 'cperl-mode-hook
3480 (set (make-local-variable 'eldoc-documentation-function)
3481 'my-cperl-eldoc-documentation-function)
3486 [2014-05-22 Thu 00:05]
3487 #+BEGIN_SRC emacs-lisp :tangle yes
3488 (use-package puppet-mode
3489 :mode ("\\.pp\\'" . puppet-mode)
3491 (use-package puppet-ext
3494 (bind-key "C-x ?" 'puppet-set-anchor puppet-mode-map)
3495 (bind-key "C-c C-r" 'puppet-create-require puppet-mode-map))))
3499 Use elpy for the emacs python fun, but dont let it initialize all the
3500 various variables. Elpy author may like them, but I'm not him...
3501 #+BEGIN_SRC emacs-lisp :tangle yes
3504 :mode ("\.py" . elpy-mode)
3507 (safe-load (concat jj-elisp-dir "/elpy/elpy-autoloads.el"))
3514 :commands (nosetests-all nosetests-module nosetests-one
3515 nosetests-failed nosetests-pdb-all
3516 nosetests-pdb-module nosetests-pdb-one)
3521 :commands (pyvenv-activate pyvenv-deactivate pyvenv-mode pyvenv-restart-python)
3524 (use-package idomenu
3529 (use-package highlight-indentation
3531 :commands (highlight-indentation-mode))
3533 (use-package find-file-in-project
3535 :commands (find-file-in-project ffip-project-files ffip ))
3540 ;; Local variables in `python-mode'. This is not removed when Elpy
3541 ;; is disabled, which can cause some confusion.
3542 (add-hook 'python-mode-hook 'elpy-initialize-local-variables)
3544 ;; Flymake support using flake8, including warning faces.
3545 (when (and (executable-find "flake8")
3546 (not (executable-find python-check-command)))
3547 (setq python-check-command "flake8"))
3549 ;; `flymake-no-changes-timeout': The original value of 0.5 is too
3550 ;; short for Python code, as that will result in the current line to
3551 ;; be highlighted most of the time, and that's annoying. This value
3552 ;; might be on the long side, but at least it does not, in general,
3553 ;; interfere with normal interaction.
3554 (setq flymake-no-changes-timeout 60)
3556 ;; `flymake-start-syntax-check-on-newline': This should be nil for
3557 ;; Python, as;; most lines with a colon at the end will mean the next
3558 ;; line is always highlighted as error, which is not helpful and
3560 (setq flymake-start-syntax-check-on-newline nil)
3562 ;; `ac-auto-show-menu': Short timeout because the menu is great.
3563 (setq ac-auto-show-menu 0.4)
3565 ;; `ac-quick-help-delay': I'd like to show the menu right with the
3566 ;; completions, but this value should be greater than
3567 ;; `ac-auto-show-menu' to show help for the first entry as well.
3568 (setq ac-quick-help-delay 0.5)
3570 ;; `yas-trigger-key': TAB, as is the default, conflicts with the
3571 ;; autocompletion. We also need to tell yasnippet about the new
3572 ;; binding. This is a bad interface to set the trigger key. Stop
3574 (let ((old (when (boundp 'yas-trigger-key)
3576 (setq yas-trigger-key "C-c C-i")
3577 (when (fboundp 'yas--trigger-key-reload)
3578 (yas--trigger-key-reload old)))
3580 ;; yas-snippet-dirs can be a string for a single directory. Make
3581 ;; sure it's a list in that case so we can add our own entry.
3582 (when (not (listp yas-snippet-dirs))
3583 (setq yas-snippet-dirs (list yas-snippet-dirs)))
3584 (add-to-list 'yas-snippet-dirs
3585 (concat (file-name-directory (locate-library "elpy"))
3589 ;; Now load yasnippets.
3592 (elpy-use-ipython)))
3597 #+BEGIN_SRC emacs-lisp :tangle no
3598 (autoload 'python-mode "python-mode" "Python Mode." t)
3599 (add-auto-mode 'python-mode "\\.py\\'")
3600 (add-auto-mode 'python-mode "\\.py$")
3601 (add-auto-mode 'python-mode "SConstruct\\'")
3602 (add-auto-mode 'python-mode "SConscript\\'")
3603 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
3606 (set-variable 'py-indent-offset 4)
3607 (set-variable 'py-smart-indentation nil)
3608 (set-variable 'indent-tabs-mode nil)
3609 (define-key python-mode-map "\C-m" 'newline-and-indent)
3610 (turn-on-eldoc-mode)
3611 (defun python-auto-fill-comments-only ()
3613 (set (make-local-variable 'fill-nobreak-predicate)
3615 (not (python-in-string/comment)))))
3616 (add-hook 'python-mode-hook
3618 (python-auto-fill-comments-only)))
3620 (autoload 'pymacs-apply "pymacs")
3621 (autoload 'pymacs-call "pymacs")
3622 (autoload 'pymacs-eval "pymacs" nil t)
3623 (autoload 'pymacs-exec "pymacs" nil t)
3624 (autoload 'pymacs-load "pymacs" nil t))
3627 If an =ipython= executable is on the path, then assume that IPython is
3628 the preferred method python evaluation.
3629 #+BEGIN_SRC emacs-lisp :tangle no
3630 (when (executable-find "ipython")
3632 (setq org-babel-python-mode 'python-mode))
3634 (setq python-shell-interpreter "ipython")
3635 (setq python-shell-interpreter-args "")
3636 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
3637 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
3638 (setq python-shell-completion-setup-code
3639 "from IPython.core.completerlib import module_completion")
3640 (setq python-shell-completion-module-string-code
3641 "';'.join(module_completion('''%s'''))\n")
3642 (setq python-shell-completion-string-code
3643 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
3645 ** rainbow-delimiters
3646 [2013-04-09 Di 23:38]
3647 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
3648 which highlights parens, brackets, and braces according to their
3649 depth. Each successive level is highlighted a different color. This
3650 makes it easy to spot matching delimiters, orient yourself in the code,
3651 and tell which statements are at the same depth.
3652 #+BEGIN_SRC emacs-lisp :tangle yes
3653 (use-package rainbow-delimiters
3654 :ensure rainbow-delimiters
3656 (global-rainbow-delimiters-mode))
3659 #+BEGIN_SRC emacs-lisp :tangle yes
3660 (use-package rainbow-mode
3661 :ensure rainbow-mode
3662 :diminish rainbow-mode)
3667 #+BEGIN_SRC emacs-lisp :tangle yes
3668 (use-package re-builder
3672 (setq reb-re-syntax 'string))
3675 [2014-05-19 Mo 22:56]
3676 Recentf is a minor mode that builds a list of recently opened
3677 files. This list is is automatically saved across Emacs sessions.
3678 #+BEGIN_SRC emacs-lisp :tangle yes
3679 (use-package recentf
3680 :if (not noninteractive)
3681 :bind ("C-x C-r" . recentf-open-files)
3685 (setq recentf-max-menu-items 25)
3686 (setq recentf-save-file (expand-file-name ".recentf" jj-cache-dir))
3688 (defun recentf-add-dired-directory ()
3689 (if (and dired-directory
3690 (file-directory-p dired-directory)
3691 (not (string= "/" dired-directory)))
3692 (let ((last-idx (1- (length dired-directory))))
3694 (if (= ?/ (aref dired-directory last-idx))
3695 (substring dired-directory 0 last-idx)
3696 dired-directory)))))
3698 (add-hook 'dired-mode-hook 'recentf-add-dired-directory)))
3700 ** Region bindings mode
3701 [2013-05-01 Wed 22:51]
3702 This mode allows to have keybindings that are only alive when the
3703 region is active. Helpful for things that only do any useful action
3704 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
3705 #+BEGIN_SRC emacs-lisp :tangle yes
3706 (use-package region-bindings-mode
3707 :ensure region-bindings-mode
3709 (region-bindings-mode-enable))
3712 [2013-05-22 Wed 22:33]
3713 Programming in ruby...
3716 #+BEGIN_SRC emacs-lisp :tangle yes
3717 (add-auto-mode 'ruby-mode
3718 "Rakefile\\'" "\\.rake\\'" "\.rxml\\'"
3719 "\\.rjs\\'" ".irbrc\\'" "\.builder\\'" "\\.ru\\'"
3720 "\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
3724 #+BEGIN_SRC emacs-lisp :tangle yes
3725 (use-package ruby-mode
3726 :mode ("\\.rb\\'" . ruby-mode)
3727 :interpreter ("ruby" . ruby-mode)
3734 (defvar yari-helm-source-ri-pages
3735 '((name . "RI documentation")
3736 (candidates . (lambda () (yari-ruby-obarray)))
3737 (action ("Show with Yari" . yari))
3738 (candidate-number-limit . 300)
3739 (requires-pattern . 2)
3740 "Source for completing RI documentation."))
3742 (defun helm-yari (&optional rehash)
3743 (interactive (list current-prefix-arg))
3744 (when current-prefix-arg (yari-ruby-obarray rehash))
3745 (helm 'yari-helm-source-ri-pages (yari-symbol-at-point)))))
3747 (defun my-ruby-smart-return ()
3749 (when (memq (char-after) '(?\| ?\" ?\'))
3751 (call-interactively 'newline-and-indent))
3753 (use-package ruby-hash-syntax
3754 :ensure ruby-hash-syntax)
3756 (use-package inf-ruby
3758 :commands inf-ruby-minor-mode
3761 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)
3762 (bind-key "<return>" 'my-ruby-smart-return ruby-mode-map)
3763 ;(bind-key "<tab>" 'indent-for-tab-command ruby-mode-map)
3766 (set (make-local-variable 'yas-fallback-behavior)
3767 '(apply ruby-indent-command . nil))
3768 (bind-key "<tab>" 'yas-expand-from-trigger-key ruby-mode-map)))
3770 ;; Stupidly the non-bundled ruby-mode isn't a derived mode of
3771 ;; prog-mode: we run the latter's hooks anyway in that case.
3772 (add-hook 'ruby-mode-hook
3774 (unless (derived-mode-p 'prog-mode)
3775 (run-hooks 'prog-mode-hook))))
3779 [2013-05-22 Wed 22:40]
3780 Save and restore the desktop
3781 #+BEGIN_SRC emacs-lisp :tangle yes
3782 (setq desktop-path (list jj-cache-dir))
3783 (desktop-save-mode 1)
3784 (defadvice desktop-read (around trace-desktop-errors activate)
3785 (let ((debug-on-error t))
3788 ;;----------------------------------------------------------------------------
3789 ;; Restore histories and registers after saving
3790 ;;----------------------------------------------------------------------------
3791 (use-package session
3792 :if (not noninteractive)
3793 :load-path "site-lisp/session/lisp/"
3796 (setq session-save-file (expand-file-name "session" jj-cache-dir))
3797 (setq desktop-globals-to-save
3798 (append '((extended-command-history . 30)
3799 (file-name-history . 100)
3801 (compile-history . 30)
3802 (minibuffer-history . 50)
3803 (query-replace-history . 60)
3804 (read-expression-history . 60)
3805 (regexp-history . 60)
3806 (regexp-search-ring . 20)
3808 (comint-input-ring . 50)
3809 (shell-command-history . 50)
3811 desktop-missing-file-warning
3815 (session-initialize)
3817 (defun remove-session-use-package-from-settings ()
3818 (when (string= (file-name-nondirectory (buffer-file-name)) "settings.el")
3820 (goto-char (point-min))
3821 (when (re-search-forward "^ '(session-use-package " nil t)
3822 (delete-region (line-beginning-position)
3823 (1+ (line-end-position)))))))
3825 (add-hook 'before-save-hook 'remove-session-use-package-from-settings)
3827 ;; expanded folded secitons as required
3828 (defun le::maybe-reveal ()
3829 (when (and (or (memq major-mode '(org-mode outline-mode))
3830 (and (boundp 'outline-minor-mode)
3831 outline-minor-mode))
3832 (outline-invisible-p))
3833 (if (eq major-mode 'org-mode)
3837 (add-hook 'session-after-jump-to-last-change-hook
3840 (defun save-information ()
3841 (with-temp-message "Saving Emacs information..."
3844 (loop for func in kill-emacs-hook
3845 unless (memq func '(exit-gnus-on-exit server-force-stop))
3848 (unless (or noninteractive
3849 (eq 'listen (process-status server-process)))
3852 (run-with-idle-timer 300 t 'save-information)
3855 (add-hook 'after-init-hook 'session-initialize t))))
3859 [2013-04-21 So 20:25]
3860 Save a bit of history
3861 #+BEGIN_SRC emacs-lisp tangle no
3863 (setq savehist-additional-variables
3864 '(search ring regexp-search-ring kill-ring compile-history))
3865 ;; save every minute
3866 (setq savehist-autosave-interval 60)
3867 (setq savehist-file (expand-file-name "savehist" jj-cache-dir))
3872 Store at which point I have been in files.
3873 #+BEGIN_SRC emacs-lisp :tangle yes
3874 (setq-default save-place t)
3875 (require 'saveplace)
3876 (setq save-place-file (expand-file-name "saved-places" jj-cache-dir))
3880 Settings for shell scripts
3881 #+BEGIN_SRC emacs-lisp :tangle yes
3882 (use-package sh-script
3886 (defvar sh-script-initialized nil)
3887 (defun initialize-sh-script ()
3888 (unless sh-script-initialized
3889 (setq sh-script-initialized t)
3890 (setq sh-indent-comment t)
3891 (info-lookup-add-help :mode 'shell-script-mode
3894 '(("(bash)Index")))))
3896 (add-hook 'shell-mode-hook 'initialize-sh-script)))
3899 #+BEGIN_SRC emacs-lisp :tangle yes
3900 (use-package sh-toggle
3901 :bind ("C-. C-z" . shell-toggle))
3904 By default, Emacs can update the time stamp for the following two
3905 formats if one exists in the first 8 lines of the file.
3908 #+BEGIN_SRC emacs-lisp :tangle yes
3909 (use-package time-stamp
3910 :commands time-stamp
3913 (add-hook 'write-file-hooks 'time-stamp)
3914 (setq time-stamp-active t))
3917 (setq time-stamp-format "%02H:%02M:%02S (%z) - %02d.%02m.%:y from %u (%U) on %s")
3918 (setq time-stamp-old-format-warn nil)
3919 (setq time-stamp-time-zone nil)))
3923 We configure only a bit of the tiny-tools to load when I should need
3924 them. I don't need much actually, but these things are nice to have.
3926 #+BEGIN_SRC emacs-lisp :tangle yes
3927 (autoload 'turn-on-tinyperl-mode "tinyperl" "" t)
3928 (add-hook 'perl-mode-hook 'turn-on-tinyperl-mode)
3929 (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode)
3931 (autoload 'tinycomment-indent-for-comment "tinycomment" "" t)
3932 (autoload 'tinyeat-forward-preserve "tinyeat" "" t)
3933 (autoload 'tinyeat-backward-preserve "tinyeat" "" t)
3934 (autoload 'tinyeat-kill-line-backward "tinyeat" "" t)
3936 *** Keyboard changes for tiny-tools
3937 #+BEGIN_SRC emacs-lisp :tangle yes
3938 (bind-key "\M-;" 'tinycomment-indent-for-comment)
3939 (bind-key "ESC C-k" 'tinyeat-kill-line-backward)
3940 (bind-key "ESC d" 'tinyeat-forward-preserve)
3941 (bind-key "<M-backspace>" 'tinyeat-backward-preserve)
3942 (bind-key "<S-backspace>" 'tinyeat-delete-whole-word)
3945 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
3946 #+BEGIN_SRC emacs-lisp :tangle yes
3951 (setq tramp-persistency-file-name (expand-file-name "tramp" jj-cache-dir))
3952 (setq shell-prompt-pattern "^[^a-zA-Z].*[#$%>] *")
3953 (add-to-list 'tramp-default-method-alist '("\\`localhost\\'" "\\`root\\'" "su")
3955 (setq tramp-debug-buffer nil)
3956 (setq tramp-default-method "sshx")
3957 (tramp-set-completion-function "ssh"
3958 '((tramp-parse-sconfig "/etc/ssh_config")
3959 (tramp-parse-sconfig "~/.ssh/config")))
3960 (setq tramp-verbose 5)
3965 For some reason I prefer this mode more than the way without. I want to
3966 see the marked region.
3967 #+BEGIN_SRC emacs-lisp :tangle yes
3968 (transient-mark-mode 1)
3971 [2013-04-21 So 11:07]
3972 Emacs undo is pretty powerful - but can also be confusing. There are
3973 tons of modes available to change it, even downgrade it to the very
3974 crappy ways one usually knows from other systems which lose
3975 information. undo-tree is different - it helps keeping you sane while
3976 keeping the full power of emacs undo/redo.
3977 #+BEGIN_SRC emacs-lisp :tangle yes
3978 (use-package undo-tree
3981 (global-undo-tree-mode)
3982 :diminish undo-tree-mode)
3985 Additionally I would like to keep the region active should I undo
3988 #+BEGIN_SRC emacs-lisp :tangle yes
3989 ;; Keep region when undoing in region
3990 (defadvice undo-tree-undo (around keep-region activate)
3992 (let ((m (set-marker (make-marker) (mark)))
3993 (p (set-marker (make-marker) (point))))
4002 Always have unique buffernames. See [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html][Uniquify - GNU Emacs Manual]]
4003 #+BEGIN_SRC emacs-lisp :tangle yes
4004 (use-package uniquify
4007 (setq uniquify-buffer-name-style 'post-forward)
4008 (setq uniquify-after-kill-buffer-p t)
4009 (setq uniquify-ignore-buffers-re "^\\*")))
4013 url contains code to parse and handle URLs - who would have thought? I
4014 set it to send Accept-language header and tell it to not send email,
4015 operating system or location info.
4016 #+BEGIN_SRC emacs-lisp :tangle yes
4017 (setq url-mime-language-string "de,en")
4018 (setq url-privacy-level (quote (email os lastloc)))
4021 [2014-06-01 Sun 21:38]
4022 visual-regexp for Emacs is like replace-regexp, but with live visual
4023 feedback directly in the buffer
4024 #+BEGIN_SRC emacs-lisp :tangle yes
4025 (use-package visual-regexp
4026 :ensure visual-regexp
4027 :bind (("C-M-%" . vr/replace)
4028 ("M-%" . vr/query-replace)
4029 ("C-c m" . vr/mc-mark))
4032 ** volatile highlights
4033 [2013-04-21 So 20:31]
4034 VolatileHighlights highlights changes to the buffer caused by commands
4035 such as ‘undo’, ‘yank’/’yank-pop’, etc. The highlight disappears at the
4036 next command. The highlighting gives useful visual feedback for what
4037 your operation actually changed in the buffer.
4038 #+BEGIN_SRC emacs-lisp :tangle yes
4039 (use-package volatile-highlights
4040 :ensure volatile-highlights
4042 (volatile-highlights-mode t)
4043 :diminish volatile-highlights-mode)
4046 This highlights some /weaselwords/, a mode to /aid in finding common
4047 writing problems/...
4048 [2013-04-27 Sa 23:29]
4049 #+BEGIN_SRC emacs-lisp :tangle no
4050 (use-package writegood-mode
4051 :ensure writegood-mode
4054 (bind-key "C-c g" 'writegood-mode))
4057 [2014-06-01 Sun 22:48]
4058 #+BEGIN_SRC emacs-lisp :tangle yes
4059 (use-package web-mode
4061 :mode (("\\.phtml\\'" . web-mode)
4062 ("\\.tpl\\.php\\'" . web-mode)
4063 ("\\.jsp\\'" . web-mode)
4064 ("\\.as[cp]x\\'" . web-mode)
4065 ("\\.erb\\'" . web-mode)
4066 ("\\.mustache\\'" . web-mode)
4067 ("\\.html\\'" . web-mode)
4068 ("\\.djhtml\\'" . web-mode))
4071 (add-hook 'web-mode-hook
4073 (setq web-mode-markup-indent-offset 2)
4074 (setq web-mode-css-indent-offset 2)
4075 (setq web-mode-code-indent-offset 2)
4076 (setq web-mode-enable-css-colorization t)
4077 (setq web-mode-enable-comment-keywords t)
4078 (setq web-mode-enable-current-element-highlight t)))))
4082 Yet another folding extension for the Emacs editor. Unlike many
4083 others, this one works by just using the existing indentation of the
4084 file, so basically works in every halfway structured file.
4085 #+BEGIN_SRC emacs-lisp :tangle yes
4086 (use-package yafolding
4087 :bind (("C-#" . yafolding)
4088 ("C-c C-f" . yafolding-toggle-all-by-current-level))
4089 :commands (yafolding yafolding-toggle-all-by-current-level)
4093 [2013-04-28 So 01:13]
4094 YAML is a nice format for data, which is both, human and machine
4095 readable/editable without getting a big headache.
4096 #+BEGIN_SRC emacs-lisp :tangle yes
4097 (use-package yaml-mode
4100 :mode ("\\.ya?ml\\'" . yaml-mode)
4102 (bind-key "C-m" 'newline-and-indent yaml-mode-map ))
4106 [2013-04-27 Sa 23:16]
4107 Yasnippet is a template system. Type an abbreviation, expand it into
4108 whatever the snippet holds.
4109 #+BEGIN_SRC emacs-lisp :tangle yes
4110 (setq yas-snippet-dirs (expand-file-name "yasnippet/snippets" jj-elisp-dir))
4111 (use-package yasnippet
4116 ;; Integrate hippie-expand with ya-snippet
4117 (add-to-list 'hippie-expand-try-functions-list
4118 'yas-hippie-try-expand)
4122 And thats it for this file, control passes "back" to [[file:../initjj.org][initjj.org/el]]
4123 which then may load more files.