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)
1299 (setq diredp-hide-details-initially-flag nil)))
1301 (use-package dired-single
1302 :ensure dired-single
1305 (bind-key "<return>" 'dired-single-buffer dired-mode-map)
1306 (bind-key "<mouse-1>" 'dired-single-buffer-mouse dired-mode-map)
1309 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
1315 (setq wdired-allow-to-change-permissions t)
1316 (bind-key "r" 'wdired-change-to-wdired-mode dired-mode-map)))
1318 (use-package gnus-dired
1321 (require 'gnus-dired)
1322 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
1323 (bind-key "a" 'gnus-dired-attach dired-mode-map)))
1325 (bind-key "M-!" 'async-shell-command dired-mode-map)
1326 (unbind-key "M-s f" dired-mode-map)
1328 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1329 "Make sure to remove \"Omit\" from the modeline."
1330 (diminish 'dired-omit-mode) dired-mode-map)
1332 ;; Omit files that Git would ignore
1333 (defun dired-omit-regexp ()
1334 (let ((file (expand-file-name ".git"))
1336 (while (and (not (file-exists-p file))
1339 (file-name-directory
1340 (directory-file-name
1341 (file-name-directory file))))
1342 ;; Give up if we are already at the root dir.
1343 (not (string= (file-name-directory file)
1345 ;; Move up to the parent dir and try again.
1346 (setq file (expand-file-name ".git" parent-dir)))
1347 ;; If we found a change log in a parent, use that.
1348 (if (file-exists-p file)
1349 (let ((regexp (funcall dired-omit-regexp-orig))
1351 (shell-command-to-string "git clean -d -x -n")))
1352 (if (= 0 (length omitted-files))
1356 (if (> (length regexp) 0)
1365 (if (= ?/ (aref str (1- (length str))))
1369 (split-string omitted-files "\n" t)
1372 (funcall dired-omit-regexp-orig))))))
1374 (add-hook 'dired-mode-hook 'dired-package-initialize)
1376 (defun dired-double-jump (first-dir second-dir)
1378 (list (read-directory-name "First directory: "
1379 (expand-file-name "~")
1381 (read-directory-name "Second directory: "
1382 (expand-file-name "~")
1383 nil nil "Archives/")))
1385 (dired-other-window second-dir))
1386 (bind-key "C-c J" 'dired-double-jump)))
1389 ** discover-my-major
1390 [2014-06-01 Sun 23:32]
1391 Discover key bindings and their meaning for the current Emacs major mode.
1392 #+BEGIN_SRC emacs-lisp :tangle yes
1393 (use-package discover-my-major
1394 :ensure discover-my-major
1395 :bind ("C-h C-m" . discover-my-major))
1398 EasyPG is a GnuPG interface for Emacs.
1399 #+BEGIN_SRC emacs-lisp :tangle yes
1404 I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1405 #+BEGIN_SRC emacs-lisp :tangle yes
1406 (defadvice epg--start (around advice-epg-disable-agent disable)
1407 "Don't allow epg--start to use gpg-agent in plain text
1409 (if (display-graphic-p)
1411 (let ((agent (getenv "GPG_AGENT_INFO")))
1412 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
1414 (setenv "GPG_AGENT_INFO" agent))))
1415 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
1416 (ad-activate 'epg--start)
1419 [2013-04-21 So 20:36]
1420 ediff - don't start another frame
1425 (defvar ctl-period-equals-map)
1426 (define-prefix-command 'ctl-period-equals-map)
1427 (bind-key "C-. =" 'ctl-period-equals-map)
1429 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
1431 :bind (("C-. = b" . ediff-buffers)
1432 ("C-. = B" . ediff-buffers3)
1433 ("C-. = =" . ediff-files)
1434 ("C-. = f" . ediff-files)
1435 ("C-. = F" . ediff-files3)
1436 ("C-. = r" . ediff-revision)
1437 ("C-. = p" . ediff-patch-file)
1438 ("C-. = P" . ediff-patch-buffer)
1439 ("C-. = l" . ediff-regions-linewise)
1440 ("C-. = w" . ediff-regions-wordwise)))
1443 EMMS is the Emacs Multimedia System.
1444 #+BEGIN_SRC emacs-lisp :tangle no
1445 (require 'emms-source-file)
1446 (require 'emms-source-playlist)
1447 (require 'emms-info)
1448 (require 'emms-cache)
1449 (require 'emms-playlist-mode)
1450 (require 'emms-playing-time)
1451 (require 'emms-player-mpd)
1452 (require 'emms-playlist-sort)
1453 (require 'emms-mark)
1454 (require 'emms-browser)
1455 (require 'emms-lyrics)
1456 (require 'emms-last-played)
1457 (require 'emms-score)
1458 (require 'emms-tag-editor)
1459 (require 'emms-history)
1460 (require 'emms-i18n)
1462 (setq emms-playlist-default-major-mode 'emms-playlist-mode)
1463 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
1464 (emms-playing-time 1)
1466 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
1467 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
1469 (when (fboundp 'emms-cache) ; work around compiler warning
1471 (setq emms-score-default-score 3)
1473 (defun emms-mpd-init ()
1474 "Connect Emms to mpd."
1476 (emms-player-mpd-connect))
1479 (require 'emms-player-mpd)
1480 (setq emms-player-mpd-server-name "localhost")
1481 (setq emms-player-mpd-server-port "6600")
1482 (add-to-list 'emms-info-functions 'emms-info-mpd)
1483 (add-to-list 'emms-player-list 'emms-player-mpd)
1484 (setq emms-volume-change-function 'emms-volume-mpd-change)
1485 (setq emms-player-mpd-sync-playlist t)
1487 (setq emms-source-file-default-directory "/var/lib/mpd/music")
1488 (setq emms-player-mpd-music-directory "/var/lib/mpd/music")
1489 (setq emms-info-auto-update t)
1490 (setq emms-lyrics-scroll-p t)
1491 (setq emms-lyrics-display-on-minibuffer t)
1492 (setq emms-lyrics-display-on-modeline nil)
1493 (setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
1495 (setq emms-last-played-format-alist
1496 '(((emms-last-played-seconds-today) . "%H:%M")
1497 (604800 . "%a %H:%M") ; this week
1498 ((emms-last-played-seconds-month) . "%d.%m.%Y")
1499 ((emms-last-played-seconds-year) . "%d.%m.%Y")
1500 (t . "Never played")))
1503 (defun my-describe (track)
1504 (let* ((empty "...")
1505 (name (emms-track-name track))
1506 (type (emms-track-type track))
1507 (short-name (file-name-nondirectory name))
1508 (play-count (or (emms-track-get track 'play-count) 0))
1509 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
1510 (artist (or (emms-track-get track 'info-artist) empty))
1511 (year (emms-track-get track 'info-year))
1512 (playing-time (or (emms-track-get track 'info-playing-time) 0))
1513 (min (/ playing-time 60))
1514 (sec (% playing-time 60))
1515 (album (or (emms-track-get track 'info-album) empty))
1516 (tracknumber (emms-track-get track 'info-tracknumber))
1517 (short-name (file-name-sans-extension
1518 (file-name-nondirectory name)))
1519 (title (or (emms-track-get track 'info-title) short-name))
1520 (rating (emms-score-get-score name))
1523 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
1524 (emms-last-played-format-date last-played)
1528 (if (and tracknumber ; tracknumber
1529 (not (zerop (string-to-number tracknumber))))
1530 (format "%02d" (string-to-number tracknumber))
1534 (make-string rating rate-char)))
1537 (setq emms-track-description-function 'my-describe)
1539 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
1540 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
1541 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
1542 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
1543 (global-set-key (kbd "H-<f9> x") 'emms-start)
1544 (global-set-key (kbd "H-<f9> v") 'emms-stop)
1545 (global-set-key (kbd "H-<f9> n") 'emms-next)
1546 (global-set-key (kbd "H-<f9> p") 'emms-previous)
1547 (global-set-key (kbd "H-<f9> o") 'emms-show)
1548 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
1549 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
1550 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
1551 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
1552 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
1554 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
1555 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
1556 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
1557 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
1559 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
1560 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
1561 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
1562 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
1564 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
1565 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
1566 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
1567 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
1569 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
1570 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
1571 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
1572 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
1573 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
1574 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
1576 (define-key emms-playlist-mode-map "x" 'emms-start)
1577 (define-key emms-playlist-mode-map "v" 'emms-stop)
1578 (define-key emms-playlist-mode-map "n" 'emms-next)
1579 (define-key emms-playlist-mode-map "p" 'emms-previous)
1581 (setq emms-playlist-buffer-name "*EMMS Playlist*"
1582 emms-playlist-mode-open-playlists t)
1588 'emms-browser-artist-face nil
1593 (setq emms-player-mpd-supported-regexp
1594 (or (emms-player-mpd-get-supported-regexp)
1595 (concat "\\`http://\\|"
1596 (emms-player-simple-regexp
1597 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
1598 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
1602 [2014-06-01 Sun 15:00]
1603 Proper whitespace handling
1604 #+BEGIN_SRC emacs-lisp :tangle yes
1605 (use-package ethan-wspace
1606 :ensure ethan-wspace
1607 :diminish (ethan-wspace-mode . "ew")
1609 (global-ethan-wspace-mode 1))
1613 [2014-06-01 Sun 15:16]
1614 #+BEGIN_SRC emacs-lisp :tangle yes
1615 (use-package expand-region
1616 :ensure expand-region
1617 :bind ("C-M-+" . er/expand-region))
1620 [2013-05-02 Thu 00:04]
1621 #+BEGIN_SRC emacs-lisp :tangle yes
1622 (use-package filladapt
1623 :diminish filladapt-mode
1625 (setq-default filladapt-mode t))
1628 [2013-04-28 So 22:21]
1629 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
1630 As the one time I tried Flymake i wasn't happy, thats easy to
1632 #+BEGIN_SRC emacs-lisp :tangle yes
1633 (use-package flycheck
1635 :bind (("M-n" . next-error)
1636 ("M-p" . previous-error))
1639 (add-hook 'find-file-hook
1641 (when (not (equal 'emacs-lisp-mode major-mode))
1645 (use-package flycheck-color-mode-line
1646 :ensure flycheck-color-mode-line)
1647 (setq flycheck-highlighting-mode nil)
1648 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
1652 Obviously emacs can do syntax hilighting. For more things than you ever
1654 And I want to have it everywhere.
1655 #+BEGIN_SRC emacs-lisp :tangle yes
1656 (use-package font-lock
1659 (global-font-lock-mode 1)
1660 (setq font-lock-maximum-decoration t)))
1663 #+BEGIN_SRC emacs-lisp :tangle yes
1664 (use-package git-commit-mode
1665 :ensure git-commit-mode
1666 :commands git-commit-mode
1667 :mode ("COMMIT_EDITMSG" . git-commit-mode))
1671 #+BEGIN_SRC emacs-lisp :tangle yes
1672 (use-package git-rebase-mode
1673 :ensure git-rebase-mode
1674 :commands git-rebase-mode
1675 :mode ("git-rebase-todo" . git-rebase-mode))
1678 [2014-05-21 Wed 22:56]
1679 #+BEGIN_SRC emacs-lisp :tangle yes
1680 (use-package git-gutter+
1682 :diminish git-gutter+-mode
1683 :bind (("C-x n" . git-gutter+-next-hunk)
1684 ("C-x p" . git-gutter+-previous-hunk)
1685 ("C-x v =" . git-gutter+-show-hunk)
1686 ("C-x r" . git-gutter+-revert-hunks)
1687 ("C-x s" . git-gutter+-stage-hunks)
1688 ("C-x c" . git-gutter+-commit)
1692 (setq git-gutter+-disabled-modes '(org-mode)))
1695 (use-package git-gutter-fringe+
1696 :ensure git-gutter-fringe+
1699 (setq git-gutter-fr+-side 'right-fringe)
1700 ;(git-gutter-fr+-minimal)
1702 (global-git-gutter+-mode 1)))
1706 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
1707 what I want every emacs to know.
1708 #+BEGIN_SRC emacs-lisp :tangle yes
1709 (bind-key "C-c g" 'gnus) ; Start gnus with M-n
1716 [2014-05-21 Wed 23:51]
1717 #+BEGIN_SRC emacs-lisp :tangle yes
1718 (use-package hi-lock
1719 :bind (("M-o l" . highlight-lines-matching-regexp)
1720 ("M-o r" . highlight-regexp)
1721 ("M-o w" . highlight-phrase)))
1725 (use-package hilit-chg
1726 :bind ("M-o C" . highlight-changes-mode))
1730 Crazy way of completion. It looks at the word before point and then
1731 tries to expand it in various ways.
1732 #+BEGIN_SRC emacs-lisp :tangle yes
1733 (use-package hippie-exp
1735 :bind ("M-/" . hippie-expand)
1738 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
1739 try-expand-dabbrev-all-buffers
1740 try-expand-dabbrev-from-kill
1741 try-complete-file-name-partially
1742 try-complete-file-name
1743 try-expand-all-abbrevs try-expand-list
1745 try-complete-lisp-symbol-partially
1746 try-complete-lisp-symbol))))
1749 Instead of default /html-mode/ I use /html-helper-mode/.
1750 #+BEGIN_SRC emacs-lisp :tangle yes
1751 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
1752 (add-auto-mode 'html-helper-mode "\\.html$")
1753 (add-auto-mode 'html-helper-mode "\\.asp$")
1754 (add-auto-mode 'html-helper-mode "\\.phtml$")
1755 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
1756 (defalias 'html-mode 'html-helper-mode)
1760 [2014-05-21 Wed 23:54]
1761 #+BEGIN_SRC emacs-lisp :tangle yes
1762 (use-package ibuffer
1764 :bind (("C-h h" . ibuffer)
1765 ("C-x C-b" . ibuffer)
1766 ("<XF86WebCam>" . ibuffer)
1771 (defvar my-ibufffer-separator " • ")
1772 (setq ibuffer-filter-group-name-face 'variable-pitch
1773 ibuffer-use-header-line t
1774 ibuffer-old-time 12)
1775 (use-package ibuffer-vc
1778 (ibuffer-vc-set-filter-groups-by-vc-root
1779 ibuffer-vc-generate-filter-groups-by-vc-root))
1780 (use-package ibuffer-tramp
1782 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
1783 ibuffer-tramp-set-filter-groups-by-tramp-connection))
1784 ;; Switching to ibuffer puts the cursor on the most recent buffer
1785 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
1786 "Open ibuffer with cursor pointed to most recent buffer name"
1787 (let ((recent-buffer-name (buffer-name)))
1789 (ibuffer-update nil t)
1790 (unless (string= recent-buffer-name "*Ibuffer*")
1791 (ibuffer-jump-to-buffer recent-buffer-name)))))
1794 (unbind-key "M-o" ibuffer-mode-map)
1795 (bind-key "s" 'isearch-forward-regexp ibuffer-mode-map)
1796 (bind-key "." 'ibuffer-invert-sorting ibuffer-mode-map)
1798 (defun ibuffer-magit-status ()
1800 (--when-let (get-buffer "*Ibuffer*")
1801 (with-current-buffer it
1802 (let* ((selected-buffer (ibuffer-current-buffer))
1803 (buffer-path (with-current-buffer
1805 (or (buffer-file-name)
1806 list-buffers-directory
1807 default-directory)))
1809 (if (file-regular-p buffer-path)
1810 (file-name-directory buffer-path)
1812 (magit-status default-directory)))))
1813 (bind-key "i" 'ibuffer-magit-status ibuffer-mode-map)
1814 (bind-key "G" 'ibuffer-magit-status ibuffer-mode-map)
1816 (setq ibuffer-directory-abbrev-alist
1821 (cons (f-slash (f-expand (cdr it))) (concat (car it) my-ibufffer-separator))
1822 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
1825 ("dak" . "/develop/dak/")
1827 ("config" . "~/.emacs.d/config/")
1829 ("systmp" . "/tmp/")
1830 ("puppet" . "~/git/puppet")
1834 (use-package ibuffer-git
1836 (use-package ibuffer-vc
1839 (define-ibuffer-column size-h
1840 (:name "Size" :inline t)
1842 ((> (buffer-size) 1000)
1843 (format "%7.1fk" (/ (buffer-size) 1000.0)))
1844 ((> (buffer-size) 1000000)
1845 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
1847 (format "%8d" (buffer-size)))))
1850 (define-ibuffer-filter filename2
1851 "Toggle current view to buffers with filename matching QUALIFIER."
1852 (:description "filename2"
1853 :reader (read-from-minibuffer "Filter by filename (regexp): "))
1854 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
1855 (ibuffer-awhen (with-current-buffer buf
1856 (or buffer-file-name
1858 (string-match qualifier it)))
1860 (defvar ibuffer-magit-filter-groups nil)
1861 (defun ibuffer-magit-define-filter-groups ()
1862 (when (and (not ibuffer-magit-filter-groups)
1863 (boundp 'magit-repo-dirs))
1864 (setq ibuffer-magit-filter-groups
1867 (file-name-nondirectory (directory-file-name it)))
1869 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
1871 (defun ibuffer-set-filter-groups-by-root ()
1873 ;; (ibuffer-projectile-define-filter-groups)
1874 ;; (ibuffer-magit-define-filter-groups)
1875 (setq ibuffer-filter-groups
1877 ;; ibuffer-projectile-filter-groups
1878 ibuffer-magit-filter-groups
1881 (or (mode . magit-log-edit-mode)
1882 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
1883 (name . "^\\*Pymacs\\*$")
1884 (name . "^\\*helm.*\\*")
1885 (name . "^\\*Compile-log\\*$")
1886 (name . "^\\*Ido Completions\\*$")
1887 (name . "^\\*magit-\\(process\\)\\*$")
1891 (name . "^\\*scratch")
1892 (name . "^\\*Messages")
1895 (ibuffer-vc-generate-filter-groups-by-vc-root)
1896 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
1898 (defun toggle-ibuffer-filter-groups ()
1901 (let ((ibuf (get-buffer "*Ibuffer*")))
1903 (with-current-buffer ibuf
1904 (let ((selected-buffer (ibuffer-current-buffer)))
1905 (if (not ibuffer-filter-groups)
1906 (ibuffer-set-filter-groups-by-root)
1907 (setq ibuffer-filter-groups nil))
1908 (pop-to-buffer ibuf)
1909 (ibuffer-update nil t)
1910 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
1912 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
1914 (setq ibuffer-default-sorting-mode 'recency
1915 ibuffer-eliding-string "…"
1916 ibuffer-compile-formats t
1917 ibuffer-git-column-length 6
1918 ibuffer-show-empty-filter-groups nil
1919 ibuffer-default-directory "~/"
1921 (setq ibuffer-formats '((mark vc-status-mini
1923 (git-status 8 8 :left)
1927 (name 18 18 :left :elide)
1929 (size-h 9 -1 :right)
1931 (mode 16 16 :left :elide)
1932 " " filename-and-process)
1934 (git-status 8 8 :left)
1940 (setq ibuffer-saved-filter-groups
1943 ("dired" (mode . dired-mode))
1944 ("perl" (mode . cperl-mode))
1946 (mode . puppet-mode)
1947 (mode . yaml-mode)))
1948 ("ruby" (mode . ruby-mode))
1950 (name . "^\\*scratch\\*$")
1951 (name . "^\\*Compile-log\\*$")
1952 (name . "^\\*Completions\\*$")
1953 (name . "^\\*Messages\\*$")
1954 (name . "^\\*Backtrace\\*$")
1955 (name . "^\\*Packages*\\*$")
1956 (name . "^\\*Help*\\*$")
1959 (mode . message-mode)
1962 (mode . gnus-group-mode)
1963 (mode . gnus-summary-mode)
1964 (mode . gnus-article-mode)
1965 (name . "^\\.bbdb$")
1966 (name . "^\\.newsrc-dribble")))
1968 (filename . ".*/org/.*")
1969 (mode . org-agenda-mode)
1970 (name . "^diary$")))
1972 (mode . magit-log-edit-mode)
1973 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
1975 ;; -------------------------------------------------
1976 ;; programming languages #1
1978 (mode . emacs-lisp-mode)
1979 (mode . python-mode)
1981 (mode . coffee-mode)
1984 (mode . actionscript-mode)
1987 (mode . haskell-mode)
1993 ;; -------------------------------------------------
1994 ;; configuration/data files
1998 (mode . conf-mode)))
1999 ;; -------------------------------------------------
2000 ;; text/notetaking/org
2001 ("org agenda" (mode . org-agenda-mode))
2004 (name . "^\\*Calendar\\*$")
2005 (name . "^diary$")))
2009 (mode . markdown-mode)))
2010 ;; -------------------------------------------------
2013 (mode . image-mode)))
2014 ;; -------------------------------------------------
2016 ("w3m" (mode . w3m-mode))
2018 (mode . magit-status-mode)
2019 (mode . magit-log-mode)
2020 (mode . vc-annotate-mode)))
2021 ("dired" (mode . dired-mode))
2026 (name . "^\\*Personal Keybindings\\*$")))
2027 ;; -------------------------------------------------
2029 ("MORE" (or (mode . magit-log-edit-mode)
2030 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2031 (name . "^\\*Pymacs\\*$")
2032 (name . "^\\*Compile-log\\*$")
2033 (name . "^\\*Completions\\*$")
2034 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
2036 ("*buffer*" (name . "\\*.*\\*"))))))
2038 (add-hook 'ibuffer-mode-hook
2040 (ibuffer-auto-mode 1)
2041 (ibuffer-switch-to-saved-filter-groups "default")))
2043 ;; Unless you turn this variable on you will be prompted every time
2044 ;; you want to delete a buffer, even unmodified ones, which is way
2045 ;; too cautious for most people. You’ll still be prompted for
2046 ;; confirmation when deleting modified buffers after the option has
2048 (setq ibuffer-expert t)
2053 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
2054 ‘TAB’ completion is to typing things manually every time.”]]
2055 #+BEGIN_SRC emacs-lisp :tangle yes
2056 (use-package icicles
2057 :load-path "elisp/icicle/"
2062 Incremental mini-buffer completion preview: Type in the minibuffer,
2063 list of matching commands is echoed
2064 #+BEGIN_SRC emacs-lisp :tangle yes
2068 [2014-05-26 Mon 22:49]
2069 #+BEGIN_SRC emacs-lisp :tangle yes
2072 :commands (iedit-mode)
2074 :bind (("C-;" . iedit-mode)
2075 ("C-," . iedit-mode-toggle-on-function))
2080 [2014-05-20 Tue 23:35]
2081 #+BEGIN_SRC emacs-lisp :tangle yes
2083 :bind ("C-h C-i" . info-lookup-symbol)
2087 ;; (defadvice info-setup (after load-info+ activate)
2088 ;; (use-package info+))
2090 (defadvice Info-exit (after remove-info-window activate)
2091 "When info mode is quit, remove the window."
2092 (if (> (length (window-list)) 1)
2095 (use-package info-look
2096 :commands info-lookup-add-help)
2098 ** linum (line number)
2099 Various modes should have line numbers in front of each line.
2101 But then there are some where it would just be deadly - like org-mode,
2102 gnus, so we have a list of modes where we don't want to see it.
2103 #+BEGIN_SRC emacs-lisp :tangle yes
2105 :diminish linum-mode
2108 (setq linum-format "%3d ")
2109 (setq linum-mode-inhibit-modes-list '(org-mode
2116 (defadvice linum-on (around linum-on-inhibit-for-modes)
2117 "Stop the load of linum-mode for some major modes."
2118 (unless (member major-mode linum-mode-inhibit-modes-list)
2121 (ad-activate 'linum-on))
2123 (global-linum-mode 1))
2126 ** lisp editing stuff
2127 [2013-04-21 So 21:00]
2128 I'm not doing much of it, except for my emacs and gnus configs, but
2129 then I like it nice too...
2130 #+BEGIN_SRC emacs-lisp :tangle yes
2131 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
2133 (defun remove-elc-on-save ()
2134 "If you're saving an elisp file, likely the .elc is no longer valid."
2135 (make-local-variable 'after-save-hook)
2136 (add-hook 'after-save-hook
2138 (if (file-exists-p (concat buffer-file-name "c"))
2139 (delete-file (concat buffer-file-name "c"))))))
2141 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
2142 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
2144 (use-package paredit
2146 :diminish paredit-mode " π")
2148 (setq lisp-coding-hook 'lisp-coding-defaults)
2149 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2151 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2152 (add-hook 'emacs-lisp-mode-hook (lambda ()
2153 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2155 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
2157 (after "elisp-slime-nav"
2158 '(diminish 'elisp-slime-nav-mode))
2159 (after "rainbow-mode"
2160 '(diminish 'rainbow-mode))
2162 '(diminish 'eldoc-mode))
2166 [2013-04-21 So 20:48]
2167 magit is a mode for interacting with git.
2168 #+BEGIN_SRC emacs-lisp :tangle yes
2171 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
2172 magit-git-repo-p magit-list-repos)
2174 :bind (("C-x g" . magit-status)
2175 ("C-x G" . magit-status-with-prefix))
2178 (setq magit-commit-signoff t
2179 magit-repo-dirs '("~/git"
2183 magit-repo-dirs-depth 4
2184 magit-log-auto-more t)
2185 (use-package magit-blame
2186 :commands magit-blame-mode)
2188 (add-hook 'magit-mode-hook 'hl-line-mode)
2189 (defun magit-status-with-prefix ()
2191 (let ((current-prefix-arg '(4)))
2192 (call-interactively 'magit-status)))
2196 (setenv "GIT_PAGER" "")
2198 (unbind-key "M-h" magit-mode-map)
2199 (unbind-key "M-s" magit-mode-map)
2201 (add-hook 'magit-log-edit-mode-hook
2203 (set-fill-column 72)
2206 (use-package magit-filenotify
2207 :ensure magit-filenotify
2208 :diminish (magit-filenotify-mode "MF")
2209 :commands (magit-filenotify-mode)
2212 (add-hook 'magit-mode-hook 'magit-filenotify-mode))
2215 (use-package magit-svn
2217 :commands (magit-svn-mode
2220 (use-package magit-find-file
2221 :ensure magit-find-file
2225 (bind-key "C-x C-f" 'magit-find-file-completing-read magit-mode-map)))))
2228 [2014-05-20 Tue 23:04]
2229 #+BEGIN_SRC emacs-lisp :tangle yes
2230 (use-package markdown-mode
2231 :mode (("\\.md\\'" . markdown-mode)
2232 ("\\.mdwn\\'" . markdown-mode))
2236 #+BEGIN_SRC emacs-lisp :tangle yes
2238 (setq message-kill-buffer-on-exit t)
2241 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2243 I want to access it from anywhere using =F6=.
2244 #+BEGIN_SRC emacs-lisp :tangle yes
2245 (use-package mingus-stays-home
2246 :bind ( "<f6>" . mingus)
2250 (setq mingus-dired-add-keys t)
2251 (setq mingus-mode-always-modeline nil)
2252 (setq mingus-mode-line-show-elapsed-percentage nil)
2253 (setq mingus-mode-line-show-volume nil)
2254 (setq mingus-mpd-config-file "/etc/mpd.conf")
2255 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2256 (setq mingus-mpd-root "/share/music/")))
2260 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
2261 #+BEGIN_SRC emacs-lisp :tangle yes
2262 (use-package miniedit
2266 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
2267 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
2268 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
2269 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
2274 [2013-05-21 Tue 23:39]
2275 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
2276 coexist in one buffer.
2277 #+BEGIN_SRC emacs-lisp :tangle yes
2278 (use-package mmm-auto
2282 (setq mmm-global-mode 'buffers-with-submode-classes)
2283 (setq mmm-submode-decoration-level 2)
2284 (eval-after-load 'mmm-vars
2290 :face mmm-code-submode-face
2291 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
2292 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
2293 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2294 @ "\n" _ "\n" @ "</script>" @)))
2297 :face mmm-code-submode-face
2298 :front "<style[^>]*>[ \t]*\n?"
2299 :back "[ \t]*</style>"
2300 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2301 @ "\n" _ "\n" @ "</style>" @)))
2304 :face mmm-code-submode-face
2307 (dolist (mode (list 'html-mode 'nxml-mode))
2308 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
2309 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
2314 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2317 #+BEGIN_SRC emacs-lisp :tangle yes
2318 (use-package mo-git-blame
2319 :ensure mo-git-blame
2320 :commands (mo-git-blame-current
2324 (setq mo-git-blame-blame-window-width 25)))
2328 [2013-04-08 Mon 23:57]
2329 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2330 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2331 #+BEGIN_SRC emacs-lisp :tangle yes
2332 (use-package multiple-cursors
2333 :ensure multiple-cursors
2335 :commands (mc/remove-fake-cursors
2336 mc/create-fake-cursor-at-point
2337 mc/pop-state-from-overlay
2338 mc/maybe-multiple-cursors-mode)
2339 :bind (("C-S-c C-S-c" . mc/edit-lines)
2340 ("C->" . mc/mark-next-like-this)
2341 ("C-<" . mc/mark-previous-like-this)
2342 ("C-c C-<" . mc/mark-all-like-this))
2345 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
2346 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
2347 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
2348 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
2349 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
2350 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
2353 [2013-05-22 Wed 22:02]
2354 nxml-mode is a major mode for editing XML.
2355 #+BEGIN_SRC emacs-lisp :tangle yes
2360 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2363 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2364 (fset 'xml-mode 'nxml-mode)
2365 (setq nxml-slash-auto-complete-flag t)
2367 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2368 (defun pp-xml-region (begin end)
2369 "Pretty format XML markup in region. The function inserts
2370 linebreaks to separate tags that have nothing but whitespace
2371 between them. It then indents the markup by using nxml's
2377 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2378 (backward-char) (insert "\n"))
2379 (indent-region begin end)))
2381 ;;----------------------------------------------------------------------------
2382 ;; Integration with tidy for html + xml
2383 ;;----------------------------------------------------------------------------
2384 ;; tidy is autoloaded
2385 (eval-after-load 'tidy
2387 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2388 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2393 *** General settings
2394 [2013-04-28 So 17:06]
2396 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
2397 it is quite extensive. Nevertheless, it starts out small, loading it.
2398 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2402 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
2403 that we need org-protocol.
2404 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2405 (require 'org-protocol)
2410 My current =org-agenda-files= variable only includes a set of
2412 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2413 (setq org-agenda-files (quote ("~/org/"
2419 (setq org-default-notes-file "~/org/notes.org")
2421 =org-mode= manages the =org-agenda-files= variable automatically using
2422 =C-c [= and =C-c ]= to add and remove files respectively. However,
2423 this replaces my directory list with a list of explicit filenames
2424 instead and is not what I want. If this occurs then adding a new org
2425 file to any of the above directories will not contribute to my agenda
2426 and I will probably miss something important.
2428 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
2429 prevent messing up my list of directories in the =org-agenda-files=
2430 variable. I just add and remove directories manually here. Changing
2431 the list of directories in =org-agenda-files= happens very rarely
2432 since new files in existing directories are automatically picked up.
2434 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2435 ;; Keep tasks with dates on the global todo lists
2436 (setq org-agenda-todo-ignore-with-date nil)
2438 ;; Keep tasks with deadlines on the global todo lists
2439 (setq org-agenda-todo-ignore-deadlines nil)
2441 ;; Keep tasks with scheduled dates on the global todo lists
2442 (setq org-agenda-todo-ignore-scheduled nil)
2444 ;; Keep tasks with timestamps on the global todo lists
2445 (setq org-agenda-todo-ignore-timestamp nil)
2447 ;; Remove completed deadline tasks from the agenda view
2448 (setq org-agenda-skip-deadline-if-done t)
2450 ;; Remove completed scheduled tasks from the agenda view
2451 (setq org-agenda-skip-scheduled-if-done t)
2453 ;; Remove completed items from search results
2454 (setq org-agenda-skip-timestamp-if-done t)
2456 ;; Include agenda archive files when searching for things
2457 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
2459 ;; Show all future entries for repeating tasks
2460 (setq org-agenda-repeating-timestamp-show-all t)
2462 ;; Show all agenda dates - even if they are empty
2463 (setq org-agenda-show-all-dates t)
2465 ;; Sorting order for tasks on the agenda
2466 (setq org-agenda-sorting-strategy
2467 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
2468 (todo category-up priority-down effort-up)
2469 (tags category-up priority-down effort-up)
2470 (search category-up))))
2472 ;; Start the weekly agenda on Monday
2473 (setq org-agenda-start-on-weekday 1)
2475 ;; Enable display of the time grid so we can see the marker for the current time
2476 (setq org-agenda-time-grid (quote ((daily today remove-match)
2477 #("----------------" 0 16 (org-heading t))
2478 (0800 1000 1200 1400 1500 1700 1900 2100))))
2480 ;; Display tags farther right
2481 (setq org-agenda-tags-column -102)
2483 ; position the habit graph on the agenda to the right of the default
2484 (setq org-habit-graph-column 50)
2486 ; turn habits back on
2487 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
2490 ;; Agenda sorting functions
2492 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
2495 (setq org-deadline-warning-days 30)
2497 ;; Always hilight the current agenda line
2498 (add-hook 'org-agenda-mode-hook
2499 '(lambda () (hl-line-mode 1))
2503 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2504 (setq org-agenda-persistent-filter t)
2505 (add-hook 'org-agenda-mode-hook
2506 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
2509 (add-hook 'org-agenda-mode-hook
2510 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
2513 (add-hook 'org-agenda-mode-hook
2514 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
2517 (add-hook 'org-agenda-mode-hook
2518 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
2521 (add-hook 'org-agenda-mode-hook
2522 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
2525 ; Rebuild the reminders everytime the agenda is displayed
2526 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
2528 ;(if (file-exists-p "~/org/refile.org")
2529 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
2531 ; Activate appointments so we get notifications
2534 (setq org-agenda-log-mode-items (quote (closed clock state)))
2535 (if (> emacs-major-version 23)
2536 (setq org-agenda-span 3)
2537 (setq org-agenda-ndays 3))
2539 (setq org-agenda-show-all-dates t)
2540 (setq org-agenda-start-on-weekday nil)
2541 (setq org-deadline-warning-days 14)
2544 *** Global keybindings.
2545 Start off by defining a series of keybindings.
2547 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
2548 setup manually, not by org-mode. Also turn off =C-c ;=, which
2549 comments headlines - a function never used.
2550 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2551 (add-hook 'org-mode-hook
2553 (org-defkey org-mode-map "\C-c[" 'undefined)
2554 (org-defkey org-mode-map "\C-c]" 'undefined)
2555 (org-defkey org-mode-map "\C-c;" 'undefined))
2559 And now a largish set of keybindings...
2560 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2561 (bind-key "C-c l" 'org-store-link)
2562 (bind-key "C-c a" 'org-agenda)
2563 ;(bind-key "C-c b" 'org-iswitchb)
2564 (define-key mode-specific-map [?a] 'org-agenda)
2566 (bind-key "<f12>" 'org-agenda)
2567 (bind-key "<f5>" 'bh/org-todo)
2568 (bind-key "<S-f5>" 'bh/widen)
2569 (bind-key "<f7>" 'bh/set-truncate-lines)
2570 (bind-key "<f8>" 'org-cycle-agenda-files)
2572 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
2573 (bind-key "<f9> b" 'bbdb)
2574 (bind-key "<f9> c" 'calendar)
2575 (bind-key "<f9> f" 'boxquote-insert-file)
2576 (bind-key "<f9> h" 'bh/hide-other)
2577 (bind-key "<f9> n" 'org-narrow-to-subtree)
2578 (bind-key "<f9> w" 'widen)
2579 (bind-key "<f9> u" 'bh/narrow-up-one-level)
2580 (bind-key "<f9> I" 'bh/punch-in)
2581 (bind-key "<f9> O" 'bh/punch-out)
2582 (bind-key "<f9> H" 'jj/punch-in-hw)
2583 (bind-key "<f9> W" 'jj/punch-out-hw)
2584 (bind-key "<f9> o" 'bh/make-org-scratch)
2585 (bind-key "<f9> p" 'bh/phone-call)
2586 (bind-key "<f9> r" 'boxquote-region)
2587 (bind-key "<f9> s" 'bh/switch-to-scratch)
2588 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
2589 (bind-key "<f9> T" 'tabify)
2590 (bind-key "<f9> U" 'untabify)
2591 (bind-key "<f9> v" 'visible-mode)
2592 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
2593 (bind-key "C-<f9>" 'previous-buffer)
2594 (bind-key "C-<f10>" 'next-buffer)
2595 (bind-key "M-<f9>" 'org-toggle-inline-images)
2596 ;(bind-key "C-x n r" 'narrow-to-region)
2597 (bind-key "<f11>" 'org-clock-goto)
2598 (bind-key "C-<f11>" 'org-clock-in)
2599 (bind-key "C-M-r" 'org-capture)
2600 (bind-key "C-c r" 'org-capture)
2601 (bind-key "C-S-<f12>" 'bh/save-then-publish)
2602 (bind-key "C-k" 'jj-org-kill-line org-mode-map)
2606 *** Tasks, States, Todo fun
2608 First we define the global todo keywords.
2609 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2610 (setq org-todo-keywords
2611 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
2612 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
2614 (setq org-todo-keyword-faces
2615 (quote (("TODO" :foreground "red" :weight bold)
2616 ("NEXT" :foreground "light blue" :weight bold)
2617 ("DONE" :foreground "forest green" :weight bold)
2618 ("WAITING" :foreground "orange" :weight bold)
2619 ("HOLD" :foreground "orange" :weight bold)
2620 ("DELEGATED" :foreground "yellow" :weight bold)
2621 ("CANCELLED" :foreground "dark green" :weight bold)
2622 ("PHONE" :foreground "dark green" :weight bold))))
2625 **** Fast Todo Selection
2626 Fast todo selection allows changing from any task todo state to any
2627 other state directly by selecting the appropriate key from the fast
2628 todo selection key menu.
2629 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2630 (setq org-use-fast-todo-selection t)
2632 Changing a task state is done with =C-c C-t KEY=
2634 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
2637 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2638 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
2640 allows changing todo states with S-left and S-right skipping all of
2641 the normal processing when entering or leaving a todo state. This
2642 cycles through the todo states but skips setting timestamps and
2643 entering notes which is very convenient when all you want to do is fix
2644 up the status of an entry.
2646 **** Todo State Triggers
2647 I have a few triggers that automatically assign tags to tasks based on
2648 state changes. If a task moves to =CANCELLED= state then it gets a
2649 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
2650 =CANCELLED= tag. These are used for filtering tasks in agenda views
2651 which I'll talk about later.
2653 The triggers break down to the following rules:
2655 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
2656 - Moving a task to =WAITING= adds a =WAITING= tag
2657 - Moving a task to =HOLD= adds a =WAITING= tag
2658 - Moving a task to a done state removes a =WAITING= tag
2659 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
2660 - Moving a task to =NEXT= removes a =WAITING= tag
2661 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
2663 The tags are used to filter tasks in the agenda views conveniently.
2664 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2665 (setq org-todo-state-tags-triggers
2666 (quote (("CANCELLED" ("CANCELLED" . t))
2667 ("WAITING" ("WAITING" . t))
2668 ("HOLD" ("WAITING" . t) ("HOLD" . t))
2669 (done ("WAITING") ("HOLD"))
2670 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
2671 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
2672 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
2675 *** Capturing new tasks
2676 Org capture replaces the old remember mode.
2677 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2678 (setq org-directory "~/org")
2679 (setq org-default-notes-file "~/org/refile.org")
2681 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
2682 ;; see http://orgmode.org/manual/Template-elements.html
2683 (setq org-capture-templates
2684 (quote (("t" "todo" entry (file "~/org/refile.org")
2685 "* TODO %?\nAdded: %U\n"
2686 :clock-in t :clock-resume t)
2687 ("l" "linktodo" entry (file "~/org/refile.org")
2688 "* TODO %?\nAdded: %U\n%a\n"
2689 :clock-in t :clock-resume t)
2690 ("r" "respond" entry (file "~/org/refile.org")
2691 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
2692 :clock-in t :clock-resume t :immediate-finish t)
2693 ("n" "note" entry (file "~/org/refile.org")
2694 "* %? :NOTE:\nAdded: %U\n%a\n"
2695 :clock-in t :clock-resume t)
2696 ("d" "Delegated" entry (file "~/org/refile.org")
2697 "* DELEGATED %?\nAdded: %U\n%a\n"
2698 :clock-in t :clock-resume t)
2699 ("j" "Journal" entry (file+datetree "~/org/diary.org")
2701 :clock-in t :clock-resume t)
2702 ("w" "org-protocol" entry (file "~/org/refile.org")
2703 "* TODO Review %c\nAdded: %U\n"
2704 :immediate-finish t)
2705 ("p" "Phone call" entry (file "~/org/refile.org")
2706 "* PHONE %? :PHONE:\nAdded: %U"
2707 :clock-in t :clock-resume t)
2708 ("x" "Bookmark link" entry (file "~/org/refile.org")
2709 "* Bookmark: %c\n%i\nAdded: %U\n"
2710 :immediate-finish t)
2711 ("h" "Habit" entry (file "~/org/refile.org")
2712 "* 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")
2716 Capture mode now handles automatically clocking in and out of a
2717 capture task. This all works out of the box now without special hooks.
2718 When I start a capture mode task the task is clocked in as specified
2719 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
2720 resumes on the original clocking task.
2722 The quick clocking in and out of capture mode tasks (often it takes
2723 less than a minute to capture some new task details) can leave
2724 empty clock drawers in my tasks which aren't really useful.
2725 The following prevents this.
2726 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2727 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
2731 All my newly captured entries end up in =refile.org= and want to be
2732 moved over to the right place. The following is the setup for it.
2733 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2734 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
2735 (setq org-refile-targets (quote ((nil :maxlevel . 9)
2736 (org-agenda-files :maxlevel . 9))))
2738 ; Use full outline paths for refile targets - we file directly with IDO
2739 (setq org-refile-use-outline-path t)
2741 ; Targets complete directly with IDO
2742 (setq org-outline-path-complete-in-steps nil)
2744 ; Allow refile to create parent tasks with confirmation
2745 (setq org-refile-allow-creating-parent-nodes (quote confirm))
2747 ; Use IDO for both buffer and file completion and ido-everywhere to t
2748 (setq org-completion-use-ido t)
2749 (setq org-completion-use-iswitchb nil)
2750 :; Use IDO for both buffer and file completion and ido-everywhere to t
2751 ;(setq ido-everywhere t)
2752 ;(setq ido-max-directory-size 100000)
2753 ;(ido-mode (quote both))
2754 ; Use the current window when visiting files and buffers with ido
2755 (setq ido-default-file-method 'selected-window)
2756 (setq ido-default-buffer-method 'selected-window)
2758 ;;;; Refile settings
2759 (setq org-refile-target-verify-function 'bh/verify-refile-target)
2763 Agenda view is the central place for org-mode interaction...
2764 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2765 ;; Do not dim blocked tasks
2766 (setq org-agenda-dim-blocked-tasks nil)
2767 ;; Compact the block agenda view
2768 (setq org-agenda-compact-blocks t)
2770 ;; Custom agenda command definitions
2771 (setq org-agenda-custom-commands
2772 (quote (("N" "Notes" tags "NOTE"
2773 ((org-agenda-overriding-header "Notes")
2774 (org-tags-match-list-sublevels t)))
2775 ("h" "Habits" tags-todo "STYLE=\"habit\""
2776 ((org-agenda-overriding-header "Habits")
2777 (org-agenda-sorting-strategy
2778 '(todo-state-down effort-up category-keep))))
2782 ((org-agenda-overriding-header "Tasks to Refile")
2783 (org-tags-match-list-sublevels nil)))
2784 (tags-todo "-HOLD-CANCELLED/!"
2785 ((org-agenda-overriding-header "Projects")
2786 (org-agenda-skip-function 'bh/skip-non-projects)
2787 (org-agenda-sorting-strategy
2789 (tags-todo "-CANCELLED/!"
2790 ((org-agenda-overriding-header "Stuck Projects")
2791 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
2792 (tags-todo "-WAITING-CANCELLED/!NEXT"
2793 ((org-agenda-overriding-header "Next Tasks")
2794 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
2795 (org-agenda-todo-ignore-scheduled t)
2796 (org-agenda-todo-ignore-deadlines t)
2797 (org-agenda-todo-ignore-with-date t)
2798 (org-tags-match-list-sublevels t)
2799 (org-agenda-sorting-strategy
2800 '(todo-state-down effort-up category-keep))))
2801 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
2802 ((org-agenda-overriding-header "Tasks")
2803 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
2804 (org-agenda-todo-ignore-scheduled t)
2805 (org-agenda-todo-ignore-deadlines t)
2806 (org-agenda-todo-ignore-with-date t)
2807 (org-agenda-sorting-strategy
2809 (tags-todo "-CANCELLED+WAITING/!"
2810 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
2811 (org-agenda-skip-function 'bh/skip-stuck-projects)
2812 (org-tags-match-list-sublevels nil)
2813 (org-agenda-todo-ignore-scheduled 'future)
2814 (org-agenda-todo-ignore-deadlines 'future)))
2816 ((org-agenda-overriding-header "Tasks to Archive")
2817 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
2818 (org-tags-match-list-sublevels nil))))
2820 ("r" "Tasks to Refile" tags "REFILE"
2821 ((org-agenda-overriding-header "Tasks to Refile")
2822 (org-tags-match-list-sublevels nil)))
2823 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
2824 ((org-agenda-overriding-header "Stuck Projects")
2825 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
2826 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
2827 ((org-agenda-overriding-header "Next Tasks")
2828 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
2829 (org-agenda-todo-ignore-scheduled t)
2830 (org-agenda-todo-ignore-deadlines t)
2831 (org-agenda-todo-ignore-with-date t)
2832 (org-tags-match-list-sublevels t)
2833 (org-agenda-sorting-strategy
2834 '(todo-state-down effort-up category-keep))))
2835 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
2836 ((org-agenda-overriding-header "Tasks")
2837 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
2838 (org-agenda-sorting-strategy
2840 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
2841 ((org-agenda-overriding-header "Projects")
2842 (org-agenda-skip-function 'bh/skip-non-projects)
2843 (org-agenda-sorting-strategy
2845 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
2846 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
2847 (org-tags-match-list-sublevels nil))
2848 ("A" "Tasks to Archive" tags "-REFILE/"
2849 ((org-agenda-overriding-header "Tasks to Archive")
2850 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
2851 (org-tags-match-list-sublevels nil))))))
2853 ; Overwrite the current window with the agenda
2854 (setq org-agenda-window-setup 'current-window)
2859 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2861 ;; Resume clocking task when emacs is restarted
2862 (org-clock-persistence-insinuate)
2864 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
2865 (setq org-clock-history-length 36)
2866 ;; Resume clocking task on clock-in if the clock is open
2867 (setq org-clock-in-resume t)
2868 ;; Change tasks to NEXT when clocking in
2869 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
2870 ;; Separate drawers for clocking and logs
2871 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
2872 ;; Save clock data and state changes and notes in the LOGBOOK drawer
2873 (setq org-clock-into-drawer t)
2874 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
2875 (setq org-clock-out-remove-zero-time-clocks t)
2876 ;; Clock out when moving task to a done state
2877 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
2878 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
2879 (setq org-clock-persist t)
2880 ;; Do not prompt to resume an active clock
2881 (setq org-clock-persist-query-resume nil)
2882 ;; Enable auto clock resolution for finding open clocks
2883 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
2884 ;; Include current clocking task in clock reports
2885 (setq org-clock-report-include-clocking-task t)
2887 ; use discrete minute intervals (no rounding) increments
2888 (setq org-time-stamp-rounding-minutes (quote (1 1)))
2890 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
2892 (setq bh/keep-clock-running nil)
2894 (setq org-agenda-clock-consistency-checks
2895 (quote (:max-duration "4:00"
2898 :gap-ok-around ("4:00"))))
2902 **** Setting a default clock task
2903 Per default the =** Organization= task in my tasks.org file receives
2904 misc clock time. This is the task I clock in on when I punch in at the
2905 start of my work day with =F9-I=. Punching-in anywhere clocks in this
2906 Organization task as the default task.
2908 If I want to change the default clocking task I just visit the
2909 new task in any org buffer and clock it in with =C-u C-u C-c C-x
2910 C-i=. Now this new task that collects miscellaneous clock
2911 minutes when the clock would normally stop.
2913 You can quickly clock in the default clocking task with =C-u C-c
2914 C-x C-i d=. Another option is to repeatedly clock out so the
2915 clock moves up the project tree until you clock out the
2916 top-level task and the clock moves to the default task.
2919 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2920 ;; Agenda clock report parameters
2921 (setq org-agenda-clockreport-parameter-plist
2922 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
2924 ;; Agenda log mode items to display (closed and state changes by default)
2925 (setq org-agenda-log-mode-items (quote (closed state)))
2927 **** Task estimates, column view
2928 Setup column view globally with the following headlines
2929 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2930 ; Set default column view headings: Task Effort Clock_Summary
2931 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
2933 Setup the estimate for effort values.
2934 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2935 ; global Effort estimate values
2936 ; global STYLE property values for completion
2937 (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")
2938 ("STYLE_ALL" . "habit"))))
2942 Tags are mostly used for filtering inside the agenda.
2943 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2944 ; Tags with fast selection keys
2945 (setq org-tag-alist (quote ((:startgroup)
2963 ; Allow setting single tags without the menu
2964 (setq org-fast-tag-selection-single-key (quote expert))
2966 ; For tag searches ignore tasks with scheduled and deadline dates
2967 (setq org-agenda-tags-todo-honor-ignore-options t)
2971 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2972 (setq org-archive-mark-done nil)
2973 (setq org-archive-location "%s_archive::* Archived Tasks")
2977 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2978 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
2979 (setq org-plantuml-jar-path "~/java/plantuml.jar")
2981 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
2983 ; Make babel results blocks lowercase
2984 (setq org-babel-results-keyword "results")
2986 (org-babel-do-load-languages
2987 (quote org-babel-load-languages)
2988 (quote ((emacs-lisp . t)
3007 ; Do not prompt to confirm evaluation
3008 ; This may be dangerous - make sure you understand the consequences
3009 ; of setting this -- see the docstring for details
3010 (setq org-confirm-babel-evaluate nil)
3012 ; Use fundamental mode when editing plantuml blocks with C-c '
3013 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
3016 #+BEGIN_SRC emacs-lisp :tangle yes
3017 ;; Don't have images visible on startup, breaks on console
3018 (setq org-startup-with-inline-images nil)
3021 #+BEGIN_SRC emacs-lisp :tangle yes
3022 (add-to-list 'org-structure-template-alist
3023 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
3024 "<comment>\n?\n</comment>"))
3026 **** ditaa, graphviz, etc
3027 Those are all nice tools. Look at
3028 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
3031 *** Publishing and exporting
3034 Org-mode can export to a variety of publishing formats including (but not limited to)
3037 (plain text - but not the original org-mode file)
3041 which enables getting to lots of other formats like ODF, XML, etc
3043 via LaTeX or Docbook
3046 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
3048 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3049 ;; Explicitly load required exporters
3053 ;; FIXME, check the following two
3054 ;(require 'ox-icalendar)
3057 ; experimenting with docbook exports - not finished
3058 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
3059 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
3061 ;; define categories that should be excluded
3062 (setq org-export-exclude-category (list "google" "google"))
3063 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
3065 ; define how the date strings look
3066 (setq org-export-date-timestamp-format "%Y-%m-%d")
3067 ; Inline images in HTML instead of producting links to the image
3068 (setq org-html-inline-images t)
3069 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
3070 (setq org-export-with-sub-superscripts nil)
3072 (setq org-html-head-extra (concat
3073 "<link rel=\"stylesheet\" href=\"http://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
3075 (setq org-html-head-include-default-style nil)
3076 ; Do not generate internal css formatting for HTML exports
3077 (setq org-export-htmlize-output-type (quote css))
3078 ; Export with LaTeX fragments
3079 (setq org-export-with-LaTeX-fragments t)
3080 ; Increase default number of headings to export
3081 (setq org-export-headline-levels 6)
3084 (setq org-publish-project-alist
3087 :base-directory "~/.emacs.d/"
3088 :base-extension "org"
3090 :publishing-directory "/develop/www/emacs"
3092 :publishing-function org-html-publish-to-html
3093 :headline-levels 4 ; Just the default for this project.
3099 :base-directory "~/.emacs.d/"
3100 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
3101 :publishing-directory "/develop/www/emacs"
3102 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
3104 :publishing-function org-publish-attachment
3106 ("inherit-org-info-js"
3107 :base-directory "/develop/vcs/org-info-js/"
3109 :base-extension "js"
3110 :publishing-directory "/develop/www/"
3111 :publishing-function org-publish-attachment
3113 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
3118 (setq org-export-with-timestamps nil)
3123 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3124 (setq org-latex-to-pdf-process
3125 '("xelatex -interaction nonstopmode %f"
3126 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
3127 (setq org-export-latex-listings 'minted)
3128 (setq org-latex-listings t)
3130 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
3131 ;; but adapted to use latexmk 4.20 or higher.
3132 (defun my-auto-tex-cmd ()
3133 "When exporting from .org with latex, automatically run latex,
3134 pdflatex, or xelatex as appropriate, using latexmk."
3136 ;; default command: oldstyle latex via dvi
3137 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
3139 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
3140 (setq texcmd "latexmk -pdf -quiet %f"))
3142 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3143 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
3144 ;; LaTeX compilation command
3145 (setq org-latex-to-pdf-process (list texcmd)))
3147 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
3149 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
3150 (setq org-export-latex-packages-alist
3152 ("" "longtable" nil)
3157 (defun my-auto-tex-parameters ()
3158 "Automatically select the tex packages to include."
3159 ;; default packages for ordinary latex or pdflatex export
3160 (setq org-export-latex-default-packages-alist
3161 '(("AUTO" "inputenc" t)
3171 ("" "hyperref" nil)))
3173 ;; Packages to include when xelatex is used
3174 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3175 (setq org-export-latex-default-packages-alist
3180 ("german" "babel" t)
3181 ("babel" "csquotes" t)
3183 ("xetex" "hyperref" nil)
3186 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
3187 (setq org-export-latex-classes
3189 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
3190 ("\\section{%s}" . "\\section*{%s}")
3191 ("\\subsection{%s}" . "\\subsection*{%s}")
3192 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
3193 ("\\paragraph{%s}" . "\\paragraph*{%s}")
3194 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
3195 org-export-latex-classes))))
3197 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
3200 *** Prevent editing invisible text
3201 The following setting prevents accidentally editing hidden text when
3202 the point is inside a folded region. This can happen if you are in
3203 the body of a heading and globally fold the org-file with =S-TAB=
3205 I find invisible edits (and undo's) hard to deal with so now I can't
3206 edit invisible text. =C-c C-r= (org-reveal) will display where the
3207 point is if it is buried in invisible text to allow editing again.
3209 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3210 (setq org-catch-invisible-edits 'error)
3214 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3215 ;; disable the default org-mode stuck projects agenda view
3216 (setq org-stuck-projects (quote ("" nil nil "")))
3218 ; force showing the next headline.
3219 (setq org-show-entry-below (quote ((default))))
3221 (setq org-show-following-heading t)
3222 (setq org-show-hierarchy-above t)
3223 (setq org-show-siblings (quote ((default))))
3225 (setq org-special-ctrl-a/e t)
3226 (setq org-special-ctrl-k t)
3227 (setq org-yank-adjusted-subtrees t)
3229 (setq org-table-export-default-format "orgtbl-to-csv")
3233 The following setting adds alphabetical lists like
3237 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3238 (if (> emacs-major-version 23)
3239 (setq org-list-allow-alphabetical t)
3240 (setq org-alphabetical-lists t))
3243 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3244 (setq org-remove-highlights-with-change nil)
3246 (setq org-list-demote-modify-bullet (quote (("+" . "-")
3253 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
3256 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
3257 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
3262 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3263 ;; Enable abbrev-mode
3264 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
3265 (setq org-startup-indented t)
3266 (setq org-startup-folded t)
3267 (setq org-cycle-separator-lines 0)
3270 I find extra blank lines in lists and headings a bit of a nuisance.
3271 To get a body after a list you need to include a blank line between
3272 the list entry and the body -- and indent the body appropriately.
3273 Most of my lists have no body detail so I like the look of collapsed
3274 lists with no blank lines better.
3276 The following setting prevents creating blank lines before headings
3277 but allows list items to adapt to existing blank lines around the items:
3278 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3279 (setq org-blank-before-new-entry (quote ((heading)
3280 (plain-list-item . auto))))
3283 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3284 (setq org-reverse-note-order nil)
3285 (setq org-default-notes-file "~/notes.org")
3288 Enforce task blocking. Tasks can't go done when there is any subtask
3289 still open. Unless they have a property of =NOBLOCKING: t=
3290 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3291 (setq org-enforce-todo-checkbox-dependencies t)
3292 (setq org-enforce-todo-dependencies t)
3295 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3296 (setq org-fast-tag-selection-single-key (quote expert))
3297 (setq org-footnote-auto-adjust t)
3298 (setq org-hide-block-startup t)
3299 (setq org-icalendar-alarm-time 15)
3300 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
3301 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
3302 (setq org-icalendar-honor-noexport-tag t)
3303 (setq org-icalendar-include-bbdb-anniversaries nil)
3304 (setq org-icalendar-include-body 200)
3305 (setq org-icalendar-include-todo nil)
3306 (setq org-icalendar-store-UID t)
3307 (setq org-icalendar-timezone "Europe/Berlin")
3308 (setq org-insert-mode-line-in-empty-file t)
3309 (setq org-log-done (quote note))
3310 (setq org-log-into-drawer t)
3311 (setq org-log-state-notes-insert-after-drawers nil)
3312 (setq org-log-reschedule (quote time))
3313 (setq org-log-states-order-reversed t)
3314 (setq org-mobile-agendas (quote all))
3315 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
3316 (setq org-mobile-inbox-for-pull "~/org/refile.org")
3317 (setq org-remember-store-without-prompt t)
3318 (setq org-return-follows-link t)
3319 (setq org-reverse-note-order t)
3321 ; regularly save our org-mode buffers
3322 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
3324 (setq org-log-done t)
3326 (setq org-enable-priority-commands t)
3327 (setq org-default-priority ?E)
3328 (setq org-lowest-priority ?E)
3333 Speed commands enable single-letter commands in Org-mode files when
3334 the point is at the beginning of a headline, or at the beginning of a
3337 See the `=org-speed-commands-default=' variable for a list of the keys
3338 and commands enabled at the beginning of headlines. All code blocks
3339 are available at the beginning of a code block, the following key
3340 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
3341 display a list of the code blocks commands and their related keys.
3343 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3344 (setq org-use-speed-commands t)
3345 (setq org-speed-commands-user (quote (("0" . ignore)
3358 ("h" . bh/hide-other)
3361 (call-interactively 'org-insert-heading-respect-content))
3362 ("k" . org-kill-note-or-show-branches)
3365 ("q" . bh/show-org-agenda)
3367 ("s" . org-save-all-org-buffers)
3371 ("z" . org-add-note)
3376 ("F" . bh/restrict-to-file-or-follow)
3379 ("J" . org-clock-goto)
3383 ("N" . bh/narrow-to-org-subtree)
3384 ("P" . bh/narrow-to-org-project)
3389 ("U" . bh/narrow-up-one-org-level)
3396 (add-hook 'org-agenda-mode-hook
3398 (define-key org-agenda-mode-map "q" 'bury-buffer))
3401 (defvar bh/current-view-project nil)
3402 (add-hook 'org-agenda-mode-hook
3403 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
3407 The following displays the contents of code blocks in Org-mode files
3408 using the major-mode of the code. It also changes the behavior of
3409 =TAB= to as if it were used in the appropriate major mode. This means
3410 that reading and editing code form inside of your Org-mode files is
3411 much more like reading and editing of code using its major mode.
3413 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3414 (setq org-src-fontify-natively t)
3415 (setq org-src-tab-acts-natively t)
3418 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3419 (setq org-src-preserve-indentation nil)
3420 (setq org-edit-src-content-indentation 0)
3424 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3425 (setq org-attach-directory "~/org/data/")
3427 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3428 (setq org-agenda-sticky t)
3431 **** Checklist handling
3432 [2013-05-11 Sat 22:15]
3434 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3435 (require 'org-checklist)
3439 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
3441 #+BEGIN_SRC emacs-lisp :tangle yes
3442 (use-package cperl-mode
3443 :commands cperl-mode
3446 (defalias 'perl-mode 'cperl-mode)
3447 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
3448 (add-auto-mode 'pod-mode "\\.pod$")
3449 (add-auto-mode 'tt-mode "\\.tt$")
3450 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
3451 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
3452 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
3456 (setq cperl-invalid-face nil
3457 cperl-close-paren-offset -4
3458 cperl-continued-statement-offset 0
3459 cperl-indent-level 4
3460 cperl-indent-parens-as-block t
3462 cperl-electric-keywords t
3463 cperl-electric-lbrace-space t
3464 cperl-electric-parens nil
3465 cperl-highlight-variables-indiscriminately t
3466 cperl-imenu-addback t
3467 cperl-invalid-face (quote underline)
3468 cperl-lazy-help-time 5
3469 cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$"
3470 cperl-syntaxify-by-font-lock t
3471 cperl-use-syntax-table-text-property-for-tags t)
3473 ;; And have cperl mode give ElDoc a useful string
3474 (defun my-cperl-eldoc-documentation-function ()
3475 "Return meaningful doc string for `eldoc-mode'."
3477 (let ((cperl-message-on-help-error nil))
3479 (add-hook 'cperl-mode-hook
3481 (set (make-local-variable 'eldoc-documentation-function)
3482 'my-cperl-eldoc-documentation-function)
3487 [2014-05-22 Thu 00:05]
3488 #+BEGIN_SRC emacs-lisp :tangle yes
3489 (use-package puppet-mode
3490 :mode ("\\.pp\\'" . puppet-mode)
3492 (use-package puppet-ext
3495 (bind-key "C-x ?" 'puppet-set-anchor puppet-mode-map)
3496 (bind-key "C-c C-r" 'puppet-create-require puppet-mode-map)
3497 (defun my-puppet-mode-hook ()
3498 (setq require-final-newline nil))
3499 (add-hook 'puppet-mode-hook 'my-puppet-mode-hook))))
3503 Use elpy for the emacs python fun, but dont let it initialize all the
3504 various variables. Elpy author may like them, but I'm not him...
3505 #+BEGIN_SRC emacs-lisp :tangle yes
3508 :mode ("\.py" . elpy-mode)
3511 (safe-load (concat jj-elisp-dir "/elpy/elpy-autoloads.el"))
3518 :commands (nosetests-all nosetests-module nosetests-one
3519 nosetests-failed nosetests-pdb-all
3520 nosetests-pdb-module nosetests-pdb-one)
3525 :commands (pyvenv-activate pyvenv-deactivate pyvenv-mode pyvenv-restart-python)
3528 (use-package idomenu
3533 (use-package highlight-indentation
3535 :commands (highlight-indentation-mode))
3537 (use-package find-file-in-project
3539 :commands (find-file-in-project ffip-project-files ffip ))
3544 ;; Local variables in `python-mode'. This is not removed when Elpy
3545 ;; is disabled, which can cause some confusion.
3546 (add-hook 'python-mode-hook 'elpy-initialize-local-variables)
3548 ;; Flymake support using flake8, including warning faces.
3549 (when (and (executable-find "flake8")
3550 (not (executable-find python-check-command)))
3551 (setq python-check-command "flake8"))
3553 ;; `flymake-no-changes-timeout': The original value of 0.5 is too
3554 ;; short for Python code, as that will result in the current line to
3555 ;; be highlighted most of the time, and that's annoying. This value
3556 ;; might be on the long side, but at least it does not, in general,
3557 ;; interfere with normal interaction.
3558 (setq flymake-no-changes-timeout 60)
3560 ;; `flymake-start-syntax-check-on-newline': This should be nil for
3561 ;; Python, as;; most lines with a colon at the end will mean the next
3562 ;; line is always highlighted as error, which is not helpful and
3564 (setq flymake-start-syntax-check-on-newline nil)
3566 ;; `ac-auto-show-menu': Short timeout because the menu is great.
3567 (setq ac-auto-show-menu 0.4)
3569 ;; `ac-quick-help-delay': I'd like to show the menu right with the
3570 ;; completions, but this value should be greater than
3571 ;; `ac-auto-show-menu' to show help for the first entry as well.
3572 (setq ac-quick-help-delay 0.5)
3574 ;; `yas-trigger-key': TAB, as is the default, conflicts with the
3575 ;; autocompletion. We also need to tell yasnippet about the new
3576 ;; binding. This is a bad interface to set the trigger key. Stop
3578 (let ((old (when (boundp 'yas-trigger-key)
3580 (setq yas-trigger-key "C-c C-i")
3581 (when (fboundp 'yas--trigger-key-reload)
3582 (yas--trigger-key-reload old)))
3584 ;; yas-snippet-dirs can be a string for a single directory. Make
3585 ;; sure it's a list in that case so we can add our own entry.
3586 (when (not (listp yas-snippet-dirs))
3587 (setq yas-snippet-dirs (list yas-snippet-dirs)))
3588 (add-to-list 'yas-snippet-dirs
3589 (concat (file-name-directory (locate-library "elpy"))
3593 ;; Now load yasnippets.
3596 (elpy-use-ipython)))
3601 #+BEGIN_SRC emacs-lisp :tangle no
3602 (autoload 'python-mode "python-mode" "Python Mode." t)
3603 (add-auto-mode 'python-mode "\\.py\\'")
3604 (add-auto-mode 'python-mode "\\.py$")
3605 (add-auto-mode 'python-mode "SConstruct\\'")
3606 (add-auto-mode 'python-mode "SConscript\\'")
3607 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
3610 (set-variable 'py-indent-offset 4)
3611 (set-variable 'py-smart-indentation nil)
3612 (set-variable 'indent-tabs-mode nil)
3613 (define-key python-mode-map "\C-m" 'newline-and-indent)
3614 (turn-on-eldoc-mode)
3615 (defun python-auto-fill-comments-only ()
3617 (set (make-local-variable 'fill-nobreak-predicate)
3619 (not (python-in-string/comment)))))
3620 (add-hook 'python-mode-hook
3622 (python-auto-fill-comments-only)))
3624 (autoload 'pymacs-apply "pymacs")
3625 (autoload 'pymacs-call "pymacs")
3626 (autoload 'pymacs-eval "pymacs" nil t)
3627 (autoload 'pymacs-exec "pymacs" nil t)
3628 (autoload 'pymacs-load "pymacs" nil t))
3631 If an =ipython= executable is on the path, then assume that IPython is
3632 the preferred method python evaluation.
3633 #+BEGIN_SRC emacs-lisp :tangle no
3634 (when (executable-find "ipython")
3636 (setq org-babel-python-mode 'python-mode))
3638 (setq python-shell-interpreter "ipython")
3639 (setq python-shell-interpreter-args "")
3640 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
3641 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
3642 (setq python-shell-completion-setup-code
3643 "from IPython.core.completerlib import module_completion")
3644 (setq python-shell-completion-module-string-code
3645 "';'.join(module_completion('''%s'''))\n")
3646 (setq python-shell-completion-string-code
3647 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
3649 ** rainbow-delimiters
3650 [2013-04-09 Di 23:38]
3651 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
3652 which highlights parens, brackets, and braces according to their
3653 depth. Each successive level is highlighted a different color. This
3654 makes it easy to spot matching delimiters, orient yourself in the code,
3655 and tell which statements are at the same depth.
3656 #+BEGIN_SRC emacs-lisp :tangle yes
3657 (use-package rainbow-delimiters
3658 :ensure rainbow-delimiters
3660 (global-rainbow-delimiters-mode))
3663 #+BEGIN_SRC emacs-lisp :tangle yes
3664 (use-package rainbow-mode
3665 :ensure rainbow-mode
3666 :diminish rainbow-mode)
3671 #+BEGIN_SRC emacs-lisp :tangle yes
3672 (use-package re-builder
3676 (setq reb-re-syntax 'string))
3679 [2014-05-19 Mo 22:56]
3680 Recentf is a minor mode that builds a list of recently opened
3681 files. This list is is automatically saved across Emacs sessions.
3682 #+BEGIN_SRC emacs-lisp :tangle yes
3683 (use-package recentf
3684 :if (not noninteractive)
3685 :bind ("C-x C-r" . recentf-open-files)
3689 (setq recentf-max-menu-items 25)
3690 (setq recentf-save-file (expand-file-name ".recentf" jj-cache-dir))
3692 (defun recentf-add-dired-directory ()
3693 (if (and dired-directory
3694 (file-directory-p dired-directory)
3695 (not (string= "/" dired-directory)))
3696 (let ((last-idx (1- (length dired-directory))))
3698 (if (= ?/ (aref dired-directory last-idx))
3699 (substring dired-directory 0 last-idx)
3700 dired-directory)))))
3702 (add-hook 'dired-mode-hook 'recentf-add-dired-directory)))
3704 ** Region bindings mode
3705 [2013-05-01 Wed 22:51]
3706 This mode allows to have keybindings that are only alive when the
3707 region is active. Helpful for things that only do any useful action
3708 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
3709 #+BEGIN_SRC emacs-lisp :tangle yes
3710 (use-package region-bindings-mode
3711 :ensure region-bindings-mode
3713 (region-bindings-mode-enable))
3716 [2013-05-22 Wed 22:33]
3717 Programming in ruby...
3720 #+BEGIN_SRC emacs-lisp :tangle yes
3721 (add-auto-mode 'ruby-mode
3722 "Rakefile\\'" "\\.rake\\'" "\.rxml\\'"
3723 "\\.rjs\\'" ".irbrc\\'" "\.builder\\'" "\\.ru\\'"
3724 "\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
3728 #+BEGIN_SRC emacs-lisp :tangle yes
3729 (use-package ruby-mode
3730 :mode ("\\.rb\\'" . ruby-mode)
3731 :interpreter ("ruby" . ruby-mode)
3738 (defvar yari-helm-source-ri-pages
3739 '((name . "RI documentation")
3740 (candidates . (lambda () (yari-ruby-obarray)))
3741 (action ("Show with Yari" . yari))
3742 (candidate-number-limit . 300)
3743 (requires-pattern . 2)
3744 "Source for completing RI documentation."))
3746 (defun helm-yari (&optional rehash)
3747 (interactive (list current-prefix-arg))
3748 (when current-prefix-arg (yari-ruby-obarray rehash))
3749 (helm 'yari-helm-source-ri-pages (yari-symbol-at-point)))))
3751 (defun my-ruby-smart-return ()
3753 (when (memq (char-after) '(?\| ?\" ?\'))
3755 (call-interactively 'newline-and-indent))
3757 (use-package ruby-hash-syntax
3758 :ensure ruby-hash-syntax)
3760 (use-package inf-ruby
3762 :commands inf-ruby-minor-mode
3765 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)
3766 (bind-key "<return>" 'my-ruby-smart-return ruby-mode-map)
3767 ;(bind-key "<tab>" 'indent-for-tab-command ruby-mode-map)
3770 (set (make-local-variable 'yas-fallback-behavior)
3771 '(apply ruby-indent-command . nil))
3772 (bind-key "<tab>" 'yas-expand-from-trigger-key ruby-mode-map)))
3774 ;; Stupidly the non-bundled ruby-mode isn't a derived mode of
3775 ;; prog-mode: we run the latter's hooks anyway in that case.
3776 (add-hook 'ruby-mode-hook
3778 (unless (derived-mode-p 'prog-mode)
3779 (run-hooks 'prog-mode-hook))))
3783 [2013-05-22 Wed 22:40]
3784 Save and restore the desktop
3785 #+BEGIN_SRC emacs-lisp :tangle yes
3786 (setq desktop-path (list jj-cache-dir))
3787 (desktop-save-mode 1)
3788 (defadvice desktop-read (around trace-desktop-errors activate)
3789 (let ((debug-on-error t))
3792 ;;----------------------------------------------------------------------------
3793 ;; Restore histories and registers after saving
3794 ;;----------------------------------------------------------------------------
3795 (use-package session
3796 :if (not noninteractive)
3797 :load-path "site-lisp/session/lisp/"
3800 (setq session-save-file (expand-file-name "session" jj-cache-dir))
3801 (setq desktop-globals-to-save
3802 (append '((extended-command-history . 30)
3803 (file-name-history . 100)
3805 (compile-history . 30)
3806 (minibuffer-history . 50)
3807 (query-replace-history . 60)
3808 (read-expression-history . 60)
3809 (regexp-history . 60)
3810 (regexp-search-ring . 20)
3812 (comint-input-ring . 50)
3813 (shell-command-history . 50)
3815 desktop-missing-file-warning
3819 (session-initialize)
3821 (defun remove-session-use-package-from-settings ()
3822 (when (string= (file-name-nondirectory (buffer-file-name)) "settings.el")
3824 (goto-char (point-min))
3825 (when (re-search-forward "^ '(session-use-package " nil t)
3826 (delete-region (line-beginning-position)
3827 (1+ (line-end-position)))))))
3829 (add-hook 'before-save-hook 'remove-session-use-package-from-settings)
3831 ;; expanded folded secitons as required
3832 (defun le::maybe-reveal ()
3833 (when (and (or (memq major-mode '(org-mode outline-mode))
3834 (and (boundp 'outline-minor-mode)
3835 outline-minor-mode))
3836 (outline-invisible-p))
3837 (if (eq major-mode 'org-mode)
3841 (add-hook 'session-after-jump-to-last-change-hook
3844 (defun save-information ()
3845 (with-temp-message "Saving Emacs information..."
3848 (loop for func in kill-emacs-hook
3849 unless (memq func '(exit-gnus-on-exit server-force-stop))
3852 (unless (or noninteractive
3853 (eq 'listen (process-status server-process)))
3856 (run-with-idle-timer 300 t 'save-information)
3859 (add-hook 'after-init-hook 'session-initialize t))))
3863 [2013-04-21 So 20:25]
3864 Save a bit of history
3865 #+BEGIN_SRC emacs-lisp tangle no
3867 (setq savehist-additional-variables
3868 '(search ring regexp-search-ring kill-ring compile-history))
3869 ;; save every minute
3870 (setq savehist-autosave-interval 60)
3871 (setq savehist-file (expand-file-name "savehist" jj-cache-dir))
3876 Store at which point I have been in files.
3877 #+BEGIN_SRC emacs-lisp :tangle yes
3878 (setq-default save-place t)
3879 (require 'saveplace)
3880 (setq save-place-file (expand-file-name "saved-places" jj-cache-dir))
3884 Settings for shell scripts
3885 #+BEGIN_SRC emacs-lisp :tangle yes
3886 (use-package sh-script
3890 (defvar sh-script-initialized nil)
3891 (defun initialize-sh-script ()
3892 (unless sh-script-initialized
3893 (setq sh-script-initialized t)
3894 (setq sh-indent-comment t)
3895 (info-lookup-add-help :mode 'shell-script-mode
3898 '(("(bash)Index")))))
3900 (add-hook 'shell-mode-hook 'initialize-sh-script)))
3903 #+BEGIN_SRC emacs-lisp :tangle yes
3904 (use-package sh-toggle
3905 :bind ("C-. C-z" . shell-toggle))
3908 By default, Emacs can update the time stamp for the following two
3909 formats if one exists in the first 8 lines of the file.
3912 #+BEGIN_SRC emacs-lisp :tangle yes
3913 (use-package time-stamp
3914 :commands time-stamp
3917 (add-hook 'write-file-hooks 'time-stamp)
3918 (setq time-stamp-active t))
3921 (setq time-stamp-format "%02H:%02M:%02S (%z) - %02d.%02m.%:y from %u (%U) on %s")
3922 (setq time-stamp-old-format-warn nil)
3923 (setq time-stamp-time-zone nil)))
3927 We configure only a bit of the tiny-tools to load when I should need
3928 them. I don't need much actually, but these things are nice to have.
3930 #+BEGIN_SRC emacs-lisp :tangle yes
3931 (autoload 'turn-on-tinyperl-mode "tinyperl" "" t)
3932 (add-hook 'perl-mode-hook 'turn-on-tinyperl-mode)
3933 (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode)
3935 (autoload 'tinycomment-indent-for-comment "tinycomment" "" t)
3936 (autoload 'tinyeat-forward-preserve "tinyeat" "" t)
3937 (autoload 'tinyeat-backward-preserve "tinyeat" "" t)
3938 (autoload 'tinyeat-kill-line-backward "tinyeat" "" t)
3940 *** Keyboard changes for tiny-tools
3941 #+BEGIN_SRC emacs-lisp :tangle yes
3942 (bind-key "\M-;" 'tinycomment-indent-for-comment)
3943 (bind-key "ESC C-k" 'tinyeat-kill-line-backward)
3944 (bind-key "ESC d" 'tinyeat-forward-preserve)
3945 (bind-key "<M-backspace>" 'tinyeat-backward-preserve)
3946 (bind-key "<S-backspace>" 'tinyeat-delete-whole-word)
3949 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
3950 #+BEGIN_SRC emacs-lisp :tangle yes
3955 (setq tramp-persistency-file-name (expand-file-name "tramp" jj-cache-dir))
3956 (setq shell-prompt-pattern "^[^a-zA-Z].*[#$%>] *")
3957 (add-to-list 'tramp-default-method-alist '("\\`localhost\\'" "\\`root\\'" "su")
3959 (setq tramp-debug-buffer nil)
3960 (setq tramp-default-method "sshx")
3961 (tramp-set-completion-function "ssh"
3962 '((tramp-parse-sconfig "/etc/ssh_config")
3963 (tramp-parse-sconfig "~/.ssh/config")))
3964 (setq tramp-verbose 5)
3969 For some reason I prefer this mode more than the way without. I want to
3970 see the marked region.
3971 #+BEGIN_SRC emacs-lisp :tangle yes
3972 (transient-mark-mode 1)
3975 [2013-04-21 So 11:07]
3976 Emacs undo is pretty powerful - but can also be confusing. There are
3977 tons of modes available to change it, even downgrade it to the very
3978 crappy ways one usually knows from other systems which lose
3979 information. undo-tree is different - it helps keeping you sane while
3980 keeping the full power of emacs undo/redo.
3981 #+BEGIN_SRC emacs-lisp :tangle yes
3982 (use-package undo-tree
3985 (global-undo-tree-mode)
3986 :diminish undo-tree-mode)
3989 Additionally I would like to keep the region active should I undo
3992 #+BEGIN_SRC emacs-lisp :tangle yes
3993 ;; Keep region when undoing in region
3994 (defadvice undo-tree-undo (around keep-region activate)
3996 (let ((m (set-marker (make-marker) (mark)))
3997 (p (set-marker (make-marker) (point))))
4006 Always have unique buffernames. See [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html][Uniquify - GNU Emacs Manual]]
4007 #+BEGIN_SRC emacs-lisp :tangle yes
4008 (use-package uniquify
4011 (setq uniquify-buffer-name-style 'post-forward)
4012 (setq uniquify-after-kill-buffer-p t)
4013 (setq uniquify-ignore-buffers-re "^\\*")))
4017 url contains code to parse and handle URLs - who would have thought? I
4018 set it to send Accept-language header and tell it to not send email,
4019 operating system or location info.
4020 #+BEGIN_SRC emacs-lisp :tangle yes
4021 (setq url-mime-language-string "de,en")
4022 (setq url-privacy-level (quote (email os lastloc)))
4025 [2014-06-01 Sun 21:38]
4026 visual-regexp for Emacs is like replace-regexp, but with live visual
4027 feedback directly in the buffer
4028 #+BEGIN_SRC emacs-lisp :tangle yes
4029 (use-package visual-regexp
4030 :ensure visual-regexp
4031 :bind (("C-M-%" . vr/replace)
4032 ("M-%" . vr/query-replace)
4033 ("C-c m" . vr/mc-mark))
4036 ** volatile highlights
4037 [2013-04-21 So 20:31]
4038 VolatileHighlights highlights changes to the buffer caused by commands
4039 such as ‘undo’, ‘yank’/’yank-pop’, etc. The highlight disappears at the
4040 next command. The highlighting gives useful visual feedback for what
4041 your operation actually changed in the buffer.
4042 #+BEGIN_SRC emacs-lisp :tangle yes
4043 (use-package volatile-highlights
4044 :ensure volatile-highlights
4046 (volatile-highlights-mode t)
4047 :diminish volatile-highlights-mode)
4050 This highlights some /weaselwords/, a mode to /aid in finding common
4051 writing problems/...
4052 [2013-04-27 Sa 23:29]
4053 #+BEGIN_SRC emacs-lisp :tangle no
4054 (use-package writegood-mode
4055 :ensure writegood-mode
4058 (bind-key "C-c g" 'writegood-mode))
4061 [2014-06-01 Sun 22:48]
4062 #+BEGIN_SRC emacs-lisp :tangle yes
4063 (use-package web-mode
4065 :mode (("\\.phtml\\'" . web-mode)
4066 ("\\.tpl\\.php\\'" . web-mode)
4067 ("\\.jsp\\'" . web-mode)
4068 ("\\.as[cp]x\\'" . web-mode)
4069 ("\\.erb\\'" . web-mode)
4070 ("\\.mustache\\'" . web-mode)
4071 ("\\.html\\'" . web-mode)
4072 ("\\.djhtml\\'" . web-mode))
4075 (add-hook 'web-mode-hook
4077 (setq web-mode-markup-indent-offset 2)
4078 (setq web-mode-css-indent-offset 2)
4079 (setq web-mode-code-indent-offset 2)
4080 (setq web-mode-enable-css-colorization t)
4081 (setq web-mode-enable-comment-keywords t)
4082 (setq web-mode-enable-current-element-highlight t)))))
4086 Yet another folding extension for the Emacs editor. Unlike many
4087 others, this one works by just using the existing indentation of the
4088 file, so basically works in every halfway structured file.
4089 #+BEGIN_SRC emacs-lisp :tangle yes
4090 (use-package yafolding
4091 :bind (("C-#" . yafolding)
4092 ("C-c C-f" . yafolding-toggle-all-by-current-level))
4093 :commands (yafolding yafolding-toggle-all-by-current-level)
4097 [2013-04-28 So 01:13]
4098 YAML is a nice format for data, which is both, human and machine
4099 readable/editable without getting a big headache.
4100 #+BEGIN_SRC emacs-lisp :tangle yes
4101 (use-package yaml-mode
4104 :mode ("\\.ya?ml\\'" . yaml-mode)
4106 (bind-key "C-m" 'newline-and-indent yaml-mode-map ))
4110 [2013-04-27 Sa 23:16]
4111 Yasnippet is a template system. Type an abbreviation, expand it into
4112 whatever the snippet holds.
4113 #+BEGIN_SRC emacs-lisp :tangle yes
4114 (setq yas-snippet-dirs (expand-file-name "yasnippet/snippets" jj-elisp-dir))
4115 (use-package yasnippet
4120 ;; Integrate hippie-expand with ya-snippet
4121 (add-to-list 'hippie-expand-try-functions-list
4122 'yas-hippie-try-expand)
4126 And thats it for this file, control passes "back" to [[file:../initjj.org][initjj.org/el]]
4127 which then may load more files.