1 #+TITLE: emacs.org - Ganneffs emacs configuration
2 #+DESCRIPTION: My current Emacs configuration
3 #+KEYWORDS: org-mode Emacs configuration
4 #+STARTUP: align fold nodlcheck hidestars oddeven lognotestate
5 #+SETUPFILE: ~/.emacs.d/elisp/org-templates/level-0.org
11 :ID: b6e6cf73-9802-4a7b-bd65-fdb6f9745319
13 The following functions are used throughout my config, and so I load
16 safe-load does not break emacs initialization, should a file be
17 unreadable while emacs boots up.
18 #+BEGIN_SRC emacs-lisp :tangle yes
19 (defvar safe-load-error-list ""
20 "*List of files that reported errors when loaded via safe-load")
22 (defun safe-load (file &optional noerror nomessage nosuffix)
23 "Load a file. If error on load, report back, wait for
24 a key stroke then continue on"
26 (condition-case nil (load file noerror nomessage nosuffix)
29 (setq safe-load-error-list (concat safe-load-error-list " " file))
30 (message "****** [Return to continue] Error loading %s" safe-load-error-list )
34 (defun safe-load-check ()
35 "Check for any previous safe-load loading errors. (safe-load.el)"
37 (if (string-equal safe-load-error-list "") ()
38 (message (concat "****** error loading: " safe-load-error-list))))
41 I have some stuff put away in my local dir. I don't want to load it all
42 at startup time, so it is using the autoload feature. For that to work
43 load the loaddefs, so autoload knows where to grab stuff
44 #+BEGIN_SRC emacs-lisp :tangle yes
45 (safe-load (concat jj-elisp-dir "/tiny/loaddefs.el"))
46 (safe-load (concat jj-elisp-local-dir "/loaddefs.el"))
48 *** Keep *scratch* around
49 Always ensure to have a scratch buffer around.
50 #+BEGIN_SRC emacs-lisp :tangle yes
51 (with-current-buffer (get-buffer-create "*scratch*")
52 (lisp-interaction-mode)
53 (make-local-variable 'kill-buffer-query-functions)
54 (add-hook 'kill-buffer-query-functions 'kill-scratch-buffer))
57 Handier way to add modes to auto-mode-alist
58 #+BEGIN_SRC emacs-lisp :tangle yes
59 (defun add-auto-mode (mode &rest patterns)
60 "Add entries to `auto-mode-alist' to use `MODE' for all given file `PATTERNS'."
61 (dolist (pattern patterns)
62 (add-to-list 'auto-mode-alist (cons pattern mode))))
64 *** config helpers use-package/bind-key
65 Helpers for the config
66 https://github.com/jwiegley/use-package
67 #+BEGIN_SRC emacs-lisp :tangle yes
68 (require 'use-package)
72 [2014-05-20 Tue 22:36]
73 #+BEGIN_SRC emacs-lisp :tangle yes
74 (defmacro hook-into-modes (func modes)
75 `(dolist (mode-hook ,modes)
76 (add-hook mode-hook ,func)))
80 The Emacs Lisp Package Archive contains things I want.
81 #+BEGIN_SRC emacs-lisp :tangle yes
82 (when (> emacs-major-version 23)
84 (setq package-user-dir (expand-file-name "elpa" jj-elisp-dir))
85 (dolist (source '(("melpa" . "http://melpa.org/packages/")
86 ("melpa-stable" . "http://stable.melpa.org/packages/")
87 ("marmalade" . "http://marmalade-repo.org/packages/")
88 ("elpy" . "http://jorgenschaefer.github.io/packages/")
89 ("elpa" . "http://elpa.gnu.org/packages/")
91 (add-to-list 'package-archives source t))
98 We need to define the load-path. As I have lots of things I add
99 locally, its getting a few entries. I disliked the repeated
100 /add-to-list/ lines, so I now just take all subdirectories of
101 jj-elisp-dir and add them.
103 Additionally I also ensure that files in there are recompiled, when
105 #+BEGIN_SRC emacs-lisp :tangle yes
107 (project (directory-files jj-elisp-dir t "\\w+"))
108 (when (file-directory-p project)
109 (if (string= project "emacs23")
110 (when (version< emacs-version "24")
111 (add-to-list 'load-path project))
112 (add-to-list 'load-path project))
113 ;(byte-recompile-directory project 0)
118 Help emacs to find the info files
119 #+BEGIN_SRC emacs-lisp :tangle no
120 (setq Info-directory-list '("~/.emacs.d/info"
121 "/usr/local/share/info/"
123 "/usr/local/gnu/info/"
124 "/usr/local/gnu/lib/info/"
125 "/usr/local/gnu/lib/emacs/info/"
126 "/usr/local/emacs/info/"
127 "/usr/local/lib/info/"
128 "/usr/local/lib/emacs/info/"
129 "/usr/share/info/emacs-23"
132 (setq Info-default-directory-list
133 (cons "~/.emacs.d/info" Info-default-directory-list))
139 :ID: 0a1560d9-7e55-47ab-be52-b3a8b8eea4aa
141 I dislike the startup message
142 #+BEGIN_SRC emacs-lisp :tangle yes
143 (setq inhibit-splash-screen t)
144 (setq inhibit-startup-message t)
147 Usually I want the lines to break at 72 characters.
148 #+BEGIN_SRC emacs-lisp :tangle yes
149 (setq fill-column 72)
152 And it is nice to have a final newline in files.
153 (Now off, ethan-wspace is doing it better).
154 #+BEGIN_SRC emacs-lisp :tangle yes
155 (setq require-final-newline nil)
156 (setq mode-require-final-newline nil)
159 After I typed 300 characters or took a break for more than a minute it
160 would be nice of emacs to save whatever I am on in one of its auto-save
161 backups. See [[info:emacs#Auto%20Save%20Control][info:emacs#Auto Save Control]] for more details.
162 #+BEGIN_SRC emacs-lisp :tangle yes
163 (setq auto-save-interval 300)
164 (setq auto-save-timeout 60)
167 Set my full name and my default mail address - for whatever wants to use
168 it later. Also, I am using gnus.
169 #+BEGIN_SRC emacs-lisp :tangle yes
170 (setq user-full-name "Joerg Jaspert")
171 (setq user-mail-address "joerg@ganneff.de")
172 (setq mail-user-agent (quote gnus-user-agent))
175 My default mail server. Well, simply a localhost, I have a forwarder that
176 puts mail off the right way, no need for emacs to have any further
178 #+BEGIN_SRC emacs-lisp :tangle yes
179 (setq smtpmail-default-smtp-server "localhost")
180 (setq smtpmail-smtp-server "localhost")
183 Enable automatic handling of compressed files.
184 #+BEGIN_SRC emacs-lisp :tangle yes
185 (auto-compression-mode 1)
188 Emacs forbids a certain set of commands, as they can be very confusing
189 for new users. Enable them.
190 #+BEGIN_SRC emacs-lisp :tangle yes
191 (put 'narrow-to-region 'disabled nil)
192 (put 'narrow-to-page 'disabled nil)
193 (put 'narrow-to-defun 'disabled nil)
194 (put 'upcase-region 'disabled nil)
195 (put 'downcase-region 'disabled nil)
199 I've tried various different fonts and while I like the Terminus font
200 most for my shells, in Emacs Inconsolata clearly wins.
201 #+BEGIN_SRC emacs-lisp :tangle yes
202 (set-frame-font "Inconsolata-14")
205 I always use dark backgrounds, so tell Emacs about it. No need to
207 #+BEGIN_SRC emacs-lisp :tangle yes
208 (setq-default frame-background-mode jj-color-style)
211 And I always liked dark backgrounds with colors setup for them. So I
212 switched through multiple themes doing it in emacs too, but never
213 entirely liked it. Until I found solarized, which is now not only my
214 emacs theme, but also for most of my other software too, especially my
215 shell. Consistent look is great.
216 #+BEGIN_SRC emacs-lisp :tangle no
217 (if (or (> emacs-major-version 23) (boundp 'custom-theme-load-path))
219 (defun jj-init-theme ()
221 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
222 (load-theme 'solarized-light t))
223 (set-face-attribute 'org-date nil :underline nil)
224 (message "Initializing theme solarized-dark")
226 (add-to-list 'custom-theme-load-path jj-theme-dir)
227 (add-hook 'after-init-hook 'jj-init-theme)
229 (add-to-list 'load-path (expand-file-name "emacs-color-theme-solarized" jj-elisp-dir))
230 (require 'color-theme-solarized)
231 (color-theme-solarized-dark)
234 #+BEGIN_SRC emacs-lisp :tangle yes
235 (use-package solarized
236 :load-path "elisp/emacs-color-theme-solarized"
239 (defun jj-init-theme ()
241 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
242 (load-theme 'solarized-light t))
243 (set-face-attribute 'org-date nil :underline nil)
244 (message "Initializing theme solarized-dark")
246 (add-to-list 'custom-theme-load-path jj-theme-dir)
247 (add-hook 'after-init-hook 'jj-init-theme)
251 Make the fringe (gutter) smaller, the argument is a width in pixels (the default is 8)
252 #+BEGIN_SRC emacs-lisp :tangle yes
253 (if (fboundp 'fringe-mode)
257 A bit more spacing between buffer lines
258 #+BEGIN_SRC emacs-lisp :tangle yes
259 (setq-default line-spacing 0.1)
262 [2013-04-21 So 20:54]
263 I do not want my cursor to blink.
264 #+BEGIN_SRC emacs-lisp :tangle yes
265 (blink-cursor-mode -1)
267 *** Menu, Tool and Scrollbar
268 I don't want to see the menu-bar, tool-bar or scrollbar.
269 #+BEGIN_SRC emacs-lisp :tangle yes
271 (dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode))
272 (when (fboundp mode) (funcall mode -1))))
274 **** When using emacs in daemon mode
275 Emacs has a very nice mode where it detaches itself and runs as daemon -
276 and you can just open /frames/ (windows) from it by using [[http://www.emacswiki.org/emacs/EmacsClient][Emacs
277 Client]]. It's fast, it's nice, it's convinient.
279 Except that Emacs behaves stupid when you do that and ignores your
280 menu/tool/scrollbar settings. Sucks.
282 For them to work even then, we have to do two things.
283 1. We have to set the frame alist. We simple set both,
284 =initial-frame-alist= and =default-frame-alist= to the same value here.
285 #+BEGIN_SRC emacs-lisp :tangle yes
286 (setq initial-frame-alist '(
287 (horizontal-scroll-bars . nil)
288 (vertical-scroll-bars . nil)
291 (setq default-frame-alist (copy-alist initial-frame-alist))
293 2. We have to disable the toolbar using the customize interface, so you
294 can find that in the [[id:0102208d-fdf6-4928-9e40-7e341bd3aa3a][Customized variables]] section.
296 *** Hilight current line in buffer
297 As it says, it does a hilight of the current line.
298 #+BEGIN_SRC emacs-lisp :tangle yes
299 (global-hl-line-mode +1)
301 *** Allow recursive minibuffers
302 This allows (additional) minibuffer commands while in the minibuffer.
303 #+BEGIN_SRC emacs-lisp :tangle yes
304 (setq enable-recursive-minibuffers 't)
307 *** Modeline related changes
308 I want to see line and column numbers, so turn them on.
309 Size indication lets me know how far I am in a buffer.
311 And modeline-posn is great. It will hilight the column number in the
312 modeline in red as soon as you are over the defined limit.
315 #+BEGIN_SRC emacs-lisp :tangle yes
317 (column-number-mode 1)
318 (size-indication-mode 1)
319 (display-time-mode 1)
320 (setq display-time-day-and-date nil)
321 (setq display-time-default-load-average nil)
322 (setq display-time-24hr-format t)
323 (setq modelinepos-column-limit 72)
325 (use-package modeline-posn
326 :ensure modeline-posn
329 (set-face-foreground 'modelinepos-column-warning "grey20")
330 (set-face-background 'modelinepos-column-warning "red")
331 (setq modelinepos-column-limit 72))
336 [2013-04-22 Mon 11:27]
337 The modeline is easily cluttered up with stuff I don't really need to
338 see. So lets hide those. There are two ways, one of them uses diminish
339 to get entirely rid of some modes, the other is a function taken from
340 "Mastering Emacs" which replaces the modes text with an own (set of)
342 #+BEGIN_SRC emacs-lisp :tangle yes
344 (diminish 'auto-fill-function)
345 (defvar mode-line-cleaner-alist
346 `((auto-complete-mode . " α")
347 (yas-minor-mode . " y")
348 (paredit-mode . " π")
352 (lisp-interaction-mode . "λ")
355 (emacs-lisp-mode . "EL")
357 (org-indent-mode . "")
362 "Alist for `clean-mode-line'.
364 When you add a new element to the alist, keep in mind that you
365 must pass the correct minor/major mode symbol and a string you
366 want to use in the modeline *in lieu of* the original.
368 Want some symbols? Go:
370 ;ςερτζθιοπασδφγηξκλυχψωβνμ
371 :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
372 @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
376 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
379 Unfortunately icicles breaks this with the way it adds/removes itself,
380 so take it our for now...
383 Back when I started with text-mode. But nowadays I want default mode to
384 be org-mode - it is just so much better to use. And does sensible things
385 with many README files out there, and various other "crap" you get to
387 #+BEGIN_SRC emacs-lisp :tangle yes
388 (setq major-mode 'org-mode)
389 (setq initial-major-mode 'org-mode)
393 [2013-04-23 Tue 16:43]
394 Shell. zsh in my case.
395 #+BEGIN_SRC emacs-lisp :tangle yes
396 (setq shell-file-name "zsh")
397 (setq shell-command-switch "-c")
398 (setq explicit-shell-file-name shell-file-name)
399 (setenv "SHELL" shell-file-name)
400 (setq explicit-sh-args '("-login" "-i"))
401 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
402 (setq comint-scroll-to-bottom-on-input t) ; always insert at the bottom
403 (setq comint-scroll-to-bottom-on-output t) ; always add output at the bottom
404 (setq comint-scroll-show-maximum-output t) ; scroll to show max possible output
405 (setq comint-completion-autolist t) ; show completion list when ambiguous
406 (setq comint-input-ignoredups t) ; no duplicates in command history
407 (setq comint-completion-addsuffix t) ; insert space/slash after file completion
411 Basic settings for emacs integrated shell
412 #+BEGIN_SRC emacs-lisp :tangle yes
417 (defun eshell-initialize ()
418 (defun eshell-spawn-external-command (beg end)
419 "Parse and expand any history references in current input."
422 (when (looking-back "&!" beg)
423 (delete-region (match-beginning 0) (match-end 0))
426 (add-hook 'eshell-expand-input-functions 'eshell-spawn-external-command)
427 (eval-after-load "em-unix"
429 (unintern 'eshell/su)
430 (unintern 'eshell/sudo))))
431 (add-hook 'eshell-first-time-mode-hook 'eshell-initialize)
440 (setq eshell-cmpl-cycle-completions nil
441 eshell-save-history-on-exit t
442 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
443 (setenv "PAGER" "cat")
444 (setq eshell-visual-commands
445 '("less" "tmux" "htop" "top" "bash" "zsh" "tail"))
446 (setq eshell-visual-subcommands
447 '(("git" "log" "l" "diff" "show")))
449 (add-to-list 'eshell-command-completions-alist
451 (add-to-list 'eshell-command-completions-alist
452 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
454 ;(set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
455 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
456 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
457 (add-hook 'eshell-preoutput-filter-functions
458 'ansi-color-filter-apply)
459 ;; Prompt with a bit of help from http://www.emacswiki.org/emacs/EshellPrompt
461 (defmacro with-face (str &rest properties)
462 `(propertize ,str 'face (list ,@properties)))
464 (defun eshell/abbr-pwd ()
465 (let ((home (getenv "HOME"))
468 ((string-equal home path) "~")
469 ((f-ancestor-of? home path) (concat "~/" (f-relative path home)))
472 (defun eshell/my-prompt ()
473 (let ((header-bg "#161616"))
475 (with-face user-login-name :foreground "cyan")
476 (with-face (concat "@" hostname) :foreground "white")
478 (with-face (eshell/abbr-pwd) :foreground "#009900")
480 (with-face "#" :foreground "red")
481 (with-face "$" :foreground "#69b7f0"))
484 (setq eshell-prompt-function 'eshell/my-prompt)
485 (setq eshell-highlight-prompt nil)
486 (setq eshell-prompt-regexp "^[^#$\n]+[#$] ")))
490 Incremental search is great, but annoyingly you need to type whatever
491 you want. If you want to search for just the next (or previous)
492 occurence of what is at your cursor position use the following.
493 *C-x* will insert the current word while *M-up* and *M-down* will just
494 jump to the next/previous occurence of it.
495 #+BEGIN_SRC emacs-lisp :tangle yes
496 (bind-key "C-x" 'sacha/isearch-yank-current-word isearch-mode-map)
497 (bind-key* "<M-up>" 'sacha/search-word-backward)
498 (bind-key* "<M-down>" 'sacha/search-word-forward)
501 *** Frame configuration
502 I want to see the buffername and its size, not the host I am on in my
504 #+BEGIN_SRC emacs-lisp :tangle yes
505 (setq frame-title-format "%b (%i)")
508 *** Protect some buffers
509 I don't want some buffers to be killed, **scratch** for example.
510 In the past I had a long function that just recreated them, but the
511 =keep-buffers= package is easier.
512 #+BEGIN_SRC emacs-lisp :tangle yes
513 (use-package keep-buffers
516 (keep-buffers-mode 1)
517 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
518 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
519 (push '("\\`*Group" . nil) keep-buffers-protected-alist)
524 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
526 #+BEGIN_SRC emacs-lisp :tangle yes
527 (defalias 'yes-or-no-p 'y-or-n-p)
530 *** Language/i18n stuff
531 In this day and age, UTF-8 is the way to go.
532 #+BEGIN_SRC emacs-lisp :tangle yes
533 (set-language-environment 'utf-8)
534 (set-default-coding-systems 'utf-8)
535 (set-terminal-coding-system 'utf-8)
536 (set-keyboard-coding-system 'utf-8)
537 (set-clipboard-coding-system 'utf-8)
538 (prefer-coding-system 'utf-8)
539 (set-charset-priority 'unicode)
540 (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
543 *** Hilight matching parentheses
544 While I do have the nifty shortcut to jump to the other parentheses,
545 hilighting them makes it obvious where they are.
546 #+BEGIN_SRC emacs-lisp :tangle yes
548 (use-package mic-paren
556 (setq show-paren-style 'parenthesis)
561 *** Kill other buffers
562 While many editors allow you to close "all the other files, not the one
563 you are in", emacs doesn't have this... Except, now it will.
564 (Update 30.05.2014: Not used ever, deactivated)
565 #+BEGIN_SRC emacs-lisp :tangle no
566 (bind-key "C-c k" 'prelude-kill-other-buffers)
569 Default scrolling behaviour in emacs is a bit annoying, who wants to
571 #+BEGIN_SRC emacs-lisp :tangle yes
572 (setq scroll-margin 0)
573 (setq scroll-conservatively 100000)
574 (setq scroll-up-aggressively 0.0)
575 (setq scroll-down-aggressively 0.0)
576 (setq scroll-preserve-screen-position t)
579 *** Copy/Paste with X
580 [2013-04-09 Di 23:31]
581 The default how emacs handles cutting/pasting with the primary selection
582 changed in emacs24. I am used to the old way, so get it back.
583 #+BEGIN_SRC emacs-lisp :tangle yes
584 (setq x-select-enable-primary t)
585 (setq x-select-enable-clipboard t ;; copy-paste should work ...
586 interprogram-paste-function ;; ...with...
587 'x-cut-buffer-or-selection-value) ;; ...other X clients
591 *** Global keyboard changes not directly related to a mode
592 Disable /suspend_frame/ function, I dislike it.
593 #+BEGIN_SRC emacs-lisp :tangle yes
595 (unbind-key "C-x C-z")
598 http://endlessparentheses.com/kill-entire-line-with-prefix-argument.html?source=rss
599 #+BEGIN_SRC emacs-lisp :tangle yes
600 (defmacro bol-with-prefix (function)
601 "Define a new function which calls FUNCTION.
602 Except it moves to beginning of line before calling FUNCTION when
603 called with a prefix argument. The FUNCTION still receives the
605 (let ((name (intern (format "endless/%s-BOL" function))))
609 "Call `%s', but move to BOL when called with a prefix argument."
614 (call-interactively ',function))
617 (global-set-key [remap paredit-kill] (bol-with-prefix paredit-kill))
618 (global-set-key [remap org-kill-line] (bol-with-prefix org-kill-line))
619 (global-set-key [remap kill-line] (bol-with-prefix kill-line))
622 Default of *C-k* is to kill from the point to the end of line. If
623 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
624 set, including newline. But to kill the entire line, one still needs a
625 *C-a* in front of it. So I change it, by defining a function to do just this for
627 #+BEGIN_SRC emacs-lisp :tangle no
628 (defun kill-entire-line ()
629 "Kill this entire line (including newline), regardless of where point is within the line."
633 (back-to-indentation))
635 (bind-key* "C-k" 'kill-entire-line)
636 (global-set-key [remap kill-whole-line] 'kill-entire-line)
639 And the same is true when I'm in org-mode, which has an own kill function...
640 (the keybinding happens later, after org-mode is loaded fully)
641 #+BEGIN_SRC emacs-lisp :tangle no
642 (defun jj-org-kill-line (&optional arg)
643 "Kill the entire line, regardless of where point is within the line, org-mode-version"
647 (back-to-indentation)
651 I really hate tabs, so I don't want any indentation to try using them.
652 And in case a project really needs them, I can change it just for that
653 file/project, but luckily none of those I work in is as broken.
654 #+BEGIN_SRC emacs-lisp :tangle yes
655 (setq-default indent-tabs-mode nil)
658 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
659 #+BEGIN_SRC emacs-lisp :tangle yes
660 (bind-key* "M-5" 'match-paren)
663 Instead of the default "mark-defun" I want a more readline-like setting.
664 #+BEGIN_SRC emacs-lisp :tangle yes
665 (bind-key "C-M-h" 'backward-kill-word)
668 Align whatever with a regexp.
669 #+BEGIN_SRC emacs-lisp :tangle yes
670 (bind-key "C-x \\" 'align-regexp)
674 #+BEGIN_SRC emacs-lisp :tangle yes
675 (bind-key "C-+" 'text-scale-increase)
676 (bind-key "C--" 'text-scale-decrease)
679 Regexes are too useful, so use the regex search by default.
680 #+begin_src emacs-lisp
681 (bind-key "C-s" 'isearch-forward-regexp)
682 (bind-key "C-r" 'isearch-backward-regexp)
683 (bind-key "C-M-s" 'isearch-forward)
684 (bind-key "C-M-r" 'isearch-backward)
687 Rgrep is infinitely useful in multi-file projects.
688 #+begin_src emacs-lisp
689 (bind-key "C-x C-g" 'rgrep)
692 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
694 #+BEGIN_SRC emacs-lisp :tangle yes
695 (bind-key "<M-S-up>" 'move-line-up)
696 (bind-key "<M-S-down>" 'move-line-down)
699 "Pull" lines up, join them
700 #+BEGIN_SRC emacs-lisp :tangle yes
701 (defun join-line-or-lines-in-region ()
702 "Join this line or the lines in the selected region.
703 Joins single lines in reverse order to the default, ie. pulls the next one up."
705 (cond ((region-active-p)
706 (let ((min (line-number-at-pos (region-beginning))))
707 (goto-char (region-end))
708 (while (> (line-number-at-pos) min)
710 (t (let ((current-prefix-arg '(4)))
711 (call-interactively 'join-line)))))
712 (bind-key "M-j" 'join-line-or-lines-in-region)
715 When I press Enter I almost always want to go to the right indentation on the next line.
716 #+BEGIN_SRC emacs-lisp :tangle yes
717 (bind-key "RET" 'newline-and-indent)
720 Easier undo, and i don't need suspend-frame
721 #+BEGIN_SRC emacs-lisp :tangle yes
722 (bind-key "C-z" 'undo)
725 Window switching, go backwards. (C-x o goes to the next window)
726 #+BEGIN_SRC emacs-lisp :tangle yes
727 (bind-key "C-x O" (lambda ()
733 #+BEGIN_SRC emacs-lisp :tangle yes
734 (bind-key "C-x C-r" 'prelude-sudo-edit)
737 M-space is bound to just-one-space, which is great for programming. What
738 it does is remove all spaces around the cursor, except for one. But to
739 be really useful, it also should include newlines. It doesn’t do this by
740 default. Rather, you have to call it with a negative argument. Sure
742 #+BEGIN_SRC emacs-lisp :tangle yes
743 (bind-key "M-SPC" 'just-one-space-with-newline)
746 Count which commands I use how often.
747 #+BEGIN_SRC emacs-lisp :tangle yes
752 (setq keyfreq-file (expand-file-name "keyfreq" jj-cache-dir))
753 (setq keyfreq-file-lock (expand-file-name "keyfreq.lock" jj-cache-dir))
755 (keyfreq-autosave-mode 1)))
758 Duplicate current line
759 #+BEGIN_SRC emacs-lisp :tangle yes
760 (defun duplicate-line ()
761 "Insert a copy of the current line after the current line."
764 (let ((line-text (buffer-substring-no-properties
765 (line-beginning-position)
766 (line-end-position))))
769 (insert line-text))))
771 (bind-key "C-c p" 'duplicate-line)
774 Smarter move to the beginning of the line. That is, it first moves to
775 the beginning of the line - and on second keypress it goes to the
776 first character on line.
777 #+BEGIN_SRC emacs-lisp :tangle yes
778 (defun smarter-move-beginning-of-line (arg)
779 "Move point back to indentation of beginning of line.
781 Move point to the first non-whitespace character on this line.
782 If point is already there, move to the beginning of the line.
783 Effectively toggle between the first non-whitespace character and
784 the beginning of the line.
786 If ARG is not nil or 1, move forward ARG - 1 lines first. If
787 point reaches the beginning or end of the buffer, stop there."
789 (setq arg (or arg 1))
793 (let ((line-move-visual nil))
794 (forward-line (1- arg))))
796 (let ((orig-point (point)))
797 (back-to-indentation)
798 (when (= orig-point (point))
799 (move-beginning-of-line 1))))
801 ;; remap C-a to `smarter-move-beginning-of-line'
802 (global-set-key [remap move-beginning-of-line]
803 'smarter-move-beginning-of-line)
807 Easily copy characters from the previous nonblank line, starting just
808 above point. With a prefix argument, only copy ARG characters (never
809 past EOL), no argument copies rest of line.
810 #+BEGIN_SRC emacs-lisp :tangle yes
812 (bind-key "H-y" 'copy-from-above-command)
815 Open a new X Terminal pointing to the directory of the current
817 #+BEGIN_SRC emacs-lisp :tangle yes
818 (bind-key "H-t" 'jj-open-shell)
822 #+BEGIN_SRC emacs-lisp :tangle yes
823 (bind-key "H-a" 'align-code)
827 #+BEGIN_SRC emacs-lisp :tangle yes
828 (bind-key "C-c d" 'insert-date)
831 Another key for indenting
832 #+BEGIN_SRC emacs-lisp :tangle yes
833 (bind-key "H-i" 'indent-region)
836 Clean all whitespace stuff
837 #+BEGIN_SRC emacs-lisp :tangle yes
838 (bind-key "H-w" 'whitespace-cleanup)
842 #+BEGIN_SRC emacs-lisp :tangle yes
843 (bind-key "H-c" 'comment-dwim)
846 Show keystrokes in progress
847 #+BEGIN_SRC emacs-lisp :tangle yes
848 (setq echo-keystrokes 0.1)
851 Usually you can press the *Ins*ert key, to get into overwrite mode. I
852 don't like that, have broken much with it and so just forbid it by
854 #+BEGIN_SRC emacs-lisp :tangle yes
855 (unbind-key "<insert>")
856 (unbind-key "<kp-insert>")
859 *** Easily navigate sillyCased words
860 #+BEGIN_SRC emacs-lisp :tangle yes
861 (global-subword-mode 1)
863 *** Delete file of current buffer, then kill buffer
864 [2014-06-14 Sat 23:03]
865 #+BEGIN_SRC emacs-lisp :tangle yes
866 (defun delete-current-buffer-file ()
867 "Removes file connected to current buffer and kills buffer."
869 (let ((filename (buffer-file-name))
870 (buffer (current-buffer))
871 (name (buffer-name)))
872 (if (not (and filename (file-exists-p filename)))
874 (when (yes-or-no-p "Are you sure you want to remove this file? ")
875 (delete-file filename)
877 (message "File '%s' successfully removed" filename)))))
879 (global-set-key (kbd "C-x C-k") 'delete-current-buffer-file)
881 *** Rename file of current buffer
882 [2014-06-14 Sat 23:04]
883 #+BEGIN_SRC emacs-lisp :tangle yes
884 (defun rename-current-buffer-file ()
885 "Renames current buffer and file it is visiting."
887 (let ((name (buffer-name))
888 (filename (buffer-file-name)))
889 (if (not (and filename (file-exists-p filename)))
890 (error "Buffer '%s' is not visiting a file!" name)
891 (let ((new-name (read-file-name "New name: " filename)))
892 (if (get-buffer new-name)
893 (error "A buffer named '%s' already exists!" new-name)
894 (rename-file filename new-name 1)
895 (rename-buffer new-name)
896 (set-visited-file-name new-name)
897 (set-buffer-modified-p nil)
898 (message "File '%s' successfully renamed to '%s'"
899 name (file-name-nondirectory new-name)))))))
901 (global-set-key (kbd "C-x C-S-r") 'rename-current-buffer-file)
903 *** Quickly find emacs lisp sources
904 [2014-06-22 Sun 23:05]
905 #+BEGIN_SRC emacs-lisp :tangle yes
906 (bind-key "C-l" 'find-library 'help-command)
907 (bind-key "C-f" 'find-function 'help-command)
908 (bind-key "C-k" 'find-function-on-key 'help-command)
909 (bind-key "C-v" 'find-variable 'help-command)
912 [2015-01-26 Mon 16:01]
913 #+BEGIN_SRC emacs-lisp :tangle yes
914 (bind-key "M-s o" 'occur-dwim)
916 ** Miscellaneous stuff
918 Searches and matches should ignore case.
919 #+BEGIN_SRC emacs-lisp :tangle yes
920 (setq-default case-fold-search t)
923 Which buffers to get rid off at midnight.
924 #+BEGIN_SRC emacs-lisp :tangle yes
925 (setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
926 "*Man " "*Buffer List*"
932 "*magit" "*Calendar")))
935 Don't display a cursor in non-selected windows.
936 #+BEGIN_SRC emacs-lisp :tangle yes
937 (setq-default cursor-in-non-selected-windows nil)
940 What should be displayed in the mode-line for files with those types
942 #+BEGIN_SRC emacs-lisp :tangle yes
943 (setq eol-mnemonic-dos "(DOS)")
944 (setq eol-mnemonic-mac "(Mac)")
947 Much larger threshold for garbage collection prevents it to run too often.
948 #+BEGIN_SRC emacs-lisp :tangle yes
949 (setq gc-cons-threshold 48000000)
952 #+BEGIN_SRC emacs-lisp :tangle yes
953 (setq max-lisp-eval-depth 1000)
954 (setq max-specpdl-size 3000)
958 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
959 #+BEGIN_SRC emacs-lisp :tangle yes
960 (defun unfill-paragraph ()
961 "Takes a multi-line paragraph and makes it into a single line of text."
963 (let ((fill-column (point-max)))
964 (fill-paragraph nil)))
965 (bind-key "H-u" 'unfill-paragraph)
968 #+BEGIN_SRC emacs-lisp :tangle yes
969 (setq-default indicate-empty-lines t)
970 (setq sentence-end-double-space nil)
973 Hilight annotations in comments, like FIXME/TODO/...
974 #+BEGIN_SRC emacs-lisp :tangle yes
975 (add-hook 'prog-mode-hook 'font-lock-comment-annotations)
979 #+BEGIN_SRC emacs-lisp :tangle yes
980 (setq browse-url-browser-function (quote browse-url-generic))
981 (setq browse-url-generic-program "/usr/bin/x-www-browser")
984 *** When saving a script - make it executable
985 #+BEGIN_SRC emacs-lisp :tangle yes
986 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
990 #+BEGIN_SRC emacs-lisp :tangle yes
994 (add-hook 'after-init-hook 'server-start)))
997 ** Customized variables
998 [2013-05-02 Thu 22:14]
999 The following contains a set of variables i may reasonably want to
1000 change on other systems - which don't affect the init file loading
1001 process. So I *can* use the customization interface for it...
1002 #+BEGIN_SRC emacs-lisp :tangle yes
1003 (defgroup ganneff nil
1004 "Modify ganneffs settings"
1005 :group 'environment)
1007 (defgroup ganneff-org-mode nil
1008 "Ganneffs org-mode settings"
1009 :tag "Ganneffs org-mode settings"
1011 :link '(custom-group-link "ganneff"))
1013 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
1014 "ID of the organization task."
1015 :tag "Organization Task ID"
1017 :group 'ganneff-org-mode)
1019 (defcustom org-my-archive-expiry-days 2
1020 "The number of days after which a completed task should be auto-archived.
1021 This can be 0 for immediate, or a floating point value."
1022 :tag "Archive expiry days"
1024 :group 'ganneff-org-mode)
1029 [2013-05-21 Tue 23:22]
1030 Restore removed var alias, used by ruby-electric-brace and others
1031 #+BEGIN_SRC emacs-lisp :tangle yes
1032 (unless (boundp 'last-command-char)
1033 (defvaralias 'last-command-char 'last-command-event))
1035 * Customized variables
1037 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
1039 Of course I want to be able to use the customize interface, and some
1040 things can only be set via it (or so they say). I usually prefer to put
1041 things I keep for a long while into statements somewhere else, not just
1042 custom-set here, but we need it anyways.
1044 #+BEGIN_SRC emacs-lisp :tangle yes
1045 (setq custom-file jj-custom-file)
1046 (safe-load custom-file)
1049 The source of this is:
1050 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
1053 * Extra modes and their configuration
1055 A defined abbrev is a word which expands, if you insert it, into some
1056 different text. Abbrevs are defined by the user to expand in specific
1058 #+BEGIN_SRC emacs-lisp :tangle yes
1060 :commands abbrev-mode
1061 :diminish abbrev-mode
1063 (hook-into-modes #'abbrev-mode '(text-mode-hook))
1066 (setq save-abbrevs 'silently)
1067 (setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
1068 (if (file-exists-p abbrev-file-name)
1069 (quietly-read-abbrev-file))
1071 (add-hook 'expand-load-hook
1073 (add-hook 'expand-expand-hook 'indent-according-to-mode)
1074 (add-hook 'expand-jump-hook 'indent-according-to-mode)))))
1077 [2013-04-28 So 11:26]
1078 Quickly move around in buffers.
1079 #+BEGIN_SRC emacs-lisp :tangle yes
1080 (use-package ace-jump-mode
1081 :ensure ace-jump-mode
1082 :commands ace-jump-mode
1083 :bind ("H-SPC" . ace-jump-mode))
1086 [2013-04-21 So 20:27]
1087 Use H-w to switch windows
1088 #+BEGIN_SRC emacs-lisp :tangle yes
1089 (use-package ace-window
1091 :commands ace-window
1092 :bind ("H-w" . ace-window))
1094 ** aggressive-indent
1095 [2014-10-27 Mon 13:08]
1096 electric-indent-mode is enough to keep your code nicely aligned when
1097 all you do is type. However, once you start shifting blocks around,
1098 transposing lines, or slurping and barfing sexps, indentation is bound
1101 aggressive-indent-mode is a minor mode that keeps your code always
1102 indented. It reindents after every command, making it more reliable
1103 than electric-indent-mode.
1104 #+BEGIN_SRC emacs-lisp :tangle yes
1105 (use-package aggressive-indent
1106 :ensure aggressive-indent
1109 (global-aggressive-indent-mode 0)
1110 (setq aggressive-indent-comments-too 0)
1111 (add-to-list 'aggressive-indent-excluded-modes 'html-mode)
1115 [2014-06-01 Sun 23:02]
1116 #+BEGIN_SRC emacs-lisp :tangle yes
1122 (global-anzu-mode 1))
1125 (setq anzu-search-threshold 1000)
1126 (set-face-attribute 'anzu-mode-line nil :foreground "yellow" :weight 'bold)))
1129 [2014-05-21 Wed 00:33]
1130 #+BEGIN_SRC emacs-lisp :tangle yes
1132 :commands (ascii-on ascii-display ascii-toggle)
1135 (defun ascii-toggle ()
1141 (bind-key "C-c e A" 'ascii-toggle)))
1144 #+BEGIN_SRC emacs-lisp :tangle yes
1145 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
1146 (setq TeX-auto-save t)
1147 (setq TeX-parse-self t)
1148 (setq TeX-PDF-mode t)
1150 ** auto-complete mode
1151 [2013-04-27 Sa 16:33]
1152 And aren't we all lazy? I definitely am, and I like my emacs doing as
1153 much possible work for me as it can.
1154 So here, auto-complete-mode, which lets emacs do this, based on what I
1156 #+BEGIN_SRC emacs-lisp :tangle yes
1157 (use-package auto-complete-config
1158 :ensure auto-complete
1161 (use-package pos-tip
1167 ;; hook AC into completion-at-point
1168 (defun sanityinc/auto-complete-at-point ()
1169 (when (and (not (minibufferp))
1170 (fboundp 'auto-complete-mode)
1173 (defun set-auto-complete-as-completion-at-point-function ()
1174 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
1175 ;; Exclude very large buffers from dabbrev
1176 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
1177 (< (buffer-size other-buffer) (* 1 1024 1024)))
1179 ;; custom keybindings to use tab, enter and up and down arrows
1180 (bind-key "\t" 'ac-expand ac-complete-mode-map)
1181 (bind-key "\r" 'ac-complete ac-complete-mode-map)
1182 (bind-key "M-n" 'ac-next ac-complete-mode-map)
1183 (bind-key "M-p" 'ac-previous ac-complete-mode-map)
1184 (bind-key "C-s" 'ac-isearch ac-completing-map)
1185 (bind-key "M-TAB" 'auto-complete ac-mode-map)
1187 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
1188 (setq ac-use-comphist t)
1189 (setq ac-expand-on-auto-complete nil)
1191 (setq ac-auto-start 3)
1193 (setq ac-menu-height 15)
1194 (setq ac-quick-help-delay 0.5)
1195 (setq ac-use-fuzzy t)
1197 (ac-flyspell-workaround)
1199 ;; use 't when auto-complete is disabled
1200 (setq tab-always-indent 'complete)
1201 (add-to-list 'completion-styles 'initials t)
1203 ;; Use space and punctuation to accept the current the most likely completion.
1204 (setq auto-completion-syntax-alist (quote (global accept . word)))
1205 ;; Avoid completion for short trivial words.
1206 (setq auto-completion-min-chars (quote (global . 3)))
1207 (setq completion-use-dynamic t)
1209 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
1211 ;; Exclude very large buffers from dabbrev
1212 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
1214 (use-package ac-dabbrev
1217 (set-default 'ac-sources
1219 ac-source-dictionary
1220 ac-source-words-in-buffer
1221 ac-source-words-in-same-mode-buffers
1222 ; ac-source-words-in-all-buffer
1225 (dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
1226 sass-mode yaml-mode csv-mode espresso-mode haskell-mode
1227 html-mode nxml-mode sh-mode smarty-mode clojure-mode
1228 lisp-mode textile-mode markdown-mode tuareg-mode python-mode
1229 js3-mode css-mode less-css-mode sql-mode ielm-mode))
1230 (add-to-list 'ac-modes mode))
1232 (add-hook 'latex-mode-hook 'auto-complete-mode)
1233 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
1234 (add-hook 'prog-mode-hook 'auto-complete-mode)
1235 (add-hook 'org-mode-hook 'auto-complete-mode)))
1240 When files change outside emacs for whatever reason I want emacs to deal
1241 with it. Not to have to revert buffers myself
1242 #+BEGIN_SRC emacs-lisp :tangle yes
1243 (use-package autorevert
1244 :commands auto-revert-mode
1245 :diminish auto-revert-mode
1248 (setq global-auto-revert-mode t)
1249 (setq global-auto-revert-non-file-buffers t)
1250 (global-auto-revert-mode)))
1254 Emacs should keep backup copies of files I edit, but I do not want them
1255 to clutter up the filesystem everywhere. So I put them into one defined
1256 place, backup-directory, which even contains my username (for systems
1257 where =temporary-file-directory= is not inside my home).
1258 #+BEGIN_SRC emacs-lisp :tangle yes
1259 (use-package backups-mode
1260 :load-path "elisp/backups-mode"
1261 :bind (("\C-cv" . save-version)
1262 ("\C-cb" . list-backups)
1263 ("\C-ck" . kill-buffer-prompt)
1264 ("\C-cw" . backup-walker-start))
1267 (setq backup-directory jj-backup-directory)
1268 ;(setq tramp-backup-directory (concat jj-backup-directory "/tramp"))
1269 ;(if (not (file-exists-p tramp-backup-directory))
1270 ; (make-directory tramp-backup-directory))
1271 ;(setq tramp-backup-directory-alist `((".*" . ,tramp-backup-directory)))
1272 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
1273 (setq auto-save-list-file-prefix (concat jj-backup-directory ".auto-saves-"))
1274 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
1276 (setq version-control t) ;; Use version numbers for backups
1277 (setq kept-new-versions 10) ;; Number of newest versions to keep
1278 (setq kept-old-versions 2) ;; Number of oldest versions to keep
1279 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
1280 (setq backup-by-copying t)
1281 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
1282 (setq make-backup-files t)
1284 (defadvice kill-buffer (around kill-buffer)
1285 "Always save before killing a file buffer"
1286 (when (and (buffer-modified-p)
1288 (file-exists-p (buffer-file-name)))
1291 (ad-activate 'kill-buffer)
1293 (defadvice save-buffers-kill-emacs (around save-buffers-kill-emacs)
1294 "Always save before killing emacs"
1295 (save-some-buffers t)
1297 (ad-activate 'save-buffers-kill-emacs)
1299 (defun kill-buffer-prompt ()
1300 "Allows one to kill a buffer without saving it.
1301 This is necessary since once you start backups-mode all file based buffers
1302 are saved automatically when they are killed"
1304 (if (and (buffer-modified-p) (buffer-file-name) (file-exists-p (buffer-file-name)) (y-or-n-p "Save buffer?"))
1306 (set-buffer-modified-p nil))
1309 (setq backup-enable-predicate
1311 (and (normal-backup-enable-predicate name)
1313 (let ((method (file-remote-p name 'method)))
1314 (when (stringp method)
1315 (member method '("su" "sudo"))))))))))
1319 [2014-12-11 Thu 11:31]
1320 #+BEGIN_SRC emacs-lisp :tangle yes
1321 (use-package browse-kill-ring
1322 :commands (browse-kill-ring browse-kill-ring-mode)
1323 :bind ("M-y" . browse-kill-ring)
1327 [2014-06-10 Tue 22:20]
1328 #+BEGIN_SRC emacs-lisp :tangle yes
1330 :commands (cal/insert)
1331 :bind ("C-c c" . cal/insert))
1334 Weeks start on Monday, not sunday.
1335 #+BEGIN_SRC emacs-lisp :tangle yes
1336 (setq calendar-week-start-day 1)
1339 Display ISO week numbers in Calendar Mode
1340 #+BEGIN_SRC emacs-lisp :tangle yes
1341 (copy-face font-lock-constant-face 'calendar-iso-week-face)
1342 (set-face-attribute 'calendar-iso-week-face nil
1344 (setq calendar-intermonth-text
1348 (calendar-iso-from-absolute
1349 (calendar-absolute-from-gregorian (list month day year)))))
1350 'font-lock-face 'calendar-iso-week-face))
1351 (copy-face 'default 'calendar-iso-week-header-face)
1352 (set-face-attribute 'calendar-iso-week-header-face nil
1354 (setq calendar-intermonth-header
1355 (propertize "Wk" ; or e.g. "KW" in Germany
1356 'font-lock-face 'calendar-iso-week-header-face))
1360 [2013-05-21 Tue 23:18]
1361 #+BEGIN_SRC emacs-lisp :tangle yes
1362 (use-package crontab-mode
1363 :ensure crontab-mode
1364 :commands crontab-mode
1365 :mode ("\\.?cron\\(tab\\)?\\'" . crontab-mode))
1369 web-mode takes over, see [[*web-mode][web-mode]]
1370 #+BEGIN_SRC emacs-lisp :tangle no
1371 (use-package css-mode
1372 :mode ("\\.css\\'" . css-mode)
1377 (use-package flymake-css
1381 (defun maybe-flymake-css-load ()
1382 "Activate flymake-css as necessary, but not in derived modes."
1383 (when (eq major-mode 'css-mode)
1384 (flymake-css-load)))
1385 (add-hook 'css-mode-hook 'maybe-flymake-css-load)))
1386 ;;; Auto-complete CSS keywords
1387 (eval-after-load 'auto-complete
1389 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
1390 (add-hook hook 'ac-css-mode-setup))))))
1394 I know that this lets it look "more like windows", but I don't much care
1395 about its paste/copy/cut keybindings, the really nice part is the great
1396 support for rectangular regions, which I started to use a lot since I
1397 know this mode. The normal keybindings for those are just to useless.
1398 #+BEGIN_SRC emacs-lisp :tangle yes
1400 (setq cua-enable-cua-keys (quote shift))
1403 Luckily cua-mode easily supports this, with the following line I just
1404 get the CUA selection and rectangle stuff, not the keybindings. Yes,
1405 even though the above =cua-enable-cua-keys= setting would only enable
1406 them if the selection is done when the region was marked with a shifted
1408 #+BEGIN_SRC emacs-lisp :tangle yes
1409 (cua-selection-mode t)
1413 #+BEGIN_SRC emacs-lisp :tangle yes
1414 (require 'dpkg-dev-el-loaddefs nil 'noerror)
1415 (require 'debian-el-loaddefs nil 'noerror)
1417 (setq debian-changelog-full-name "Joerg Jaspert")
1418 (setq debian-changelog-mailing-address "joerg@debian.org")
1422 #+BEGIN_SRC emacs-lisp :tangle yes
1423 (use-package diff-mode
1425 :mode (("\\.diff" . diff-mode))
1427 (use-package diff-mode-))
1432 #+BEGIN_SRC emacs-lisp :tangle yes
1434 :commands (dired dired-other-window dired-other-frame dired-noselect
1435 dired-mode dired-jump)
1440 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
1441 (setq dired-dwim-target t)
1442 (setq dired-listing-switches "-alh")
1443 (setq dired-recursive-copies (quote top))
1444 (setq dired-recursive-deletes (quote top))
1445 (bind-key "F" 'find-name-dired dired-mode-map)
1447 (defvar mark-files-cache (make-hash-table :test #'equal))
1449 (defun mark-similar-versions (name)
1451 (if (string-match "^\\(.+?\\)-[0-9._-]+$" pat)
1452 (setq pat (match-string 1 pat)))
1453 (or (gethash pat mark-files-cache)
1454 (ignore (puthash pat t mark-files-cache)))))
1456 (defun dired-mark-similar-version ()
1458 (setq mark-files-cache (make-hash-table :test #'equal))
1459 (dired-mark-sexp '(mark-similar-versions name)))
1463 :init (setq diredp-hide-details-initially-flag nil))
1465 (use-package dired-x)
1466 (setq dired-guess-shell-alist-user
1467 '(("\\.pdf\\'" "mupdf" "evince")
1468 ("\\.\\(?:djvu\\|eps\\)\\'" "evince")
1469 ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "eog")
1470 ("\\.\\(?:xcf\\)\\'" "gimp")
1471 ("\\.csv\\'" "libreoffice")
1472 ("\\.tex\\'" "pdflatex" "latex")
1473 ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\)\\(?:\\.part\\)?\\'" "vlc")
1474 ("\\.html?\\'" "conkeror")))
1476 (use-package dired-single
1477 :ensure dired-single
1480 (bind-key "<return>" 'dired-single-buffer dired-mode-map)
1481 (bind-key "<mouse-1>" 'dired-single-buffer-mouse dired-mode-map)
1484 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
1490 (setq wdired-allow-to-change-permissions t)
1491 (bind-key "r" 'wdired-change-to-wdired-mode dired-mode-map)))
1493 (use-package gnus-dired
1494 :commands (gnus-dired-attach gnus-dired-mode)
1497 ;;(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
1498 (bind-key "a" 'gnus-dired-attach dired-mode-map)))
1500 (defun dired-package-initialize ()
1501 (unless (featurep 'runner)
1502 (use-package dired-x)
1506 (bind-key "M-!" 'async-shell-command dired-mode-map)
1507 (unbind-key "M-s f" dired-mode-map)
1509 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1510 "Make sure to remove \"Omit\" from the modeline."
1511 (diminish 'dired-omit-mode) dired-mode-map)
1513 ;; Omit files that Git would ignore
1514 (defun dired-omit-regexp ()
1515 (let ((file (expand-file-name ".git"))
1517 (while (and (not (file-exists-p file))
1520 (file-name-directory
1521 (directory-file-name
1522 (file-name-directory file))))
1523 ;; Give up if we are already at the root dir.
1524 (not (string= (file-name-directory file)
1526 ;; Move up to the parent dir and try again.
1527 (setq file (expand-file-name ".git" parent-dir)))
1528 ;; If we found a change log in a parent, use that.
1529 (if (file-exists-p file)
1530 (let ((regexp (funcall dired-omit-regexp-orig))
1532 (shell-command-to-string "git clean -d -x -n")))
1533 (if (= 0 (length omitted-files))
1537 (if (> (length regexp) 0)
1546 (if (= ?/ (aref str (1- (length str))))
1550 (split-string omitted-files "\n" t)
1553 (funcall dired-omit-regexp-orig))))))
1555 (add-hook 'dired-mode-hook 'dired-package-initialize)
1557 (defun dired-double-jump (first-dir second-dir)
1559 (list (read-directory-name "First directory: "
1560 (expand-file-name "~")
1561 nil nil "/Downloads/")
1562 (read-directory-name "Second directory: "
1563 (expand-file-name "~")
1566 (dired-other-window second-dir))
1567 (bind-key "C-c J" 'dired-double-jump)
1569 (defun dired-back-to-top ()
1571 (beginning-of-buffer)
1572 (dired-next-line 4))
1574 (define-key dired-mode-map
1575 (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
1577 (defun dired-jump-to-bottom ()
1580 (dired-next-line -1))
1582 (define-key dired-mode-map
1583 (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)))
1586 ** discover-my-major
1587 [2014-06-01 Sun 23:32]
1588 Discover key bindings and their meaning for the current Emacs major mode.
1589 #+BEGIN_SRC emacs-lisp :tangle yes
1590 (use-package discover-my-major
1591 :ensure discover-my-major
1592 :bind ("C-h C-m" . discover-my-major))
1595 EasyPG is a GnuPG interface for Emacs.
1596 Bookmark: [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1597 #+BEGIN_SRC emacs-lisp :tangle yes
1598 (use-package epa-file
1602 ;; I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1603 (defadvice epg--start (around advice-epg-disable-agent disable)
1604 "Don't allow epg--start to use gpg-agent in plain text
1606 (if (display-graphic-p)
1608 (let ((agent (getenv "GPG_AGENT_INFO")))
1609 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
1611 (setenv "GPG_AGENT_INFO" agent))))
1612 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
1613 (ad-activate 'epg--start)
1617 [2013-04-21 So 20:36]
1618 ediff - don't start another frame
1619 #+BEGIN_SRC emacs-lisp :tangle yes
1623 (defvar ctl-period-equals-map)
1624 (define-prefix-command 'ctl-period-equals-map)
1625 (bind-key "C-. =" 'ctl-period-equals-map)
1626 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
1628 :bind (("C-. = b" . ediff-buffers)
1629 ("C-. = B" . ediff-buffers3)
1630 ("C-. = =" . ediff-files)
1631 ("C-. = f" . ediff-files)
1632 ("C-. = F" . ediff-files3)
1633 ("C-. = r" . ediff-revision)
1634 ("C-. = p" . ediff-patch-file)
1635 ("C-. = P" . ediff-patch-buffer)
1636 ("C-. = l" . ediff-regions-linewise)
1637 ("C-. = w" . ediff-regions-wordwise))
1639 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1640 (setq ediff-split-window-function 'split-window-horizontally)
1641 (bind-key "j" 'ediff-next-difference ediff-mode-map)
1642 (bind-key "k" 'ediff-previous-difference ediff-mode-map))
1646 EMMS is the Emacs Multimedia System.
1647 #+BEGIN_SRC emacs-lisp :tangle no
1648 (require 'emms-source-file)
1649 (require 'emms-source-playlist)
1650 (require 'emms-info)
1651 (require 'emms-cache)
1652 (require 'emms-playlist-mode)
1653 (require 'emms-playing-time)
1654 (require 'emms-player-mpd)
1655 (require 'emms-playlist-sort)
1656 (require 'emms-mark)
1657 (require 'emms-browser)
1658 (require 'emms-lyrics)
1659 (require 'emms-last-played)
1660 (require 'emms-score)
1661 (require 'emms-tag-editor)
1662 (require 'emms-history)
1663 (require 'emms-i18n)
1665 (setq emms-playlist-default-major-mode 'emms-playlist-mode)
1666 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
1667 (emms-playing-time 1)
1669 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
1670 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
1672 (when (fboundp 'emms-cache) ; work around compiler warning
1674 (setq emms-score-default-score 3)
1676 (defun emms-mpd-init ()
1677 "Connect Emms to mpd."
1679 (emms-player-mpd-connect))
1682 (require 'emms-player-mpd)
1683 (setq emms-player-mpd-server-name "localhost")
1684 (setq emms-player-mpd-server-port "6600")
1685 (add-to-list 'emms-info-functions 'emms-info-mpd)
1686 (add-to-list 'emms-player-list 'emms-player-mpd)
1687 (setq emms-volume-change-function 'emms-volume-mpd-change)
1688 (setq emms-player-mpd-sync-playlist t)
1690 (setq emms-source-file-default-directory "/var/lib/mpd/music")
1691 (setq emms-player-mpd-music-directory "/var/lib/mpd/music")
1692 (setq emms-info-auto-update t)
1693 (setq emms-lyrics-scroll-p t)
1694 (setq emms-lyrics-display-on-minibuffer t)
1695 (setq emms-lyrics-display-on-modeline nil)
1696 (setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
1698 (setq emms-last-played-format-alist
1699 '(((emms-last-played-seconds-today) . "%H:%M")
1700 (604800 . "%a %H:%M") ; this week
1701 ((emms-last-played-seconds-month) . "%d.%m.%Y")
1702 ((emms-last-played-seconds-year) . "%d.%m.%Y")
1703 (t . "Never played")))
1706 (defun my-describe (track)
1707 (let* ((empty "...")
1708 (name (emms-track-name track))
1709 (type (emms-track-type track))
1710 (short-name (file-name-nondirectory name))
1711 (play-count (or (emms-track-get track 'play-count) 0))
1712 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
1713 (artist (or (emms-track-get track 'info-artist) empty))
1714 (year (emms-track-get track 'info-year))
1715 (playing-time (or (emms-track-get track 'info-playing-time) 0))
1716 (min (/ playing-time 60))
1717 (sec (% playing-time 60))
1718 (album (or (emms-track-get track 'info-album) empty))
1719 (tracknumber (emms-track-get track 'info-tracknumber))
1720 (short-name (file-name-sans-extension
1721 (file-name-nondirectory name)))
1722 (title (or (emms-track-get track 'info-title) short-name))
1723 (rating (emms-score-get-score name))
1726 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
1727 (emms-last-played-format-date last-played)
1731 (if (and tracknumber ; tracknumber
1732 (not (zerop (string-to-number tracknumber))))
1733 (format "%02d" (string-to-number tracknumber))
1737 (make-string rating rate-char)))
1740 (setq emms-track-description-function 'my-describe)
1742 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
1743 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
1744 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
1745 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
1746 (global-set-key (kbd "H-<f9> x") 'emms-start)
1747 (global-set-key (kbd "H-<f9> v") 'emms-stop)
1748 (global-set-key (kbd "H-<f9> n") 'emms-next)
1749 (global-set-key (kbd "H-<f9> p") 'emms-previous)
1750 (global-set-key (kbd "H-<f9> o") 'emms-show)
1751 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
1752 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
1753 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
1754 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
1755 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
1757 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
1758 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
1759 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
1760 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
1762 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
1763 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
1764 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
1765 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
1767 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
1768 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
1769 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
1770 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
1772 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
1773 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
1774 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
1775 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
1776 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
1777 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
1779 (define-key emms-playlist-mode-map "x" 'emms-start)
1780 (define-key emms-playlist-mode-map "v" 'emms-stop)
1781 (define-key emms-playlist-mode-map "n" 'emms-next)
1782 (define-key emms-playlist-mode-map "p" 'emms-previous)
1784 (setq emms-playlist-buffer-name "*EMMS Playlist*"
1785 emms-playlist-mode-open-playlists t)
1791 'emms-browser-artist-face nil
1796 (setq emms-player-mpd-supported-regexp
1797 (or (emms-player-mpd-get-supported-regexp)
1798 (concat "\\`http://\\|"
1799 (emms-player-simple-regexp
1800 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
1801 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
1805 [2014-06-01 Sun 15:00]
1806 Proper whitespace handling
1807 #+BEGIN_SRC emacs-lisp :tangle yes
1808 (use-package ethan-wspace
1809 :ensure ethan-wspace
1810 :diminish (ethan-wspace-mode . "ew")
1812 (global-ethan-wspace-mode 1))
1816 [2014-06-01 Sun 15:16]
1817 #+BEGIN_SRC emacs-lisp :tangle yes
1818 (use-package expand-region
1819 :ensure expand-region
1820 :bind ("C-M-+" . er/expand-region))
1823 [2013-05-02 Thu 00:04]
1824 Filladapt by KyleJones enhances Emacs’ fill functions by guessing a
1825 fill prefix, such as a comment sequence in program code, and handling
1826 bullet points like “1.” or “*”.
1827 #+BEGIN_SRC emacs-lisp :tangle yes
1828 (use-package filladapt
1829 :diminish filladapt-mode
1831 (setq-default filladapt-mode t))
1834 [2013-04-28 So 22:21]
1835 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
1836 As the one time I tried Flymake i wasn't happy, thats easy to
1838 #+BEGIN_SRC emacs-lisp :tangle yes
1839 (use-package flycheck
1841 :diminish flycheck-mode
1842 :bind (("M-n" . next-error)
1843 ("M-p" . previous-error))
1846 (add-hook 'find-file-hook
1848 (when (not (equal 'emacs-lisp-mode major-mode))
1852 (use-package flycheck-color-mode-line
1853 :ensure flycheck-color-mode-line)
1854 (setq flycheck-highlighting-mode nil)
1855 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
1859 Obviously emacs can do syntax hilighting. For more things than you ever
1861 And I want to have it everywhere.
1862 #+BEGIN_SRC emacs-lisp :tangle yes
1863 (use-package font-lock
1866 (global-font-lock-mode 1)
1867 (setq font-lock-maximum-decoration t)))
1870 #+BEGIN_SRC emacs-lisp :tangle yes
1871 (use-package git-commit-mode
1872 :ensure git-commit-mode
1873 :commands git-commit-mode
1874 :mode ("COMMIT_EDITMSG" . git-commit-mode))
1878 #+BEGIN_SRC emacs-lisp :tangle yes
1879 (use-package git-rebase-mode
1880 :ensure git-rebase-mode
1881 :commands git-rebase-mode
1882 :mode ("git-rebase-todo" . git-rebase-mode))
1885 [2014-05-21 Wed 22:56]
1886 #+BEGIN_SRC emacs-lisp :tangle yes
1887 (use-package git-gutter+
1889 :diminish git-gutter+-mode
1890 :bind (("C-x n" . git-gutter+-next-hunk)
1891 ("C-x p" . git-gutter+-previous-hunk)
1892 ("C-x v =" . git-gutter+-show-hunk)
1893 ("C-x r" . git-gutter+-revert-hunks)
1894 ("C-x s" . git-gutter+-stage-hunks)
1895 ("C-x c" . git-gutter+-commit)
1899 (setq git-gutter+-disabled-modes '(org-mode))
1900 (global-git-gutter+-mode 1))
1903 (use-package git-gutter-fringe+
1904 :ensure git-gutter-fringe+
1907 (setq git-gutter-fr+-side 'right-fringe)
1908 ;(git-gutter-fr+-minimal)
1913 [2014-07-23 Mi 12:57]
1914 Browse historic versions of a file with p (previous) and n (next).
1915 #+BEGIN_SRC emacs-lisp :tangle yes
1916 (use-package git-timemachine
1917 :ensure git-timemachine)
1920 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
1921 what I want every emacs to know.
1922 #+BEGIN_SRC emacs-lisp :tangle yes
1923 (bind-key "C-c g" 'gnus) ; Start gnus with M-n
1929 [2015-02-20 Fri 16:27]
1930 When working with many windows at the same time, each window has a
1931 size that is not convenient for editing.
1933 golden-ratio helps on this issue by resizing automatically the windows
1934 you are working on to the size specified in the "Golden Ratio". The
1935 window that has the main focus will have the perfect size for editing,
1936 while the ones that are not being actively edited will be re-sized to
1937 a smaller size that doesn't get in the way, but at the same time will
1938 be readable enough to know it's content.
1939 #+BEGIN_SRC emacs-lisp :tangle yes
1940 (use-package golden-ratio
1941 :ensure golden-ratio
1944 (golden-ratio-mode 1)))
1947 [2014-06-11 Wed 22:27]
1948 guide-key.el displays the available key bindings automatically and
1951 For whatever reason I like this more than icicles <backtab> completion
1953 #+BEGIN_SRC emacs-lisp :tangle yes
1954 (use-package guide-key
1956 :diminish guide-key-mode
1959 (setq guide-key/guide-key-sequence '("C-x" "C-c"))
1961 (setq guide-key/recursive-key-sequence-flag t)
1962 (setq guide-key/popup-window-position 'bottom)
1963 (setq guide-key/idle-delay 0.5)))
1968 [2014-05-21 Wed 23:51]
1969 #+BEGIN_SRC emacs-lisp :tangle yes
1970 (use-package hi-lock
1971 :bind (("M-o l" . highlight-lines-matching-regexp)
1972 ("M-o r" . highlight-regexp)
1973 ("M-o w" . highlight-phrase)))
1975 (use-package hilit-chg
1976 :bind ("M-o C" . highlight-changes-mode))
1980 Crazy way of completion. It looks at the word before point and then
1981 tries to expand it in various ways.
1982 #+BEGIN_SRC emacs-lisp :tangle yes
1983 (use-package hippie-exp
1984 :bind ("M-/" . hippie-expand)
1987 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
1988 try-expand-dabbrev-all-buffers
1989 try-expand-dabbrev-from-kill
1990 try-complete-file-name-partially
1991 try-complete-file-name
1992 try-expand-all-abbrevs try-expand-list
1994 try-complete-lisp-symbol-partially
1995 try-complete-lisp-symbol))))
1998 Replaced by web-mode [[*web-mode][web-mode]]
1999 #+BEGIN_SRC emacs-lisp :tangle no
2000 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
2001 (add-auto-mode 'html-helper-mode "\\.html$")
2002 (add-auto-mode 'html-helper-mode "\\.asp$")
2003 (add-auto-mode 'html-helper-mode "\\.phtml$")
2004 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
2005 (defalias 'html-mode 'html-helper-mode)
2008 [2015-01-26 Mon 15:50]
2009 This is a package for GNU Emacs that can be used to tie related
2010 commands into a family of short bindings with a common prefix - a
2013 Once you summon the Hydra through the prefixed binding (the body + any
2014 one head), all heads can be called in succession with only a short
2017 The Hydra is vanquished once Hercules, any binding that isn't the
2018 Hydra's head, arrives. Note that Hercules, besides vanquishing the
2019 Hydra, will still serve his orignal purpose, calling his proper
2020 command. This makes the Hydra very seamless, it's like a minor mode
2021 that disables itself auto-magically.
2022 #+BEGIN_SRC emacs-lisp :tangle yes
2027 (setq hydra-is-helpful t)
2029 (defhydra hydra-zoom (global-map "<f2>")
2031 ("g" text-scale-increase "in")
2032 ("l" text-scale-decrease "out")
2036 '(("h" first-error "first")
2037 ("j" next-error "next")
2038 ("k" previous-error "prev")
2044 ("a" abbrev-mode "abbrev" :color blue)
2045 ("d" toggle-debug-on-error "debug" :color blue)
2046 ("f" auto-fill-mode "fill" :color blue)
2047 ("t" toggle-truncate-lines "truncate" :color blue)
2048 ("w" whitespace-mode "whitespace" :color blue)
2049 ("q" nil "cancel")))
2054 [2014-05-21 Wed 23:54]
2055 #+BEGIN_SRC emacs-lisp :tangle yes
2056 (use-package ibuffer
2058 :bind (("C-h h" . ibuffer)
2059 ("C-x C-b" . ibuffer)
2060 ("<XF86WebCam>" . ibuffer)
2065 (use-package ibuffer-vc
2068 (ibuffer-vc-set-filter-groups-by-vc-root
2069 ibuffer-vc-generate-filter-groups-by-vc-root))
2070 (use-package ibuffer-tramp
2072 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
2073 ibuffer-tramp-set-filter-groups-by-tramp-connection))
2074 ;; Switching to ibuffer puts the cursor on the most recent buffer
2075 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
2076 "Open ibuffer with cursor pointed to most recent buffer name"
2077 (let ((recent-buffer-name (buffer-name)))
2079 (ibuffer-update nil t)
2080 (unless (string= recent-buffer-name "*Ibuffer*")
2081 (ibuffer-jump-to-buffer recent-buffer-name)))))
2084 (defvar my-ibufffer-separator " • ")
2085 (setq ibuffer-filter-group-name-face 'variable-pitch
2086 ibuffer-use-header-line t
2087 ibuffer-old-time 12)
2088 (unbind-key "M-o" ibuffer-mode-map)
2089 (bind-key "s" 'isearch-forward-regexp ibuffer-mode-map)
2090 (bind-key "." 'ibuffer-invert-sorting ibuffer-mode-map)
2092 (defun ibuffer-magit-status ()
2094 (--when-let (get-buffer "*Ibuffer*")
2095 (with-current-buffer it
2096 (let* ((selected-buffer (ibuffer-current-buffer))
2097 (buffer-path (with-current-buffer
2099 (or (buffer-file-name)
2100 list-buffers-directory
2101 default-directory)))
2103 (if (file-regular-p buffer-path)
2104 (file-name-directory buffer-path)
2106 (magit-status default-directory)))))
2107 (bind-key "i" 'ibuffer-magit-status ibuffer-mode-map)
2108 (bind-key "G" 'ibuffer-magit-status ibuffer-mode-map)
2110 (setq ibuffer-directory-abbrev-alist
2115 (cons (f-slash (f-expand (cdr it))) my-ibufffer-separator)
2116 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
2118 ("dak" . "/develop/dak/")
2120 ("config" . "~/.emacs.d/config/")
2122 ("systmp" . "/tmp/")
2123 ("puppet" . "~/git/puppet")
2127 (use-package ibuffer-git
2129 (use-package ibuffer-vc
2132 (define-ibuffer-column size-h
2133 (:name "Size" :inline t)
2135 ((> (buffer-size) 1000)
2136 (format "%7.1fk" (/ (buffer-size) 1000.0)))
2137 ((> (buffer-size) 1000000)
2138 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
2140 (format "%8d" (buffer-size)))))
2142 (use-package ibuf-ext)
2143 (define-ibuffer-filter filename2
2144 "Toggle current view to buffers with filename matching QUALIFIER."
2145 (:description "filename2"
2146 :reader (read-from-minibuffer "Filter by filename (regexp): "))
2147 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
2148 (ibuffer-awhen (with-current-buffer buf
2149 (or buffer-file-name
2151 (string-match qualifier it)))
2153 (defvar ibuffer-magit-filter-groups nil)
2154 (defun ibuffer-magit-define-filter-groups ()
2155 (when (and (not ibuffer-magit-filter-groups)
2156 (boundp 'magit-repo-dirs))
2157 (setq ibuffer-magit-filter-groups
2160 (file-name-nondirectory (directory-file-name it)))
2162 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
2164 (defun ibuffer-set-filter-groups-by-root ()
2166 ;; (ibuffer-projectile-define-filter-groups)
2167 ;; (ibuffer-magit-define-filter-groups)
2168 (setq ibuffer-filter-groups
2170 ;; ibuffer-projectile-filter-groups
2171 ibuffer-magit-filter-groups
2174 (or (mode . magit-log-edit-mode)
2175 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2176 (name . "^\\*Pymacs\\*$")
2177 (name . "^\\*helm.*\\*")
2178 (name . "^\\*Compile-log\\*$")
2179 (name . "^\\*Ido Completions\\*$")
2180 (name . "^\\*magit-\\(process\\)\\*$")
2184 (name . "^\\*scratch")
2185 (name . "^\\*Messages")
2188 (ibuffer-vc-generate-filter-groups-by-vc-root)
2189 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
2191 (defun toggle-ibuffer-filter-groups ()
2194 (let ((ibuf (get-buffer "*Ibuffer*")))
2196 (with-current-buffer ibuf
2197 (let ((selected-buffer (ibuffer-current-buffer)))
2198 (if (not ibuffer-filter-groups)
2199 (ibuffer-set-filter-groups-by-root)
2200 (setq ibuffer-filter-groups nil))
2201 (pop-to-buffer ibuf)
2202 (ibuffer-update nil t)
2203 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
2205 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
2207 (setq ibuffer-default-sorting-mode 'recency
2208 ibuffer-eliding-string "…"
2209 ibuffer-compile-formats t
2210 ibuffer-git-column-length 6
2211 ibuffer-show-empty-filter-groups nil
2212 ibuffer-default-directory "~/"
2214 (setq ibuffer-formats '((mark vc-status-mini
2216 (git-status 8 8 :left)
2220 (name 18 18 :left :elide)
2222 (size-h 9 -1 :right)
2224 (mode 16 16 :left :elide)
2225 " " filename-and-process)
2227 (git-status 8 8 :left)
2233 (setq ibuffer-saved-filter-groups
2236 ("dired" (mode . dired-mode))
2237 ("perl" (mode . cperl-mode))
2239 (mode . puppet-mode)
2240 (mode . yaml-mode)))
2241 ("ruby" (mode . ruby-mode))
2243 (name . "^\\*scratch\\*$")
2244 (name . "^\\*Compile-log\\*$")
2245 (name . "^\\*Completions\\*$")
2246 (name . "^\\*Messages\\*$")
2247 (name . "^\\*Backtrace\\*$")
2248 (name . "^\\*Packages*\\*$")
2249 (name . "^\\*Help*\\*$")
2252 (mode . message-mode)
2255 (mode . gnus-group-mode)
2256 (mode . gnus-summary-mode)
2257 (mode . gnus-article-mode)
2258 (name . "^\\.bbdb$")
2259 (name . "^\\.newsrc-dribble")))
2261 (filename . ".*/org/.*")
2262 (mode . org-agenda-mode)
2263 (name . "^diary$")))
2265 (mode . magit-log-edit-mode)
2266 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
2268 ;; -------------------------------------------------
2269 ;; programming languages #1
2271 (mode . emacs-lisp-mode)
2272 (mode . python-mode)
2274 (mode . coffee-mode)
2277 (mode . actionscript-mode)
2280 (mode . haskell-mode)
2286 ;; -------------------------------------------------
2287 ;; configuration/data files
2291 (mode . conf-mode)))
2292 ;; -------------------------------------------------
2293 ;; text/notetaking/org
2294 ("org agenda" (mode . org-agenda-mode))
2297 (name . "^\\*Calendar\\*$")
2298 (name . "^diary$")))
2302 (mode . markdown-mode)))
2303 ;; -------------------------------------------------
2306 (mode . image-mode)))
2307 ;; -------------------------------------------------
2309 ("w3m" (mode . w3m-mode))
2311 (mode . magit-status-mode)
2312 (mode . magit-log-mode)
2313 (mode . vc-annotate-mode)))
2314 ("dired" (mode . dired-mode))
2319 (name . "^\\*Personal Keybindings\\*$")))
2320 ;; -------------------------------------------------
2322 ("MORE" (or (mode . magit-log-edit-mode)
2323 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2324 (name . "^\\*Pymacs\\*$")
2325 (name . "^\\*Compile-log\\*$")
2326 (name . "^\\*Completions\\*$")
2327 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
2329 ("*buffer*" (name . "\\*.*\\*"))))))
2331 (add-hook 'ibuffer-mode-hook
2333 (ibuffer-auto-mode 1)
2334 (ibuffer-switch-to-saved-filter-groups "default")))
2336 ;; Unless you turn this variable on you will be prompted every time
2337 ;; you want to delete a buffer, even unmodified ones, which is way
2338 ;; too cautious for most people. You’ll still be prompted for
2339 ;; confirmation when deleting modified buffers after the option has
2341 (setq ibuffer-expert t)
2346 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
2347 ‘TAB’ completion is to typing things manually every time.”]]
2348 #+BEGIN_SRC emacs-lisp :tangle yes
2349 (use-package icicles
2350 :load-path "elisp/icicle/"
2355 Incremental mini-buffer completion preview: Type in the minibuffer,
2356 list of matching commands is echoed
2357 #+BEGIN_SRC emacs-lisp :tangle yes
2361 [2014-05-26 Mon 22:49]
2362 #+BEGIN_SRC emacs-lisp :tangle yes
2365 :commands (iedit-mode)
2367 :bind (("C-;" . iedit-mode)
2368 ("C-," . iedit-mode-toggle-on-function))
2373 [2014-05-20 Tue 23:35]
2374 #+BEGIN_SRC emacs-lisp :tangle yes
2376 :bind ("C-h C-i" . info-lookup-symbol)
2380 ;; (defadvice info-setup (after load-info+ activate)
2381 ;; (use-package info+))
2383 (defadvice Info-exit (after remove-info-window activate)
2384 "When info mode is quit, remove the window."
2385 (if (> (length (window-list)) 1)
2388 (use-package info-look
2389 :commands info-lookup-add-help)
2391 ** linum (line number)
2392 Various modes should have line numbers in front of each line.
2394 But then there are some where it would just be deadly - like org-mode,
2395 gnus, so we have a list of modes where we don't want to see it.
2396 #+BEGIN_SRC emacs-lisp :tangle yes
2398 :diminish linum-mode
2401 (setq linum-format "%3d ")
2402 (setq linum-mode-inhibit-modes-list '(org-mode
2409 (defadvice linum-on (around linum-on-inhibit-for-modes)
2410 "Stop the load of linum-mode for some major modes."
2411 (unless (member major-mode linum-mode-inhibit-modes-list)
2414 (ad-activate 'linum-on)
2415 (use-package linum-relative
2416 :ensure linum-relative
2417 :bind ("C-c r" . linum-relative-toggle))
2420 (global-linum-mode 1))
2423 ** lisp editing stuff
2424 [2013-04-21 So 21:00]
2425 I'm not doing much of it, except for my emacs and gnus configs, but
2426 then I like it nice too...
2427 #+BEGIN_SRC emacs-lisp :tangle yes
2428 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
2430 (defun remove-elc-on-save ()
2431 "If you're saving an elisp file, likely the .elc is no longer valid."
2432 (make-local-variable 'after-save-hook)
2433 (add-hook 'after-save-hook
2435 (if (file-exists-p (concat buffer-file-name "c"))
2436 (delete-file (concat buffer-file-name "c"))))))
2438 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
2439 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
2441 (use-package paredit
2443 :diminish paredit-mode " π")
2445 (setq lisp-coding-hook 'lisp-coding-defaults)
2446 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2448 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2449 (add-hook 'emacs-lisp-mode-hook (lambda ()
2450 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2452 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
2454 (after "elisp-slime-nav"
2455 '(diminish 'elisp-slime-nav-mode))
2456 (after "rainbow-mode"
2457 '(diminish 'rainbow-mode))
2459 '(diminish 'eldoc-mode))
2463 [2013-04-21 So 20:48]
2464 magit is a mode for interacting with git.
2465 #+BEGIN_SRC emacs-lisp :tangle yes
2468 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
2469 magit-git-repo-p magit-list-repos)
2471 :bind (("C-x g" . magit-status)
2472 ("C-x G" . magit-status-with-prefix))
2475 (setq magit-commit-signoff t
2476 magit-repo-dirs '("~/git"
2480 magit-repo-dirs-depth 4
2481 magit-log-auto-more t)
2482 (use-package magit-blame
2483 :commands magit-blame-mode)
2485 (use-package magit-svn
2487 :commands (magit-svn-mode
2490 (add-hook 'magit-mode-hook 'hl-line-mode)
2491 (defun magit-status-with-prefix ()
2493 (let ((current-prefix-arg '(4)))
2494 (call-interactively 'magit-status)))
2498 (setenv "GIT_PAGER" "")
2500 (unbind-key "M-h" magit-mode-map)
2501 (unbind-key "M-s" magit-mode-map)
2503 (use-package magit-find-file
2504 :ensure magit-find-file
2505 :commands (magit-find-file-completing-read)
2509 (bind-key "C-x C-f" 'magit-find-file-completing-read magit-mode-map)))
2511 (add-hook 'magit-log-edit-mode-hook
2513 (set-fill-column 72)
2516 (defadvice magit-status (around magit-fullscreen activate)
2517 (window-configuration-to-register :magit-fullscreen)
2519 (delete-other-windows))
2521 (defun magit-quit-session ()
2522 "Restores the previous window configuration and kills the magit buffer"
2525 (jump-to-register :magit-fullscreen))
2527 (bind-key "q" 'magit-quit-session magit-status-mode-map)
2531 [2014-05-20 Tue 23:04]
2532 #+BEGIN_SRC emacs-lisp :tangle yes
2533 (use-package markdown-mode
2534 :mode (("\\.md\\'" . markdown-mode)
2535 ("\\.mdwn\\'" . markdown-mode))
2539 #+BEGIN_SRC emacs-lisp :tangle yes
2541 (setq message-kill-buffer-on-exit t)
2544 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2546 I want to access it from anywhere using =F6=.
2547 #+BEGIN_SRC emacs-lisp :tangle yes
2548 (use-package mingus-stays-home
2549 :bind ( "<f6>" . mingus)
2553 (setq mingus-dired-add-keys t)
2554 (setq mingus-mode-always-modeline nil)
2555 (setq mingus-mode-line-show-elapsed-percentage nil)
2556 (setq mingus-mode-line-show-volume nil)
2557 (setq mingus-mpd-config-file "/etc/mpd.conf")
2558 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2559 (setq mingus-mpd-root "/share/music/")))
2563 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
2564 #+BEGIN_SRC emacs-lisp :tangle yes
2565 (use-package miniedit
2569 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
2570 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
2571 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
2572 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
2578 [2013-05-21 Tue 23:39]
2579 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
2580 coexist in one buffer.
2581 #+BEGIN_SRC emacs-lisp :tangle yes
2582 (use-package mmm-auto
2586 (setq mmm-global-mode 'buffers-with-submode-classes)
2587 (setq mmm-submode-decoration-level 2)
2588 (eval-after-load 'mmm-vars
2594 :face mmm-code-submode-face
2595 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
2596 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
2597 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2598 @ "\n" _ "\n" @ "</script>" @)))
2601 :face mmm-code-submode-face
2602 :front "<style[^>]*>[ \t]*\n?"
2603 :back "[ \t]*</style>"
2604 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2605 @ "\n" _ "\n" @ "</style>" @)))
2608 :face mmm-code-submode-face
2611 (dolist (mode (list 'html-mode 'nxml-mode))
2612 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
2613 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
2618 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2621 #+BEGIN_SRC emacs-lisp :tangle yes
2622 (use-package mo-git-blame
2623 :ensure mo-git-blame
2624 :commands (mo-git-blame-current
2628 (setq mo-git-blame-blame-window-width 25)))
2632 [2013-04-08 Mon 23:57]
2633 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2634 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2635 #+BEGIN_SRC emacs-lisp :tangle yes
2636 (use-package multiple-cursors
2637 :ensure multiple-cursors
2639 :commands (mc/remove-fake-cursors
2640 mc/create-fake-cursor-at-point
2641 mc/pop-state-from-overlay
2642 mc/maybe-multiple-cursors-mode)
2643 :bind (("C-S-c C-S-c" . mc/edit-lines)
2644 ("C->" . mc/mark-next-like-this)
2645 ("C-<" . mc/mark-previous-like-this)
2646 ("C-c C-<" . mc/mark-all-like-this)
2647 ("C-c i" . mc/insert-numbers))
2650 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
2651 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
2652 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
2653 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
2654 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
2655 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
2658 [2014-08-27 Wed 17:15]
2660 #+BEGIN_SRC emacs-lisp :tangle yes
2661 (use-package neotree
2664 :bind (("<f8>" . neotree-toggle))
2665 :commands (neotree-find
2670 (setq neo-smart-open t))
2673 (bind-key "^" 'neotree-select-up-node neotree-mode-map)))
2676 [2013-05-22 Wed 22:02]
2677 nxml-mode is a major mode for editing XML.
2678 #+BEGIN_SRC emacs-lisp :tangle yes
2683 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2686 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2687 (fset 'xml-mode 'nxml-mode)
2688 (setq nxml-slash-auto-complete-flag t)
2690 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2691 (defun pp-xml-region (begin end)
2692 "Pretty format XML markup in region. The function inserts
2693 linebreaks to separate tags that have nothing but whitespace
2694 between them. It then indents the markup by using nxml's
2700 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2701 (backward-char) (insert "\n"))
2702 (indent-region begin end)))
2704 ;;----------------------------------------------------------------------------
2705 ;; Integration with tidy for html + xml
2706 ;;----------------------------------------------------------------------------
2707 ;; tidy is autoloaded
2708 (eval-after-load 'tidy
2710 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2711 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2716 *** General settings
2717 [2013-04-28 So 17:06]
2719 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
2720 it is quite extensive. Nevertheless, it starts out small, loading it.
2721 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2725 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
2726 that we need org-protocol.
2727 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2728 (require 'org-protocol)
2733 My current =org-agenda-files= variable only includes a set of
2735 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2736 (setq org-agenda-files (quote ("~/org/"
2742 (setq org-default-notes-file "~/org/notes.org")
2744 =org-mode= manages the =org-agenda-files= variable automatically using
2745 =C-c [= and =C-c ]= to add and remove files respectively. However,
2746 this replaces my directory list with a list of explicit filenames
2747 instead and is not what I want. If this occurs then adding a new org
2748 file to any of the above directories will not contribute to my agenda
2749 and I will probably miss something important.
2751 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
2752 prevent messing up my list of directories in the =org-agenda-files=
2753 variable. I just add and remove directories manually here. Changing
2754 the list of directories in =org-agenda-files= happens very rarely
2755 since new files in existing directories are automatically picked up.
2757 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2758 ;; Keep tasks with dates on the global todo lists
2759 (setq org-agenda-todo-ignore-with-date nil)
2761 ;; Keep tasks with deadlines on the global todo lists
2762 (setq org-agenda-todo-ignore-deadlines nil)
2764 ;; Keep tasks with scheduled dates on the global todo lists
2765 (setq org-agenda-todo-ignore-scheduled nil)
2767 ;; Keep tasks with timestamps on the global todo lists
2768 (setq org-agenda-todo-ignore-timestamp nil)
2770 ;; Remove completed deadline tasks from the agenda view
2771 (setq org-agenda-skip-deadline-if-done t)
2773 ;; Remove completed scheduled tasks from the agenda view
2774 (setq org-agenda-skip-scheduled-if-done t)
2776 ;; Remove completed items from search results
2777 (setq org-agenda-skip-timestamp-if-done t)
2779 ;; Include agenda archive files when searching for things
2780 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
2782 ;; Show all future entries for repeating tasks
2783 (setq org-agenda-repeating-timestamp-show-all t)
2785 ;; Show all agenda dates - even if they are empty
2786 (setq org-agenda-show-all-dates t)
2788 ;; Sorting order for tasks on the agenda
2789 (setq org-agenda-sorting-strategy
2790 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
2791 (todo category-up priority-down effort-up)
2792 (tags category-up priority-down effort-up)
2793 (search category-up))))
2795 ;; Start the weekly agenda on Monday
2796 (setq org-agenda-start-on-weekday 1)
2798 ;; Enable display of the time grid so we can see the marker for the current time
2799 (setq org-agenda-time-grid (quote ((daily today remove-match)
2800 #("----------------" 0 16 (org-heading t))
2801 (0800 1000 1200 1400 1500 1700 1900 2100))))
2803 ;; Display tags farther right
2804 (setq org-agenda-tags-column -102)
2806 ; position the habit graph on the agenda to the right of the default
2807 (setq org-habit-graph-column 50)
2809 ; turn habits back on
2810 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
2813 ;; Agenda sorting functions
2815 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
2818 (setq org-deadline-warning-days 30)
2820 ;; Always hilight the current agenda line
2821 (add-hook 'org-agenda-mode-hook
2822 '(lambda () (hl-line-mode 1))
2826 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2827 (setq org-agenda-persistent-filter t)
2828 (add-hook 'org-agenda-mode-hook
2829 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
2832 (add-hook 'org-agenda-mode-hook
2833 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
2836 (add-hook 'org-agenda-mode-hook
2837 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
2840 (add-hook 'org-agenda-mode-hook
2841 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
2844 (add-hook 'org-agenda-mode-hook
2845 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
2848 ; Rebuild the reminders everytime the agenda is displayed
2849 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
2851 ;(if (file-exists-p "~/org/refile.org")
2852 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
2854 ; Activate appointments so we get notifications
2857 (setq org-agenda-log-mode-items (quote (closed clock state)))
2858 (if (> emacs-major-version 23)
2859 (setq org-agenda-span 3)
2860 (setq org-agenda-ndays 3))
2862 (setq org-agenda-show-all-dates t)
2863 (setq org-agenda-start-on-weekday nil)
2864 (setq org-deadline-warning-days 14)
2867 *** Global keybindings.
2868 Start off by defining a series of keybindings.
2870 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
2871 setup manually, not by org-mode. Also turn off =C-c ;=, which
2872 comments headlines - a function never used.
2873 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2874 (add-hook 'org-mode-hook
2876 (org-defkey org-mode-map "\C-c[" 'undefined)
2877 (org-defkey org-mode-map "\C-c]" 'undefined)
2878 (org-defkey org-mode-map "\C-c;" 'undefined))
2882 And now a largish set of keybindings...
2883 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2884 (bind-key "C-c l" 'org-store-link)
2885 (bind-key "C-c a" 'org-agenda)
2886 ;(bind-key "C-c b" 'org-iswitchb)
2887 (define-key mode-specific-map [?a] 'org-agenda)
2889 (bind-key "<f12>" 'org-agenda)
2890 (bind-key "<f5>" 'bh/org-todo)
2891 (bind-key "<S-f5>" 'bh/widen)
2892 (bind-key "<f7>" 'bh/set-truncate-lines)
2893 ;(bind-key "<f8>" 'org-cycle-agenda-files)
2895 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
2896 (bind-key "<f9> b" 'bbdb)
2897 (bind-key "<f9> c" 'calendar)
2898 (bind-key "<f9> f" 'boxquote-insert-file)
2899 (bind-key "<f9> h" 'bh/hide-other)
2900 (bind-key "<f9> n" 'org-narrow-to-subtree)
2901 (bind-key "<f9> w" 'widen)
2902 (bind-key "<f9> u" 'bh/narrow-up-one-level)
2903 (bind-key "<f9> I" 'bh/punch-in)
2904 (bind-key "<f9> O" 'bh/punch-out)
2905 (bind-key "<f9> H" 'jj/punch-in-hw)
2906 (bind-key "<f9> W" 'jj/punch-out-hw)
2907 (bind-key "<f9> o" 'bh/make-org-scratch)
2908 (bind-key "<f9> p" 'bh/phone-call)
2909 (bind-key "<f9> r" 'boxquote-region)
2910 (bind-key "<f9> s" 'bh/switch-to-scratch)
2911 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
2912 (bind-key "<f9> T" 'tabify)
2913 (bind-key "<f9> U" 'untabify)
2914 (bind-key "<f9> v" 'visible-mode)
2915 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
2916 (bind-key "C-<f9>" 'previous-buffer)
2917 (bind-key "C-<f10>" 'next-buffer)
2918 (bind-key "M-<f9>" 'org-toggle-inline-images)
2919 ;(bind-key "C-x n r" 'narrow-to-region)
2920 (bind-key "<f11>" 'org-clock-goto)
2921 (bind-key "C-<f11>" 'org-clock-in)
2922 (bind-key "C-M-r" 'org-capture)
2923 (bind-key "C-c r" 'org-capture)
2924 (bind-key "C-S-<f12>" 'bh/save-then-publish)
2925 ;(bind-key "C-k" 'jj-org-kill-line org-mode-map)
2929 *** Tasks, States, Todo fun
2931 First we define the global todo keywords.
2932 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2933 (setq org-todo-keywords
2934 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
2935 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
2937 (setq org-todo-keyword-faces
2938 (quote (("TODO" :foreground "red" :weight bold)
2939 ("NEXT" :foreground "light blue" :weight bold)
2940 ("DONE" :foreground "forest green" :weight bold)
2941 ("WAITING" :foreground "orange" :weight bold)
2942 ("HOLD" :foreground "orange" :weight bold)
2943 ("DELEGATED" :foreground "yellow" :weight bold)
2944 ("CANCELLED" :foreground "dark green" :weight bold)
2945 ("PHONE" :foreground "dark green" :weight bold))))
2948 **** Fast Todo Selection
2949 Fast todo selection allows changing from any task todo state to any
2950 other state directly by selecting the appropriate key from the fast
2951 todo selection key menu.
2952 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2953 (setq org-use-fast-todo-selection t)
2955 Changing a task state is done with =C-c C-t KEY=
2957 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
2960 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2961 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
2963 allows changing todo states with S-left and S-right skipping all of
2964 the normal processing when entering or leaving a todo state. This
2965 cycles through the todo states but skips setting timestamps and
2966 entering notes which is very convenient when all you want to do is fix
2967 up the status of an entry.
2969 **** Todo State Triggers
2970 I have a few triggers that automatically assign tags to tasks based on
2971 state changes. If a task moves to =CANCELLED= state then it gets a
2972 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
2973 =CANCELLED= tag. These are used for filtering tasks in agenda views
2974 which I'll talk about later.
2976 The triggers break down to the following rules:
2978 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
2979 - Moving a task to =WAITING= adds a =WAITING= tag
2980 - Moving a task to =HOLD= adds a =WAITING= tag
2981 - Moving a task to a done state removes a =WAITING= tag
2982 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
2983 - Moving a task to =NEXT= removes a =WAITING= tag
2984 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
2986 The tags are used to filter tasks in the agenda views conveniently.
2987 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2988 (setq org-todo-state-tags-triggers
2989 (quote (("CANCELLED" ("CANCELLED" . t))
2990 ("WAITING" ("WAITING" . t))
2991 ("HOLD" ("WAITING" . t) ("HOLD" . t))
2992 (done ("WAITING") ("HOLD"))
2993 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
2994 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
2995 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
2998 *** Capturing new tasks
2999 Org capture replaces the old remember mode.
3000 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3001 (setq org-directory "~/org")
3002 (setq org-default-notes-file "~/org/refile.org")
3004 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
3005 ;; see http://orgmode.org/manual/Template-elements.html
3006 (setq org-capture-templates
3007 (quote (("t" "todo" entry (file "~/org/refile.org")
3008 "* TODO %?\nAdded: %U\n"
3009 :clock-in t :clock-resume t)
3010 ("l" "linktodo" entry (file "~/org/refile.org")
3011 "* TODO %?\nAdded: %U\n%a\n"
3012 :clock-in t :clock-resume t)
3013 ("r" "respond" entry (file "~/org/refile.org")
3014 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
3015 :clock-in t :clock-resume t :immediate-finish t)
3016 ("n" "note" entry (file "~/org/refile.org")
3017 "* %? :NOTE:\nAdded: %U\n%a\n"
3018 :clock-in t :clock-resume t)
3019 ("d" "Delegated" entry (file "~/org/refile.org")
3020 "* DELEGATED %?\nAdded: %U\n%a\n"
3021 :clock-in t :clock-resume t)
3022 ("j" "Journal" entry (file+datetree "~/org/diary.org")
3024 :clock-in t :clock-resume t)
3025 ("w" "org-protocol" entry (file "~/org/refile.org")
3026 "* TODO Review %c\nAdded: %U\n"
3027 :immediate-finish t)
3028 ("p" "Phone call" entry (file "~/org/refile.org")
3029 "* PHONE %? :PHONE:\nAdded: %U"
3030 :clock-in t :clock-resume t)
3031 ("x" "Bookmark link" entry (file "~/org/refile.org")
3032 "* Bookmark: %c\n%i\nAdded: %U\n"
3033 :immediate-finish t)
3034 ("h" "Habit" entry (file "~/org/refile.org")
3035 "* 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")
3039 Capture mode now handles automatically clocking in and out of a
3040 capture task. This all works out of the box now without special hooks.
3041 When I start a capture mode task the task is clocked in as specified
3042 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
3043 resumes on the original clocking task.
3045 The quick clocking in and out of capture mode tasks (often it takes
3046 less than a minute to capture some new task details) can leave
3047 empty clock drawers in my tasks which aren't really useful.
3048 The following prevents this.
3049 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3050 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
3054 All my newly captured entries end up in =refile.org= and want to be
3055 moved over to the right place. The following is the setup for it.
3056 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3057 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
3058 (setq org-refile-targets (quote ((nil :maxlevel . 9)
3059 (org-agenda-files :maxlevel . 9))))
3061 ; Use full outline paths for refile targets - we file directly with IDO
3062 (setq org-refile-use-outline-path t)
3064 ; Targets complete directly with IDO
3065 (setq org-outline-path-complete-in-steps nil)
3067 ; Allow refile to create parent tasks with confirmation
3068 (setq org-refile-allow-creating-parent-nodes (quote confirm))
3070 ; Use IDO for both buffer and file completion and ido-everywhere to t
3071 (setq org-completion-use-ido t)
3072 (setq org-completion-use-iswitchb nil)
3073 :; Use IDO for both buffer and file completion and ido-everywhere to t
3074 ;(setq ido-everywhere t)
3075 ;(setq ido-max-directory-size 100000)
3076 ;(ido-mode (quote both))
3077 ; Use the current window when visiting files and buffers with ido
3078 (setq ido-default-file-method 'selected-window)
3079 (setq ido-default-buffer-method 'selected-window)
3081 ;;;; Refile settings
3082 (setq org-refile-target-verify-function 'bh/verify-refile-target)
3086 Agenda view is the central place for org-mode interaction...
3087 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3088 ;; Do not dim blocked tasks
3089 (setq org-agenda-dim-blocked-tasks nil)
3090 ;; Compact the block agenda view
3091 (setq org-agenda-compact-blocks t)
3093 ;; Custom agenda command definitions
3094 (setq org-agenda-custom-commands
3095 (quote (("N" "Notes" tags "NOTE"
3096 ((org-agenda-overriding-header "Notes")
3097 (org-tags-match-list-sublevels t)))
3098 ("h" "Habits" tags-todo "STYLE=\"habit\""
3099 ((org-agenda-overriding-header "Habits")
3100 (org-agenda-sorting-strategy
3101 '(todo-state-down effort-up category-keep))))
3105 ((org-agenda-overriding-header "Tasks to Refile")
3106 (org-tags-match-list-sublevels nil)))
3107 (tags-todo "-HOLD-CANCELLED/!"
3108 ((org-agenda-overriding-header "Projects")
3109 (org-agenda-skip-function 'bh/skip-non-projects)
3110 (org-agenda-sorting-strategy
3112 (tags-todo "-CANCELLED/!"
3113 ((org-agenda-overriding-header "Stuck Projects")
3114 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3115 (tags-todo "-WAITING-CANCELLED/!NEXT"
3116 ((org-agenda-overriding-header "Next Tasks")
3117 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3118 (org-agenda-todo-ignore-scheduled t)
3119 (org-agenda-todo-ignore-deadlines t)
3120 (org-agenda-todo-ignore-with-date t)
3121 (org-tags-match-list-sublevels t)
3122 (org-agenda-sorting-strategy
3123 '(todo-state-down effort-up category-keep))))
3124 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3125 ((org-agenda-overriding-header "Tasks")
3126 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3127 (org-agenda-todo-ignore-scheduled t)
3128 (org-agenda-todo-ignore-deadlines t)
3129 (org-agenda-todo-ignore-with-date t)
3130 (org-agenda-sorting-strategy
3132 (tags-todo "-CANCELLED+WAITING/!"
3133 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
3134 (org-agenda-skip-function 'bh/skip-stuck-projects)
3135 (org-tags-match-list-sublevels nil)
3136 (org-agenda-todo-ignore-scheduled 'future)
3137 (org-agenda-todo-ignore-deadlines 'future)))
3139 ((org-agenda-overriding-header "Tasks to Archive")
3140 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3141 (org-tags-match-list-sublevels nil))))
3143 ("r" "Tasks to Refile" tags "REFILE"
3144 ((org-agenda-overriding-header "Tasks to Refile")
3145 (org-tags-match-list-sublevels nil)))
3146 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
3147 ((org-agenda-overriding-header "Stuck Projects")
3148 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3149 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
3150 ((org-agenda-overriding-header "Next Tasks")
3151 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3152 (org-agenda-todo-ignore-scheduled t)
3153 (org-agenda-todo-ignore-deadlines t)
3154 (org-agenda-todo-ignore-with-date t)
3155 (org-tags-match-list-sublevels t)
3156 (org-agenda-sorting-strategy
3157 '(todo-state-down effort-up category-keep))))
3158 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3159 ((org-agenda-overriding-header "Tasks")
3160 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3161 (org-agenda-sorting-strategy
3163 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
3164 ((org-agenda-overriding-header "Projects")
3165 (org-agenda-skip-function 'bh/skip-non-projects)
3166 (org-agenda-sorting-strategy
3168 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
3169 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
3170 (org-tags-match-list-sublevels nil))
3171 ("A" "Tasks to Archive" tags "-REFILE/"
3172 ((org-agenda-overriding-header "Tasks to Archive")
3173 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3174 (org-tags-match-list-sublevels nil))))))
3176 ; Overwrite the current window with the agenda
3177 (setq org-agenda-window-setup 'current-window)
3182 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3184 ;; Resume clocking task when emacs is restarted
3185 (org-clock-persistence-insinuate)
3187 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
3188 (setq org-clock-history-length 36)
3189 ;; Resume clocking task on clock-in if the clock is open
3190 (setq org-clock-in-resume t)
3191 ;; Change tasks to NEXT when clocking in
3192 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
3193 ;; Separate drawers for clocking and logs
3194 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
3195 ;; Save clock data and state changes and notes in the LOGBOOK drawer
3196 (setq org-clock-into-drawer t)
3197 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
3198 (setq org-clock-out-remove-zero-time-clocks t)
3199 ;; Clock out when moving task to a done state
3200 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
3201 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
3202 (setq org-clock-persist t)
3203 ;; Do not prompt to resume an active clock
3204 (setq org-clock-persist-query-resume nil)
3205 ;; Enable auto clock resolution for finding open clocks
3206 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
3207 ;; Include current clocking task in clock reports
3208 (setq org-clock-report-include-clocking-task t)
3210 ; use discrete minute intervals (no rounding) increments
3211 (setq org-time-stamp-rounding-minutes (quote (1 1)))
3213 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
3215 (setq bh/keep-clock-running nil)
3217 (setq org-agenda-clock-consistency-checks
3218 (quote (:max-duration "4:00"
3221 :gap-ok-around ("4:00"))))
3225 **** Setting a default clock task
3226 Per default the =** Organization= task in my tasks.org file receives
3227 misc clock time. This is the task I clock in on when I punch in at the
3228 start of my work day with =F9-I=. Punching-in anywhere clocks in this
3229 Organization task as the default task.
3231 If I want to change the default clocking task I just visit the
3232 new task in any org buffer and clock it in with =C-u C-u C-c C-x
3233 C-i=. Now this new task that collects miscellaneous clock
3234 minutes when the clock would normally stop.
3236 You can quickly clock in the default clocking task with =C-u C-c
3237 C-x C-i d=. Another option is to repeatedly clock out so the
3238 clock moves up the project tree until you clock out the
3239 top-level task and the clock moves to the default task.
3242 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3243 ;; Agenda clock report parameters
3244 (setq org-agenda-clockreport-parameter-plist
3245 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
3247 ;; Agenda log mode items to display (closed and state changes by default)
3248 (setq org-agenda-log-mode-items (quote (closed state)))
3250 **** Task estimates, column view
3251 Setup column view globally with the following headlines
3252 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3253 ; Set default column view headings: Task Effort Clock_Summary
3254 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
3256 Setup the estimate for effort values.
3257 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3258 ; global Effort estimate values
3259 ; global STYLE property values for completion
3260 (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")
3261 ("STYLE_ALL" . "habit"))))
3265 Tags are mostly used for filtering inside the agenda.
3266 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3267 ; Tags with fast selection keys
3268 (setq org-tag-alist (quote ((:startgroup)
3286 ; Allow setting single tags without the menu
3287 (setq org-fast-tag-selection-single-key (quote expert))
3289 ; For tag searches ignore tasks with scheduled and deadline dates
3290 (setq org-agenda-tags-todo-honor-ignore-options t)
3294 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3295 (setq org-archive-mark-done nil)
3296 (setq org-archive-location "%s_archive::* Archived Tasks")
3300 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3301 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
3302 (setq org-plantuml-jar-path "~/java/plantuml.jar")
3304 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
3306 ; Make babel results blocks lowercase
3307 (setq org-babel-results-keyword "results")
3309 (org-babel-do-load-languages
3310 (quote org-babel-load-languages)
3311 (quote ((emacs-lisp . t)
3330 ; Do not prompt to confirm evaluation
3331 ; This may be dangerous - make sure you understand the consequences
3332 ; of setting this -- see the docstring for details
3333 (setq org-confirm-babel-evaluate nil)
3335 ; Use fundamental mode when editing plantuml blocks with C-c '
3336 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
3339 #+BEGIN_SRC emacs-lisp :tangle yes
3340 ;; Don't have images visible on startup, breaks on console
3341 (setq org-startup-with-inline-images nil)
3344 #+BEGIN_SRC emacs-lisp :tangle yes
3345 (add-to-list 'org-structure-template-alist
3346 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
3347 "<comment>\n?\n</comment>"))
3349 **** ditaa, graphviz, etc
3350 Those are all nice tools. Look at
3351 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
3354 *** Publishing and exporting
3357 Org-mode can export to a variety of publishing formats including (but not limited to)
3360 (plain text - but not the original org-mode file)
3364 which enables getting to lots of other formats like ODF, XML, etc
3366 via LaTeX or Docbook
3369 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
3371 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3372 ;; Explicitly load required exporters
3376 ;; FIXME, check the following two
3377 ;(require 'ox-icalendar)
3380 ; experimenting with docbook exports - not finished
3381 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
3382 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
3384 ;; define categories that should be excluded
3385 (setq org-export-exclude-category (list "google" "google"))
3386 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
3388 ; define how the date strings look
3389 (setq org-export-date-timestamp-format "%Y-%m-%d")
3390 ; Inline images in HTML instead of producting links to the image
3391 (setq org-html-inline-images t)
3392 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
3393 (setq org-export-with-sub-superscripts nil)
3395 (setq org-html-head-extra (concat
3396 "<link rel=\"stylesheet\" href=\"http://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
3398 (setq org-html-head-include-default-style nil)
3399 ; Do not generate internal css formatting for HTML exports
3400 (setq org-export-htmlize-output-type (quote css))
3401 ; Export with LaTeX fragments
3402 (setq org-export-with-LaTeX-fragments t)
3403 ; Increase default number of headings to export
3404 (setq org-export-headline-levels 6)
3407 (setq org-publish-project-alist
3410 :base-directory "~/.emacs.d/"
3411 :base-extension "org"
3413 :publishing-directory "/develop/www/emacs"
3415 :publishing-function org-html-publish-to-html
3416 :headline-levels 4 ; Just the default for this project.
3422 :base-directory "~/.emacs.d/"
3423 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
3424 :publishing-directory "/develop/www/emacs"
3425 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
3427 :publishing-function org-publish-attachment
3429 ("inherit-org-info-js"
3430 :base-directory "/develop/vcs/org-info-js/"
3432 :base-extension "js"
3433 :publishing-directory "/develop/www/"
3434 :publishing-function org-publish-attachment
3436 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
3441 (setq org-export-with-timestamps nil)
3446 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3447 (setq org-latex-to-pdf-process
3448 '("xelatex -interaction nonstopmode %f"
3449 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
3450 (setq org-export-latex-listings 'minted)
3451 (setq org-latex-listings t)
3453 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
3454 ;; but adapted to use latexmk 4.20 or higher.
3455 (defun my-auto-tex-cmd ()
3456 "When exporting from .org with latex, automatically run latex,
3457 pdflatex, or xelatex as appropriate, using latexmk."
3459 ;; default command: oldstyle latex via dvi
3460 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
3462 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
3463 (setq texcmd "latexmk -pdf -quiet %f"))
3465 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3466 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
3467 ;; LaTeX compilation command
3468 (setq org-latex-to-pdf-process (list texcmd)))
3470 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
3472 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
3473 (setq org-export-latex-packages-alist
3475 ("" "longtable" nil)
3480 (defun my-auto-tex-parameters ()
3481 "Automatically select the tex packages to include."
3482 ;; default packages for ordinary latex or pdflatex export
3483 (setq org-export-latex-default-packages-alist
3484 '(("AUTO" "inputenc" t)
3494 ("" "hyperref" nil)))
3496 ;; Packages to include when xelatex is used
3497 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3498 (setq org-export-latex-default-packages-alist
3503 ("german" "babel" t)
3504 ("babel" "csquotes" t)
3506 ("xetex" "hyperref" nil)
3509 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
3510 (setq org-export-latex-classes
3512 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
3513 ("\\section{%s}" . "\\section*{%s}")
3514 ("\\subsection{%s}" . "\\subsection*{%s}")
3515 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
3516 ("\\paragraph{%s}" . "\\paragraph*{%s}")
3517 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
3518 org-export-latex-classes))))
3520 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
3523 *** Prevent editing invisible text
3524 The following setting prevents accidentally editing hidden text when
3525 the point is inside a folded region. This can happen if you are in
3526 the body of a heading and globally fold the org-file with =S-TAB=
3528 I find invisible edits (and undo's) hard to deal with so now I can't
3529 edit invisible text. =C-c C-r= (org-reveal) will display where the
3530 point is if it is buried in invisible text to allow editing again.
3532 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3533 (setq org-catch-invisible-edits 'error)
3537 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3538 ;; disable the default org-mode stuck projects agenda view
3539 (setq org-stuck-projects (quote ("" nil nil "")))
3541 ; force showing the next headline.
3542 (setq org-show-entry-below (quote ((default))))
3544 (setq org-show-following-heading t)
3545 (setq org-show-hierarchy-above t)
3546 (setq org-show-siblings (quote ((default))))
3548 (setq org-special-ctrl-a/e t)
3549 (setq org-special-ctrl-k t)
3550 (setq org-yank-adjusted-subtrees t)
3552 (setq org-table-export-default-format "orgtbl-to-csv")
3556 The following setting adds alphabetical lists like
3560 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3561 (if (> emacs-major-version 23)
3562 (setq org-list-allow-alphabetical t)
3563 (setq org-alphabetical-lists t))
3566 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3567 (setq org-remove-highlights-with-change nil)
3569 (setq org-list-demote-modify-bullet (quote (("+" . "-")
3576 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
3579 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
3580 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
3585 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3586 ;; Enable abbrev-mode
3587 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
3588 (setq org-startup-indented t)
3589 (setq org-startup-folded t)
3590 (setq org-cycle-separator-lines 0)
3593 I find extra blank lines in lists and headings a bit of a nuisance.
3594 To get a body after a list you need to include a blank line between
3595 the list entry and the body -- and indent the body appropriately.
3596 Most of my lists have no body detail so I like the look of collapsed
3597 lists with no blank lines better.
3599 The following setting prevents creating blank lines before headings
3600 but allows list items to adapt to existing blank lines around the items:
3601 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3602 (setq org-blank-before-new-entry (quote ((heading)
3603 (plain-list-item . auto))))
3606 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3607 (setq org-reverse-note-order nil)
3608 (setq org-default-notes-file "~/notes.org")
3611 Enforce task blocking. Tasks can't go done when there is any subtask
3612 still open. Unless they have a property of =NOBLOCKING: t=
3613 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3614 (setq org-enforce-todo-checkbox-dependencies t)
3615 (setq org-enforce-todo-dependencies t)
3618 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3619 (setq org-fast-tag-selection-single-key (quote expert))
3620 (setq org-footnote-auto-adjust t)
3621 (setq org-hide-block-startup t)
3622 (setq org-icalendar-alarm-time 15)
3623 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
3624 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
3625 (setq org-icalendar-honor-noexport-tag t)
3626 (setq org-icalendar-include-bbdb-anniversaries nil)
3627 (setq org-icalendar-include-body 200)
3628 (setq org-icalendar-include-todo nil)
3629 (setq org-icalendar-store-UID t)
3630 (setq org-icalendar-timezone "Europe/Berlin")
3631 (setq org-insert-mode-line-in-empty-file t)
3632 (setq org-log-done (quote note))
3633 (setq org-log-into-drawer t)
3634 (setq org-log-state-notes-insert-after-drawers nil)
3635 (setq org-log-reschedule (quote time))
3636 (setq org-log-states-order-reversed t)
3637 (setq org-mobile-agendas (quote all))
3638 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
3639 (setq org-mobile-inbox-for-pull "~/org/refile.org")
3640 (setq org-remember-store-without-prompt t)
3641 (setq org-return-follows-link t)
3642 (setq org-reverse-note-order t)
3644 ; regularly save our org-mode buffers
3645 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
3647 (setq org-log-done t)
3649 (setq org-enable-priority-commands t)
3650 (setq org-default-priority ?E)
3651 (setq org-lowest-priority ?E)
3656 Speed commands enable single-letter commands in Org-mode files when
3657 the point is at the beginning of a headline, or at the beginning of a
3660 See the `=org-speed-commands-default=' variable for a list of the keys
3661 and commands enabled at the beginning of headlines. All code blocks
3662 are available at the beginning of a code block, the following key
3663 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
3664 display a list of the code blocks commands and their related keys.
3666 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3667 (setq org-use-speed-commands t)
3668 (setq org-speed-commands-user (quote (("0" . ignore)
3681 ("h" . bh/hide-other)
3684 (call-interactively 'org-insert-heading-respect-content))
3685 ("k" . org-kill-note-or-show-branches)
3688 ("q" . bh/show-org-agenda)
3690 ("s" . org-save-all-org-buffers)
3694 ("z" . org-add-note)
3699 ("F" . bh/restrict-to-file-or-follow)
3702 ("J" . org-clock-goto)
3706 ("N" . bh/narrow-to-org-subtree)
3707 ("P" . bh/narrow-to-org-project)
3712 ("U" . bh/narrow-up-one-org-level)
3719 (add-hook 'org-agenda-mode-hook
3721 (define-key org-agenda-mode-map "q" 'bury-buffer))
3724 (defvar bh/current-view-project nil)
3725 (add-hook 'org-agenda-mode-hook
3726 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
3730 The following displays the contents of code blocks in Org-mode files
3731 using the major-mode of the code. It also changes the behavior of
3732 =TAB= to as if it were used in the appropriate major mode. This means
3733 that reading and editing code form inside of your Org-mode files is
3734 much more like reading and editing of code using its major mode.
3736 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3737 (setq org-src-fontify-natively t)
3738 (setq org-src-tab-acts-natively t)
3741 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3742 (setq org-src-preserve-indentation nil)
3743 (setq org-edit-src-content-indentation 0)
3747 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3748 (setq org-attach-directory "~/org/data/")
3750 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3751 (setq org-agenda-sticky t)
3754 **** Checklist handling
3755 [2013-05-11 Sat 22:15]
3757 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3758 (require 'org-checklist)
3762 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
3764 #+BEGIN_SRC emacs-lisp :tangle yes
3765 (use-package cperl-mode
3766 :commands cperl-mode
3769 (defalias 'perl-mode 'cperl-mode)
3770 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
3771 (add-auto-mode 'pod-mode "\\.pod$")
3772 (add-auto-mode 'tt-mode "\\.tt$")
3773 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
3774 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
3775 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
3779 (setq cperl-invalid-face nil
3780 cperl-close-paren-offset -4
3781 cperl-continued-statement-offset 0
3782 cperl-indent-level 4
3783 cperl-indent-parens-as-block t
3785 cperl-electric-keywords t
3786 cperl-electric-lbrace-space t
3787 cperl-electric-parens nil
3788 cperl-highlight-variables-indiscriminately t
3789 cperl-imenu-addback t
3790 cperl-invalid-face (quote underline)
3791 cperl-lazy-help-time 5
3792 cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$"
3793 cperl-syntaxify-by-font-lock t
3794 cperl-use-syntax-table-text-property-for-tags t)
3796 ;; And have cperl mode give ElDoc a useful string
3797 (defun my-cperl-eldoc-documentation-function ()
3798 "Return meaningful doc string for `eldoc-mode'."
3800 (let ((cperl-message-on-help-error nil))
3802 (add-hook 'cperl-mode-hook
3804 (set (make-local-variable 'eldoc-documentation-function)
3805 'my-cperl-eldoc-documentation-function)
3810 [2014-05-22 Thu 00:05]
3811 #+BEGIN_SRC emacs-lisp :tangle yes
3812 (use-package puppet-mode
3813 :mode ("\\.pp\\'" . puppet-mode)
3815 (use-package puppet-ext
3818 (bind-key "C-x ?" 'puppet-set-anchor puppet-mode-map)
3819 (bind-key "C-c C-r" 'puppet-create-require puppet-mode-map)
3820 (defun my-puppet-mode-hook ()
3821 (setq require-final-newline nil))
3822 (add-hook 'puppet-mode-hook 'my-puppet-mode-hook))))
3826 Use elpy for the emacs python fun, but dont let it initialize all the
3827 various variables. Elpy author may like them, but I'm not him...
3828 #+BEGIN_SRC emacs-lisp :tangle yes
3831 :mode ("\.py" . python-mode)
3834 (safe-load (concat jj-elisp-dir "/elpy/elpy-autoloads.el"))
3841 :commands (nosetests-all nosetests-module nosetests-one
3842 nosetests-failed nosetests-pdb-all
3843 nosetests-pdb-module nosetests-pdb-one)
3848 :commands (pyvenv-activate pyvenv-deactivate pyvenv-mode pyvenv-restart-python)
3851 (use-package idomenu
3856 (use-package highlight-indentation
3858 :commands (highlight-indentation-mode))
3860 (use-package find-file-in-project
3862 :commands (find-file-in-project ffip-project-files ffip ))
3867 ;; Local variables in `python-mode'. This is not removed when Elpy
3868 ;; is disabled, which can cause some confusion.
3869 (add-hook 'python-mode-hook 'elpy-initialize-local-variables)
3871 (defun my-python-mode-hook ()
3872 (setq require-final-newline nil)
3873 (setq mode-require-final-newline))
3874 (add-hook 'python-mode-hook 'my-python-mode-hook)
3876 ;; Flymake support using flake8, including warning faces.
3877 (when (and (executable-find "flake8")
3878 (not (executable-find python-check-command)))
3879 (setq python-check-command "flake8"))
3881 ;; `flymake-no-changes-timeout': The original value of 0.5 is too
3882 ;; short for Python code, as that will result in the current line to
3883 ;; be highlighted most of the time, and that's annoying. This value
3884 ;; might be on the long side, but at least it does not, in general,
3885 ;; interfere with normal interaction.
3886 (setq flymake-no-changes-timeout 60)
3888 ;; `flymake-start-syntax-check-on-newline': This should be nil for
3889 ;; Python, as;; most lines with a colon at the end will mean the next
3890 ;; line is always highlighted as error, which is not helpful and
3892 (setq flymake-start-syntax-check-on-newline nil)
3894 ;; `ac-auto-show-menu': Short timeout because the menu is great.
3895 (setq ac-auto-show-menu 0.4)
3897 ;; `ac-quick-help-delay': I'd like to show the menu right with the
3898 ;; completions, but this value should be greater than
3899 ;; `ac-auto-show-menu' to show help for the first entry as well.
3900 (setq ac-quick-help-delay 0.5)
3902 ;; `yas-trigger-key': TAB, as is the default, conflicts with the
3903 ;; autocompletion. We also need to tell yasnippet about the new
3904 ;; binding. This is a bad interface to set the trigger key. Stop
3906 (let ((old (when (boundp 'yas-trigger-key)
3908 (setq yas-trigger-key "C-c C-i")
3909 (when (fboundp 'yas--trigger-key-reload)
3910 (yas--trigger-key-reload old)))
3912 ;; yas-snippet-dirs can be a string for a single directory. Make
3913 ;; sure it's a list in that case so we can add our own entry.
3914 (when (not (listp yas-snippet-dirs))
3915 (setq yas-snippet-dirs (list yas-snippet-dirs)))
3916 (add-to-list 'yas-snippet-dirs
3917 (concat (file-name-directory (locate-library "elpy"))
3921 ;; Now load yasnippets.
3924 (elpy-use-ipython)))
3929 #+BEGIN_SRC emacs-lisp :tangle no
3930 (autoload 'python-mode "python-mode" "Python Mode." t)
3931 (add-auto-mode 'python-mode "\\.py\\'")
3932 (add-auto-mode 'python-mode "\\.py$")
3933 (add-auto-mode 'python-mode "SConstruct\\'")
3934 (add-auto-mode 'python-mode "SConscript\\'")
3935 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
3938 (set-variable 'py-indent-offset 4)
3939 (set-variable 'py-smart-indentation nil)
3940 (set-variable 'indent-tabs-mode nil)
3941 (define-key python-mode-map "\C-m" 'newline-and-indent)
3942 (turn-on-eldoc-mode)
3943 (defun python-auto-fill-comments-only ()
3945 (set (make-local-variable 'fill-nobreak-predicate)
3947 (not (python-in-string/comment)))))
3948 (add-hook 'python-mode-hook
3950 (python-auto-fill-comments-only)))
3952 (autoload 'pymacs-apply "pymacs")
3953 (autoload 'pymacs-call "pymacs")
3954 (autoload 'pymacs-eval "pymacs" nil t)
3955 (autoload 'pymacs-exec "pymacs" nil t)
3956 (autoload 'pymacs-load "pymacs" nil t))
3959 If an =ipython= executable is on the path, then assume that IPython is
3960 the preferred method python evaluation.
3961 #+BEGIN_SRC emacs-lisp :tangle no
3962 (when (executable-find "ipython")
3964 (setq org-babel-python-mode 'python-mode))
3966 (setq python-shell-interpreter "ipython")
3967 (setq python-shell-interpreter-args "")
3968 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
3969 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
3970 (setq python-shell-completion-setup-code
3971 "from IPython.core.completerlib import module_completion")
3972 (setq python-shell-completion-module-string-code
3973 "';'.join(module_completion('''%s'''))\n")
3974 (setq python-shell-completion-string-code
3975 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
3977 ** rainbow-delimiters
3978 [2013-04-09 Di 23:38]
3979 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
3980 which highlights parens, brackets, and braces according to their
3981 depth. Each successive level is highlighted a different color. This
3982 makes it easy to spot matching delimiters, orient yourself in the code,
3983 and tell which statements are at the same depth.
3984 #+BEGIN_SRC emacs-lisp :tangle yes
3985 (use-package rainbow-delimiters
3986 :ensure rainbow-delimiters
3988 (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
3991 #+BEGIN_SRC emacs-lisp :tangle yes
3992 (use-package rainbow-mode
3993 :ensure rainbow-mode
3994 :diminish rainbow-mode)
3999 #+BEGIN_SRC emacs-lisp :tangle yes
4000 (use-package re-builder
4004 (setq reb-re-syntax 'string))
4007 [2014-05-19 Mo 22:56]
4008 Recentf is a minor mode that builds a list of recently opened
4009 files. This list is is automatically saved across Emacs sessions.
4010 #+BEGIN_SRC emacs-lisp :tangle yes
4011 (use-package recentf
4012 :if (not noninteractive)
4013 :bind ("C-x C-r" . recentf-open-files)
4017 (setq recentf-max-menu-items 25)
4018 (setq recentf-save-file (expand-file-name ".recentf" jj-cache-dir))
4020 (defun recentf-add-dired-directory ()
4021 (if (and dired-directory
4022 (file-directory-p dired-directory)
4023 (not (string= "/" dired-directory)))
4024 (let ((last-idx (1- (length dired-directory))))
4026 (if (= ?/ (aref dired-directory last-idx))
4027 (substring dired-directory 0 last-idx)
4028 dired-directory)))))
4030 (add-hook 'dired-mode-hook 'recentf-add-dired-directory)))
4032 ** Region bindings mode
4033 [2013-05-01 Wed 22:51]
4034 This mode allows to have keybindings that are only alive when the
4035 region is active. Helpful for things that only do any useful action
4036 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
4037 #+BEGIN_SRC emacs-lisp :tangle yes
4038 (use-package region-bindings-mode
4039 :ensure region-bindings-mode
4041 (region-bindings-mode-enable))
4044 [2013-05-22 Wed 22:33]
4045 Programming in ruby...
4048 #+BEGIN_SRC emacs-lisp :tangle yes
4049 (add-auto-mode 'ruby-mode
4050 "Rakefile\\'" "\\.rake\\'" "\.rxml\\'"
4051 "\\.rjs\\'" ".irbrc\\'" "\.builder\\'" "\\.ru\\'"
4052 "\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
4056 #+BEGIN_SRC emacs-lisp :tangle yes
4057 (use-package ruby-mode
4058 :mode ("\\.rb\\'" . ruby-mode)
4059 :interpreter ("ruby" . ruby-mode)
4066 (defvar yari-helm-source-ri-pages
4067 '((name . "RI documentation")
4068 (candidates . (lambda () (yari-ruby-obarray)))
4069 (action ("Show with Yari" . yari))
4070 (candidate-number-limit . 300)
4071 (requires-pattern . 2)
4072 "Source for completing RI documentation."))
4074 (defun helm-yari (&optional rehash)
4075 (interactive (list current-prefix-arg))
4076 (when current-prefix-arg (yari-ruby-obarray rehash))
4077 (helm 'yari-helm-source-ri-pages (yari-symbol-at-point)))))
4079 (defun my-ruby-smart-return ()
4081 (when (memq (char-after) '(?\| ?\" ?\'))
4083 (call-interactively 'newline-and-indent))
4085 (use-package ruby-hash-syntax
4086 :ensure ruby-hash-syntax)
4088 (use-package inf-ruby
4090 :commands inf-ruby-minor-mode
4093 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)
4094 (bind-key "<return>" 'my-ruby-smart-return ruby-mode-map)
4095 ;(bind-key "<tab>" 'indent-for-tab-command ruby-mode-map)
4098 (set (make-local-variable 'yas-fallback-behavior)
4099 '(apply ruby-indent-command . nil))
4100 (bind-key "<tab>" 'yas-expand-from-trigger-key ruby-mode-map)))
4102 ;; Stupidly the non-bundled ruby-mode isn't a derived mode of
4103 ;; prog-mode: we run the latter's hooks anyway in that case.
4104 (add-hook 'ruby-mode-hook
4106 (unless (derived-mode-p 'prog-mode)
4107 (run-hooks 'prog-mode-hook))))
4111 [2013-05-22 Wed 22:40]
4112 Save and restore the desktop
4113 #+BEGIN_SRC emacs-lisp :tangle yes
4114 (setq desktop-path (list jj-cache-dir))
4115 (desktop-save-mode 1)
4116 (defadvice desktop-read (around trace-desktop-errors activate)
4117 (let ((debug-on-error t))
4120 ;;----------------------------------------------------------------------------
4121 ;; Restore histories and registers after saving
4122 ;;----------------------------------------------------------------------------
4123 (use-package session
4124 :if (not noninteractive)
4125 :load-path "site-lisp/session/lisp/"
4128 (setq session-save-file (expand-file-name "session" jj-cache-dir))
4129 (setq desktop-globals-to-save
4130 (append '((extended-command-history . 30)
4131 (file-name-history . 100)
4133 (compile-history . 30)
4134 (minibuffer-history . 50)
4135 (query-replace-history . 60)
4136 (read-expression-history . 60)
4137 (regexp-history . 60)
4138 (regexp-search-ring . 20)
4140 (comint-input-ring . 50)
4141 (shell-command-history . 50)
4143 desktop-missing-file-warning
4147 (session-initialize)
4149 (defun remove-session-use-package-from-settings ()
4150 (when (string= (file-name-nondirectory (buffer-file-name)) "settings.el")
4152 (goto-char (point-min))
4153 (when (re-search-forward "^ '(session-use-package " nil t)
4154 (delete-region (line-beginning-position)
4155 (1+ (line-end-position)))))))
4157 (add-hook 'before-save-hook 'remove-session-use-package-from-settings)
4159 ;; expanded folded secitons as required
4160 (defun le::maybe-reveal ()
4161 (when (and (or (memq major-mode '(org-mode outline-mode))
4162 (and (boundp 'outline-minor-mode)
4163 outline-minor-mode))
4164 (outline-invisible-p))
4165 (if (eq major-mode 'org-mode)
4169 (add-hook 'session-after-jump-to-last-change-hook
4172 (defun save-information ()
4173 (with-temp-message "Saving Emacs information..."
4176 (loop for func in kill-emacs-hook
4177 unless (memq func '(exit-gnus-on-exit server-force-stop))
4180 (unless (or noninteractive
4181 (eq 'listen (process-status server-process)))
4184 (run-with-idle-timer 300 t 'save-information)
4187 (add-hook 'after-init-hook 'session-initialize t))))
4191 [2013-04-21 So 20:25]
4192 Save a bit of history
4193 #+BEGIN_SRC emacs-lisp tangle no