1 #+TITLE: emacs.org - Ganneffs emacs configuration
2 #+DESCRIPTION: My current Emacs configuration
3 #+KEYWORDS: org-mode Emacs configuration
4 #+STARTUP: align fold nodlcheck hidestars oddeven lognotestate
5 #+SETUPFILE: ~/.emacs.d/elisp/org-templates/level-0.org
11 :ID: b6e6cf73-9802-4a7b-bd65-fdb6f9745319
13 The following functions are used throughout my config, and so I load
16 safe-load does not break emacs initialization, should a file be
17 unreadable while emacs boots up.
18 #+BEGIN_SRC emacs-lisp
19 (defvar safe-load-error-list ""
20 "*List of files that reported errors when loaded via safe-load")
22 (defun safe-load (file &optional noerror nomessage nosuffix)
23 "Load a file. If error on load, report back, wait for
24 a key stroke then continue on"
26 (condition-case nil (load file noerror nomessage nosuffix)
29 (setq safe-load-error-list (concat safe-load-error-list " " file))
30 (message "****** [Return to continue] Error loading %s" safe-load-error-list )
34 (defun safe-load-check ()
35 "Check for any previous safe-load loading errors. (safe-load.el)"
37 (if (string-equal safe-load-error-list "") ()
38 (message (concat "****** error loading: " safe-load-error-list))))
41 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
45 (safe-load (concat jj-elisp-dir "/tiny/loaddefs.el"))
46 (safe-load (concat jj-elisp-local-dir "/loaddefs.el"))
49 Handier way to add modes to auto-mode-alist
50 #+BEGIN_SRC emacs-lisp
51 (defun add-auto-mode (mode &rest patterns)
52 "Add entries to `auto-mode-alist' to use `MODE' for all given file `PATTERNS'."
53 (dolist (pattern patterns)
54 (add-to-list 'auto-mode-alist (cons pattern mode))))
56 *** config helpers use-package/bind-key
57 Helpers for the config
58 https://github.com/jwiegley/use-package
59 #+BEGIN_SRC emacs-lisp
60 (require 'use-package)
64 [2014-05-20 Tue 22:36]
65 #+BEGIN_SRC emacs-lisp
66 (defmacro hook-into-modes (func modes)
67 `(dolist (mode-hook ,modes)
68 (add-hook mode-hook ,func)))
72 The Emacs Lisp Package Archive contains things I want.
73 #+BEGIN_SRC emacs-lisp
74 (when (> emacs-major-version 23)
76 (setq package-user-dir (expand-file-name "elpa" jj-elisp-dir))
77 (dolist (source '(("melpa" . "http://melpa.org/packages/")
78 ("melpa-stable" . "http://stable.melpa.org/packages/")
79 ("marmalade" . "http://marmalade-repo.org/packages/")
80 ("elpy" . "http://jorgenschaefer.github.io/packages/")
81 ("elpa" . "http://elpa.gnu.org/packages/")
83 (add-to-list 'package-archives source t))
90 We need to define the load-path. As I have lots of things I add
91 locally, its getting a few entries. I disliked the repeated
92 /add-to-list/ lines, so I now just take all subdirectories of
93 jj-elisp-dir and add them.
95 #+BEGIN_SRC emacs-lisp
97 (project (directory-files jj-elisp-dir t "\\w+"))
98 (when (file-directory-p project)
99 (if (string= project "emacs23")
100 (when (version< emacs-version "24")
101 (add-to-list 'load-path project))
102 (add-to-list 'load-path project))
103 ;(byte-recompile-directory project 0)
108 Help emacs to find the info files
109 #+BEGIN_SRC emacs-lisp :tangle no
110 (setq Info-directory-list (cons jj-info-dir
111 '("/usr/local/share/info/"
113 "/usr/local/gnu/info/"
114 "/usr/local/gnu/lib/info/"
115 "/usr/local/gnu/lib/emacs/info/"
116 "/usr/local/emacs/info/"
117 "/usr/local/lib/info/"
118 "/usr/local/lib/emacs/info/"
119 "/usr/share/info/emacs-23"
121 "/usr/share/info/")))
122 (setq Info-default-directory-list
123 (cons jj-info-dir Info-default-directory-list))
129 :ID: 0a1560d9-7e55-47ab-be52-b3a8b8eea4aa
131 I dislike the startup message
132 #+BEGIN_SRC emacs-lisp
133 (setq inhibit-splash-screen t)
134 (setq inhibit-startup-message t)
137 Usually I want the lines to break at 72 characters.
138 #+BEGIN_SRC emacs-lisp
139 (setq fill-column 72)
142 And it is nice to have a final newline in files.
143 (Now off, ethan-wspace is doing it better).
144 #+BEGIN_SRC emacs-lisp
145 (setq require-final-newline nil)
146 (setq mode-require-final-newline nil)
149 After I typed 300 characters or took a break for more than a minute it
150 would be nice of emacs to save whatever I am on in one of its auto-save
151 backups. See [[info:emacs#Auto%20Save%20Control][info:emacs#Auto Save Control]] for more details.
152 #+BEGIN_SRC emacs-lisp
153 (setq auto-save-interval 300)
154 (setq auto-save-timeout 60)
157 Set my full name and my default mail address - for whatever wants to use
158 it later. Also, I am using gnus.
159 #+BEGIN_SRC emacs-lisp
160 (setq user-full-name "Joerg Jaspert")
161 (setq user-mail-address "joerg@ganneff.de")
162 (setq mail-user-agent (quote gnus-user-agent))
165 My default mail server. Well, simply a localhost, I have a forwarder that
166 puts mail off the right way, no need for emacs to have any further
168 #+BEGIN_SRC emacs-lisp
169 (setq smtpmail-default-smtp-server "localhost")
170 (setq smtpmail-smtp-server "localhost")
173 Enable automatic handling of compressed files.
174 #+BEGIN_SRC emacs-lisp
175 (auto-compression-mode 1)
178 Emacs forbids a certain set of commands, as they can be very confusing
179 for new users. Enable them.
180 #+BEGIN_SRC emacs-lisp
181 (put 'narrow-to-region 'disabled nil)
182 (put 'narrow-to-page 'disabled nil)
183 (put 'narrow-to-defun 'disabled nil)
184 (put 'upcase-region 'disabled nil)
185 (put 'downcase-region 'disabled nil)
189 I've tried various different fonts and while I like the Terminus font
190 most for my shells, in Emacs Inconsolata clearly wins.
191 #+BEGIN_SRC emacs-lisp
192 (set-frame-font "Inconsolata-14")
195 I always use dark backgrounds, so tell Emacs about it. No need to
197 #+BEGIN_SRC emacs-lisp
198 (setq-default frame-background-mode jj-color-style)
201 And I always liked dark backgrounds with colors setup for them. So I
202 switched through multiple themes doing it in emacs too, but never
203 entirely liked it. Until I found solarized, which is now not only my
204 emacs theme, but also for most of my other software too, especially my
205 shell. Consistent look is great.
206 #+BEGIN_SRC emacs-lisp :tangle no
207 (if (or (> emacs-major-version 23) (boundp 'custom-theme-load-path))
209 (defun jj-init-theme ()
211 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
212 (load-theme 'solarized-light t))
213 (set-face-attribute 'org-date nil :underline nil)
214 (message "Initializing theme solarized-dark")
216 (add-to-list 'custom-theme-load-path jj-theme-dir)
217 (add-hook 'after-init-hook 'jj-init-theme)
219 (add-to-list 'load-path (expand-file-name "emacs-color-theme-solarized" jj-elisp-dir))
220 (require 'color-theme-solarized)
221 (color-theme-solarized-dark)
224 #+BEGIN_SRC emacs-lisp
225 (use-package solarized
226 :load-path "elisp/solarized-emacs"
229 (defun jj-init-theme ()
231 ;; ;; make the fringe stand out from the background
232 (setq solarized-distinct-fringe-background t)
234 ;; ;; Don't change the font for some headings and titles
235 ;; (setq solarized-use-variable-pitch nil)
237 ;; ;; make the modeline high contrast
238 ;; (setq solarized-high-contrast-mode-line t)
240 ;; ;; Use less bolding
241 ;; (setq solarized-use-less-bold t)
243 ;; ;; Use more italics
244 ;; (setq solarized-use-more-italic t)
246 ;; ;; Use less colors for indicators such as git:gutter, flycheck and similar
247 ;; (setq solarized-emphasize-indicators nil)
249 ;; ;; Don't change size of org-mode headlines (but keep other size-changes)
250 ;; (setq solarized-scale-org-headlines nil)
252 ;; ;; Avoid all font-size changes
253 ;; (setq solarized-height-minus-1 1)
254 ;; (setq solarized-height-plus-1 1)
255 ;; (setq solarized-height-plus-2 1)
256 ;; (setq solarized-height-plus-3 1)
257 ;; (setq solarized-height-plus-4 1)
258 (setq x-underline-at-descent-line t)
260 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
261 (load-theme 'solarized-light t))
262 (set-face-attribute 'org-date nil :underline nil)
263 (message "Initializing theme solarized-dark")
265 (add-to-list 'custom-theme-load-path jj-theme-dir)
266 (add-hook 'after-init-hook 'jj-init-theme)
270 Make the fringe (gutter) smaller, the argument is a width in pixels (the default is 8)
271 #+BEGIN_SRC emacs-lisp
272 (if (fboundp 'fringe-mode)
276 A bit more spacing between buffer lines
277 #+BEGIN_SRC emacs-lisp
278 (setq-default line-spacing 0.1)
281 [2013-04-21 So 20:54]
282 I do not want my cursor to blink.
283 #+BEGIN_SRC emacs-lisp
284 (blink-cursor-mode -1)
286 *** Menu, Tool and Scrollbar
287 I don't want to see the menu-bar, tool-bar or scrollbar.
288 #+BEGIN_SRC emacs-lisp
290 (dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode))
291 (when (fboundp mode) (funcall mode -1))))
293 **** When using emacs in daemon mode
294 Emacs has a very nice mode where it detaches itself and runs as daemon -
295 and you can just open /frames/ (windows) from it by using [[http://www.emacswiki.org/emacs/EmacsClient][Emacs
296 Client]]. It's fast, it's nice, it's convinient.
298 Except that Emacs behaves stupid when you do that and ignores your
299 menu/tool/scrollbar settings. Sucks.
301 For them to work even then, we have to do two things.
302 1. We have to set the frame alist. We simple set both,
303 =initial-frame-alist= and =default-frame-alist= to the same value here.
304 #+BEGIN_SRC emacs-lisp
305 (setq initial-frame-alist '(
306 (horizontal-scroll-bars . nil)
307 (vertical-scroll-bars . nil)
310 (setq default-frame-alist (copy-alist initial-frame-alist))
312 2. We have to disable the toolbar using the customize interface, so you
313 can find that in the [[id:0102208d-fdf6-4928-9e40-7e341bd3aa3a][Customized variables]] section.
315 *** Hilight current line in buffer
316 As it says, it does a hilight of the current line.
317 #+BEGIN_SRC emacs-lisp
318 (global-hl-line-mode +1)
320 *** Allow recursive minibuffers
321 This allows (additional) minibuffer commands while in the minibuffer.
322 #+BEGIN_SRC emacs-lisp
323 (setq enable-recursive-minibuffers 't)
326 *** Modeline related changes
327 I want to see line and column numbers, so turn them on.
328 Size indication lets me know how far I am in a buffer.
330 And modeline-posn is great. It will hilight the column number in the
331 modeline in red as soon as you are over the defined limit.
334 #+BEGIN_SRC emacs-lisp
336 (column-number-mode 1)
337 (size-indication-mode 1)
338 (display-time-mode 1)
339 (setq display-time-day-and-date nil)
340 (setq display-time-default-load-average nil)
341 (setq display-time-24hr-format t)
342 (setq modelinepos-column-limit 72)
344 (use-package modeline-posn
345 :ensure modeline-posn
348 (set-face-foreground 'modelinepos-column-warning "grey20")
349 (set-face-background 'modelinepos-column-warning "red")
350 (setq modelinepos-column-limit 72))
355 [2013-04-22 Mon 11:27]
356 The modeline is easily cluttered up with stuff I don't really need to
357 see. So lets hide those. There are two ways, one of them uses diminish
358 to get entirely rid of some modes, the other is a function taken from
359 "Mastering Emacs" which replaces the modes text with an own (set of)
361 #+BEGIN_SRC emacs-lisp
363 (diminish 'auto-fill-function)
364 (defvar mode-line-cleaner-alist
365 `((auto-complete-mode . " α")
366 (yas-minor-mode . " y")
367 (paredit-mode . " π")
371 (lisp-interaction-mode . "λ")
374 (emacs-lisp-mode . "EL")
376 (org-indent-mode . "")
381 "Alist for `clean-mode-line'.
383 When you add a new element to the alist, keep in mind that you
384 must pass the correct minor/major mode symbol and a string you
385 want to use in the modeline *in lieu of* the original.
387 Want some symbols? Go:
389 ;ςερτζθιοπασδφγηξκλυχψωβνμ
390 :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
391 @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
395 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
398 Unfortunately icicles breaks this with the way it adds/removes itself,
399 so take it our for now...
402 Back when I started with text-mode. But nowadays I want default mode to
403 be org-mode - it is just so much better to use. And does sensible things
404 with many README files out there, and various other "crap" you get to
406 #+BEGIN_SRC emacs-lisp :tangle yes
407 (setq-default major-mode 'org-mode)
409 #+BEGIN_SRC emacs-lisp :tangle no
410 (setq initial-major-mode 'org-mode)
414 [2013-04-23 Tue 16:43]
415 Shell. zsh in my case.
416 #+BEGIN_SRC emacs-lisp
417 (setq shell-file-name "zsh")
418 (setq shell-command-switch "-c")
419 (setq explicit-shell-file-name shell-file-name)
420 (setenv "SHELL" shell-file-name)
421 (setq explicit-sh-args '("-login" "-i"))
422 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
423 (setq comint-scroll-to-bottom-on-input t) ; always insert at the bottom
424 (setq comint-scroll-to-bottom-on-output t) ; always add output at the bottom
425 (setq comint-scroll-show-maximum-output t) ; scroll to show max possible output
426 (setq comint-completion-autolist t) ; show completion list when ambiguous
427 (setq comint-input-ignoredups t) ; no duplicates in command history
428 (setq comint-completion-addsuffix t) ; insert space/slash after file completion
429 (setq comint-buffer-maximum-size 20000) ; max lenght of the buffer in lines
430 (setq comint-prompt-read-only nil) ; if this is t, it breaks shell-command
434 ** Miscellaneous stuff
435 Searches and matches should ignore case.
436 #+BEGIN_SRC emacs-lisp
437 (setq-default case-fold-search t)
440 Which buffers to get rid off at midnight.
441 #+BEGIN_SRC emacs-lisp
442 (setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
443 "*Man " "*Buffer List*"
449 "*magit" "*Calendar")))
452 Don't display a cursor in non-selected windows.
453 #+BEGIN_SRC emacs-lisp
454 (setq-default cursor-in-non-selected-windows nil)
457 What should be displayed in the mode-line for files with those types
459 #+BEGIN_SRC emacs-lisp
460 (setq eol-mnemonic-dos "(DOS)")
461 (setq eol-mnemonic-mac "(Mac)")
464 Much larger threshold for garbage collection prevents it to run too often.
465 #+BEGIN_SRC emacs-lisp
466 (setq gc-cons-threshold 48000000)
469 #+BEGIN_SRC emacs-lisp
470 (setq max-lisp-eval-depth 1000)
471 (setq max-specpdl-size 3000)
475 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
476 #+BEGIN_SRC emacs-lisp
477 (defun unfill-paragraph ()
478 "Takes a multi-line paragraph and makes it into a single line of text."
480 (let ((fill-column (point-max)))
481 (fill-paragraph nil)))
482 (bind-key "H-u" 'unfill-paragraph)
485 #+BEGIN_SRC emacs-lisp
486 (setq-default indicate-empty-lines t)
487 (setq sentence-end-double-space nil)
490 Hilight annotations in comments, like FIXME/TODO/...
491 #+BEGIN_SRC emacs-lisp
492 (add-hook 'prog-mode-hook 'font-lock-comment-annotations)
496 #+BEGIN_SRC emacs-lisp
497 (setq browse-url-browser-function (quote browse-url-generic))
498 (setq browse-url-generic-program "/usr/bin/x-www-browser")
501 *** When saving a script - make it executable
502 #+BEGIN_SRC emacs-lisp
503 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
507 #+BEGIN_SRC emacs-lisp
511 (add-hook 'after-init-hook 'server-start)))
514 ** Customized variables
515 [2013-05-02 Thu 22:14]
516 The following contains a set of variables i may reasonably want to
517 change on other systems - which don't affect the init file loading
518 process. So I *can* use the customization interface for it...
519 #+BEGIN_SRC emacs-lisp
520 (defgroup ganneff nil
521 "Modify ganneffs settings"
524 (defgroup ganneff-org-mode nil
525 "Ganneffs org-mode settings"
526 :tag "Ganneffs org-mode settings"
528 :link '(custom-group-link "ganneff"))
530 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
531 "ID of the organization task."
532 :tag "Organization Task ID"
534 :group 'ganneff-org-mode)
536 (defcustom org-my-archive-expiry-days 2
537 "The number of days after which a completed task should be auto-archived.
538 This can be 0 for immediate, or a floating point value."
539 :tag "Archive expiry days"
541 :group 'ganneff-org-mode)
546 [2013-05-21 Tue 23:22]
547 Restore removed var alias, used by ruby-electric-brace and others
548 #+BEGIN_SRC emacs-lisp
549 (unless (boundp 'last-command-char)
550 (defvaralias 'last-command-char 'last-command-event))
552 * Customized variables
554 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
556 Of course I want to be able to use the customize interface, and some
557 things can only be set via it (or so they say). I usually prefer to put
558 things I keep for a long while into statements somewhere else, not just
559 custom-set here, but we need it anyways.
561 #+BEGIN_SRC emacs-lisp
562 (setq custom-file jj-custom-file)
563 (safe-load custom-file)
566 The source of this is:
567 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
568 * Extra modes and their configuration
570 A defined abbrev is a word which expands, if you insert it, into some
571 different text. Abbrevs are defined by the user to expand in specific
573 #+BEGIN_SRC emacs-lisp
575 :commands abbrev-mode
576 :diminish abbrev-mode
578 (hook-into-modes #'abbrev-mode '(text-mode-hook))
581 (setq save-abbrevs 'silently)
582 (setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
583 (if (file-exists-p abbrev-file-name)
584 (quietly-read-abbrev-file))
586 (add-hook 'expand-load-hook
588 (add-hook 'expand-expand-hook 'indent-according-to-mode)
589 (add-hook 'expand-jump-hook 'indent-according-to-mode)))))
592 [2013-04-28 So 11:26]
593 Quickly move around in buffers.
594 #+BEGIN_SRC emacs-lisp
595 (use-package ace-jump-mode
596 :ensure ace-jump-mode
597 :commands ace-jump-mode
598 :bind ("H-SPC" . ace-jump-mode))
601 [2013-04-21 So 20:27]
602 Use H-w to switch windows
603 #+BEGIN_SRC emacs-lisp
604 (use-package ace-window
607 :bind ("H-w" . ace-window))
610 [2014-10-27 Mon 13:08]
611 electric-indent-mode is enough to keep your code nicely aligned when
612 all you do is type. However, once you start shifting blocks around,
613 transposing lines, or slurping and barfing sexps, indentation is bound
616 aggressive-indent-mode is a minor mode that keeps your code always
617 indented. It reindents after every command, making it more reliable
618 than electric-indent-mode.
619 #+BEGIN_SRC emacs-lisp
620 (use-package aggressive-indent
621 :ensure aggressive-indent
622 :commands (aggressive-indent-mode global-aggressive-indent-mode)
625 (global-aggressive-indent-mode 0)
626 (setq aggressive-indent-comments-too 0)
627 (add-to-list 'aggressive-indent-excluded-modes 'html-mode)
631 [2014-06-01 Sun 23:02]
632 Provides a minor mode which displays current match and total matches
633 information in the mode-line in various search modes.
634 #+BEGIN_SRC emacs-lisp
641 (global-anzu-mode 1))
644 (setq anzu-search-threshold 1000)
645 (set-face-attribute 'anzu-mode-line nil :foreground "yellow" :weight 'bold)))
648 [2014-05-21 Wed 00:33]
649 #+BEGIN_SRC emacs-lisp
651 :commands (ascii-on ascii-toggle ascii-display)
652 :bind (("C-c e A" . ascii-toggle))
655 (defun ascii-toggle ()
657 (defvar ascii-display nil)
662 (bind-key "C-c e A" 'ascii-toggle)))
665 #+BEGIN_SRC emacs-lisp
666 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
667 (setq TeX-auto-save t)
668 (setq TeX-parse-self t)
669 (setq TeX-PDF-mode t)
671 ** auto-complete mode
672 [2013-04-27 Sa 16:33]
673 And aren't we all lazy? I definitely am, and I like my emacs doing as
674 much possible work for me as it can.
675 So here, auto-complete-mode, which lets emacs do this, based on what I
677 #+BEGIN_SRC emacs-lisp
678 (use-package auto-complete-config
679 :ensure auto-complete
684 ;; hook AC into completion-at-point
685 (defun sanityinc/auto-complete-at-point ()
686 (when (and (not (minibufferp))
687 (fboundp 'auto-complete-mode)
690 (defun set-auto-complete-as-completion-at-point-function ()
691 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
692 ;; Exclude very large buffers from dabbrev
693 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
694 (< (buffer-size other-buffer) (* 1 1024 1024)))
699 ;; custom keybindings to use tab, enter and up and down arrows
700 (bind-key "\t" 'ac-expand ac-complete-mode-map)
701 (bind-key "\r" 'ac-complete ac-complete-mode-map)
702 (bind-key "M-n" 'ac-next ac-complete-mode-map)
703 (bind-key "M-p" 'ac-previous ac-complete-mode-map)
704 (bind-key "C-s" 'ac-isearch ac-completing-map)
705 (bind-key "M-TAB" 'auto-complete ac-mode-map)
707 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
708 (setq ac-use-comphist t)
709 (setq ac-expand-on-auto-complete nil)
711 (setq ac-auto-start 3)
713 (setq ac-menu-height 15)
714 (setq ac-quick-help-delay 0.5)
715 (setq ac-use-fuzzy t)
717 (ac-flyspell-workaround)
719 ;; use 't when auto-complete is disabled
720 (setq tab-always-indent 'complete)
721 (add-to-list 'completion-styles 'initials t)
723 ;; Use space and punctuation to accept the current the most likely completion.
724 (setq auto-completion-syntax-alist (quote (global accept . word)))
725 ;; Avoid completion for short trivial words.
726 (setq auto-completion-min-chars (quote (global . 3)))
727 (setq completion-use-dynamic t)
729 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
731 ;; Exclude very large buffers from dabbrev
732 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
734 (use-package ac-dabbrev
737 (set-default 'ac-sources
740 ac-source-words-in-buffer
741 ac-source-words-in-same-mode-buffers
742 ; ac-source-words-in-all-buffer
745 (dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
746 sass-mode yaml-mode csv-mode espresso-mode haskell-mode
747 html-mode nxml-mode sh-mode smarty-mode clojure-mode
748 lisp-mode textile-mode markdown-mode tuareg-mode python-mode
749 js3-mode css-mode less-css-mode sql-mode ielm-mode))
750 (add-to-list 'ac-modes mode))
752 (add-hook 'latex-mode-hook 'auto-complete-mode)
753 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
754 (add-hook 'prog-mode-hook 'auto-complete-mode)
755 (add-hook 'org-mode-hook 'auto-complete-mode)))
760 When files change outside emacs for whatever reason I want emacs to deal
761 with it. Not to have to revert buffers myself
762 #+BEGIN_SRC emacs-lisp
763 (use-package autorevert
764 :commands auto-revert-mode
765 :diminish auto-revert-mode
768 (setq global-auto-revert-mode t)
769 (setq global-auto-revert-non-file-buffers t)
770 (global-auto-revert-mode)))
774 Emacs should keep backup copies of files I edit, but I do not want them
775 to clutter up the filesystem everywhere. So I put them into one defined
776 place, backup-directory, which even contains my username (for systems
777 where =temporary-file-directory= is not inside my home).
778 #+BEGIN_SRC emacs-lisp
779 (use-package backups-mode
780 :load-path "elisp/backups-mode"
781 :bind (("\C-cv" . save-version)
782 ("\C-cb" . list-backups)
783 ("\C-ck" . kill-buffer-prompt)
784 ("\C-cw" . backup-walker-start))
787 (setq backup-directory jj-backup-directory)
788 ;(setq tramp-backup-directory (concat jj-backup-directory "/tramp"))
789 ;(if (not (file-exists-p tramp-backup-directory))
790 ; (make-directory tramp-backup-directory))
791 ;(setq tramp-backup-directory-alist `((".*" . ,tramp-backup-directory)))
792 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
793 (setq auto-save-list-file-prefix (concat jj-backup-directory ".auto-saves-"))
794 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
796 (setq version-control t) ;; Use version numbers for backups
797 (setq kept-new-versions 10) ;; Number of newest versions to keep
798 (setq kept-old-versions 2) ;; Number of oldest versions to keep
799 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
800 (setq backup-by-copying t)
801 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
802 (setq make-backup-files t)
804 (defadvice kill-buffer (around kill-buffer)
805 "Always save before killing a file buffer"
806 (when (and (buffer-modified-p)
808 (file-exists-p (buffer-file-name)))
811 (ad-activate 'kill-buffer)
813 (defadvice save-buffers-kill-emacs (around save-buffers-kill-emacs)
814 "Always save before killing emacs"
815 (save-some-buffers t)
817 (ad-activate 'save-buffers-kill-emacs)
819 (defun kill-buffer-prompt ()
820 "Allows one to kill a buffer without saving it.
821 This is necessary since once you start backups-mode all file based buffers
822 are saved automatically when they are killed"
824 (if (and (buffer-modified-p) (buffer-file-name) (file-exists-p (buffer-file-name)) (y-or-n-p "Save buffer?"))
826 (set-buffer-modified-p nil))
829 (setq backup-enable-predicate
831 (and (normal-backup-enable-predicate name)
833 (let ((method (file-remote-p name 'method)))
834 (when (stringp method)
835 (member method '("su" "sudo"))))))))))
839 [2014-12-11 Thu 11:31]
840 #+BEGIN_SRC emacs-lisp
841 (use-package browse-kill-ring
842 :commands (browse-kill-ring browse-kill-ring-mode)
843 :bind ("M-y" . browse-kill-ring)
847 [2014-06-10 Tue 22:20]
848 #+BEGIN_SRC emacs-lisp
850 :commands (cal/insert)
851 :bind ("C-c c" . cal/insert)
854 ; Weeks start on Monday, not sunday.
855 (setq calendar-week-start-day 1)
857 ; Display ISO week numbers in Calendar Mode
858 (copy-face font-lock-constant-face 'calendar-iso-week-face)
859 (set-face-attribute 'calendar-iso-week-face nil :height 0.7)
860 (setq calendar-intermonth-text
864 (calendar-iso-from-absolute
865 (calendar-absolute-from-gregorian (list month day year)))))
866 'font-lock-face 'calendar-iso-week-face))
867 (copy-face 'default 'calendar-iso-week-header-face)
868 (set-face-attribute 'calendar-iso-week-header-face nil :height 0.7)
869 (setq calendar-intermonth-header
870 (propertize "Wk" ; or e.g. "KW" in Germany
871 'font-lock-face 'calendar-iso-week-header-face))))
876 [2013-05-21 Tue 23:18]
877 #+BEGIN_SRC emacs-lisp
878 (use-package crontab-mode
880 :commands crontab-mode
881 :mode ("\\.?cron\\(tab\\)?\\'" . crontab-mode))
885 web-mode takes over, see [[*web-mode][web-mode]]
886 #+BEGIN_SRC emacs-lisp :tangle no
887 (use-package css-mode
888 :mode ("\\.css\\'" . css-mode)
893 (use-package flymake-css
897 (defun maybe-flymake-css-load ()
898 "Activate flymake-css as necessary, but not in derived modes."
899 (when (eq major-mode 'css-mode)
901 (add-hook 'css-mode-hook 'maybe-flymake-css-load)))
902 ;;; Auto-complete CSS keywords
903 (eval-after-load 'auto-complete
905 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
906 (add-hook hook 'ac-css-mode-setup))))))
910 I know that this lets it look "more like windows", but I don't much care
911 about its paste/copy/cut keybindings, the really nice part is the great
912 support for rectangular regions, which I started to use a lot since I
913 know this mode. The normal keybindings for those are just to useless.
914 #+BEGIN_SRC emacs-lisp
916 (setq cua-enable-cua-keys (quote shift))
919 Luckily cua-mode easily supports this, with the following line I just
920 get the CUA selection and rectangle stuff, not the keybindings. Yes,
921 even though the above =cua-enable-cua-keys= setting would only enable
922 them if the selection is done when the region was marked with a shifted
924 #+BEGIN_SRC emacs-lisp
925 (cua-selection-mode t)
929 #+BEGIN_SRC emacs-lisp
930 (require 'dpkg-dev-el-loaddefs nil 'noerror)
931 (require 'debian-el-loaddefs nil 'noerror)
933 (setq debian-changelog-full-name "Joerg Jaspert")
934 (setq debian-changelog-mailing-address "joerg@debian.org")
938 #+BEGIN_SRC emacs-lisp
939 (use-package diff-mode
941 :mode (("\\.diff" . diff-mode))
943 (use-package diff-mode-))
947 #+BEGIN_SRC emacs-lisp
949 :commands (dired dired-other-window dired-other-frame dired-noselect
950 dired-mode dired-jump)
951 :defines (dired-omit-regexp-orig)
954 (setq diredp-hide-details-initially-flag nil))
957 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
958 (setq dired-dwim-target t)
959 (setq dired-listing-switches "-alh")
960 (setq dired-listing-switches "-alXh --group-directories-first")
961 (setq dired-recursive-copies (quote top))
962 (setq dired-recursive-deletes (quote top))
963 (setq dired-guess-shell-alist-user
964 '(("\\.pdf\\'" "mupdf" "evince")
965 ("\\.\\(?:djvu\\|eps\\)\\'" "evince")
966 ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "eog")
967 ("\\.\\(?:xcf\\)\\'" "gimp")
968 ("\\.csv\\'" "libreoffice")
969 ("\\.tex\\'" "pdflatex" "latex")
970 ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\)\\(?:\\.part\\)?\\'" "vlc")
971 ("\\.html?\\'" "conkeror")))
973 (bind-key "F" 'find-name-dired dired-mode-map)
978 (use-package dired-x)
980 (use-package dired-single
984 (bind-key "<return>" 'dired-single-buffer dired-mode-map)
985 (bind-key "<mouse-1>" 'dired-single-buffer-mouse dired-mode-map)
988 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
994 (setq wdired-allow-to-change-permissions t)
995 (bind-key "r" 'wdired-change-to-wdired-mode dired-mode-map)))
997 (use-package gnus-dired
998 :commands (gnus-dired-attach gnus-dired-mode)
1001 ;;(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
1002 (bind-key "a" 'gnus-dired-attach dired-mode-map)))
1007 (defvar mark-files-cache (make-hash-table :test #'equal))
1009 (defun mark-similar-versions (name)
1011 (if (string-match "^\\(.+?\\)-[0-9._-]+$" pat)
1012 (setq pat (match-string 1 pat)))
1013 (or (gethash pat mark-files-cache)
1014 (ignore (puthash pat t mark-files-cache)))))
1016 (defun dired-mark-similar-version ()
1018 (setq mark-files-cache (make-hash-table :test #'equal))
1019 (dired-mark-sexp '(mark-similar-versions name)))
1021 (defun dired-package-initialize ()
1022 (unless (featurep 'runner)
1023 (bind-key "M-!" 'async-shell-command dired-mode-map)
1024 (unbind-key "M-s f" dired-mode-map)
1026 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1027 "Make sure to remove \"Omit\" from the modeline."
1028 (diminish 'dired-omit-mode) dired-mode-map)
1030 ;; Omit files that Git would ignore
1031 (defun dired-omit-regexp ()
1032 (let ((file (expand-file-name ".git"))
1034 (while (and (not (file-exists-p file))
1037 (file-name-directory
1038 (directory-file-name
1039 (file-name-directory file))))
1040 ;; Give up if we are already at the root dir.
1041 (not (string= (file-name-directory file)
1043 ;; Move up to the parent dir and try again.
1044 (setq file (expand-file-name ".git" parent-dir)))
1045 ;; If we found a change log in a parent, use that.
1046 (if (file-exists-p file)
1047 (let ((regexp (funcall dired-omit-regexp-orig))
1049 (shell-command-to-string "git clean -d -x -n")))
1050 (if (= 0 (length omitted-files))
1054 (if (> (length regexp) 0)
1063 (if (= ?/ (aref str (1- (length str))))
1067 (split-string omitted-files "\n" t)
1070 (funcall dired-omit-regexp-orig))))))
1072 (add-hook 'dired-mode-hook 'dired-package-initialize)
1074 (defun dired-double-jump (first-dir second-dir)
1076 (list (read-directory-name "First directory: "
1077 (expand-file-name "~")
1078 nil nil "/Downloads/")
1079 (read-directory-name "Second directory: "
1080 (expand-file-name "~")
1083 (dired-other-window second-dir))
1084 (bind-key "C-c J" 'dired-double-jump)
1086 (defun dired-back-to-top ()
1088 (goto-char (point-min))
1089 (dired-next-line 4))
1091 (define-key dired-mode-map
1092 (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
1094 (defun dired-jump-to-bottom ()
1096 (goto-char (point-max))
1097 (dired-next-line -1))
1099 (define-key dired-mode-map
1100 (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)))
1103 ** discover-my-major
1104 [2014-06-01 Sun 23:32]
1105 Discover key bindings and their meaning for the current Emacs major mode.
1106 #+BEGIN_SRC emacs-lisp
1107 (use-package discover-my-major
1108 :ensure discover-my-major
1109 :commands discover-my-major
1110 :bind ("C-h C-m" . discover-my-major))
1113 EasyPG is a GnuPG interface for Emacs.
1114 Bookmark: [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1115 #+BEGIN_SRC emacs-lisp
1116 (use-package epa-file
1120 ;; I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1121 (defadvice epg--start (around advice-epg-disable-agent disable)
1122 "Don't allow epg--start to use gpg-agent in plain text
1124 (if (display-graphic-p)
1126 (let ((agent (getenv "GPG_AGENT_INFO")))
1127 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
1129 (setenv "GPG_AGENT_INFO" agent))))
1130 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
1131 (ad-activate 'epg--start)
1135 [2013-04-21 So 20:36]
1136 ediff - don't start another frame
1137 #+BEGIN_SRC emacs-lisp
1141 (defvar ctl-period-equals-map)
1142 (define-prefix-command 'ctl-period-equals-map)
1143 (bind-key "C-. =" 'ctl-period-equals-map)
1144 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
1146 :bind (("C-. = b" . ediff-buffers)
1147 ("C-. = B" . ediff-buffers3)
1148 ("C-. = =" . ediff-files)
1149 ("C-. = f" . ediff-files)
1150 ("C-. = F" . ediff-files3)
1151 ("C-. = r" . ediff-revision)
1152 ("C-. = p" . ediff-patch-file)
1153 ("C-. = P" . ediff-patch-buffer)
1154 ("C-. = l" . ediff-regions-linewise)
1155 ("C-. = w" . ediff-regions-wordwise))
1157 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1158 (setq ediff-split-window-function 'split-window-horizontally)
1164 EMMS is the Emacs Multimedia System.
1165 #+BEGIN_SRC emacs-lisp :tangle no
1166 (require 'emms-source-file)
1167 (require 'emms-source-playlist)
1168 (require 'emms-info)
1169 (require 'emms-cache)
1170 (require 'emms-playlist-mode)
1171 (require 'emms-playing-time)
1172 (require 'emms-player-mpd)
1173 (require 'emms-playlist-sort)
1174 (require 'emms-mark)
1175 (require 'emms-browser)
1176 (require 'emms-lyrics)
1177 (require 'emms-last-played)
1178 (require 'emms-score)
1179 (require 'emms-tag-editor)
1180 (require 'emms-history)
1181 (require 'emms-i18n)
1183 (setq emms-playlist-default-major-mode 'emms-playlist-mode)
1184 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
1185 (emms-playing-time 1)
1187 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
1188 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
1190 (when (fboundp 'emms-cache) ; work around compiler warning
1192 (setq emms-score-default-score 3)
1194 (defun emms-mpd-init ()
1195 "Connect Emms to mpd."
1197 (emms-player-mpd-connect))
1200 (require 'emms-player-mpd)
1201 (setq emms-player-mpd-server-name "localhost")
1202 (setq emms-player-mpd-server-port "6600")
1203 (add-to-list 'emms-info-functions 'emms-info-mpd)
1204 (add-to-list 'emms-player-list 'emms-player-mpd)
1205 (setq emms-volume-change-function 'emms-volume-mpd-change)
1206 (setq emms-player-mpd-sync-playlist t)
1208 (setq emms-source-file-default-directory "/var/lib/mpd/music")
1209 (setq emms-player-mpd-music-directory "/var/lib/mpd/music")
1210 (setq emms-info-auto-update t)
1211 (setq emms-lyrics-scroll-p t)
1212 (setq emms-lyrics-display-on-minibuffer t)
1213 (setq emms-lyrics-display-on-modeline nil)
1214 (setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
1216 (setq emms-last-played-format-alist
1217 '(((emms-last-played-seconds-today) . "%H:%M")
1218 (604800 . "%a %H:%M") ; this week
1219 ((emms-last-played-seconds-month) . "%d.%m.%Y")
1220 ((emms-last-played-seconds-year) . "%d.%m.%Y")
1221 (t . "Never played")))
1224 (defun my-describe (track)
1225 (let* ((empty "...")
1226 (name (emms-track-name track))
1227 (type (emms-track-type track))
1228 (short-name (file-name-nondirectory name))
1229 (play-count (or (emms-track-get track 'play-count) 0))
1230 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
1231 (artist (or (emms-track-get track 'info-artist) empty))
1232 (year (emms-track-get track 'info-year))
1233 (playing-time (or (emms-track-get track 'info-playing-time) 0))
1234 (min (/ playing-time 60))
1235 (sec (% playing-time 60))
1236 (album (or (emms-track-get track 'info-album) empty))
1237 (tracknumber (emms-track-get track 'info-tracknumber))
1238 (short-name (file-name-sans-extension
1239 (file-name-nondirectory name)))
1240 (title (or (emms-track-get track 'info-title) short-name))
1241 (rating (emms-score-get-score name))
1244 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
1245 (emms-last-played-format-date last-played)
1249 (if (and tracknumber ; tracknumber
1250 (not (zerop (string-to-number tracknumber))))
1251 (format "%02d" (string-to-number tracknumber))
1255 (make-string rating rate-char)))
1258 (setq emms-track-description-function 'my-describe)
1260 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
1261 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
1262 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
1263 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
1264 (global-set-key (kbd "H-<f9> x") 'emms-start)
1265 (global-set-key (kbd "H-<f9> v") 'emms-stop)
1266 (global-set-key (kbd "H-<f9> n") 'emms-next)
1267 (global-set-key (kbd "H-<f9> p") 'emms-previous)
1268 (global-set-key (kbd "H-<f9> o") 'emms-show)
1269 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
1270 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
1271 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
1272 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
1273 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
1275 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
1276 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
1277 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
1278 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
1280 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
1281 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
1282 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
1283 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
1285 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
1286 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
1287 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
1288 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
1290 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
1291 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
1292 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
1293 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
1294 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
1295 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
1297 (define-key emms-playlist-mode-map "x" 'emms-start)
1298 (define-key emms-playlist-mode-map "v" 'emms-stop)
1299 (define-key emms-playlist-mode-map "n" 'emms-next)
1300 (define-key emms-playlist-mode-map "p" 'emms-previous)
1302 (setq emms-playlist-buffer-name "*EMMS Playlist*"
1303 emms-playlist-mode-open-playlists t)
1309 'emms-browser-artist-face nil
1314 (setq emms-player-mpd-supported-regexp
1315 (or (emms-player-mpd-get-supported-regexp)
1316 (concat "\\`http://\\|"
1317 (emms-player-simple-regexp
1318 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
1319 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
1323 Basic settings for emacs integrated shell
1324 #+BEGIN_SRC emacs-lisp :tangle no
1330 (defun eshell-initialize ()
1331 (defun eshell-spawn-external-command (beg end)
1332 "Parse and expand any history references in current input."
1335 (when (looking-back "&!" beg)
1336 (delete-region (match-beginning 0) (match-end 0))
1338 (insert "spawn "))))
1339 (add-hook 'eshell-expand-input-functions 'eshell-spawn-external-command)
1340 (eval-after-load "em-unix"
1342 (unintern 'eshell/su)
1343 (unintern 'eshell/sudo))))
1344 (add-hook 'eshell-first-time-mode-hook 'eshell-initialize)
1348 (defalias 'emacs 'find-file)
1349 (defalias 'ec 'find-file)
1350 (defalias 'e 'find-file)
1354 (use-package 'em-cmpl)
1355 (use-package 'em-prompt)
1356 (use-package 'em-term)
1358 (setq eshell-cmpl-cycle-completions nil
1359 eshell-save-history-on-exit t
1360 eshell-buffer-maximum-lines 20000
1361 eshell-history-size 350
1362 eshell-buffer-shorthand t
1363 eshell-highlight-prompt t
1364 eshell-plain-echo-behavior t
1365 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
1367 (setenv "PAGER" "cat")
1368 (setq eshell-visual-commands
1369 '("less" "tmux" "htop" "top" "bash" "zsh" "tail"))
1370 (setq eshell-visual-subcommands
1371 '(("git" "log" "l" "diff" "show")))
1373 (add-to-list 'eshell-command-completions-alist
1374 '("gunzip" "gz\\'"))
1375 (add-to-list 'eshell-command-completions-alist
1376 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
1378 (when (not (functionp 'eshell/rgrep))
1379 (defun eshell/rgrep (&rest args)
1380 "Use Emacs grep facility instead of calling external grep."
1381 (eshell-grep "rgrep" args t)))
1383 ;(set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
1384 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
1385 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
1386 (add-hook 'eshell-preoutput-filter-functions
1387 'ansi-color-filter-apply)
1388 ;; Prompt with a bit of help from http://www.emacswiki.org/emacs/EshellPrompt
1390 (defmacro with-face (str &rest properties)
1391 `(propertize ,str 'face (list ,@properties)))
1393 (defun eshell/abbr-pwd ()
1394 (let ((home (getenv "HOME"))
1395 (path (eshell/pwd)))
1397 ((string-equal home path) "~")
1398 ((f-ancestor-of? home path) (concat "~/" (f-relative path home)))
1401 (defun eshell/my-prompt ()
1402 (let ((header-bg "#161616"))
1404 (with-face user-login-name :foreground "cyan")
1405 (with-face (concat "@" hostname) :foreground "white")
1407 (with-face (eshell/abbr-pwd) :foreground "#009900")
1408 (if (= (user-uid) 0)
1409 (with-face "#" :foreground "red")
1410 (with-face "$" :foreground "#69b7f0"))
1413 (use-package eshell-prompt-extras
1417 (setq eshell-highlight-prompt nil
1418 ;; epe-git-dirty-char "Ϟ"
1419 epe-git-dirty-char "*"
1420 eshell-prompt-function 'epe-theme-dakrone)))
1422 (defun eshell/magit ()
1423 "Function to open magit-status for the current directory"
1425 (magit-status default-directory)
1428 (setq eshell-prompt-function 'eshell/my-prompt)
1429 (setq eshell-highlight-prompt nil)
1430 (setq eshell-prompt-regexp "^[^#$\n]+[#$] ")))
1435 Incremental search is great, but annoyingly you need to type whatever
1436 you want. If you want to search for just the next (or previous)
1437 occurence of what is at your cursor position use the following.
1438 *C-x* will insert the current word while *M-up* and *M-down* will just
1439 jump to the next/previous occurence of it.
1440 #+BEGIN_SRC emacs-lisp
1441 (bind-key "C-x" 'sacha/isearch-yank-current-word isearch-mode-map)
1442 (bind-key* "<M-up>" 'sacha/search-word-backward)
1443 (bind-key* "<M-down>" 'sacha/search-word-forward)
1446 *** Frame configuration
1447 I want to see the buffername and its size, not the host I am on in my
1449 #+BEGIN_SRC emacs-lisp
1450 (setq frame-title-format "%b (%i)")
1453 *** Protect some buffers
1454 I don't want some buffers to be killed, **scratch** for example.
1455 In the past I had a long function that just recreated them, but the
1456 =keep-buffers= package is easier.
1457 #+BEGIN_SRC emacs-lisp
1458 (use-package keep-buffers
1461 (keep-buffers-mode 1)
1462 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
1463 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
1468 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
1470 #+BEGIN_SRC emacs-lisp
1471 (defalias 'yes-or-no-p 'y-or-n-p)
1474 *** Language/i18n stuff
1475 In this day and age, UTF-8 is the way to go.
1476 #+BEGIN_SRC emacs-lisp
1477 (set-language-environment 'utf-8)
1478 (set-default-coding-systems 'utf-8)
1479 (set-terminal-coding-system 'utf-8)
1480 (set-keyboard-coding-system 'utf-8)
1481 (set-clipboard-coding-system 'utf-8)
1482 (prefer-coding-system 'utf-8)
1483 (set-charset-priority 'unicode)
1484 (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
1485 (when (display-graphic-p)
1486 (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
1489 *** Hilight matching parentheses
1490 While I do have the nifty shortcut to jump to the other parentheses,
1491 hilighting them makes it obvious where they are.
1492 #+BEGIN_SRC emacs-lisp
1493 (use-package mic-paren
1497 *** Kill other buffers
1498 While many editors allow you to close "all the other files, not the one
1499 you are in", emacs doesn't have this... Except, now it will.
1500 (Update 30.05.2014: Not used ever, deactivated)
1501 #+BEGIN_SRC emacs-lisp :tangle no
1502 (bind-key "C-c k" 'prelude-kill-other-buffers)
1505 Default scrolling behaviour in emacs is a bit annoying, who wants to
1507 #+BEGIN_SRC emacs-lisp
1508 (setq scroll-margin 0)
1509 (setq scroll-conservatively 100000)
1510 (setq scroll-up-aggressively 0.0)
1511 (setq scroll-down-aggressively 0.0)
1512 (setq scroll-preserve-screen-position t)
1515 *** Copy/Paste with X
1516 [2013-04-09 Di 23:31]
1517 The default how emacs handles cutting/pasting with the primary selection
1518 changed in emacs24. I am used to the old way, so get it back.
1519 #+BEGIN_SRC emacs-lisp
1520 (setq select-enable-primary t)
1521 (setq select-enable-clipboard nil)
1522 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
1523 (setq mouse-drag-copy-region t)
1525 *** Global keyboard changes not directly related to a mode
1526 Disable /suspend_frame/ function, I dislike it.
1527 #+BEGIN_SRC emacs-lisp
1529 (unbind-key "C-x C-z")
1532 http://endlessparentheses.com/kill-entire-line-with-prefix-argument.html?source=rss
1533 #+BEGIN_SRC emacs-lisp
1534 (defmacro bol-with-prefix (function)
1535 "Define a new function which calls FUNCTION.
1536 Except it moves to beginning of line before calling FUNCTION when
1537 called with a prefix argument. The FUNCTION still receives the
1539 (let ((name (intern (format "endless/%s-BOL" function))))
1543 "Call `%s', but move to BOL when called with a prefix argument."
1548 (call-interactively ',function))
1551 (global-set-key [remap paredit-kill] (bol-with-prefix paredit-kill))
1552 (global-set-key [remap org-kill-line] (bol-with-prefix org-kill-line))
1553 (global-set-key [remap kill-line] (bol-with-prefix kill-line))
1556 Default of *C-k* is to kill from the point to the end of line. If
1557 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
1558 set, including newline. But to kill the entire line, one still needs a
1559 *C-a* in front of it. So I change it, by defining a function to do just this for
1561 #+BEGIN_SRC emacs-lisp :tangle no
1562 (defun kill-entire-line ()
1563 "Kill this entire line (including newline), regardless of where point is within the line."
1567 (back-to-indentation))
1569 (bind-key* "C-k" 'kill-entire-line)
1570 (global-set-key [remap kill-whole-line] 'kill-entire-line)
1573 And the same is true when I'm in org-mode, which has an own kill function...
1574 (the keybinding happens later, after org-mode is loaded fully)
1575 #+BEGIN_SRC emacs-lisp :tangle no
1576 (defun jj-org-kill-line (&optional arg)
1577 "Kill the entire line, regardless of where point is within the line, org-mode-version"
1581 (back-to-indentation)
1585 I really hate tabs, so I don't want any indentation to try using them.
1586 And in case a project really needs them, I can change it just for that
1587 file/project, but luckily none of those I work in is as broken.
1588 #+BEGIN_SRC emacs-lisp
1589 (setq-default indent-tabs-mode nil)
1592 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
1593 #+BEGIN_SRC emacs-lisp
1594 (bind-key* "M-5" 'match-paren)
1597 Instead of the default "mark-defun" I want a more readline-like setting.
1598 #+BEGIN_SRC emacs-lisp
1599 (bind-key "C-M-h" 'backward-kill-word)
1602 Align whatever with a regexp.
1603 #+BEGIN_SRC emacs-lisp
1604 (bind-key "C-x \\" 'align-regexp)
1608 #+BEGIN_SRC emacs-lisp
1609 (bind-key "C-+" 'text-scale-increase)
1610 (bind-key "C--" 'text-scale-decrease)
1613 Regexes are too useful, so use the regex search by default.
1614 #+begin_src emacs-lisp
1615 (bind-key "C-s" 'isearch-forward-regexp)
1616 (bind-key "C-r" 'isearch-backward-regexp)
1617 (bind-key "C-M-s" 'isearch-forward)
1618 (bind-key "C-M-r" 'isearch-backward)
1621 Rgrep is infinitely useful in multi-file projects.
1622 #+begin_src emacs-lisp
1623 (bind-key "C-x C-g" 'rgrep)
1626 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
1627 AKA transpose lines.
1628 #+BEGIN_SRC emacs-lisp
1629 (bind-key "<M-S-up>" 'move-line-up)
1630 (bind-key "<M-S-down>" 'move-line-down)
1633 "Pull" lines up, join them
1634 #+BEGIN_SRC emacs-lisp
1635 (defun join-line-or-lines-in-region ()
1636 "Join this line or the lines in the selected region.
1637 Joins single lines in reverse order to the default, ie. pulls the next one up."
1639 (cond ((region-active-p)
1640 (let ((min (line-number-at-pos (region-beginning))))
1641 (goto-char (region-end))
1642 (while (> (line-number-at-pos) min)
1644 (t (let ((current-prefix-arg '(4)))
1645 (call-interactively 'join-line)))))
1646 (bind-key "M-j" 'join-line-or-lines-in-region)
1649 When I press Enter I almost always want to go to the right indentation on the next line.
1650 #+BEGIN_SRC emacs-lisp
1651 (bind-key "RET" 'newline-and-indent)
1654 Easier undo, and i don't need suspend-frame
1655 #+BEGIN_SRC emacs-lisp
1656 (bind-key "C-z" 'undo)
1659 Window switching, go backwards. (C-x o goes to the next window)
1660 #+BEGIN_SRC emacs-lisp
1661 (bind-key "C-x O" (lambda ()
1667 #+BEGIN_SRC emacs-lisp
1668 (bind-key "C-x C-r" 'prelude-sudo-edit)
1671 M-space is bound to just-one-space, which is great for programming. What
1672 it does is remove all spaces around the cursor, except for one. But to
1673 be really useful, it also should include newlines. It doesn’t do this by
1674 default. Rather, you have to call it with a negative argument. Sure
1676 #+BEGIN_SRC emacs-lisp
1677 (bind-key "M-SPC" 'just-one-space-with-newline)
1680 Count which commands I use how often.
1681 #+BEGIN_SRC emacs-lisp
1682 (use-package keyfreq
1686 (setq keyfreq-file (expand-file-name "keyfreq" jj-cache-dir))
1687 (setq keyfreq-file-lock (expand-file-name "keyfreq.lock" jj-cache-dir))
1689 (keyfreq-autosave-mode 1)))
1692 Duplicate current line
1693 #+BEGIN_SRC emacs-lisp
1694 (defun duplicate-line ()
1695 "Insert a copy of the current line after the current line."
1698 (let ((line-text (buffer-substring-no-properties
1699 (line-beginning-position)
1700 (line-end-position))))
1701 (move-end-of-line 1)
1703 (insert line-text))))
1705 (bind-key "C-c p" 'duplicate-line)
1708 Smarter move to the beginning of the line. That is, it first moves to
1709 the beginning of the line - and on second keypress it goes to the
1710 first character on line.
1711 #+BEGIN_SRC emacs-lisp
1712 (defun smarter-move-beginning-of-line (arg)
1713 "Move point back to indentation of beginning of line.
1715 Move point to the first non-whitespace character on this line.
1716 If point is already there, move to the beginning of the line.
1717 Effectively toggle between the first non-whitespace character and
1718 the beginning of the line.
1720 If ARG is not nil or 1, move forward ARG - 1 lines first. If
1721 point reaches the beginning or end of the buffer, stop there."
1723 (setq arg (or arg 1))
1727 (let ((line-move-visual nil))
1728 (forward-line (1- arg))))
1730 (let ((orig-point (point)))
1731 (back-to-indentation)
1732 (when (= orig-point (point))
1733 (move-beginning-of-line 1))))
1735 ;; remap C-a to `smarter-move-beginning-of-line'
1736 (global-set-key [remap move-beginning-of-line]
1737 'smarter-move-beginning-of-line)
1741 Easily copy characters from the previous nonblank line, starting just
1742 above point. With a prefix argument, only copy ARG characters (never
1743 past EOL), no argument copies rest of line.
1744 #+BEGIN_SRC emacs-lisp
1746 (bind-key "H-y" 'copy-from-above-command)
1749 Open a new X Terminal pointing to the directory of the current
1751 #+BEGIN_SRC emacs-lisp
1752 (bind-key "H-t" 'jj-open-shell)
1756 #+BEGIN_SRC emacs-lisp
1757 (bind-key "H-a" 'align-code)
1761 #+BEGIN_SRC emacs-lisp
1762 (bind-key "C-c d" 'insert-date)
1765 Another key for indenting
1766 #+BEGIN_SRC emacs-lisp
1767 (bind-key "H-i" 'indent-region)
1770 Clean all whitespace stuff
1771 #+BEGIN_SRC emacs-lisp
1772 (bind-key "H-w" 'whitespace-cleanup)
1776 #+BEGIN_SRC emacs-lisp
1777 (bind-key "H-c" 'comment-dwim)
1780 Show keystrokes in progress
1781 #+BEGIN_SRC emacs-lisp
1782 (setq echo-keystrokes 0.1)
1785 Usually you can press the *Ins*ert key, to get into overwrite mode. I
1786 don't like that, have broken much with it and so just forbid it by
1788 #+BEGIN_SRC emacs-lisp
1789 (unbind-key "<insert>")
1790 (unbind-key "<kp-insert>")
1793 *** Easily navigate sillyCased words
1794 #+BEGIN_SRC emacs-lisp
1795 (global-subword-mode 1)
1797 *** Delete file of current buffer, then kill buffer
1798 [2014-06-14 Sat 23:03]
1799 #+BEGIN_SRC emacs-lisp
1800 (defun delete-current-buffer-file ()
1801 "Removes file connected to current buffer and kills buffer."
1803 (let ((filename (buffer-file-name))
1804 (buffer (current-buffer))
1805 (name (buffer-name)))
1806 (if (not (and filename (file-exists-p filename)))
1808 (when (yes-or-no-p "Are you sure you want to remove this file? ")
1809 (delete-file filename)
1810 (kill-buffer buffer)
1811 (message "File '%s' successfully removed" filename)))))
1813 (global-set-key (kbd "C-x C-k") 'delete-current-buffer-file)
1815 *** Rename file of current buffer
1816 [2014-06-14 Sat 23:04]
1817 #+BEGIN_SRC emacs-lisp
1818 (defun rename-current-buffer-file ()
1819 "Renames current buffer and file it is visiting."
1821 (let ((name (buffer-name))
1822 (filename (buffer-file-name)))
1823 (if (not (and filename (file-exists-p filename)))
1824 (error "Buffer '%s' is not visiting a file!" name)
1825 (let ((new-name (read-file-name "New name: " filename)))
1826 (if (get-buffer new-name)
1827 (error "A buffer named '%s' already exists!" new-name)
1828 (rename-file filename new-name 1)
1829 (rename-buffer new-name)
1830 (set-visited-file-name new-name)
1831 (set-buffer-modified-p nil)
1832 (message "File '%s' successfully renamed to '%s'"
1833 name (file-name-nondirectory new-name)))))))
1835 (global-set-key (kbd "C-x C-S-r") 'rename-current-buffer-file)
1837 *** Quickly find emacs lisp sources
1838 [2014-06-22 Sun 23:05]
1839 #+BEGIN_SRC emacs-lisp
1840 (bind-key "C-l" 'find-library 'help-command)
1841 (bind-key "C-f" 'find-function 'help-command)
1842 (bind-key "C-k" 'find-function-on-key 'help-command)
1843 (bind-key "C-v" 'find-variable 'help-command)
1846 [2015-01-26 Mon 16:01]
1847 #+BEGIN_SRC emacs-lisp
1848 (bind-key "M-s o" 'occur-dwim)
1852 [2014-06-01 Sun 15:00]
1853 Proper whitespace handling
1854 #+BEGIN_SRC emacs-lisp
1855 (use-package ethan-wspace
1856 :ensure ethan-wspace
1857 :diminish (ethan-wspace-mode . "ew")
1859 (global-ethan-wspace-mode 1))
1863 [2014-06-01 Sun 15:16]
1864 #+BEGIN_SRC emacs-lisp
1865 (use-package expand-region
1866 :ensure expand-region
1867 :bind ("C-M-+" . er/expand-region)
1868 :commands er/expand-region)
1871 [2013-05-02 Thu 00:04]
1872 Filladapt by KyleJones enhances Emacs’ fill functions by guessing a
1873 fill prefix, such as a comment sequence in program code, and handling
1874 bullet points like “1.” or “*”.
1875 #+BEGIN_SRC emacs-lisp
1876 (use-package filladapt
1877 :diminish filladapt-mode
1879 (setq-default filladapt-mode t))
1882 [2013-04-28 So 22:21]
1883 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
1884 As the one time I tried Flymake i wasn't happy, thats easy to
1886 #+BEGIN_SRC emacs-lisp
1887 (use-package flycheck
1889 :diminish flycheck-mode
1890 :bind (("M-n" . next-error)
1891 ("M-p" . previous-error))
1894 (add-hook 'find-file-hook
1896 (when (not (equal 'emacs-lisp-mode major-mode))
1900 (use-package flycheck-color-mode-line
1901 :ensure flycheck-color-mode-line)
1902 (setq flycheck-highlighting-mode nil)
1903 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
1907 Obviously emacs can do syntax hilighting. For more things than you ever
1909 And I want to have it everywhere.
1910 #+BEGIN_SRC emacs-lisp
1911 (use-package font-lock
1914 (global-font-lock-mode 1)
1915 (setq font-lock-maximum-decoration t)))
1918 #+BEGIN_SRC emacs-lisp
1919 (use-package git-commit-mode
1920 :ensure git-commit-mode
1921 :commands git-commit-mode
1922 :mode ("COMMIT_EDITMSG" . git-commit-mode))
1926 #+BEGIN_SRC emacs-lisp
1927 (use-package git-rebase-mode
1928 :ensure git-rebase-mode
1929 :commands git-rebase-mode
1930 :mode ("git-rebase-todo" . git-rebase-mode))
1933 [2014-05-21 Wed 22:56]
1934 #+BEGIN_SRC emacs-lisp
1935 (use-package git-gutter+
1937 :diminish git-gutter+-mode
1938 :bind (("C-x n" . git-gutter+-next-hunk)
1939 ("C-x p" . git-gutter+-previous-hunk)
1940 ("C-x v =" . git-gutter+-show-hunk)
1941 ("C-x r" . git-gutter+-revert-hunks)
1942 ("C-x s" . git-gutter+-stage-hunks)
1943 ("C-x c" . git-gutter+-commit)
1947 (setq git-gutter+-disabled-modes '(org-mode))
1948 (global-git-gutter+-mode 1))
1951 (use-package git-gutter-fringe+
1952 :ensure git-gutter-fringe+
1955 (setq git-gutter-fr+-side 'right-fringe)
1956 ;(git-gutter-fr+-minimal)
1961 [2015-02-22 Sun 14:00]
1962 Provides function that popup commit message at current line. This is
1963 useful when you want to know why this line was changed.
1964 #+BEGIN_SRC emacs-lisp
1965 (use-package git-messenger
1966 :ensure git-messenger
1967 :commands (git-messenger:popup-message)
1968 :bind (("C-x v p" . git-messenger:popup-message))
1971 (bind-key "m" 'git-messenger:copy-message git-messenger-map)
1972 (add-hook 'git-messenger:popup-buffer-hook 'magit-commit-mode)
1973 (setq git-messenger:show-detail t)))
1976 [2014-07-23 Mi 12:57]
1977 Browse historic versions of a file with p (previous) and n (next).
1978 #+BEGIN_SRC emacs-lisp
1979 (use-package git-timemachine
1980 :ensure git-timemachine
1981 :commands git-timemachine)
1984 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
1985 what I want every emacs to know.
1986 #+BEGIN_SRC emacs-lisp
1987 (bind-key "C-c g" 'gnus) ; Start gnus with M-n
1993 [2015-02-20 Fri 16:27]
1994 When working with many windows at the same time, each window has a
1995 size that is not convenient for editing.
1997 golden-ratio helps on this issue by resizing automatically the windows
1998 you are working on to the size specified in the "Golden Ratio". The
1999 window that has the main focus will have the perfect size for editing,
2000 while the ones that are not being actively edited will be re-sized to
2001 a smaller size that doesn't get in the way, but at the same time will
2002 be readable enough to know it's content.
2003 #+BEGIN_SRC emacs-lisp
2004 (use-package golden-ratio
2005 :ensure golden-ratio
2006 :diminish golden-ratio-mode
2009 (golden-ratio-mode 1)
2010 (setq golden-ratio-exclude-buffer-names '("*LV*" "*guide-key*"))
2011 (setq golden-ratio-exclude-modes '("calendar-mode" "gnus-summary-mode"
2012 "gnus-article-mode" "calc-mode" "calc-trail-mode"
2017 [2015-02-22 Sun 13:28]
2018 Move point through buffer-undo-list positions.
2019 #+BEGIN_SRC emacs-lisp
2020 (use-package goto-last-change
2021 :commands (goto-last-change)
2022 :bind (("M-g l" . goto-last-change))
2026 [2014-06-11 Wed 22:27]
2027 guide-key.el displays the available key bindings automatically and
2030 For whatever reason I like this more than icicles <backtab> completion
2032 #+BEGIN_SRC emacs-lisp
2033 (use-package guide-key
2035 :diminish guide-key-mode
2038 (setq guide-key/guide-key-sequence '("C-x" "C-c" "M-g"))
2040 (setq guide-key/recursive-key-sequence-flag t)
2041 (setq guide-key/popup-window-position 'bottom)
2042 (setq guide-key/idle-delay 0.5)))
2047 [2014-05-21 Wed 23:51]
2048 #+BEGIN_SRC emacs-lisp
2049 (use-package hi-lock
2050 :bind (("M-o l" . highlight-lines-matching-regexp)
2051 ("M-o r" . highlight-regexp)
2052 ("M-o w" . highlight-phrase)))
2054 (use-package hilit-chg
2055 :bind ("M-o C" . highlight-changes-mode))
2059 Crazy way of completion. It looks at the word before point and then
2060 tries to expand it in various ways.
2061 #+BEGIN_SRC emacs-lisp
2062 (use-package hippie-exp
2063 :bind ("M-/" . hippie-expand)
2064 :commands hippie-expand
2067 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
2068 try-expand-dabbrev-all-buffers
2069 try-expand-dabbrev-from-kill
2070 try-complete-file-name-partially
2071 try-complete-file-name
2072 try-expand-all-abbrevs try-expand-list
2074 try-complete-lisp-symbol-partially
2075 try-complete-lisp-symbol))))
2078 Replaced by web-mode [[*web-mode][web-mode]]
2079 #+BEGIN_SRC emacs-lisp :tangle no
2080 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
2081 (add-auto-mode 'html-helper-mode "\\.html$")
2082 (add-auto-mode 'html-helper-mode "\\.asp$")
2083 (add-auto-mode 'html-helper-mode "\\.phtml$")
2084 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
2085 (defalias 'html-mode 'html-helper-mode)
2088 [2015-01-26 Mon 15:50]
2089 This is a package for GNU Emacs that can be used to tie related
2090 commands into a family of short bindings with a common prefix - a
2093 Once you summon the Hydra through the prefixed binding (the body + any
2094 one head), all heads can be called in succession with only a short
2097 The Hydra is vanquished once Hercules, any binding that isn't the
2098 Hydra's head, arrives. Note that Hercules, besides vanquishing the
2099 Hydra, will still serve his orignal purpose, calling his proper
2100 command. This makes the Hydra very seamless, it's like a minor mode
2101 that disables itself auto-magically.
2102 #+BEGIN_SRC emacs-lisp
2107 (setq hydra-is-helpful t)
2110 (defhydra hydra-zoom (:color red)
2112 ("g" text-scale-increase "in")
2113 ("l" text-scale-decrease "out")
2115 (bind-key "<F2>" 'hydra-zoom/toggle)
2117 (defhydra hydra-error (:color red)
2119 ("h" first-error "first")
2120 ("j" next-error "next")
2121 ("k" previous-error "prev")
2122 ("v" recenter-top-bottom "recenter")
2124 (bind-key "M-g e" 'hydra-error/body)
2126 (defhydra hydra-gnus (:color red)
2128 ("m" gnus-uu-mark-thread "mark thread")
2129 ("d" gnus-summary-delete-article "delete article(s)")
2130 ("r" gnus-summary-mark-as-read-forward "mark read")
2131 ("n" gnus-summary-next-thread "next thread")
2132 ("p" gnus-summary-prev-thread "previous thread")
2133 ("g" gnus-summary-next-group "next group")
2134 ("l" gnus-recenter "recenter")
2135 ("x" gnus-summary-limit-to-unread "unread")
2137 (bind-key "C-c h" 'hydra-gnus/body)
2139 (defhydra hydra-launcher (:color blue)
2142 ("r" (browse-url "http://www.reddit.com/r/emacs/") "reddit")
2143 ("w" (browse-url "http://www.emacswiki.org/") "emacswiki")
2146 (bind-key "C-c r" 'hydra-launcher/body)
2148 ; whitespace mode gets loaded late, so variable may not be there yet. Workaround...
2149 (defvar whitespace-mode nil)
2150 (defhydra hydra-toggle (:color pink)
2152 _a_ abbrev-mode: % 4`abbrev-mode^^^^ _f_ auto-fill-mode: %`auto-fill-function
2153 _c_ auto-complete-mode: % 4`auto-complete-mode _r_ auto-revert-mode: %`auto-revert-mode
2154 _d_ debug-on-error: % 4`debug-on-error^ _t_ truncate-lines: %`truncate-lines
2155 _w_ whitespace-mode: % 4`whitespace-mode _g_ golden-ratio-mode: %`golden-ratio-mode
2156 _l_ linum-mode: % 4`linum-mode _k_ linum relative: %`linum-format
2159 ("a" abbrev-mode nil)
2160 ("c" auto-complete-mode nil)
2161 ("i" aggressive-indent-mode nil)
2162 ("d" toggle-debug-on-error nil)
2163 ("f" auto-fill-mode nil)
2164 ("g" golden-ratio-mode nil)
2165 ("t" toggle-truncate-lines nil)
2166 ("w" whitespace-mode nil)
2167 ("r" auto-revert-mode nil)
2168 ("l" linum-mode nil)
2169 ("k" linum-relative-toggle nil)
2171 (bind-key "C-c C-v" 'hydra-toggle/body)
2177 [2014-05-21 Wed 23:54]
2178 #+BEGIN_SRC emacs-lisp
2179 (use-package ibuffer
2181 :bind (("C-h h" . ibuffer)
2182 ("C-x C-b" . ibuffer)
2183 ("<XF86WebCam>" . ibuffer)
2186 :defines (ibuffer-filtering-alist
2187 ibuffer-filter-groups ibuffer-compile-formats ibuffer-git-column-length
2188 ibuffer-show-empty-filter-groups ibuffer-saved-filter-groups)
2191 (defvar my-ibufffer-separator " • ")
2192 (setq ibuffer-filter-group-name-face 'variable-pitch
2193 ibuffer-use-header-line t
2194 ibuffer-old-time 12)
2195 (unbind-key "M-o" ibuffer-mode-map)
2196 (bind-key "s" 'isearch-forward-regexp ibuffer-mode-map)
2197 (bind-key "." 'ibuffer-invert-sorting ibuffer-mode-map)
2202 (use-package ibuffer-vc
2205 (ibuffer-vc-set-filter-groups-by-vc-root
2206 ibuffer-vc-generate-filter-groups-by-vc-root))
2208 (use-package ibuffer-tramp
2210 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
2211 ibuffer-tramp-set-filter-groups-by-tramp-connection))
2212 ;; Switching to ibuffer puts the cursor on the most recent buffer
2213 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
2214 "Open ibuffer with cursor pointed to most recent buffer name"
2215 (let ((recent-buffer-name (buffer-name)))
2217 (ibuffer-update nil t)
2218 (unless (string= recent-buffer-name "*Ibuffer*")
2219 (ibuffer-jump-to-buffer recent-buffer-name))))
2221 (defun ibuffer-magit-status ()
2223 (--when-let (get-buffer "*Ibuffer*")
2224 (with-current-buffer it
2225 (let* ((selected-buffer (ibuffer-current-buffer))
2226 (buffer-path (with-current-buffer
2228 (or (buffer-file-name)
2229 list-buffers-directory
2230 default-directory)))
2232 (if (file-regular-p buffer-path)
2233 (file-name-directory buffer-path)
2235 (magit-status default-directory)))))
2236 (bind-key "i" 'ibuffer-magit-status ibuffer-mode-map)
2237 (bind-key "G" 'ibuffer-magit-status ibuffer-mode-map)
2239 (setq ibuffer-directory-abbrev-alist
2244 (cons (f-slash (f-expand (cdr it))) my-ibufffer-separator)
2245 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
2247 ("dak" . "/develop/dak/")
2249 ("config" . "~/.emacs.d/config/")
2251 ("systmp" . "/tmp/")
2252 ("puppet" . "~/git/puppet")
2256 (use-package ibuffer-git
2258 (use-package ibuffer-vc
2261 (define-ibuffer-column size-h
2262 (:name "Size" :inline t)
2264 ((> (buffer-size) 1000)
2265 (format "%7.1fk" (/ (buffer-size) 1000.0)))
2266 ((> (buffer-size) 1000000)
2267 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
2269 (format "%8d" (buffer-size)))))
2271 (use-package ibuf-ext)
2272 (define-ibuffer-filter filename2
2273 "Toggle current view to buffers with filename matching QUALIFIER."
2274 (:description "filename2"
2275 :reader (read-from-minibuffer "Filter by filename (regexp): "))
2276 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
2277 (ibuffer-awhen (with-current-buffer buf
2278 (or buffer-file-name
2280 (string-match qualifier it)))
2282 (defvar ibuffer-magit-filter-groups nil)
2283 (defun ibuffer-magit-define-filter-groups ()
2284 (when (and (not ibuffer-magit-filter-groups)
2285 (boundp 'magit-repo-dirs))
2286 (setq ibuffer-magit-filter-groups
2289 (file-name-nondirectory (directory-file-name it)))
2291 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
2293 (defun ibuffer-set-filter-groups-by-root ()
2295 ;; (ibuffer-projectile-define-filter-groups)
2296 ;; (ibuffer-magit-define-filter-groups)
2297 (setq ibuffer-filter-groups
2299 ;; ibuffer-projectile-filter-groups
2300 ibuffer-magit-filter-groups
2303 (or (mode . magit-log-edit-mode)
2304 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2305 (name . "^\\*Pymacs\\*$")
2306 (name . "^\\*helm.*\\*")
2307 (name . "^\\*Compile-log\\*$")
2308 (name . "^\\*Ido Completions\\*$")
2309 (name . "^\\*magit-\\(process\\)\\*$")
2313 (name . "^\\*scratch")
2314 (name . "^\\*Messages")
2317 (ibuffer-vc-generate-filter-groups-by-vc-root)
2318 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
2320 (defun toggle-ibuffer-filter-groups ()
2323 (let ((ibuf (get-buffer "*Ibuffer*")))
2325 (with-current-buffer ibuf
2326 (let ((selected-buffer (ibuffer-current-buffer)))
2327 (if (not ibuffer-filter-groups)
2328 (ibuffer-set-filter-groups-by-root)
2329 (setq ibuffer-filter-groups nil))
2330 (pop-to-buffer ibuf)
2331 (ibuffer-update nil t)
2332 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
2334 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
2336 (defun ibuffer-back-to-top ()
2338 (beginning-of-buffer)
2341 (defun ibuffer-jump-to-bottom ()
2347 (define-key ibuffer-mode-map
2348 (vector 'remap 'end-of-buffer) 'ibuffer-jump-to-bottom)
2349 (define-key ibuffer-mode-map
2350 (vector 'remap 'beginning-of-buffer) 'ibuffer-back-to-top)
2352 (setq ibuffer-default-sorting-mode 'recency
2353 ibuffer-eliding-string "…"
2354 ibuffer-compile-formats t
2355 ibuffer-git-column-length 6
2356 ibuffer-show-empty-filter-groups nil
2357 ibuffer-default-directory "~/"
2360 (setq ibuffer-formats '((mark vc-status-mini
2362 (git-status 8 8 :left)
2366 (name 18 18 :left :elide)
2368 (size-h 9 -1 :right)
2370 (mode 16 16 :left :elide)
2371 " " filename-and-process)
2373 (git-status 8 8 :left)
2379 (setq ibuffer-saved-filter-groups
2382 ("dired" (mode . dired-mode))
2383 ("perl" (mode . cperl-mode))
2385 (mode . puppet-mode)
2386 (mode . yaml-mode)))
2387 ("ruby" (mode . ruby-mode))
2389 (name . "^\\*scratch\\*$")
2390 (name . "^\\*Compile-log\\*$")
2391 (name . "^\\*Completions\\*$")
2392 (name . "^\\*Messages\\*$")
2393 (name . "^\\*Backtrace\\*$")
2394 (name . "^\\*Packages*\\*$")
2395 (name . "^\\*Help*\\*$")
2398 (mode . message-mode)
2401 (mode . gnus-group-mode)
2402 (mode . gnus-summary-mode)
2403 (mode . gnus-article-mode)
2404 (name . "^\\.bbdb$")
2405 (name . "^\\.newsrc-dribble")))
2407 (filename . ".*/org/.*")
2408 (mode . org-agenda-mode)
2409 (name . "^diary$")))
2411 (mode . magit-log-edit-mode)
2412 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
2414 ;; -------------------------------------------------
2415 ;; programming languages #1
2417 (mode . emacs-lisp-mode)
2418 (mode . python-mode)
2420 (mode . coffee-mode)
2423 (mode . actionscript-mode)
2426 (mode . haskell-mode)
2432 ;; -------------------------------------------------
2433 ;; configuration/data files
2437 (mode . conf-mode)))
2438 ;; -------------------------------------------------
2439 ;; text/notetaking/org
2440 ("org agenda" (mode . org-agenda-mode))
2443 (name . "^\\*Calendar\\*$")
2444 (name . "^diary$")))
2448 (mode . markdown-mode)))
2449 ;; -------------------------------------------------
2452 (mode . image-mode)))
2453 ;; -------------------------------------------------
2455 ("w3m" (mode . w3m-mode))
2457 (mode . magit-status-mode)
2458 (mode . magit-log-mode)
2459 (mode . vc-annotate-mode)))
2460 ("dired" (mode . dired-mode))
2465 (name . "^\\*Personal Keybindings\\*$")))
2466 ;; -------------------------------------------------
2468 ("MORE" (or (mode . magit-log-edit-mode)
2469 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2470 (name . "^\\*Pymacs\\*$")
2471 (name . "^\\*Compile-log\\*$")
2472 (name . "^\\*Completions\\*$")
2473 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
2475 ("*buffer*" (name . "\\*.*\\*"))))))
2477 (add-hook 'ibuffer-mode-hook
2479 (ibuffer-auto-mode 1)
2480 (ibuffer-switch-to-saved-filter-groups "default")))
2482 ;; Unless you turn this variable on you will be prompted every time
2483 ;; you want to delete a buffer, even unmodified ones, which is way
2484 ;; too cautious for most people. You’ll still be prompted for
2485 ;; confirmation when deleting modified buffers after the option has
2487 (setq ibuffer-expert t)
2492 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
2493 ‘TAB’ completion is to typing things manually every time.”]]
2494 #+BEGIN_SRC emacs-lisp
2495 (use-package icicles
2496 :load-path "elisp/icicle/"
2501 Incremental mini-buffer completion preview: Type in the minibuffer,
2502 list of matching commands is echoed
2503 #+BEGIN_SRC emacs-lisp
2507 [2014-05-26 Mon 22:49]
2508 #+BEGIN_SRC emacs-lisp
2511 :commands (iedit-mode)
2513 :bind (("C-;" . iedit-mode)
2514 ("C-," . iedit-mode-toggle-on-function))
2519 [2014-05-20 Tue 23:35]
2520 #+BEGIN_SRC emacs-lisp
2522 :bind ("C-h C-i" . info-lookup-symbol)
2523 :commands info-lookup-symbol
2526 ;; (defadvice info-setup (after load-info+ activate)
2527 ;; (use-package info+))
2529 (defadvice Info-exit (after remove-info-window activate)
2530 "When info mode is quit, remove the window."
2531 (if (> (length (window-list)) 1)
2534 (use-package info-look
2535 :commands info-lookup-add-help)
2537 ** linum (line number)
2538 Various modes should have line numbers in front of each line.
2540 But then there are some where it would just be deadly - like org-mode,
2541 gnus, so we have a list of modes where we don't want to see it.
2542 #+BEGIN_SRC emacs-lisp
2544 :diminish linum-mode
2547 (setq linum-format "%3d ")
2548 (setq linum-mode-inhibit-modes-list '(org-mode
2555 (defadvice linum-on (around linum-on-inhibit-for-modes)
2556 "Stop the load of linum-mode for some major modes."
2557 (unless (member major-mode linum-mode-inhibit-modes-list)
2560 (ad-activate 'linum-on)
2562 (use-package linum-relative
2563 :ensure linum-relative
2566 (setq linum-format 'dynamic)
2569 (global-linum-mode 1))
2572 ** lisp editing stuff
2574 [2013-04-21 So 21:00]
2575 I'm not doing much of it, except for my emacs and gnus configs, but
2576 then I like it nice too...
2577 #+BEGIN_SRC emacs-lisp
2578 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
2580 (defun remove-elc-on-save ()
2581 "If you're saving an elisp file, likely the .elc is no longer valid."
2582 (make-local-variable 'after-save-hook)
2583 (add-hook 'after-save-hook
2585 (if (file-exists-p (concat buffer-file-name "c"))
2586 (delete-file (concat buffer-file-name "c"))))))
2588 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
2589 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
2591 (use-package paredit
2593 :diminish paredit-mode " π")
2595 (setq lisp-coding-hook 'lisp-coding-defaults)
2596 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2598 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2599 (add-hook 'emacs-lisp-mode-hook (lambda ()
2600 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2602 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
2604 (after "elisp-slime-nav"
2605 '(diminish 'elisp-slime-nav-mode))
2606 (after "rainbow-mode"
2607 '(diminish 'rainbow-mode))
2609 '(diminish 'eldoc-mode))
2612 [2013-04-21 So 20:48]
2613 magit is a mode for interacting with git.
2614 #+BEGIN_SRC emacs-lisp
2617 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
2618 magit-git-repo-p magit-list-repos)
2620 :bind (("C-x g" . magit-status)
2621 ("C-x G" . magit-status-with-prefix))
2624 (setq magit-commit-signoff t
2625 magit-repo-dirs '("~/git"
2629 magit-repo-dirs-depth 4
2630 magit-log-auto-more t)
2632 (use-package magit-blame
2633 :commands magit-blame-mode
2636 (use-package magit-svn
2638 :commands (magit-svn-mode
2642 (add-hook 'magit-mode-hook 'hl-line-mode)
2643 (defun magit-status-with-prefix ()
2645 (let ((current-prefix-arg '(4)))
2646 (call-interactively 'magit-status)))
2650 (setenv "GIT_PAGER" "")
2652 (unbind-key "M-h" magit-mode-map)
2653 (unbind-key "M-s" magit-mode-map)
2655 (use-package magit-find-file
2656 :ensure magit-find-file
2657 :commands (magit-find-file-completing-read)
2661 (bind-key "C-x C-f" 'magit-find-file-completing-read magit-mode-map)))
2663 (add-hook 'magit-log-edit-mode-hook
2665 (set-fill-column 72)
2668 (defadvice magit-status (around magit-fullscreen activate)
2669 (window-configuration-to-register :magit-fullscreen)
2671 (delete-other-windows))
2673 (defun magit-quit-session ()
2674 "Restores the previous window configuration and kills the magit buffer"
2677 (jump-to-register :magit-fullscreen))
2679 (bind-key "q" 'magit-quit-session magit-status-mode-map)
2683 [2014-05-20 Tue 23:04]
2684 #+BEGIN_SRC emacs-lisp
2685 (use-package markdown-mode
2686 :mode (("\\.md\\'" . markdown-mode)
2687 ("\\.mdwn\\'" . markdown-mode))
2691 #+BEGIN_SRC emacs-lisp
2692 (use-package message
2695 (setq message-kill-buffer-on-exit t)))
2698 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2700 I want to access it from anywhere using =F6=.
2701 #+BEGIN_SRC emacs-lisp
2702 (use-package mingus-stays-home
2703 :bind ( "<f6>" . mingus)
2707 (setq mingus-dired-add-keys t)
2708 (setq mingus-mode-always-modeline nil)
2709 (setq mingus-mode-line-show-elapsed-percentage nil)
2710 (setq mingus-mode-line-show-volume nil)
2711 (setq mingus-mpd-config-file "/etc/mpd.conf")
2712 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2713 (setq mingus-mpd-root "/share/music/")))
2717 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
2718 #+BEGIN_SRC emacs-lisp
2719 (use-package miniedit
2724 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
2725 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
2726 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
2727 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
2732 [2013-05-21 Tue 23:39]
2733 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
2734 coexist in one buffer.
2735 #+BEGIN_SRC emacs-lisp :tangle no
2736 (use-package mmm-auto
2740 (setq mmm-global-mode 'buffers-with-submode-classes)
2741 (setq mmm-submode-decoration-level 2)
2742 (eval-after-load 'mmm-vars
2748 :face mmm-code-submode-face
2749 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
2750 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
2751 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2752 @ "\n" _ "\n" @ "</script>" @)))
2755 :face mmm-code-submode-face
2756 :front "<style[^>]*>[ \t]*\n?"
2757 :back "[ \t]*</style>"
2758 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2759 @ "\n" _ "\n" @ "</style>" @)))
2762 :face mmm-code-submode-face
2765 (dolist (mode (list 'html-mode 'nxml-mode))
2766 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
2767 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
2772 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2774 #+BEGIN_SRC emacs-lisp
2775 (use-package mo-git-blame
2776 :ensure mo-git-blame
2777 :commands (mo-git-blame-current
2781 (setq mo-git-blame-blame-window-width 25)))
2785 [2013-04-08 Mon 23:57]
2786 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2787 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2788 #+BEGIN_SRC emacs-lisp
2789 (use-package multiple-cursors
2790 :ensure multiple-cursors
2792 :commands (mc/remove-fake-cursors
2793 mc/create-fake-cursor-at-point
2794 mc/pop-state-from-overlay
2795 mc/maybe-multiple-cursors-mode)
2796 :defines (multiple-cursors-mode
2798 mc--read-quoted-char
2799 rectangular-region-mode)
2800 :bind (("C-S-c C-S-c" . mc/edit-lines)
2801 ("C->" . mc/mark-next-like-this)
2802 ("C-<" . mc/mark-previous-like-this)
2803 ("C-c C-<" . mc/mark-all-like-this)
2804 ("C-c i" . mc/insert-numbers))
2807 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
2808 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
2809 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
2810 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
2811 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
2812 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
2815 [2014-08-27 Wed 17:15]
2817 #+BEGIN_SRC emacs-lisp
2818 (use-package neotree
2821 :bind (("<f8>" . neotree-toggle))
2822 :commands (neotree-find
2827 (setq neo-smart-open t))
2830 (bind-key "^" 'neotree-select-up-node neotree-mode-map)))
2833 [2013-05-22 Wed 22:02]
2834 nxml-mode is a major mode for editing XML.
2835 #+BEGIN_SRC emacs-lisp
2840 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2843 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2844 (fset 'xml-mode 'nxml-mode)
2845 (setq nxml-slash-auto-complete-flag t)
2847 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2848 (defun pp-xml-region (begin end)
2849 "Pretty format XML markup in region. The function inserts
2850 linebreaks to separate tags that have nothing but whitespace
2851 between them. It then indents the markup by using nxml's
2857 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2858 (backward-char) (insert "\n"))
2859 (indent-region begin end)))
2861 ;;----------------------------------------------------------------------------
2862 ;; Integration with tidy for html + xml
2863 ;;----------------------------------------------------------------------------
2864 ;; tidy is autoloaded
2865 (eval-after-load 'tidy
2867 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2868 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2873 *** General settings
2874 [2013-04-28 So 17:06]
2876 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
2877 it is quite extensive. Nevertheless, it starts out small, loading it.
2878 #+BEGIN_SRC emacs-lisp
2882 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
2883 that we need org-protocol.
2884 #+BEGIN_SRC emacs-lisp
2885 (require 'org-protocol)
2890 My current =org-agenda-files= variable only includes a set of
2892 #+BEGIN_SRC emacs-lisp
2893 (setq org-agenda-files (quote ("~/org/"
2899 (setq org-default-notes-file "~/org/notes.org")
2901 =org-mode= manages the =org-agenda-files= variable automatically using
2902 =C-c [= and =C-c ]= to add and remove files respectively. However,
2903 this replaces my directory list with a list of explicit filenames
2904 instead and is not what I want. If this occurs then adding a new org
2905 file to any of the above directories will not contribute to my agenda
2906 and I will probably miss something important.
2908 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
2909 prevent messing up my list of directories in the =org-agenda-files=
2910 variable. I just add and remove directories manually here. Changing
2911 the list of directories in =org-agenda-files= happens very rarely
2912 since new files in existing directories are automatically picked up.
2914 #+BEGIN_SRC emacs-lisp
2915 ;; Keep tasks with dates on the global todo lists
2916 (setq org-agenda-todo-ignore-with-date nil)
2918 ;; Keep tasks with deadlines on the global todo lists
2919 (setq org-agenda-todo-ignore-deadlines nil)
2921 ;; Keep tasks with scheduled dates on the global todo lists
2922 (setq org-agenda-todo-ignore-scheduled nil)
2924 ;; Keep tasks with timestamps on the global todo lists
2925 (setq org-agenda-todo-ignore-timestamp nil)
2927 ;; Remove completed deadline tasks from the agenda view
2928 (setq org-agenda-skip-deadline-if-done t)
2930 ;; Remove completed scheduled tasks from the agenda view
2931 (setq org-agenda-skip-scheduled-if-done t)
2933 ;; Remove completed items from search results
2934 (setq org-agenda-skip-timestamp-if-done t)
2936 ;; Include agenda archive files when searching for things
2937 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
2939 ;; Show all future entries for repeating tasks
2940 (setq org-agenda-repeating-timestamp-show-all t)
2942 ;; Show all agenda dates - even if they are empty
2943 (setq org-agenda-show-all-dates t)
2945 ;; Sorting order for tasks on the agenda
2946 (setq org-agenda-sorting-strategy
2947 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
2948 (todo category-up priority-down effort-up)
2949 (tags category-up priority-down effort-up)
2950 (search category-up))))
2952 ;; Start the weekly agenda on Monday
2953 (setq org-agenda-start-on-weekday 1)
2955 ;; Enable display of the time grid so we can see the marker for the current time
2956 (setq org-agenda-time-grid (quote ((daily today remove-match)
2957 #("----------------" 0 16 (org-heading t))
2958 (0800 1000 1200 1400 1500 1700 1900 2100))))
2960 ;; Display tags farther right
2961 (setq org-agenda-tags-column -102)
2963 ; position the habit graph on the agenda to the right of the default
2964 (setq org-habit-graph-column 50)
2966 ; turn habits back on
2967 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
2970 ;; Agenda sorting functions
2972 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
2975 (setq org-deadline-warning-days 30)
2977 ;; Always hilight the current agenda line
2978 (add-hook 'org-agenda-mode-hook
2979 '(lambda () (hl-line-mode 1))
2983 #+BEGIN_SRC emacs-lisp
2984 (setq org-agenda-persistent-filter t)
2985 (add-hook 'org-agenda-mode-hook
2986 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
2989 (add-hook 'org-agenda-mode-hook
2990 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
2993 (add-hook 'org-agenda-mode-hook
2994 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
2997 (add-hook 'org-agenda-mode-hook
2998 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
3001 (add-hook 'org-agenda-mode-hook
3002 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
3005 ; Rebuild the reminders everytime the agenda is displayed
3006 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
3008 ;(if (file-exists-p "~/org/refile.org")
3009 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
3011 ; Activate appointments so we get notifications
3014 (setq org-agenda-log-mode-items (quote (closed clock state)))
3015 (if (> emacs-major-version 23)
3016 (setq org-agenda-span 3)
3017 (setq org-agenda-ndays 3))
3019 (setq org-agenda-show-all-dates t)
3020 (setq org-agenda-start-on-weekday nil)
3021 (setq org-deadline-warning-days 14)
3024 *** Global keybindings.
3025 Start off by defining a series of keybindings.
3027 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
3028 setup manually, not by org-mode. Also turn off =C-c ;=, which
3029 comments headlines - a function never used.
3030 #+BEGIN_SRC emacs-lisp
3031 (add-hook 'org-mode-hook
3033 (org-defkey org-mode-map "\C-c[" 'undefined)
3034 (org-defkey org-mode-map "\C-c]" 'undefined)
3035 (org-defkey org-mode-map "\C-c;" 'undefined))
3039 And now a largish set of keybindings...
3040 #+BEGIN_SRC emacs-lisp
3041 (bind-key "C-c l" 'org-store-link)
3042 (bind-key "C-c a" 'org-agenda)
3043 ;(bind-key "C-c b" 'org-iswitchb)
3044 (define-key mode-specific-map [?a] 'org-agenda)
3046 (bind-key "<f12>" 'org-agenda)
3047 (bind-key "<f5>" 'bh/org-todo)
3048 (bind-key "<S-f5>" 'bh/widen)
3049 (bind-key "<f7>" 'bh/set-truncate-lines)
3050 ;(bind-key "<f8>" 'org-cycle-agenda-files)
3052 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
3053 (bind-key "<f9> b" 'bbdb)
3054 (bind-key "<f9> c" 'calendar)
3055 (bind-key "<f9> f" 'boxquote-insert-file)
3056 (bind-key "<f9> h" 'bh/hide-other)
3057 (bind-key "<f9> n" 'org-narrow-to-subtree)
3058 (bind-key "<f9> w" 'widen)
3059 (bind-key "<f9> u" 'bh/narrow-up-one-level)
3060 (bind-key "<f9> I" 'bh/punch-in)
3061 (bind-key "<f9> O" 'bh/punch-out)
3062 (bind-key "<f9> H" 'jj/punch-in-hw)
3063 (bind-key "<f9> W" 'jj/punch-out-hw)
3064 (bind-key "<f9> o" 'bh/make-org-scratch)
3065 (bind-key "<f9> p" 'bh/phone-call)
3066 (bind-key "<f9> r" 'boxquote-region)
3067 (bind-key "<f9> s" 'bh/switch-to-scratch)
3068 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
3069 (bind-key "<f9> T" 'tabify)
3070 (bind-key "<f9> U" 'untabify)
3071 (bind-key "<f9> v" 'visible-mode)
3072 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
3073 (bind-key "C-<f9>" 'previous-buffer)
3074 (bind-key "C-<f10>" 'next-buffer)
3075 (bind-key "M-<f9>" 'org-toggle-inline-images)
3076 ;(bind-key "C-x n r" 'narrow-to-region)
3077 (bind-key "<f11>" 'org-clock-goto)
3078 (bind-key "C-<f11>" 'org-clock-in)
3079 (bind-key "C-M-r" 'org-capture)
3080 (bind-key "C-c r" 'org-capture)
3081 (bind-key "C-S-<f12>" 'bh/save-then-publish)
3082 ;(bind-key "C-k" 'jj-org-kill-line org-mode-map)
3086 *** Tasks, States, Todo fun
3088 First we define the global todo keywords.
3089 #+BEGIN_SRC emacs-lisp
3090 (setq org-todo-keywords
3091 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
3092 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
3094 (setq org-todo-keyword-faces
3095 (quote (("TODO" :foreground "red" :weight bold)
3096 ("NEXT" :foreground "light blue" :weight bold)
3097 ("DONE" :foreground "forest green" :weight bold)
3098 ("WAITING" :foreground "orange" :weight bold)
3099 ("HOLD" :foreground "orange" :weight bold)
3100 ("DELEGATED" :foreground "yellow" :weight bold)
3101 ("CANCELLED" :foreground "dark green" :weight bold)
3102 ("PHONE" :foreground "dark green" :weight bold))))
3105 **** Fast Todo Selection
3106 Fast todo selection allows changing from any task todo state to any
3107 other state directly by selecting the appropriate key from the fast
3108 todo selection key menu.
3109 #+BEGIN_SRC emacs-lisp
3110 (setq org-use-fast-todo-selection t)
3112 Changing a task state is done with =C-c C-t KEY=
3114 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
3117 #+BEGIN_SRC emacs-lisp
3118 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
3120 allows changing todo states with S-left and S-right skipping all of
3121 the normal processing when entering or leaving a todo state. This
3122 cycles through the todo states but skips setting timestamps and
3123 entering notes which is very convenient when all you want to do is fix
3124 up the status of an entry.
3126 **** Todo State Triggers
3127 I have a few triggers that automatically assign tags to tasks based on
3128 state changes. If a task moves to =CANCELLED= state then it gets a
3129 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
3130 =CANCELLED= tag. These are used for filtering tasks in agenda views
3131 which I'll talk about later.
3133 The triggers break down to the following rules:
3135 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
3136 - Moving a task to =WAITING= adds a =WAITING= tag
3137 - Moving a task to =HOLD= adds a =WAITING= tag
3138 - Moving a task to a done state removes a =WAITING= tag
3139 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
3140 - Moving a task to =NEXT= removes a =WAITING= tag
3141 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
3143 The tags are used to filter tasks in the agenda views conveniently.
3144 #+BEGIN_SRC emacs-lisp
3145 (setq org-todo-state-tags-triggers
3146 (quote (("CANCELLED" ("CANCELLED" . t))
3147 ("WAITING" ("WAITING" . t))
3148 ("HOLD" ("WAITING" . t) ("HOLD" . t))
3149 (done ("WAITING") ("HOLD"))
3150 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
3151 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
3152 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
3155 *** Capturing new tasks
3156 Org capture replaces the old remember mode.
3157 #+BEGIN_SRC emacs-lisp
3158 (setq org-directory "~/org")
3159 (setq org-default-notes-file "~/org/refile.org")
3161 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
3162 ;; see http://orgmode.org/manual/Template-elements.html
3163 (setq org-capture-templates
3164 (quote (("t" "todo" entry (file "~/org/refile.org")
3165 "* TODO %?\nAdded: %U\n"
3166 :clock-in t :clock-resume t)
3167 ("l" "linktodo" entry (file "~/org/refile.org")
3168 "* TODO %?\nAdded: %U\n%a\n"
3169 :clock-in t :clock-resume t)
3170 ("r" "respond" entry (file "~/org/refile.org")
3171 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
3172 :clock-in t :clock-resume t :immediate-finish t)
3173 ("n" "note" entry (file "~/org/refile.org")
3174 "* %? :NOTE:\nAdded: %U\n%a\n"
3175 :clock-in t :clock-resume t)
3176 ("d" "Delegated" entry (file "~/org/refile.org")
3177 "* DELEGATED %?\nAdded: %U\n%a\n"
3178 :clock-in t :clock-resume t)
3179 ("j" "Journal" entry (file+datetree "~/org/diary.org")
3181 :clock-in t :clock-resume t)
3182 ("w" "org-protocol" entry (file "~/org/refile.org")
3183 "* TODO Review %c\nAdded: %U\n"
3184 :immediate-finish t)
3185 ("p" "Phone call" entry (file "~/org/refile.org")
3186 "* PHONE %? :PHONE:\nAdded: %U"
3187 :clock-in t :clock-resume t)
3188 ("x" "Bookmark link" entry (file "~/org/refile.org")
3189 "* Bookmark: %c\n%i\nAdded: %U\n"
3190 :immediate-finish t)
3191 ("h" "Habit" entry (file "~/org/refile.org")
3192 "* 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")
3196 Capture mode now handles automatically clocking in and out of a
3197 capture task. This all works out of the box now without special hooks.
3198 When I start a capture mode task the task is clocked in as specified
3199 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
3200 resumes on the original clocking task.
3202 The quick clocking in and out of capture mode tasks (often it takes
3203 less than a minute to capture some new task details) can leave
3204 empty clock drawers in my tasks which aren't really useful.
3205 The following prevents this.
3206 #+BEGIN_SRC emacs-lisp
3207 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
3211 All my newly captured entries end up in =refile.org= and want to be
3212 moved over to the right place. The following is the setup for it.
3213 #+BEGIN_SRC emacs-lisp
3214 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
3215 (setq org-refile-targets (quote ((nil :maxlevel . 9)
3216 (org-agenda-files :maxlevel . 9))))
3218 ; Use full outline paths for refile targets - we file directly with IDO
3219 (setq org-refile-use-outline-path t)
3221 ; Targets complete directly with IDO
3222 (setq org-outline-path-complete-in-steps nil)
3224 ; Allow refile to create parent tasks with confirmation
3225 (setq org-refile-allow-creating-parent-nodes (quote confirm))
3227 ; Use IDO for both buffer and file completion and ido-everywhere to t
3228 (setq org-completion-use-ido t)
3229 (setq org-completion-use-iswitchb nil)
3230 :; Use IDO for both buffer and file completion and ido-everywhere to t
3231 ;(setq ido-everywhere t)
3232 ;(setq ido-max-directory-size 100000)
3233 ;(ido-mode (quote both))
3234 ; Use the current window when visiting files and buffers with ido
3235 (setq ido-default-file-method 'selected-window)
3236 (setq ido-default-buffer-method 'selected-window)
3238 ;;;; Refile settings
3239 (setq org-refile-target-verify-function 'bh/verify-refile-target)
3243 Agenda view is the central place for org-mode interaction...
3244 #+BEGIN_SRC emacs-lisp
3245 ;; Do not dim blocked tasks
3246 (setq org-agenda-dim-blocked-tasks nil)
3247 ;; Compact the block agenda view
3248 (setq org-agenda-compact-blocks t)
3250 ;; Custom agenda command definitions
3251 (setq org-agenda-custom-commands
3252 (quote (("N" "Notes" tags "NOTE"
3253 ((org-agenda-overriding-header "Notes")
3254 (org-tags-match-list-sublevels t)))
3255 ("h" "Habits" tags-todo "STYLE=\"habit\""
3256 ((org-agenda-overriding-header "Habits")
3257 (org-agenda-sorting-strategy
3258 '(todo-state-down effort-up category-keep))))
3262 ((org-agenda-overriding-header "Tasks to Refile")
3263 (org-tags-match-list-sublevels nil)))
3264 (tags-todo "-HOLD-CANCELLED/!"
3265 ((org-agenda-overriding-header "Projects")
3266 (org-agenda-skip-function 'bh/skip-non-projects)
3267 (org-agenda-sorting-strategy
3269 (tags-todo "-CANCELLED/!"
3270 ((org-agenda-overriding-header "Stuck Projects")
3271 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3272 (tags-todo "-WAITING-CANCELLED/!NEXT"
3273 ((org-agenda-overriding-header "Next Tasks")
3274 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3275 (org-agenda-todo-ignore-scheduled t)
3276 (org-agenda-todo-ignore-deadlines t)
3277 (org-agenda-todo-ignore-with-date t)
3278 (org-tags-match-list-sublevels t)
3279 (org-agenda-sorting-strategy
3280 '(todo-state-down effort-up category-keep))))
3281 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3282 ((org-agenda-overriding-header "Tasks")
3283 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3284 (org-agenda-todo-ignore-scheduled t)
3285 (org-agenda-todo-ignore-deadlines t)
3286 (org-agenda-todo-ignore-with-date t)
3287 (org-agenda-sorting-strategy
3289 (tags-todo "-CANCELLED+WAITING/!"
3290 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
3291 (org-agenda-skip-function 'bh/skip-stuck-projects)
3292 (org-tags-match-list-sublevels nil)
3293 (org-agenda-todo-ignore-scheduled 'future)
3294 (org-agenda-todo-ignore-deadlines 'future)))
3296 ((org-agenda-overriding-header "Tasks to Archive")
3297 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3298 (org-tags-match-list-sublevels nil))))
3300 ("r" "Tasks to Refile" tags "REFILE"
3301 ((org-agenda-overriding-header "Tasks to Refile")
3302 (org-tags-match-list-sublevels nil)))
3303 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
3304 ((org-agenda-overriding-header "Stuck Projects")
3305 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3306 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
3307 ((org-agenda-overriding-header "Next Tasks")
3308 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3309 (org-agenda-todo-ignore-scheduled t)
3310 (org-agenda-todo-ignore-deadlines t)
3311 (org-agenda-todo-ignore-with-date t)
3312 (org-tags-match-list-sublevels t)
3313 (org-agenda-sorting-strategy
3314 '(todo-state-down effort-up category-keep))))
3315 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3316 ((org-agenda-overriding-header "Tasks")
3317 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3318 (org-agenda-sorting-strategy
3320 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
3321 ((org-agenda-overriding-header "Projects")
3322 (org-agenda-skip-function 'bh/skip-non-projects)
3323 (org-agenda-sorting-strategy
3325 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
3326 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
3327 (org-tags-match-list-sublevels nil))
3328 ("A" "Tasks to Archive" tags "-REFILE/"
3329 ((org-agenda-overriding-header "Tasks to Archive")
3330 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3331 (org-tags-match-list-sublevels nil))))))
3333 ; Overwrite the current window with the agenda
3334 (setq org-agenda-window-setup 'current-window)
3339 #+BEGIN_SRC emacs-lisp
3341 ;; Resume clocking task when emacs is restarted
3342 (org-clock-persistence-insinuate)
3344 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
3345 (setq org-clock-history-length 36)
3346 ;; Resume clocking task on clock-in if the clock is open
3347 (setq org-clock-in-resume t)
3348 ;; Change tasks to NEXT when clocking in
3349 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
3350 ;; Separate drawers for clocking and logs
3351 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
3352 ;; Save clock data and state changes and notes in the LOGBOOK drawer
3353 (setq org-clock-into-drawer t)
3354 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
3355 (setq org-clock-out-remove-zero-time-clocks t)
3356 ;; Clock out when moving task to a done state
3357 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
3358 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
3359 (setq org-clock-persist t)
3360 ;; Do not prompt to resume an active clock
3361 (setq org-clock-persist-query-resume nil)
3362 ;; Enable auto clock resolution for finding open clocks
3363 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
3364 ;; Include current clocking task in clock reports
3365 (setq org-clock-report-include-clocking-task t)
3367 ; use discrete minute intervals (no rounding) increments
3368 (setq org-time-stamp-rounding-minutes (quote (1 1)))
3370 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
3372 (setq bh/keep-clock-running nil)
3374 (setq org-agenda-clock-consistency-checks
3375 (quote (:max-duration "4:00"
3378 :gap-ok-around ("4:00"))))
3382 **** Setting a default clock task
3383 Per default the =** Organization= task in my tasks.org file receives
3384 misc clock time. This is the task I clock in on when I punch in at the
3385 start of my work day with =F9-I=. Punching-in anywhere clocks in this
3386 Organization task as the default task.
3388 If I want to change the default clocking task I just visit the
3389 new task in any org buffer and clock it in with =C-u C-u C-c C-x
3390 C-i=. Now this new task that collects miscellaneous clock
3391 minutes when the clock would normally stop.
3393 You can quickly clock in the default clocking task with =C-u C-c
3394 C-x C-i d=. Another option is to repeatedly clock out so the
3395 clock moves up the project tree until you clock out the
3396 top-level task and the clock moves to the default task.
3399 #+BEGIN_SRC emacs-lisp
3400 ;; Agenda clock report parameters
3401 (setq org-agenda-clockreport-parameter-plist
3402 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
3404 ;; Agenda log mode items to display (closed and state changes by default)
3405 (setq org-agenda-log-mode-items (quote (closed state)))
3407 **** Task estimates, column view
3408 Setup column view globally with the following headlines
3409 #+BEGIN_SRC emacs-lisp
3410 ; Set default column view headings: Task Effort Clock_Summary
3411 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
3413 Setup the estimate for effort values.
3414 #+BEGIN_SRC emacs-lisp
3415 ; global Effort estimate values
3416 ; global STYLE property values for completion
3417 (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")
3418 ("STYLE_ALL" . "habit"))))
3422 Tags are mostly used for filtering inside the agenda.
3423 #+BEGIN_SRC emacs-lisp
3424 ; Tags with fast selection keys
3425 (setq org-tag-alist (quote ((:startgroup)
3443 ; Allow setting single tags without the menu
3444 (setq org-fast-tag-selection-single-key (quote expert))
3446 ; For tag searches ignore tasks with scheduled and deadline dates
3447 (setq org-agenda-tags-todo-honor-ignore-options t)
3451 #+BEGIN_SRC emacs-lisp
3452 (setq org-archive-mark-done nil)
3453 (setq org-archive-location "%s_archive::* Archived Tasks")
3457 #+BEGIN_SRC emacs-lisp
3458 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
3459 (setq org-plantuml-jar-path "~/java/plantuml.jar")
3461 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
3463 ; Make babel results blocks lowercase
3464 (setq org-babel-results-keyword "results")
3466 (org-babel-do-load-languages
3467 (quote org-babel-load-languages)
3468 (quote ((emacs-lisp . t)
3487 ; Do not prompt to confirm evaluation
3488 ; This may be dangerous - make sure you understand the consequences
3489 ; of setting this -- see the docstring for details
3490 (setq org-confirm-babel-evaluate nil)
3492 ; Use fundamental mode when editing plantuml blocks with C-c '
3493 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
3496 #+BEGIN_SRC emacs-lisp
3497 ;; Don't have images visible on startup, breaks on console
3498 (setq org-startup-with-inline-images nil)
3501 #+BEGIN_SRC emacs-lisp
3502 (add-to-list 'org-structure-template-alist
3503 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
3504 "<comment>\n?\n</comment>"))
3506 **** ditaa, graphviz, etc
3507 Those are all nice tools. Look at
3508 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
3511 *** Publishing and exporting
3514 Org-mode can export to a variety of publishing formats including (but not limited to)
3517 (plain text - but not the original org-mode file)
3521 which enables getting to lots of other formats like ODF, XML, etc
3523 via LaTeX or Docbook
3526 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
3528 #+BEGIN_SRC emacs-lisp
3529 ;; Explicitly load required exporters
3533 ;; FIXME, check the following two
3534 ;(require 'ox-icalendar)
3537 ; experimenting with docbook exports - not finished
3538 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
3539 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
3541 ;; define categories that should be excluded
3542 (setq org-export-exclude-category (list "google" "google"))
3543 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
3545 ; define how the date strings look
3546 (setq org-export-date-timestamp-format "%Y-%m-%d")
3547 ; Inline images in HTML instead of producting links to the image
3548 (setq org-html-inline-images t)
3549 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
3550 (setq org-export-with-sub-superscripts nil)
3552 (setq org-html-head-extra (concat
3553 "<link rel=\"stylesheet\" href=\"https://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
3555 (setq org-html-head-include-default-style nil)
3556 ; Do not generate internal css formatting for HTML exports
3557 (setq org-export-htmlize-output-type (quote css))
3558 ; Export with LaTeX fragments
3559 (setq org-export-with-LaTeX-fragments t)
3560 ; Increase default number of headings to export
3561 (setq org-export-headline-levels 6)
3564 (setq org-publish-project-alist
3567 :base-directory "~/.emacs.d/"
3568 :base-extension "org"
3570 :publishing-directory "/develop/www/emacs"
3572 :publishing-function org-html-publish-to-html
3573 :headline-levels 4 ; Just the default for this project.
3579 :base-directory "~/.emacs.d/"
3580 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
3581 :publishing-directory "/develop/www/emacs"
3582 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
3584 :publishing-function org-publish-attachment
3586 ("inherit-org-info-js"
3587 :base-directory "/develop/vcs/org-info-js/"
3589 :base-extension "js"
3590 :publishing-directory "/develop/www/"
3591 :publishing-function org-publish-attachment
3593 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
3598 (setq org-export-with-timestamps nil)
3603 #+BEGIN_SRC emacs-lisp
3604 (setq org-latex-to-pdf-process
3605 '("xelatex -interaction nonstopmode %f"
3606 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
3607 (setq org-export-latex-listings 'minted)
3608 (setq org-latex-listings t)
3610 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
3611 ;; but adapted to use latexmk 4.20 or higher.
3612 (defun my-auto-tex-cmd ()
3613 "When exporting from .org with latex, automatically run latex,
3614 pdflatex, or xelatex as appropriate, using latexmk."
3616 ;; default command: oldstyle latex via dvi
3617 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
3619 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
3620 (setq texcmd "latexmk -pdf -quiet %f"))
3622 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3623 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
3624 ;; LaTeX compilation command
3625 (setq org-latex-to-pdf-process (list texcmd)))
3627 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
3629 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
3630 (setq org-export-latex-packages-alist
3632 ("" "longtable" nil)
3637 (defun my-auto-tex-parameters ()
3638 "Automatically select the tex packages to include."
3639 ;; default packages for ordinary latex or pdflatex export
3640 (setq org-export-latex-default-packages-alist
3641 '(("AUTO" "inputenc" t)
3651 ("" "hyperref" nil)))
3653 ;; Packages to include when xelatex is used
3654 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3655 (setq org-export-latex-default-packages-alist
3660 ("german" "babel" t)
3661 ("babel" "csquotes" t)
3663 ("xetex" "hyperref" nil)
3666 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
3667 (setq org-export-latex-classes
3669 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
3670 ("\\section{%s}" . "\\section*{%s}")
3671 ("\\subsection{%s}" . "\\subsection*{%s}")
3672 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
3673 ("\\paragraph{%s}" . "\\paragraph*{%s}")
3674 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
3675 org-export-latex-classes))))
3677 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
3680 *** Prevent editing invisible text
3681 The following setting prevents accidentally editing hidden text when
3682 the point is inside a folded region. This can happen if you are in
3683 the body of a heading and globally fold the org-file with =S-TAB=
3685 I find invisible edits (and undo's) hard to deal with so now I can't
3686 edit invisible text. =C-c C-r= (org-reveal) will display where the
3687 point is if it is buried in invisible text to allow editing again.
3689 #+BEGIN_SRC emacs-lisp
3690 (setq org-catch-invisible-edits 'error)
3694 #+BEGIN_SRC emacs-lisp
3695 ;; disable the default org-mode stuck projects agenda view
3696 (setq org-stuck-projects (quote ("" nil nil "")))
3698 ; force showing the next headline.
3699 (setq org-show-entry-below (quote ((default))))
3701 (setq org-show-following-heading t)
3702 (setq org-show-hierarchy-above t)
3703 (setq org-show-siblings (quote ((default))))
3705 (setq org-special-ctrl-a/e t)
3706 (setq org-special-ctrl-k t)
3707 (setq org-yank-adjusted-subtrees t)
3709 (setq org-table-export-default-format "orgtbl-to-csv")
3713 The following setting adds alphabetical lists like
3717 #+BEGIN_SRC emacs-lisp
3718 (if (> emacs-major-version 23)
3719 (setq org-list-allow-alphabetical t)
3720 (setq org-alphabetical-lists t))
3723 #+BEGIN_SRC emacs-lisp
3724 (setq org-remove-highlights-with-change nil)
3726 (setq org-list-demote-modify-bullet (quote (("+" . "-")
3733 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
3736 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
3737 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
3742 #+BEGIN_SRC emacs-lisp
3743 ;; Enable abbrev-mode
3744 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
3745 (setq org-startup-indented t)
3746 (setq org-startup-folded t)
3747 (setq org-cycle-separator-lines 0)
3750 I find extra blank lines in lists and headings a bit of a nuisance.
3751 To get a body after a list you need to include a blank line between
3752 the list entry and the body -- and indent the body appropriately.
3753 Most of my lists have no body detail so I like the look of collapsed
3754 lists with no blank lines better.
3756 The following setting prevents creating blank lines before headings
3757 but allows list items to adapt to existing blank lines around the items:
3758 #+BEGIN_SRC emacs-lisp
3759 (setq org-blank-before-new-entry (quote ((heading)
3760 (plain-list-item . auto))))
3763 #+BEGIN_SRC emacs-lisp
3764 (setq org-reverse-note-order nil)
3765 (setq org-default-notes-file "~/notes.org")
3768 Enforce task blocking. Tasks can't go done when there is any subtask
3769 still open. Unless they have a property of =NOBLOCKING: t=
3770 #+BEGIN_SRC emacs-lisp
3771 (setq org-enforce-todo-checkbox-dependencies t)
3772 (setq org-enforce-todo-dependencies t)
3775 #+BEGIN_SRC emacs-lisp
3776 (setq org-fast-tag-selection-single-key (quote expert))
3777 (setq org-footnote-auto-adjust t)
3778 (setq org-hide-block-startup t)
3779 (setq org-icalendar-alarm-time 15)
3780 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
3781 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
3782 (setq org-icalendar-honor-noexport-tag t)
3783 (setq org-icalendar-include-bbdb-anniversaries nil)
3784 (setq org-icalendar-include-body 200)
3785 (setq org-icalendar-include-todo nil)
3786 (setq org-icalendar-store-UID t)
3787 (setq org-icalendar-timezone "Europe/Berlin")
3788 (setq org-insert-mode-line-in-empty-file t)
3789 (setq org-log-done (quote note))
3790 (setq org-log-into-drawer t)
3791 (setq org-log-state-notes-insert-after-drawers nil)
3792 (setq org-log-reschedule (quote time))
3793 (setq org-log-states-order-reversed t)
3794 (setq org-mobile-agendas (quote all))
3795 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
3796 (setq org-mobile-inbox-for-pull "~/org/refile.org")
3797 (setq org-remember-store-without-prompt t)
3798 (setq org-return-follows-link t)
3799 (setq org-reverse-note-order t)
3801 ; regularly save our org-mode buffers
3802 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
3804 (setq org-log-done t)
3806 (setq org-enable-priority-commands t)
3807 (setq org-default-priority ?E)
3808 (setq org-lowest-priority ?E)
3813 Speed commands enable single-letter commands in Org-mode files when
3814 the point is at the beginning of a headline, or at the beginning of a
3817 See the `=org-speed-commands-default=' variable for a list of the keys
3818 and commands enabled at the beginning of headlines. All code blocks
3819 are available at the beginning of a code block, the following key
3820 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
3821 display a list of the code blocks commands and their related keys.
3823 #+BEGIN_SRC emacs-lisp
3824 (setq org-use-speed-commands nil)
3825 (setq org-speed-commands-user (quote (("0" . ignore)
3838 ("h" . bh/hide-other)
3841 (call-interactively 'org-insert-heading-respect-content))
3842 ("k" . org-kill-note-or-show-branches)
3845 ("q" . bh/show-org-agenda)
3847 ("s" . org-save-all-org-buffers)
3851 ("z" . org-add-note)
3856 ("F" . bh/restrict-to-file-or-follow)
3859 ("J" . org-clock-goto)
3863 ("N" . bh/narrow-to-org-subtree)
3864 ("P" . bh/narrow-to-org-project)
3869 ("U" . bh/narrow-up-one-org-level)
3876 (add-hook 'org-agenda-mode-hook
3878 (define-key org-agenda-mode-map "q" 'bury-buffer))
3881 (defvar bh/current-view-project nil)
3882 (add-hook 'org-agenda-mode-hook
3883 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
3888 The following displays the contents of code blocks in Org-mode files
3889 using the major-mode of the code. It also changes the behavior of
3890 =TAB= to as if it were used in the appropriate major mode. This means
3891 that reading and editing code form inside of your Org-mode files is
3892 much more like reading and editing of code using its major mode.
3894 #+BEGIN_SRC emacs-lisp
3895 (setq org-src-fontify-natively t)
3896 (setq org-src-tab-acts-natively t)
3899 #+BEGIN_SRC emacs-lisp
3900 (setq org-src-preserve-indentation nil)
3901 (setq org-edit-src-content-indentation 0)
3905 #+BEGIN_SRC emacs-lisp
3906 (setq org-attach-directory "~/org/data/")
3908 #+BEGIN_SRC emacs-lisp
3909 (setq org-agenda-sticky t)
3912 **** Checklist handling
3913 [2013-05-11 Sat 22:15]
3915 #+BEGIN_SRC emacs-lisp
3916 ;(require 'org-checklist)
3920 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
3922 #+BEGIN_SRC emacs-lisp
3923 (use-package cperl-mode
3924 :commands cperl-mode
3927 (defalias 'perl-mode 'cperl-mode)
3928 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
3929 (add-auto-mode 'pod-mode "\\.pod$")
3930 (add-auto-mode 'tt-mode "\\.tt$")
3931 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
3932 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
3933 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
3937 (setq cperl-invalid-face nil
3938 cperl-close-paren-offset -4
3939 cperl-continued-statement-offset 0
3940 cperl-indent-level 4
3941 cperl-indent-parens-as-block t
3943 cperl-electric-keywords t
3944 cperl-electric-lbrace-space t
3945 cperl-electric-parens nil
3946 cperl-highlight-variables-indiscriminately t
3947 cperl-imenu-addback t
3948 cperl-invalid-face (quote underline)
3949 cperl-lazy-help-time 5
3950 cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$"
3951 cperl-syntaxify-by-font-lock t
3952 cperl-use-syntax-table-text-property-for-tags t)
3954 ;; And have cperl mode give ElDoc a useful string
3955 (defun my-cperl-eldoc-documentation-function ()
3956 "Return meaningful doc string for `eldoc-mode'."
3958 (let ((cperl-message-on-help-error nil))
3960 (add-hook 'cperl-mode-hook
3962 (set (make-local-variable 'eldoc-documentation-function)
3963 'my-cperl-eldoc-documentation-function)
3968 [2014-05-22 Thu 00:05]
3969 #+BEGIN_SRC emacs-lisp
3970 (use-package puppet-mode
3971 :mode ("\\.pp\\'" . puppet-mode)
3972 :commands puppet-mode
3975 (defun my-puppet-mode-hook ()
3976 (setq require-final-newline nil))
3977 (add-hook 'puppet-mode-hook 'my-puppet-mode-hook))
3980 (use-package puppet-ext
3983 (bind-key "C-x ?" 'puppet-set-anchor puppet-mode-map)
3984 (bind-key "C-c C-r" 'puppet-create-require puppet-mode-map)))))
3988 Use elpy for the emacs python fun, but dont let it initialize all the
3989 various variables. Elpy author may like them, but I'm not him...
3990 #+BEGIN_SRC emacs-lisp
3993 :mode ("\.py" . python-mode)
3996 (safe-load (concat jj-elisp-dir "/elpy/elpy-autoloads.el"))
4003 :commands (nosetests-all nosetests-module nosetests-one
4004 nosetests-failed nosetests-pdb-all
4005 nosetests-pdb-module nosetests-pdb-one)
4010 :commands (pyvenv-activate pyvenv-deactivate pyvenv-mode pyvenv-restart-python)
4013 (use-package idomenu
4018 (use-package highlight-indentation
4020 :commands (highlight-indentation-mode))
4022 (use-package find-file-in-project
4024 :commands (find-file-in-project ffip-project-files ffip ))
4029 ;; Local variables in `python-mode'. This is not removed when Elpy
4030 ;; is disabled, which can cause some confusion.
4031 (add-hook 'python-mode-hook 'elpy-initialize-local-variables)
4033 (defun my-python-mode-hook ()
4034 (setq require-final-newline nil)
4035 (setq mode-require-final-newline))
4036 (add-hook 'python-mode-hook 'my-python-mode-hook)
4038 ;; Flymake support using flake8, including warning faces.
4039 (when (and (executable-find "flake8")
4040 (not (executable-find python-check-command)))
4041 (setq python-check-command "flake8"))
4043 ;; `flymake-no-changes-timeout': The original value of 0.5 is too
4044 ;; short for Python code, as that will result in the current line to
4045 ;; be highlighted most of the time, and that's annoying. This value
4046 ;; might be on the long side, but at least it does not, in general,
4047 ;; interfere with normal interaction.
4048 (setq flymake-no-changes-timeout 60)
4050 ;; `flymake-start-syntax-check-on-newline': This should be nil for
4051 ;; Python, as;; most lines with a colon at the end will mean the next
4052 ;; line is always highlighted as error, which is not helpful and
4054 (setq flymake-start-syntax-check-on-newline nil)
4056 ;; `ac-auto-show-menu': Short timeout because the menu is great.
4057 (setq ac-auto-show-menu 0.4)
4059 ;; `ac-quick-help-delay': I'd like to show the menu right with the
4060 ;; completions, but this value should be greater than
4061 ;; `ac-auto-show-menu' to show help for the first entry as well.
4062 (setq ac-quick-help-delay 0.5)
4064 ;; `yas-trigger-key': TAB, as is the default, conflicts with the
4065 ;; autocompletion. We also need to tell yasnippet about the new
4066 ;; binding. This is a bad interface to set the trigger key. Stop
4068 (let ((old (when (boundp 'yas-trigger-key)
4070 (setq yas-trigger-key "C-c C-i")
4071 (when (fboundp 'yas--trigger-key-reload)
4072 (yas--trigger-key-reload old)))
4074 ;; yas-snippet-dirs can be a string for a single directory. Make
4075 ;; sure it's a list in that case so we can add our own entry.
4076 (when (not (listp yas-snippet-dirs))
4077 (setq yas-snippet-dirs (list yas-snippet-dirs)))
4078 (add-to-list 'yas-snippet-dirs
4079 (concat (file-name-directory (locate-library "elpy"))
4083 ;; Now load yasnippets.
4086 (elpy-use-ipython)))
4091 #+BEGIN_SRC emacs-lisp :tangle no
4092 (autoload 'python-mode "python-mode" "Python Mode." t)
4093 (add-auto-mode 'python-mode "\\.py\\'")
4094 (add-auto-mode 'python-mode "\\.py$")
4095 (add-auto-mode 'python-mode "SConstruct\\'")
4096 (add-auto-mode 'python-mode "SConscript\\'")
4097 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
4100 (set-variable 'py-indent-offset 4)
4101 (set-variable 'py-smart-indentation nil)
4102 (set-variable 'indent-tabs-mode nil)
4103 (define-key python-mode-map "\C-m" 'newline-and-indent)
4104 (turn-on-eldoc-mode)
4105 (defun python-auto-fill-comments-only ()
4107 (set (make-local-variable 'fill-nobreak-predicate)
4109 (not (python-in-string/comment)))))
4110 (add-hook 'python-mode-hook
4112 (python-auto-fill-comments-only)))
4114 (autoload 'pymacs-apply "pymacs")
4115 (autoload 'pymacs-call "pymacs")
4116 (autoload 'pymacs-eval "pymacs" nil t)
4117 (autoload 'pymacs-exec "pymacs" nil t)
4118 (autoload 'pymacs-load "pymacs" nil t))
4121 If an =ipython= executable is on the path, then assume that IPython is
4122 the preferred method python evaluation.
4123 #+BEGIN_SRC emacs-lisp :tangle no
4124 (when (executable-find "ipython")
4126 (setq org-babel-python-mode 'python-mode))
4128 (setq python-shell-interpreter "ipython")
4129 (setq python-shell-interpreter-args "")
4130 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
4131 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
4132 (setq python-shell-completion-setup-code
4133 "from IPython.core.completerlib import module_completion")
4134 (setq python-shell-completion-module-string-code
4135 "';'.join(module_completion('''%s'''))\n")
4136 (setq python-shell-completion-string-code
4137 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
4139 ** rainbow-delimiters
4140 [2013-04-09 Di 23:38]
4141 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
4142 which highlights parens, brackets, and braces according to their
4143 depth. Each successive level is highlighted a different color. This
4144 makes it easy to spot matching delimiters, orient yourself in the code,
4145 and tell which statements are at the same depth.
4146 #+BEGIN_SRC emacs-lisp
4147 (use-package rainbow-delimiters
4148 :ensure rainbow-delimiters
4149 :commands rainbow-delimiters-mode
4151 (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
4154 #+BEGIN_SRC emacs-lisp
4155 (use-package rainbow-mode
4156 :ensure rainbow-mode
4158 :diminish rainbow-mode)
4163 #+BEGIN_SRC emacs-lisp
4164 (use-package re-builder
4165 :commands re-builder
4168 (setq reb-re-syntax 'string))
4171 [2014-05-19 Mo 22:56]
4172 Recentf is a minor mode that builds a list of recently opened
4173 files. This list is is automatically saved across Emacs sessions.
4174 #+BEGIN_SRC emacs-lisp
4175 (use-package recentf
4176 :if (not noninteractive)
4177 :bind ("C-x C-r" . recentf-open-files)
4182 (setq recentf-max-menu-items 25)
4183 (setq recentf-save-file (expand-file-name ".recentf" jj-cache-dir))
4185 (defun recentf-add-dired-directory ()
4186 (if (and dired-directory
4187 (file-directory-p dired-directory)
4188 (not (string= "/" dired-directory)))
4189 (let ((last-idx (1- (length dired-directory))))
4191 (if (= ?/ (aref dired-directory last-idx))
4192 (substring dired-directory 0 last-idx)
4193 dired-directory)))))
4195 (add-hook 'dired-mode-hook 'recentf-add-dired-directory)))
4197 ** Region bindings mode
4198 [2013-05-01 Wed 22:51]
4199 This mode allows to have keybindings that are only alive when the
4200 region is active. Helpful for things that only do any useful action
4201 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
4202 #+BEGIN_SRC emacs-lisp
4203 (use-package region-bindings-mode
4204 :ensure region-bindings-mode
4206 (region-bindings-mode-enable))