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 (cons jj-info-dir
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"
131 "/usr/share/info/")))
132 (setq Info-default-directory-list
133 (cons jj-info-dir 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
408 (setq comint-buffer-maximum-size 20000) ; max lenght of the buffer in lines
409 (setq comint-prompt-read-only nil) ; if this is t, it breaks shell-command
413 ** Miscellaneous stuff
415 Searches and matches should ignore case.
416 #+BEGIN_SRC emacs-lisp :tangle yes
417 (setq-default case-fold-search t)
420 Which buffers to get rid off at midnight.
421 #+BEGIN_SRC emacs-lisp :tangle yes
422 (setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
423 "*Man " "*Buffer List*"
429 "*magit" "*Calendar")))
432 Don't display a cursor in non-selected windows.
433 #+BEGIN_SRC emacs-lisp :tangle yes
434 (setq-default cursor-in-non-selected-windows nil)
437 What should be displayed in the mode-line for files with those types
439 #+BEGIN_SRC emacs-lisp :tangle yes
440 (setq eol-mnemonic-dos "(DOS)")
441 (setq eol-mnemonic-mac "(Mac)")
444 Much larger threshold for garbage collection prevents it to run too often.
445 #+BEGIN_SRC emacs-lisp :tangle yes
446 (setq gc-cons-threshold 48000000)
449 #+BEGIN_SRC emacs-lisp :tangle yes
450 (setq max-lisp-eval-depth 1000)
451 (setq max-specpdl-size 3000)
455 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
456 #+BEGIN_SRC emacs-lisp :tangle yes
457 (defun unfill-paragraph ()
458 "Takes a multi-line paragraph and makes it into a single line of text."
460 (let ((fill-column (point-max)))
461 (fill-paragraph nil)))
462 (bind-key "H-u" 'unfill-paragraph)
465 #+BEGIN_SRC emacs-lisp :tangle yes
466 (setq-default indicate-empty-lines t)
467 (setq sentence-end-double-space nil)
470 Hilight annotations in comments, like FIXME/TODO/...
471 #+BEGIN_SRC emacs-lisp :tangle yes
472 (add-hook 'prog-mode-hook 'font-lock-comment-annotations)
476 #+BEGIN_SRC emacs-lisp :tangle yes
477 (setq browse-url-browser-function (quote browse-url-generic))
478 (setq browse-url-generic-program "/usr/bin/x-www-browser")
481 *** When saving a script - make it executable
482 #+BEGIN_SRC emacs-lisp :tangle yes
483 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
487 #+BEGIN_SRC emacs-lisp :tangle yes
491 (add-hook 'after-init-hook 'server-start)))
494 ** Customized variables
495 [2013-05-02 Thu 22:14]
496 The following contains a set of variables i may reasonably want to
497 change on other systems - which don't affect the init file loading
498 process. So I *can* use the customization interface for it...
499 #+BEGIN_SRC emacs-lisp :tangle yes
500 (defgroup ganneff nil
501 "Modify ganneffs settings"
504 (defgroup ganneff-org-mode nil
505 "Ganneffs org-mode settings"
506 :tag "Ganneffs org-mode settings"
508 :link '(custom-group-link "ganneff"))
510 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
511 "ID of the organization task."
512 :tag "Organization Task ID"
514 :group 'ganneff-org-mode)
516 (defcustom org-my-archive-expiry-days 2
517 "The number of days after which a completed task should be auto-archived.
518 This can be 0 for immediate, or a floating point value."
519 :tag "Archive expiry days"
521 :group 'ganneff-org-mode)
526 [2013-05-21 Tue 23:22]
527 Restore removed var alias, used by ruby-electric-brace and others
528 #+BEGIN_SRC emacs-lisp :tangle yes
529 (unless (boundp 'last-command-char)
530 (defvaralias 'last-command-char 'last-command-event))
532 * Customized variables
534 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
536 Of course I want to be able to use the customize interface, and some
537 things can only be set via it (or so they say). I usually prefer to put
538 things I keep for a long while into statements somewhere else, not just
539 custom-set here, but we need it anyways.
541 #+BEGIN_SRC emacs-lisp :tangle yes
542 (setq custom-file jj-custom-file)
543 (safe-load custom-file)
546 The source of this is:
547 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
550 * Extra modes and their configuration
552 A defined abbrev is a word which expands, if you insert it, into some
553 different text. Abbrevs are defined by the user to expand in specific
555 #+BEGIN_SRC emacs-lisp :tangle yes
557 :commands abbrev-mode
558 :diminish abbrev-mode
560 (hook-into-modes #'abbrev-mode '(text-mode-hook))
563 (setq save-abbrevs 'silently)
564 (setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
565 (if (file-exists-p abbrev-file-name)
566 (quietly-read-abbrev-file))
568 (add-hook 'expand-load-hook
570 (add-hook 'expand-expand-hook 'indent-according-to-mode)
571 (add-hook 'expand-jump-hook 'indent-according-to-mode)))))
574 [2013-04-28 So 11:26]
575 Quickly move around in buffers.
576 #+BEGIN_SRC emacs-lisp :tangle yes
577 (use-package ace-jump-mode
578 :ensure ace-jump-mode
579 :commands ace-jump-mode
580 :bind ("H-SPC" . ace-jump-mode))
583 [2013-04-21 So 20:27]
584 Use H-w to switch windows
585 #+BEGIN_SRC emacs-lisp :tangle yes
586 (use-package ace-window
589 :bind ("H-w" . ace-window))
592 [2014-10-27 Mon 13:08]
593 electric-indent-mode is enough to keep your code nicely aligned when
594 all you do is type. However, once you start shifting blocks around,
595 transposing lines, or slurping and barfing sexps, indentation is bound
598 aggressive-indent-mode is a minor mode that keeps your code always
599 indented. It reindents after every command, making it more reliable
600 than electric-indent-mode.
601 #+BEGIN_SRC emacs-lisp :tangle yes
602 (use-package aggressive-indent
603 :ensure aggressive-indent
604 :commands (aggressive-indent-mode global-aggressive-indent-mode)
607 (global-aggressive-indent-mode 0)
608 (setq aggressive-indent-comments-too 0)
609 (add-to-list 'aggressive-indent-excluded-modes 'html-mode)
613 [2014-06-01 Sun 23:02]
614 Provides a minor mode which displays current match and total matches
615 information in the mode-line in various search modes.
616 #+BEGIN_SRC emacs-lisp :tangle yes
623 (global-anzu-mode 1))
626 (setq anzu-search-threshold 1000)
627 (set-face-attribute 'anzu-mode-line nil :foreground "yellow" :weight 'bold)))
630 [2014-05-21 Wed 00:33]
631 #+BEGIN_SRC emacs-lisp :tangle yes
633 :commands (ascii-on ascii-toggle ascii-display)
634 :bind (("C-c e A" . ascii-toggle))
637 (defun ascii-toggle ()
639 (defvar ascii-display nil)
644 (bind-key "C-c e A" 'ascii-toggle)))
647 #+BEGIN_SRC emacs-lisp :tangle yes
648 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
649 (setq TeX-auto-save t)
650 (setq TeX-parse-self t)
651 (setq TeX-PDF-mode t)
653 ** auto-complete mode
654 [2013-04-27 Sa 16:33]
655 And aren't we all lazy? I definitely am, and I like my emacs doing as
656 much possible work for me as it can.
657 So here, auto-complete-mode, which lets emacs do this, based on what I
659 #+BEGIN_SRC emacs-lisp :tangle yes
660 (use-package auto-complete-config
661 :ensure auto-complete
666 ;; hook AC into completion-at-point
667 (defun sanityinc/auto-complete-at-point ()
668 (when (and (not (minibufferp))
669 (fboundp 'auto-complete-mode)
672 (defun set-auto-complete-as-completion-at-point-function ()
673 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
674 ;; Exclude very large buffers from dabbrev
675 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
676 (< (buffer-size other-buffer) (* 1 1024 1024)))
681 ;; custom keybindings to use tab, enter and up and down arrows
682 (bind-key "\t" 'ac-expand ac-complete-mode-map)
683 (bind-key "\r" 'ac-complete ac-complete-mode-map)
684 (bind-key "M-n" 'ac-next ac-complete-mode-map)
685 (bind-key "M-p" 'ac-previous ac-complete-mode-map)
686 (bind-key "C-s" 'ac-isearch ac-completing-map)
687 (bind-key "M-TAB" 'auto-complete ac-mode-map)
689 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
690 (setq ac-use-comphist t)
691 (setq ac-expand-on-auto-complete nil)
693 (setq ac-auto-start 3)
695 (setq ac-menu-height 15)
696 (setq ac-quick-help-delay 0.5)
697 (setq ac-use-fuzzy t)
699 (ac-flyspell-workaround)
701 ;; use 't when auto-complete is disabled
702 (setq tab-always-indent 'complete)
703 (add-to-list 'completion-styles 'initials t)
705 ;; Use space and punctuation to accept the current the most likely completion.
706 (setq auto-completion-syntax-alist (quote (global accept . word)))
707 ;; Avoid completion for short trivial words.
708 (setq auto-completion-min-chars (quote (global . 3)))
709 (setq completion-use-dynamic t)
711 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
713 ;; Exclude very large buffers from dabbrev
714 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
716 (use-package ac-dabbrev
719 (set-default 'ac-sources
722 ac-source-words-in-buffer
723 ac-source-words-in-same-mode-buffers
724 ; ac-source-words-in-all-buffer
727 (dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
728 sass-mode yaml-mode csv-mode espresso-mode haskell-mode
729 html-mode nxml-mode sh-mode smarty-mode clojure-mode
730 lisp-mode textile-mode markdown-mode tuareg-mode python-mode
731 js3-mode css-mode less-css-mode sql-mode ielm-mode))
732 (add-to-list 'ac-modes mode))
734 (add-hook 'latex-mode-hook 'auto-complete-mode)
735 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
736 (add-hook 'prog-mode-hook 'auto-complete-mode)
737 (add-hook 'org-mode-hook 'auto-complete-mode)))
742 When files change outside emacs for whatever reason I want emacs to deal
743 with it. Not to have to revert buffers myself
744 #+BEGIN_SRC emacs-lisp :tangle yes
745 (use-package autorevert
746 :commands auto-revert-mode
747 :diminish auto-revert-mode
750 (setq global-auto-revert-mode t)
751 (setq global-auto-revert-non-file-buffers t)
752 (global-auto-revert-mode)))
756 Emacs should keep backup copies of files I edit, but I do not want them
757 to clutter up the filesystem everywhere. So I put them into one defined
758 place, backup-directory, which even contains my username (for systems
759 where =temporary-file-directory= is not inside my home).
760 #+BEGIN_SRC emacs-lisp :tangle yes
761 (use-package backups-mode
762 :load-path "elisp/backups-mode"
763 :bind (("\C-cv" . save-version)
764 ("\C-cb" . list-backups)
765 ("\C-ck" . kill-buffer-prompt)
766 ("\C-cw" . backup-walker-start))
769 (setq backup-directory jj-backup-directory)
770 ;(setq tramp-backup-directory (concat jj-backup-directory "/tramp"))
771 ;(if (not (file-exists-p tramp-backup-directory))
772 ; (make-directory tramp-backup-directory))
773 ;(setq tramp-backup-directory-alist `((".*" . ,tramp-backup-directory)))
774 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
775 (setq auto-save-list-file-prefix (concat jj-backup-directory ".auto-saves-"))
776 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
778 (setq version-control t) ;; Use version numbers for backups
779 (setq kept-new-versions 10) ;; Number of newest versions to keep
780 (setq kept-old-versions 2) ;; Number of oldest versions to keep
781 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
782 (setq backup-by-copying t)
783 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
784 (setq make-backup-files t)
786 (defadvice kill-buffer (around kill-buffer)
787 "Always save before killing a file buffer"
788 (when (and (buffer-modified-p)
790 (file-exists-p (buffer-file-name)))
793 (ad-activate 'kill-buffer)
795 (defadvice save-buffers-kill-emacs (around save-buffers-kill-emacs)
796 "Always save before killing emacs"
797 (save-some-buffers t)
799 (ad-activate 'save-buffers-kill-emacs)
801 (defun kill-buffer-prompt ()
802 "Allows one to kill a buffer without saving it.
803 This is necessary since once you start backups-mode all file based buffers
804 are saved automatically when they are killed"
806 (if (and (buffer-modified-p) (buffer-file-name) (file-exists-p (buffer-file-name)) (y-or-n-p "Save buffer?"))
808 (set-buffer-modified-p nil))
811 (setq backup-enable-predicate
813 (and (normal-backup-enable-predicate name)
815 (let ((method (file-remote-p name 'method)))
816 (when (stringp method)
817 (member method '("su" "sudo"))))))))))
821 [2014-12-11 Thu 11:31]
822 #+BEGIN_SRC emacs-lisp :tangle yes
823 (use-package browse-kill-ring
824 :commands (browse-kill-ring browse-kill-ring-mode)
825 :bind ("M-y" . browse-kill-ring)
829 [2014-06-10 Tue 22:20]
830 #+BEGIN_SRC emacs-lisp :tangle yes
832 :commands (cal/insert)
833 :bind ("C-c c" . cal/insert)
836 ; Weeks start on Monday, not sunday.
837 (setq calendar-week-start-day 1)
839 ; Display ISO week numbers in Calendar Mode
840 (copy-face font-lock-constant-face 'calendar-iso-week-face)
841 (set-face-attribute 'calendar-iso-week-face nil :height 0.7)
842 (setq calendar-intermonth-text
846 (calendar-iso-from-absolute
847 (calendar-absolute-from-gregorian (list month day year)))))
848 'font-lock-face 'calendar-iso-week-face))
849 (copy-face 'default 'calendar-iso-week-header-face)
850 (set-face-attribute 'calendar-iso-week-header-face nil :height 0.7)
851 (setq calendar-intermonth-header
852 (propertize "Wk" ; or e.g. "KW" in Germany
853 'font-lock-face 'calendar-iso-week-header-face))))
858 [2013-05-21 Tue 23:18]
859 #+BEGIN_SRC emacs-lisp :tangle yes
860 (use-package crontab-mode
862 :commands crontab-mode
863 :mode ("\\.?cron\\(tab\\)?\\'" . crontab-mode))
867 web-mode takes over, see [[*web-mode][web-mode]]
868 #+BEGIN_SRC emacs-lisp :tangle no
869 (use-package css-mode
870 :mode ("\\.css\\'" . css-mode)
875 (use-package flymake-css
879 (defun maybe-flymake-css-load ()
880 "Activate flymake-css as necessary, but not in derived modes."
881 (when (eq major-mode 'css-mode)
883 (add-hook 'css-mode-hook 'maybe-flymake-css-load)))
884 ;;; Auto-complete CSS keywords
885 (eval-after-load 'auto-complete
887 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
888 (add-hook hook 'ac-css-mode-setup))))))
892 I know that this lets it look "more like windows", but I don't much care
893 about its paste/copy/cut keybindings, the really nice part is the great
894 support for rectangular regions, which I started to use a lot since I
895 know this mode. The normal keybindings for those are just to useless.
896 #+BEGIN_SRC emacs-lisp :tangle yes
898 (setq cua-enable-cua-keys (quote shift))
901 Luckily cua-mode easily supports this, with the following line I just
902 get the CUA selection and rectangle stuff, not the keybindings. Yes,
903 even though the above =cua-enable-cua-keys= setting would only enable
904 them if the selection is done when the region was marked with a shifted
906 #+BEGIN_SRC emacs-lisp :tangle yes
907 (cua-selection-mode t)
911 #+BEGIN_SRC emacs-lisp :tangle yes
912 (require 'dpkg-dev-el-loaddefs nil 'noerror)
913 (require 'debian-el-loaddefs nil 'noerror)
915 (setq debian-changelog-full-name "Joerg Jaspert")
916 (setq debian-changelog-mailing-address "joerg@debian.org")
920 #+BEGIN_SRC emacs-lisp :tangle yes
921 (use-package diff-mode
923 :mode (("\\.diff" . diff-mode))
925 (use-package diff-mode-))
930 #+BEGIN_SRC emacs-lisp :tangle yes
932 :commands (dired dired-other-window dired-other-frame dired-noselect
933 dired-mode dired-jump)
934 :defines (dired-omit-regexp-orig)
937 (setq diredp-hide-details-initially-flag nil))
940 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
941 (setq dired-dwim-target t)
942 (setq dired-listing-switches "-alh")
943 (setq dired-listing-switches "-alXh --group-directories-first")
944 (setq dired-recursive-copies (quote top))
945 (setq dired-recursive-deletes (quote top))
946 (setq dired-guess-shell-alist-user
947 '(("\\.pdf\\'" "mupdf" "evince")
948 ("\\.\\(?:djvu\\|eps\\)\\'" "evince")
949 ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "eog")
950 ("\\.\\(?:xcf\\)\\'" "gimp")
951 ("\\.csv\\'" "libreoffice")
952 ("\\.tex\\'" "pdflatex" "latex")
953 ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\)\\(?:\\.part\\)?\\'" "vlc")
954 ("\\.html?\\'" "conkeror")))
956 (bind-key "F" 'find-name-dired dired-mode-map)
961 (use-package dired-x)
963 (use-package dired-single
967 (bind-key "<return>" 'dired-single-buffer dired-mode-map)
968 (bind-key "<mouse-1>" 'dired-single-buffer-mouse dired-mode-map)
971 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
977 (setq wdired-allow-to-change-permissions t)
978 (bind-key "r" 'wdired-change-to-wdired-mode dired-mode-map)))
980 (use-package gnus-dired
981 :commands (gnus-dired-attach gnus-dired-mode)
984 ;;(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
985 (bind-key "a" 'gnus-dired-attach dired-mode-map)))
990 (defvar mark-files-cache (make-hash-table :test #'equal))
992 (defun mark-similar-versions (name)
994 (if (string-match "^\\(.+?\\)-[0-9._-]+$" pat)
995 (setq pat (match-string 1 pat)))
996 (or (gethash pat mark-files-cache)
997 (ignore (puthash pat t mark-files-cache)))))
999 (defun dired-mark-similar-version ()
1001 (setq mark-files-cache (make-hash-table :test #'equal))
1002 (dired-mark-sexp '(mark-similar-versions name)))
1004 (defun dired-package-initialize ()
1005 (unless (featurep 'runner)
1006 (bind-key "M-!" 'async-shell-command dired-mode-map)
1007 (unbind-key "M-s f" dired-mode-map)
1009 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1010 "Make sure to remove \"Omit\" from the modeline."
1011 (diminish 'dired-omit-mode) dired-mode-map)
1013 ;; Omit files that Git would ignore
1014 (defun dired-omit-regexp ()
1015 (let ((file (expand-file-name ".git"))
1017 (while (and (not (file-exists-p file))
1020 (file-name-directory
1021 (directory-file-name
1022 (file-name-directory file))))
1023 ;; Give up if we are already at the root dir.
1024 (not (string= (file-name-directory file)
1026 ;; Move up to the parent dir and try again.
1027 (setq file (expand-file-name ".git" parent-dir)))
1028 ;; If we found a change log in a parent, use that.
1029 (if (file-exists-p file)
1030 (let ((regexp (funcall dired-omit-regexp-orig))
1032 (shell-command-to-string "git clean -d -x -n")))
1033 (if (= 0 (length omitted-files))
1037 (if (> (length regexp) 0)
1046 (if (= ?/ (aref str (1- (length str))))
1050 (split-string omitted-files "\n" t)
1053 (funcall dired-omit-regexp-orig))))))
1055 (add-hook 'dired-mode-hook 'dired-package-initialize)
1057 (defun dired-double-jump (first-dir second-dir)
1059 (list (read-directory-name "First directory: "
1060 (expand-file-name "~")
1061 nil nil "/Downloads/")
1062 (read-directory-name "Second directory: "
1063 (expand-file-name "~")
1066 (dired-other-window second-dir))
1067 (bind-key "C-c J" 'dired-double-jump)
1069 (defun dired-back-to-top ()
1071 (goto-char (point-min))
1072 (dired-next-line 4))
1074 (define-key dired-mode-map
1075 (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
1077 (defun dired-jump-to-bottom ()
1079 (goto-char (point-max))
1080 (dired-next-line -1))
1082 (define-key dired-mode-map
1083 (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)))
1086 ** discover-my-major
1087 [2014-06-01 Sun 23:32]
1088 Discover key bindings and their meaning for the current Emacs major mode.
1089 #+BEGIN_SRC emacs-lisp :tangle yes
1090 (use-package discover-my-major
1091 :ensure discover-my-major
1092 :commands discover-my-major
1093 :bind ("C-h C-m" . discover-my-major))
1096 EasyPG is a GnuPG interface for Emacs.
1097 Bookmark: [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1098 #+BEGIN_SRC emacs-lisp :tangle yes
1099 (use-package epa-file
1103 ;; I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1104 (defadvice epg--start (around advice-epg-disable-agent disable)
1105 "Don't allow epg--start to use gpg-agent in plain text
1107 (if (display-graphic-p)
1109 (let ((agent (getenv "GPG_AGENT_INFO")))
1110 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
1112 (setenv "GPG_AGENT_INFO" agent))))
1113 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
1114 (ad-activate 'epg--start)
1118 [2013-04-21 So 20:36]
1119 ediff - don't start another frame
1120 #+BEGIN_SRC emacs-lisp :tangle yes
1124 (defvar ctl-period-equals-map)
1125 (define-prefix-command 'ctl-period-equals-map)
1126 (bind-key "C-. =" 'ctl-period-equals-map)
1127 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
1129 :bind (("C-. = b" . ediff-buffers)
1130 ("C-. = B" . ediff-buffers3)
1131 ("C-. = =" . ediff-files)
1132 ("C-. = f" . ediff-files)
1133 ("C-. = F" . ediff-files3)
1134 ("C-. = r" . ediff-revision)
1135 ("C-. = p" . ediff-patch-file)
1136 ("C-. = P" . ediff-patch-buffer)
1137 ("C-. = l" . ediff-regions-linewise)
1138 ("C-. = w" . ediff-regions-wordwise))
1140 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1141 (setq ediff-split-window-function 'split-window-horizontally)
1147 EMMS is the Emacs Multimedia System.
1148 #+BEGIN_SRC emacs-lisp :tangle no
1149 (require 'emms-source-file)
1150 (require 'emms-source-playlist)
1151 (require 'emms-info)
1152 (require 'emms-cache)
1153 (require 'emms-playlist-mode)
1154 (require 'emms-playing-time)
1155 (require 'emms-player-mpd)
1156 (require 'emms-playlist-sort)
1157 (require 'emms-mark)
1158 (require 'emms-browser)
1159 (require 'emms-lyrics)
1160 (require 'emms-last-played)
1161 (require 'emms-score)
1162 (require 'emms-tag-editor)
1163 (require 'emms-history)
1164 (require 'emms-i18n)
1166 (setq emms-playlist-default-major-mode 'emms-playlist-mode)
1167 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
1168 (emms-playing-time 1)
1170 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
1171 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
1173 (when (fboundp 'emms-cache) ; work around compiler warning
1175 (setq emms-score-default-score 3)
1177 (defun emms-mpd-init ()
1178 "Connect Emms to mpd."
1180 (emms-player-mpd-connect))
1183 (require 'emms-player-mpd)
1184 (setq emms-player-mpd-server-name "localhost")
1185 (setq emms-player-mpd-server-port "6600")
1186 (add-to-list 'emms-info-functions 'emms-info-mpd)
1187 (add-to-list 'emms-player-list 'emms-player-mpd)
1188 (setq emms-volume-change-function 'emms-volume-mpd-change)
1189 (setq emms-player-mpd-sync-playlist t)
1191 (setq emms-source-file-default-directory "/var/lib/mpd/music")
1192 (setq emms-player-mpd-music-directory "/var/lib/mpd/music")
1193 (setq emms-info-auto-update t)
1194 (setq emms-lyrics-scroll-p t)
1195 (setq emms-lyrics-display-on-minibuffer t)
1196 (setq emms-lyrics-display-on-modeline nil)
1197 (setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
1199 (setq emms-last-played-format-alist
1200 '(((emms-last-played-seconds-today) . "%H:%M")
1201 (604800 . "%a %H:%M") ; this week
1202 ((emms-last-played-seconds-month) . "%d.%m.%Y")
1203 ((emms-last-played-seconds-year) . "%d.%m.%Y")
1204 (t . "Never played")))
1207 (defun my-describe (track)
1208 (let* ((empty "...")
1209 (name (emms-track-name track))
1210 (type (emms-track-type track))
1211 (short-name (file-name-nondirectory name))
1212 (play-count (or (emms-track-get track 'play-count) 0))
1213 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
1214 (artist (or (emms-track-get track 'info-artist) empty))
1215 (year (emms-track-get track 'info-year))
1216 (playing-time (or (emms-track-get track 'info-playing-time) 0))
1217 (min (/ playing-time 60))
1218 (sec (% playing-time 60))
1219 (album (or (emms-track-get track 'info-album) empty))
1220 (tracknumber (emms-track-get track 'info-tracknumber))
1221 (short-name (file-name-sans-extension
1222 (file-name-nondirectory name)))
1223 (title (or (emms-track-get track 'info-title) short-name))
1224 (rating (emms-score-get-score name))
1227 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
1228 (emms-last-played-format-date last-played)
1232 (if (and tracknumber ; tracknumber
1233 (not (zerop (string-to-number tracknumber))))
1234 (format "%02d" (string-to-number tracknumber))
1238 (make-string rating rate-char)))
1241 (setq emms-track-description-function 'my-describe)
1243 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
1244 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
1245 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
1246 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
1247 (global-set-key (kbd "H-<f9> x") 'emms-start)
1248 (global-set-key (kbd "H-<f9> v") 'emms-stop)
1249 (global-set-key (kbd "H-<f9> n") 'emms-next)
1250 (global-set-key (kbd "H-<f9> p") 'emms-previous)
1251 (global-set-key (kbd "H-<f9> o") 'emms-show)
1252 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
1253 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
1254 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
1255 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
1256 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
1258 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
1259 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
1260 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
1261 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
1263 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
1264 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
1265 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
1266 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
1268 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
1269 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
1270 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
1271 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
1273 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
1274 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
1275 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
1276 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
1277 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
1278 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
1280 (define-key emms-playlist-mode-map "x" 'emms-start)
1281 (define-key emms-playlist-mode-map "v" 'emms-stop)
1282 (define-key emms-playlist-mode-map "n" 'emms-next)
1283 (define-key emms-playlist-mode-map "p" 'emms-previous)
1285 (setq emms-playlist-buffer-name "*EMMS Playlist*"
1286 emms-playlist-mode-open-playlists t)
1292 'emms-browser-artist-face nil
1297 (setq emms-player-mpd-supported-regexp
1298 (or (emms-player-mpd-get-supported-regexp)
1299 (concat "\\`http://\\|"
1300 (emms-player-simple-regexp
1301 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
1302 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
1306 Basic settings for emacs integrated shell
1307 #+BEGIN_SRC emacs-lisp :tangle no
1313 (defun eshell-initialize ()
1314 (defun eshell-spawn-external-command (beg end)
1315 "Parse and expand any history references in current input."
1318 (when (looking-back "&!" beg)
1319 (delete-region (match-beginning 0) (match-end 0))
1321 (insert "spawn "))))
1322 (add-hook 'eshell-expand-input-functions 'eshell-spawn-external-command)
1323 (eval-after-load "em-unix"
1325 (unintern 'eshell/su)
1326 (unintern 'eshell/sudo))))
1327 (add-hook 'eshell-first-time-mode-hook 'eshell-initialize)
1331 (defalias 'emacs 'find-file)
1332 (defalias 'ec 'find-file)
1333 (defalias 'e 'find-file)
1337 (use-package 'em-cmpl)
1338 (use-package 'em-prompt)
1339 (use-package 'em-term)
1341 (setq eshell-cmpl-cycle-completions nil
1342 eshell-save-history-on-exit t
1343 eshell-buffer-maximum-lines 20000
1344 eshell-history-size 350
1345 eshell-buffer-shorthand t
1346 eshell-highlight-prompt t
1347 eshell-plain-echo-behavior t
1348 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
1350 (setenv "PAGER" "cat")
1351 (setq eshell-visual-commands
1352 '("less" "tmux" "htop" "top" "bash" "zsh" "tail"))
1353 (setq eshell-visual-subcommands
1354 '(("git" "log" "l" "diff" "show")))
1356 (add-to-list 'eshell-command-completions-alist
1357 '("gunzip" "gz\\'"))
1358 (add-to-list 'eshell-command-completions-alist
1359 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
1361 (when (not (functionp 'eshell/rgrep))
1362 (defun eshell/rgrep (&rest args)
1363 "Use Emacs grep facility instead of calling external grep."
1364 (eshell-grep "rgrep" args t)))
1366 ;(set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
1367 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
1368 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
1369 (add-hook 'eshell-preoutput-filter-functions
1370 'ansi-color-filter-apply)
1371 ;; Prompt with a bit of help from http://www.emacswiki.org/emacs/EshellPrompt
1373 (defmacro with-face (str &rest properties)
1374 `(propertize ,str 'face (list ,@properties)))
1376 (defun eshell/abbr-pwd ()
1377 (let ((home (getenv "HOME"))
1378 (path (eshell/pwd)))
1380 ((string-equal home path) "~")
1381 ((f-ancestor-of? home path) (concat "~/" (f-relative path home)))
1384 (defun eshell/my-prompt ()
1385 (let ((header-bg "#161616"))
1387 (with-face user-login-name :foreground "cyan")
1388 (with-face (concat "@" hostname) :foreground "white")
1390 (with-face (eshell/abbr-pwd) :foreground "#009900")
1391 (if (= (user-uid) 0)
1392 (with-face "#" :foreground "red")
1393 (with-face "$" :foreground "#69b7f0"))
1396 (use-package eshell-prompt-extras
1400 (setq eshell-highlight-prompt nil
1401 ;; epe-git-dirty-char "Ϟ"
1402 epe-git-dirty-char "*"
1403 eshell-prompt-function 'epe-theme-dakrone)))
1405 (defun eshell/magit ()
1406 "Function to open magit-status for the current directory"
1408 (magit-status default-directory)
1411 (setq eshell-prompt-function 'eshell/my-prompt)
1412 (setq eshell-highlight-prompt nil)
1413 (setq eshell-prompt-regexp "^[^#$\n]+[#$] ")))
1418 Incremental search is great, but annoyingly you need to type whatever
1419 you want. If you want to search for just the next (or previous)
1420 occurence of what is at your cursor position use the following.
1421 *C-x* will insert the current word while *M-up* and *M-down* will just
1422 jump to the next/previous occurence of it.
1423 #+BEGIN_SRC emacs-lisp :tangle yes
1424 (bind-key "C-x" 'sacha/isearch-yank-current-word isearch-mode-map)
1425 (bind-key* "<M-up>" 'sacha/search-word-backward)
1426 (bind-key* "<M-down>" 'sacha/search-word-forward)
1429 *** Frame configuration
1430 I want to see the buffername and its size, not the host I am on in my
1432 #+BEGIN_SRC emacs-lisp :tangle yes
1433 (setq frame-title-format "%b (%i)")
1436 *** Protect some buffers
1437 I don't want some buffers to be killed, **scratch** for example.
1438 In the past I had a long function that just recreated them, but the
1439 =keep-buffers= package is easier.
1440 #+BEGIN_SRC emacs-lisp :tangle yes
1441 (use-package keep-buffers
1444 (keep-buffers-mode 1)
1445 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
1446 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
1447 (push '("\\`*Group" . nil) keep-buffers-protected-alist)
1452 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
1454 #+BEGIN_SRC emacs-lisp :tangle yes
1455 (defalias 'yes-or-no-p 'y-or-n-p)
1458 *** Language/i18n stuff
1459 In this day and age, UTF-8 is the way to go.
1460 #+BEGIN_SRC emacs-lisp :tangle yes
1461 (set-language-environment 'utf-8)
1462 (set-default-coding-systems 'utf-8)
1463 (set-terminal-coding-system 'utf-8)
1464 (set-keyboard-coding-system 'utf-8)
1465 (set-clipboard-coding-system 'utf-8)
1466 (prefer-coding-system 'utf-8)
1467 (set-charset-priority 'unicode)
1468 (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
1469 (when (display-graphic-p)
1470 (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
1473 *** Hilight matching parentheses
1474 While I do have the nifty shortcut to jump to the other parentheses,
1475 hilighting them makes it obvious where they are.
1476 #+BEGIN_SRC emacs-lisp :tangle yes
1477 (use-package mic-paren
1481 *** Kill other buffers
1482 While many editors allow you to close "all the other files, not the one
1483 you are in", emacs doesn't have this... Except, now it will.
1484 (Update 30.05.2014: Not used ever, deactivated)
1485 #+BEGIN_SRC emacs-lisp :tangle no
1486 (bind-key "C-c k" 'prelude-kill-other-buffers)
1489 Default scrolling behaviour in emacs is a bit annoying, who wants to
1491 #+BEGIN_SRC emacs-lisp :tangle yes
1492 (setq scroll-margin 0)
1493 (setq scroll-conservatively 100000)
1494 (setq scroll-up-aggressively 0.0)
1495 (setq scroll-down-aggressively 0.0)
1496 (setq scroll-preserve-screen-position t)
1499 *** Copy/Paste with X
1500 [2013-04-09 Di 23:31]
1501 The default how emacs handles cutting/pasting with the primary selection
1502 changed in emacs24. I am used to the old way, so get it back.
1503 #+BEGIN_SRC emacs-lisp :tangle yes
1504 (setq select-enable-primary t)
1505 (setq select-enable-clipboard nil)
1506 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
1507 (setq mouse-drag-copy-region t)
1509 *** Global keyboard changes not directly related to a mode
1510 Disable /suspend_frame/ function, I dislike it.
1511 #+BEGIN_SRC emacs-lisp :tangle yes
1513 (unbind-key "C-x C-z")
1516 http://endlessparentheses.com/kill-entire-line-with-prefix-argument.html?source=rss
1517 #+BEGIN_SRC emacs-lisp :tangle yes
1518 (defmacro bol-with-prefix (function)
1519 "Define a new function which calls FUNCTION.
1520 Except it moves to beginning of line before calling FUNCTION when
1521 called with a prefix argument. The FUNCTION still receives the
1523 (let ((name (intern (format "endless/%s-BOL" function))))
1527 "Call `%s', but move to BOL when called with a prefix argument."
1532 (call-interactively ',function))
1535 (global-set-key [remap paredit-kill] (bol-with-prefix paredit-kill))
1536 (global-set-key [remap org-kill-line] (bol-with-prefix org-kill-line))
1537 (global-set-key [remap kill-line] (bol-with-prefix kill-line))
1540 Default of *C-k* is to kill from the point to the end of line. If
1541 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
1542 set, including newline. But to kill the entire line, one still needs a
1543 *C-a* in front of it. So I change it, by defining a function to do just this for
1545 #+BEGIN_SRC emacs-lisp :tangle no
1546 (defun kill-entire-line ()
1547 "Kill this entire line (including newline), regardless of where point is within the line."
1551 (back-to-indentation))
1553 (bind-key* "C-k" 'kill-entire-line)
1554 (global-set-key [remap kill-whole-line] 'kill-entire-line)
1557 And the same is true when I'm in org-mode, which has an own kill function...
1558 (the keybinding happens later, after org-mode is loaded fully)
1559 #+BEGIN_SRC emacs-lisp :tangle no
1560 (defun jj-org-kill-line (&optional arg)
1561 "Kill the entire line, regardless of where point is within the line, org-mode-version"
1565 (back-to-indentation)
1569 I really hate tabs, so I don't want any indentation to try using them.
1570 And in case a project really needs them, I can change it just for that
1571 file/project, but luckily none of those I work in is as broken.
1572 #+BEGIN_SRC emacs-lisp :tangle yes
1573 (setq-default indent-tabs-mode nil)
1576 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
1577 #+BEGIN_SRC emacs-lisp :tangle yes
1578 (bind-key* "M-5" 'match-paren)
1581 Instead of the default "mark-defun" I want a more readline-like setting.
1582 #+BEGIN_SRC emacs-lisp :tangle yes
1583 (bind-key "C-M-h" 'backward-kill-word)
1586 Align whatever with a regexp.
1587 #+BEGIN_SRC emacs-lisp :tangle yes
1588 (bind-key "C-x \\" 'align-regexp)
1592 #+BEGIN_SRC emacs-lisp :tangle yes
1593 (bind-key "C-+" 'text-scale-increase)
1594 (bind-key "C--" 'text-scale-decrease)
1597 Regexes are too useful, so use the regex search by default.
1598 #+begin_src emacs-lisp
1599 (bind-key "C-s" 'isearch-forward-regexp)
1600 (bind-key "C-r" 'isearch-backward-regexp)
1601 (bind-key "C-M-s" 'isearch-forward)
1602 (bind-key "C-M-r" 'isearch-backward)
1605 Rgrep is infinitely useful in multi-file projects.
1606 #+begin_src emacs-lisp
1607 (bind-key "C-x C-g" 'rgrep)
1610 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
1611 AKA transpose lines.
1612 #+BEGIN_SRC emacs-lisp :tangle yes
1613 (bind-key "<M-S-up>" 'move-line-up)
1614 (bind-key "<M-S-down>" 'move-line-down)
1617 "Pull" lines up, join them
1618 #+BEGIN_SRC emacs-lisp :tangle yes
1619 (defun join-line-or-lines-in-region ()
1620 "Join this line or the lines in the selected region.
1621 Joins single lines in reverse order to the default, ie. pulls the next one up."
1623 (cond ((region-active-p)
1624 (let ((min (line-number-at-pos (region-beginning))))
1625 (goto-char (region-end))
1626 (while (> (line-number-at-pos) min)
1628 (t (let ((current-prefix-arg '(4)))
1629 (call-interactively 'join-line)))))
1630 (bind-key "M-j" 'join-line-or-lines-in-region)
1633 When I press Enter I almost always want to go to the right indentation on the next line.
1634 #+BEGIN_SRC emacs-lisp :tangle yes
1635 (bind-key "RET" 'newline-and-indent)
1638 Easier undo, and i don't need suspend-frame
1639 #+BEGIN_SRC emacs-lisp :tangle yes
1640 (bind-key "C-z" 'undo)
1643 Window switching, go backwards. (C-x o goes to the next window)
1644 #+BEGIN_SRC emacs-lisp :tangle yes
1645 (bind-key "C-x O" (lambda ()
1651 #+BEGIN_SRC emacs-lisp :tangle yes
1652 (bind-key "C-x C-r" 'prelude-sudo-edit)
1655 M-space is bound to just-one-space, which is great for programming. What
1656 it does is remove all spaces around the cursor, except for one. But to
1657 be really useful, it also should include newlines. It doesn’t do this by
1658 default. Rather, you have to call it with a negative argument. Sure
1660 #+BEGIN_SRC emacs-lisp :tangle yes
1661 (bind-key "M-SPC" 'just-one-space-with-newline)
1664 Count which commands I use how often.
1665 #+BEGIN_SRC emacs-lisp :tangle yes
1666 (use-package keyfreq
1670 (setq keyfreq-file (expand-file-name "keyfreq" jj-cache-dir))
1671 (setq keyfreq-file-lock (expand-file-name "keyfreq.lock" jj-cache-dir))
1673 (keyfreq-autosave-mode 1)))
1676 Duplicate current line
1677 #+BEGIN_SRC emacs-lisp :tangle yes
1678 (defun duplicate-line ()
1679 "Insert a copy of the current line after the current line."
1682 (let ((line-text (buffer-substring-no-properties
1683 (line-beginning-position)
1684 (line-end-position))))
1685 (move-end-of-line 1)
1687 (insert line-text))))
1689 (bind-key "C-c p" 'duplicate-line)
1692 Smarter move to the beginning of the line. That is, it first moves to
1693 the beginning of the line - and on second keypress it goes to the
1694 first character on line.
1695 #+BEGIN_SRC emacs-lisp :tangle yes
1696 (defun smarter-move-beginning-of-line (arg)
1697 "Move point back to indentation of beginning of line.
1699 Move point to the first non-whitespace character on this line.
1700 If point is already there, move to the beginning of the line.
1701 Effectively toggle between the first non-whitespace character and
1702 the beginning of the line.
1704 If ARG is not nil or 1, move forward ARG - 1 lines first. If
1705 point reaches the beginning or end of the buffer, stop there."
1707 (setq arg (or arg 1))
1711 (let ((line-move-visual nil))
1712 (forward-line (1- arg))))
1714 (let ((orig-point (point)))
1715 (back-to-indentation)
1716 (when (= orig-point (point))
1717 (move-beginning-of-line 1))))
1719 ;; remap C-a to `smarter-move-beginning-of-line'
1720 (global-set-key [remap move-beginning-of-line]
1721 'smarter-move-beginning-of-line)
1725 Easily copy characters from the previous nonblank line, starting just
1726 above point. With a prefix argument, only copy ARG characters (never
1727 past EOL), no argument copies rest of line.
1728 #+BEGIN_SRC emacs-lisp :tangle yes
1730 (bind-key "H-y" 'copy-from-above-command)
1733 Open a new X Terminal pointing to the directory of the current
1735 #+BEGIN_SRC emacs-lisp :tangle yes
1736 (bind-key "H-t" 'jj-open-shell)
1740 #+BEGIN_SRC emacs-lisp :tangle yes
1741 (bind-key "H-a" 'align-code)
1745 #+BEGIN_SRC emacs-lisp :tangle yes
1746 (bind-key "C-c d" 'insert-date)
1749 Another key for indenting
1750 #+BEGIN_SRC emacs-lisp :tangle yes
1751 (bind-key "H-i" 'indent-region)
1754 Clean all whitespace stuff
1755 #+BEGIN_SRC emacs-lisp :tangle yes
1756 (bind-key "H-w" 'whitespace-cleanup)
1760 #+BEGIN_SRC emacs-lisp :tangle yes
1761 (bind-key "H-c" 'comment-dwim)
1764 Show keystrokes in progress
1765 #+BEGIN_SRC emacs-lisp :tangle yes
1766 (setq echo-keystrokes 0.1)
1769 Usually you can press the *Ins*ert key, to get into overwrite mode. I
1770 don't like that, have broken much with it and so just forbid it by
1772 #+BEGIN_SRC emacs-lisp :tangle yes
1773 (unbind-key "<insert>")
1774 (unbind-key "<kp-insert>")
1777 *** Easily navigate sillyCased words
1778 #+BEGIN_SRC emacs-lisp :tangle yes
1779 (global-subword-mode 1)
1781 *** Delete file of current buffer, then kill buffer
1782 [2014-06-14 Sat 23:03]
1783 #+BEGIN_SRC emacs-lisp :tangle yes
1784 (defun delete-current-buffer-file ()
1785 "Removes file connected to current buffer and kills buffer."
1787 (let ((filename (buffer-file-name))
1788 (buffer (current-buffer))
1789 (name (buffer-name)))
1790 (if (not (and filename (file-exists-p filename)))
1792 (when (yes-or-no-p "Are you sure you want to remove this file? ")
1793 (delete-file filename)
1794 (kill-buffer buffer)
1795 (message "File '%s' successfully removed" filename)))))
1797 (global-set-key (kbd "C-x C-k") 'delete-current-buffer-file)
1799 *** Rename file of current buffer
1800 [2014-06-14 Sat 23:04]
1801 #+BEGIN_SRC emacs-lisp :tangle yes
1802 (defun rename-current-buffer-file ()
1803 "Renames current buffer and file it is visiting."
1805 (let ((name (buffer-name))
1806 (filename (buffer-file-name)))
1807 (if (not (and filename (file-exists-p filename)))
1808 (error "Buffer '%s' is not visiting a file!" name)
1809 (let ((new-name (read-file-name "New name: " filename)))
1810 (if (get-buffer new-name)
1811 (error "A buffer named '%s' already exists!" new-name)
1812 (rename-file filename new-name 1)
1813 (rename-buffer new-name)
1814 (set-visited-file-name new-name)
1815 (set-buffer-modified-p nil)
1816 (message "File '%s' successfully renamed to '%s'"
1817 name (file-name-nondirectory new-name)))))))
1819 (global-set-key (kbd "C-x C-S-r") 'rename-current-buffer-file)
1821 *** Quickly find emacs lisp sources
1822 [2014-06-22 Sun 23:05]
1823 #+BEGIN_SRC emacs-lisp :tangle yes
1824 (bind-key "C-l" 'find-library 'help-command)
1825 (bind-key "C-f" 'find-function 'help-command)
1826 (bind-key "C-k" 'find-function-on-key 'help-command)
1827 (bind-key "C-v" 'find-variable 'help-command)
1830 [2015-01-26 Mon 16:01]
1831 #+BEGIN_SRC emacs-lisp :tangle yes
1832 (bind-key "M-s o" 'occur-dwim)
1836 [2014-06-01 Sun 15:00]
1837 Proper whitespace handling
1838 #+BEGIN_SRC emacs-lisp :tangle yes
1839 (use-package ethan-wspace
1840 :ensure ethan-wspace
1841 :diminish (ethan-wspace-mode . "ew")
1843 (global-ethan-wspace-mode 1))
1847 [2014-06-01 Sun 15:16]
1848 #+BEGIN_SRC emacs-lisp :tangle yes
1849 (use-package expand-region
1850 :ensure expand-region
1851 :bind ("C-M-+" . er/expand-region)
1852 :commands er/expand-region)
1855 [2013-05-02 Thu 00:04]
1856 Filladapt by KyleJones enhances Emacs’ fill functions by guessing a
1857 fill prefix, such as a comment sequence in program code, and handling
1858 bullet points like “1.” or “*”.
1859 #+BEGIN_SRC emacs-lisp :tangle yes
1860 (use-package filladapt
1861 :diminish filladapt-mode
1863 (setq-default filladapt-mode t))
1866 [2013-04-28 So 22:21]
1867 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
1868 As the one time I tried Flymake i wasn't happy, thats easy to
1870 #+BEGIN_SRC emacs-lisp :tangle yes
1871 (use-package flycheck
1873 :diminish flycheck-mode
1874 :bind (("M-n" . next-error)
1875 ("M-p" . previous-error))
1878 (add-hook 'find-file-hook
1880 (when (not (equal 'emacs-lisp-mode major-mode))
1884 (use-package flycheck-color-mode-line
1885 :ensure flycheck-color-mode-line)
1886 (setq flycheck-highlighting-mode nil)
1887 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
1891 Obviously emacs can do syntax hilighting. For more things than you ever
1893 And I want to have it everywhere.
1894 #+BEGIN_SRC emacs-lisp :tangle yes
1895 (use-package font-lock
1898 (global-font-lock-mode 1)
1899 (setq font-lock-maximum-decoration t)))
1902 #+BEGIN_SRC emacs-lisp :tangle yes
1903 (use-package git-commit-mode
1904 :ensure git-commit-mode
1905 :commands git-commit-mode
1906 :mode ("COMMIT_EDITMSG" . git-commit-mode))
1910 #+BEGIN_SRC emacs-lisp :tangle yes
1911 (use-package git-rebase-mode
1912 :ensure git-rebase-mode
1913 :commands git-rebase-mode
1914 :mode ("git-rebase-todo" . git-rebase-mode))
1917 [2014-05-21 Wed 22:56]
1918 #+BEGIN_SRC emacs-lisp :tangle yes
1919 (use-package git-gutter+
1921 :diminish git-gutter+-mode
1922 :bind (("C-x n" . git-gutter+-next-hunk)
1923 ("C-x p" . git-gutter+-previous-hunk)
1924 ("C-x v =" . git-gutter+-show-hunk)
1925 ("C-x r" . git-gutter+-revert-hunks)
1926 ("C-x s" . git-gutter+-stage-hunks)
1927 ("C-x c" . git-gutter+-commit)
1931 (setq git-gutter+-disabled-modes '(org-mode))
1932 (global-git-gutter+-mode 1))
1935 (use-package git-gutter-fringe+
1936 :ensure git-gutter-fringe+
1939 (setq git-gutter-fr+-side 'right-fringe)
1940 ;(git-gutter-fr+-minimal)
1945 [2015-02-22 Sun 14:00]
1946 Provides function that popup commit message at current line. This is
1947 useful when you want to know why this line was changed.
1948 #+BEGIN_SRC emacs-lisp :tangle yes
1949 (use-package git-messenger
1950 :ensure git-messenger
1951 :commands (git-messenger:popup-message)
1952 :bind (("C-x v p" . git-messenger:popup-message))
1955 (bind-key "m" 'git-messenger:copy-message git-messenger-map)
1956 (add-hook 'git-messenger:popup-buffer-hook 'magit-commit-mode)
1957 (setq git-messenger:show-detail t)))
1960 [2014-07-23 Mi 12:57]
1961 Browse historic versions of a file with p (previous) and n (next).
1962 #+BEGIN_SRC emacs-lisp :tangle yes
1963 (use-package git-timemachine
1964 :ensure git-timemachine
1965 :commands git-timemachine)
1968 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
1969 what I want every emacs to know.
1970 #+BEGIN_SRC emacs-lisp :tangle yes
1971 (bind-key "C-c g" 'gnus) ; Start gnus with M-n
1977 [2015-02-20 Fri 16:27]
1978 When working with many windows at the same time, each window has a
1979 size that is not convenient for editing.
1981 golden-ratio helps on this issue by resizing automatically the windows
1982 you are working on to the size specified in the "Golden Ratio". The
1983 window that has the main focus will have the perfect size for editing,
1984 while the ones that are not being actively edited will be re-sized to
1985 a smaller size that doesn't get in the way, but at the same time will
1986 be readable enough to know it's content.
1987 #+BEGIN_SRC emacs-lisp :tangle yes
1988 (use-package golden-ratio
1989 :ensure golden-ratio
1990 :diminish golden-ratio-mode
1993 (golden-ratio-mode 1)
1994 (setq golden-ratio-exclude-buffer-names '("*LV*" "*guide-key*"))
1995 (setq golden-ratio-exclude-modes '("calendar-mode" "gnus-summary-mode"
1996 "gnus-article-mode" "calc-mode" "calc-trail-mode"
2001 [2015-02-22 Sun 13:28]
2002 Move point through buffer-undo-list positions.
2003 #+BEGIN_SRC emacs-lisp :tangle yes
2004 (use-package goto-last-change
2005 :commands (goto-last-change)
2006 :bind (("M-g l" . goto-last-change))
2010 [2014-06-11 Wed 22:27]
2011 guide-key.el displays the available key bindings automatically and
2014 For whatever reason I like this more than icicles <backtab> completion
2016 #+BEGIN_SRC emacs-lisp :tangle yes
2017 (use-package guide-key
2019 :diminish guide-key-mode
2022 (setq guide-key/guide-key-sequence '("C-x" "C-c" "M-g"))
2024 (setq guide-key/recursive-key-sequence-flag t)
2025 (setq guide-key/popup-window-position 'bottom)
2026 (setq guide-key/idle-delay 0.5)))
2031 [2014-05-21 Wed 23:51]
2032 #+BEGIN_SRC emacs-lisp :tangle yes
2033 (use-package hi-lock
2034 :bind (("M-o l" . highlight-lines-matching-regexp)
2035 ("M-o r" . highlight-regexp)
2036 ("M-o w" . highlight-phrase)))
2038 (use-package hilit-chg
2039 :bind ("M-o C" . highlight-changes-mode))
2043 Crazy way of completion. It looks at the word before point and then
2044 tries to expand it in various ways.
2045 #+BEGIN_SRC emacs-lisp :tangle yes
2046 (use-package hippie-exp
2047 :bind ("M-/" . hippie-expand)
2048 :commands hippie-expand
2051 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
2052 try-expand-dabbrev-all-buffers
2053 try-expand-dabbrev-from-kill
2054 try-complete-file-name-partially
2055 try-complete-file-name
2056 try-expand-all-abbrevs try-expand-list
2058 try-complete-lisp-symbol-partially
2059 try-complete-lisp-symbol))))
2062 Replaced by web-mode [[*web-mode][web-mode]]
2063 #+BEGIN_SRC emacs-lisp :tangle no
2064 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
2065 (add-auto-mode 'html-helper-mode "\\.html$")
2066 (add-auto-mode 'html-helper-mode "\\.asp$")
2067 (add-auto-mode 'html-helper-mode "\\.phtml$")
2068 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
2069 (defalias 'html-mode 'html-helper-mode)
2072 [2015-01-26 Mon 15:50]
2073 This is a package for GNU Emacs that can be used to tie related
2074 commands into a family of short bindings with a common prefix - a
2077 Once you summon the Hydra through the prefixed binding (the body + any
2078 one head), all heads can be called in succession with only a short
2081 The Hydra is vanquished once Hercules, any binding that isn't the
2082 Hydra's head, arrives. Note that Hercules, besides vanquishing the
2083 Hydra, will still serve his orignal purpose, calling his proper
2084 command. This makes the Hydra very seamless, it's like a minor mode
2085 that disables itself auto-magically.
2086 #+BEGIN_SRC emacs-lisp :tangle yes
2091 (setq hydra-is-helpful t)
2094 (defhydra hydra-zoom (:color red)
2096 ("g" text-scale-increase "in")
2097 ("l" text-scale-decrease "out")
2099 (bind-key "<F2>" 'hydra-zoom/toggle)
2101 (defhydra hydra-error (:color red)
2103 ("h" first-error "first")
2104 ("j" next-error "next")
2105 ("k" previous-error "prev")
2106 ("v" recenter-top-bottom "recenter")
2108 (bind-key "M-g e" 'hydra-error/body)
2110 (defhydra hydra-gnus (:color red)
2112 ("m" gnus-uu-mark-thread "mark thread")
2113 ("d" gnus-summary-delete-article "delete article(s)")
2114 ("r" gnus-summary-mark-as-read-forward "mark read")
2115 ("n" gnus-summary-next-thread "next thread")
2116 ("p" gnus-summary-prev-thread "previous thread")
2117 ("g" gnus-summary-next-group "next group")
2118 ("l" gnus-recenter "recenter")
2120 (bind-key "C-c h" 'hydra-gnus/body)
2122 (defhydra hydra-launcher (:color blue)
2125 ("r" (browse-url "http://www.reddit.com/r/emacs/") "reddit")
2126 ("w" (browse-url "http://www.emacswiki.org/") "emacswiki")
2129 (bind-key "C-c r" 'hydra-launcher/body)
2131 ; whitespace mode gets loaded late, so variable may not be there yet. Workaround...
2132 (defvar whitespace-mode nil)
2133 (defhydra hydra-toggle (:color pink)
2135 _a_ abbrev-mode: % 4`abbrev-mode^^^^ _f_ auto-fill-mode: %`auto-fill-function
2136 _c_ auto-complete-mode: % 4`auto-complete-mode _r_ auto-revert-mode: %`auto-revert-mode
2137 _d_ debug-on-error: % 4`debug-on-error^ _t_ truncate-lines: %`truncate-lines
2138 _w_ whitespace-mode: % 4`whitespace-mode _g_ golden-ratio-mode: %`golden-ratio-mode
2139 _l_ linum-mode: % 4`linum-mode _k_ linum relative: %`linum-format
2142 ("a" abbrev-mode nil)
2143 ("c" auto-complete-mode nil)
2144 ("i" aggressive-indent-mode nil)
2145 ("d" toggle-debug-on-error nil)
2146 ("f" auto-fill-mode nil)
2147 ("g" golden-ratio-mode nil)
2148 ("t" toggle-truncate-lines nil)
2149 ("w" whitespace-mode nil)
2150 ("r" auto-revert-mode nil)
2151 ("l" linum-mode nil)
2152 ("k" linum-relative-toggle nil)
2154 (bind-key "C-c C-v" 'hydra-toggle/body)
2160 [2014-05-21 Wed 23:54]
2161 #+BEGIN_SRC emacs-lisp :tangle yes
2162 (use-package ibuffer
2164 :bind (("C-h h" . ibuffer)
2165 ("C-x C-b" . ibuffer)
2166 ("<XF86WebCam>" . ibuffer)
2169 :defines (ibuffer-filtering-alist
2170 ibuffer-filter-groups ibuffer-compile-formats ibuffer-git-column-length
2171 ibuffer-show-empty-filter-groups ibuffer-saved-filter-groups)
2174 (defvar my-ibufffer-separator " • ")
2175 (setq ibuffer-filter-group-name-face 'variable-pitch
2176 ibuffer-use-header-line t
2177 ibuffer-old-time 12)
2178 (unbind-key "M-o" ibuffer-mode-map)
2179 (bind-key "s" 'isearch-forward-regexp ibuffer-mode-map)
2180 (bind-key "." 'ibuffer-invert-sorting ibuffer-mode-map)
2185 (use-package ibuffer-vc
2188 (ibuffer-vc-set-filter-groups-by-vc-root
2189 ibuffer-vc-generate-filter-groups-by-vc-root))
2191 (use-package ibuffer-tramp
2193 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
2194 ibuffer-tramp-set-filter-groups-by-tramp-connection))
2195 ;; Switching to ibuffer puts the cursor on the most recent buffer
2196 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
2197 "Open ibuffer with cursor pointed to most recent buffer name"
2198 (let ((recent-buffer-name (buffer-name)))
2200 (ibuffer-update nil t)
2201 (unless (string= recent-buffer-name "*Ibuffer*")
2202 (ibuffer-jump-to-buffer recent-buffer-name))))
2204 (defun ibuffer-magit-status ()
2206 (--when-let (get-buffer "*Ibuffer*")
2207 (with-current-buffer it
2208 (let* ((selected-buffer (ibuffer-current-buffer))
2209 (buffer-path (with-current-buffer
2211 (or (buffer-file-name)
2212 list-buffers-directory
2213 default-directory)))
2215 (if (file-regular-p buffer-path)
2216 (file-name-directory buffer-path)
2218 (magit-status default-directory)))))
2219 (bind-key "i" 'ibuffer-magit-status ibuffer-mode-map)
2220 (bind-key "G" 'ibuffer-magit-status ibuffer-mode-map)
2222 (setq ibuffer-directory-abbrev-alist
2227 (cons (f-slash (f-expand (cdr it))) my-ibufffer-separator)
2228 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
2230 ("dak" . "/develop/dak/")
2232 ("config" . "~/.emacs.d/config/")
2234 ("systmp" . "/tmp/")
2235 ("puppet" . "~/git/puppet")
2239 (use-package ibuffer-git
2241 (use-package ibuffer-vc
2244 (define-ibuffer-column size-h
2245 (:name "Size" :inline t)
2247 ((> (buffer-size) 1000)
2248 (format "%7.1fk" (/ (buffer-size) 1000.0)))
2249 ((> (buffer-size) 1000000)
2250 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
2252 (format "%8d" (buffer-size)))))
2254 (use-package ibuf-ext)
2255 (define-ibuffer-filter filename2
2256 "Toggle current view to buffers with filename matching QUALIFIER."
2257 (:description "filename2"
2258 :reader (read-from-minibuffer "Filter by filename (regexp): "))
2259 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
2260 (ibuffer-awhen (with-current-buffer buf
2261 (or buffer-file-name
2263 (string-match qualifier it)))
2265 (defvar ibuffer-magit-filter-groups nil)
2266 (defun ibuffer-magit-define-filter-groups ()
2267 (when (and (not ibuffer-magit-filter-groups)
2268 (boundp 'magit-repo-dirs))
2269 (setq ibuffer-magit-filter-groups
2272 (file-name-nondirectory (directory-file-name it)))
2274 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
2276 (defun ibuffer-set-filter-groups-by-root ()
2278 ;; (ibuffer-projectile-define-filter-groups)
2279 ;; (ibuffer-magit-define-filter-groups)
2280 (setq ibuffer-filter-groups
2282 ;; ibuffer-projectile-filter-groups
2283 ibuffer-magit-filter-groups
2286 (or (mode . magit-log-edit-mode)
2287 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2288 (name . "^\\*Pymacs\\*$")
2289 (name . "^\\*helm.*\\*")
2290 (name . "^\\*Compile-log\\*$")
2291 (name . "^\\*Ido Completions\\*$")
2292 (name . "^\\*magit-\\(process\\)\\*$")
2296 (name . "^\\*scratch")
2297 (name . "^\\*Messages")
2300 (ibuffer-vc-generate-filter-groups-by-vc-root)
2301 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
2303 (defun toggle-ibuffer-filter-groups ()
2306 (let ((ibuf (get-buffer "*Ibuffer*")))
2308 (with-current-buffer ibuf
2309 (let ((selected-buffer (ibuffer-current-buffer)))
2310 (if (not ibuffer-filter-groups)
2311 (ibuffer-set-filter-groups-by-root)
2312 (setq ibuffer-filter-groups nil))
2313 (pop-to-buffer ibuf)
2314 (ibuffer-update nil t)
2315 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
2317 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
2319 (defun ibuffer-back-to-top ()
2321 (beginning-of-buffer)
2324 (defun ibuffer-jump-to-bottom ()
2330 (define-key ibuffer-mode-map
2331 (vector 'remap 'end-of-buffer) 'ibuffer-jump-to-bottom)
2332 (define-key ibuffer-mode-map
2333 (vector 'remap 'beginning-of-buffer) 'ibuffer-back-to-top)
2335 (setq ibuffer-default-sorting-mode 'recency
2336 ibuffer-eliding-string "…"
2337 ibuffer-compile-formats t
2338 ibuffer-git-column-length 6
2339 ibuffer-show-empty-filter-groups nil
2340 ibuffer-default-directory "~/"
2343 (setq ibuffer-formats '((mark vc-status-mini
2345 (git-status 8 8 :left)
2349 (name 18 18 :left :elide)
2351 (size-h 9 -1 :right)
2353 (mode 16 16 :left :elide)
2354 " " filename-and-process)
2356 (git-status 8 8 :left)
2362 (setq ibuffer-saved-filter-groups
2365 ("dired" (mode . dired-mode))
2366 ("perl" (mode . cperl-mode))
2368 (mode . puppet-mode)
2369 (mode . yaml-mode)))
2370 ("ruby" (mode . ruby-mode))
2372 (name . "^\\*scratch\\*$")
2373 (name . "^\\*Compile-log\\*$")
2374 (name . "^\\*Completions\\*$")
2375 (name . "^\\*Messages\\*$")
2376 (name . "^\\*Backtrace\\*$")
2377 (name . "^\\*Packages*\\*$")
2378 (name . "^\\*Help*\\*$")
2381 (mode . message-mode)
2384 (mode . gnus-group-mode)
2385 (mode . gnus-summary-mode)
2386 (mode . gnus-article-mode)
2387 (name . "^\\.bbdb$")
2388 (name . "^\\.newsrc-dribble")))
2390 (filename . ".*/org/.*")
2391 (mode . org-agenda-mode)
2392 (name . "^diary$")))
2394 (mode . magit-log-edit-mode)
2395 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
2397 ;; -------------------------------------------------
2398 ;; programming languages #1
2400 (mode . emacs-lisp-mode)
2401 (mode . python-mode)
2403 (mode . coffee-mode)
2406 (mode . actionscript-mode)
2409 (mode . haskell-mode)
2415 ;; -------------------------------------------------
2416 ;; configuration/data files
2420 (mode . conf-mode)))
2421 ;; -------------------------------------------------
2422 ;; text/notetaking/org
2423 ("org agenda" (mode . org-agenda-mode))
2426 (name . "^\\*Calendar\\*$")
2427 (name . "^diary$")))
2431 (mode . markdown-mode)))
2432 ;; -------------------------------------------------
2435 (mode . image-mode)))
2436 ;; -------------------------------------------------
2438 ("w3m" (mode . w3m-mode))
2440 (mode . magit-status-mode)
2441 (mode . magit-log-mode)
2442 (mode . vc-annotate-mode)))
2443 ("dired" (mode . dired-mode))
2448 (name . "^\\*Personal Keybindings\\*$")))
2449 ;; -------------------------------------------------
2451 ("MORE" (or (mode . magit-log-edit-mode)
2452 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2453 (name . "^\\*Pymacs\\*$")
2454 (name . "^\\*Compile-log\\*$")
2455 (name . "^\\*Completions\\*$")
2456 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
2458 ("*buffer*" (name . "\\*.*\\*"))))))
2460 (add-hook 'ibuffer-mode-hook
2462 (ibuffer-auto-mode 1)
2463 (ibuffer-switch-to-saved-filter-groups "default")))
2465 ;; Unless you turn this variable on you will be prompted every time
2466 ;; you want to delete a buffer, even unmodified ones, which is way
2467 ;; too cautious for most people. You’ll still be prompted for
2468 ;; confirmation when deleting modified buffers after the option has
2470 (setq ibuffer-expert t)
2475 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
2476 ‘TAB’ completion is to typing things manually every time.”]]
2477 #+BEGIN_SRC emacs-lisp :tangle yes
2478 (use-package icicles
2479 :load-path "elisp/icicle/"
2484 Incremental mini-buffer completion preview: Type in the minibuffer,
2485 list of matching commands is echoed
2486 #+BEGIN_SRC emacs-lisp :tangle yes
2490 [2014-05-26 Mon 22:49]
2491 #+BEGIN_SRC emacs-lisp :tangle yes
2494 :commands (iedit-mode)
2496 :bind (("C-;" . iedit-mode)
2497 ("C-," . iedit-mode-toggle-on-function))
2502 [2014-05-20 Tue 23:35]
2503 #+BEGIN_SRC emacs-lisp :tangle yes
2505 :bind ("C-h C-i" . info-lookup-symbol)
2506 :commands info-lookup-symbol
2509 ;; (defadvice info-setup (after load-info+ activate)
2510 ;; (use-package info+))
2512 (defadvice Info-exit (after remove-info-window activate)
2513 "When info mode is quit, remove the window."
2514 (if (> (length (window-list)) 1)
2517 (use-package info-look
2518 :commands info-lookup-add-help)
2520 ** linum (line number)
2521 Various modes should have line numbers in front of each line.
2523 But then there are some where it would just be deadly - like org-mode,
2524 gnus, so we have a list of modes where we don't want to see it.
2525 #+BEGIN_SRC emacs-lisp :tangle yes
2527 :diminish linum-mode
2530 (setq linum-format "%3d ")
2531 (setq linum-mode-inhibit-modes-list '(org-mode
2538 (defadvice linum-on (around linum-on-inhibit-for-modes)
2539 "Stop the load of linum-mode for some major modes."
2540 (unless (member major-mode linum-mode-inhibit-modes-list)
2543 (ad-activate 'linum-on)
2545 (use-package linum-relative
2546 :ensure linum-relative
2549 (setq linum-format 'dynamic)
2552 (global-linum-mode 1))
2555 ** lisp editing stuff
2557 [2013-04-21 So 21:00]
2558 I'm not doing much of it, except for my emacs and gnus configs, but
2559 then I like it nice too...
2560 #+BEGIN_SRC emacs-lisp :tangle yes
2561 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
2563 (defun remove-elc-on-save ()
2564 "If you're saving an elisp file, likely the .elc is no longer valid."
2565 (make-local-variable 'after-save-hook)
2566 (add-hook 'after-save-hook
2568 (if (file-exists-p (concat buffer-file-name "c"))
2569 (delete-file (concat buffer-file-name "c"))))))
2571 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
2572 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
2574 (use-package paredit
2576 :diminish paredit-mode " π")
2578 (setq lisp-coding-hook 'lisp-coding-defaults)
2579 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2581 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2582 (add-hook 'emacs-lisp-mode-hook (lambda ()
2583 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2585 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
2587 (after "elisp-slime-nav"
2588 '(diminish 'elisp-slime-nav-mode))
2589 (after "rainbow-mode"
2590 '(diminish 'rainbow-mode))
2592 '(diminish 'eldoc-mode))
2595 [2013-04-21 So 20:48]
2596 magit is a mode for interacting with git.
2597 #+BEGIN_SRC emacs-lisp :tangle yes
2600 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
2601 magit-git-repo-p magit-list-repos)
2603 :bind (("C-x g" . magit-status)
2604 ("C-x G" . magit-status-with-prefix))
2607 (setq magit-commit-signoff t
2608 magit-repo-dirs '("~/git"
2612 magit-repo-dirs-depth 4
2613 magit-log-auto-more t)
2615 (use-package magit-blame
2616 :commands magit-blame-mode
2619 (use-package magit-svn
2621 :commands (magit-svn-mode
2625 (add-hook 'magit-mode-hook 'hl-line-mode)
2626 (defun magit-status-with-prefix ()
2628 (let ((current-prefix-arg '(4)))
2629 (call-interactively 'magit-status)))
2633 (setenv "GIT_PAGER" "")
2635 (unbind-key "M-h" magit-mode-map)
2636 (unbind-key "M-s" magit-mode-map)
2638 (use-package magit-find-file
2639 :ensure magit-find-file
2640 :commands (magit-find-file-completing-read)
2644 (bind-key "C-x C-f" 'magit-find-file-completing-read magit-mode-map)))
2646 (add-hook 'magit-log-edit-mode-hook
2648 (set-fill-column 72)
2651 (defadvice magit-status (around magit-fullscreen activate)
2652 (window-configuration-to-register :magit-fullscreen)
2654 (delete-other-windows))
2656 (defun magit-quit-session ()
2657 "Restores the previous window configuration and kills the magit buffer"
2660 (jump-to-register :magit-fullscreen))
2662 (bind-key "q" 'magit-quit-session magit-status-mode-map)
2666 [2014-05-20 Tue 23:04]
2667 #+BEGIN_SRC emacs-lisp :tangle yes
2668 (use-package markdown-mode
2669 :mode (("\\.md\\'" . markdown-mode)
2670 ("\\.mdwn\\'" . markdown-mode))
2674 #+BEGIN_SRC emacs-lisp :tangle yes
2675 (use-package message
2678 (setq message-kill-buffer-on-exit t)))
2681 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2683 I want to access it from anywhere using =F6=.
2684 #+BEGIN_SRC emacs-lisp :tangle yes
2685 (use-package mingus-stays-home
2686 :bind ( "<f6>" . mingus)
2690 (setq mingus-dired-add-keys t)
2691 (setq mingus-mode-always-modeline nil)
2692 (setq mingus-mode-line-show-elapsed-percentage nil)
2693 (setq mingus-mode-line-show-volume nil)
2694 (setq mingus-mpd-config-file "/etc/mpd.conf")
2695 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2696 (setq mingus-mpd-root "/share/music/")))
2700 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
2701 #+BEGIN_SRC emacs-lisp :tangle yes
2702 (use-package miniedit
2707 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
2708 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
2709 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
2710 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
2716 [2013-05-21 Tue 23:39]
2717 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
2718 coexist in one buffer.
2719 #+BEGIN_SRC emacs-lisp :tangle no
2720 (use-package mmm-auto
2724 (setq mmm-global-mode 'buffers-with-submode-classes)
2725 (setq mmm-submode-decoration-level 2)
2726 (eval-after-load 'mmm-vars
2732 :face mmm-code-submode-face
2733 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
2734 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
2735 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2736 @ "\n" _ "\n" @ "</script>" @)))
2739 :face mmm-code-submode-face
2740 :front "<style[^>]*>[ \t]*\n?"
2741 :back "[ \t]*</style>"
2742 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2743 @ "\n" _ "\n" @ "</style>" @)))
2746 :face mmm-code-submode-face
2749 (dolist (mode (list 'html-mode 'nxml-mode))
2750 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
2751 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
2756 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2758 #+BEGIN_SRC emacs-lisp :tangle yes
2759 (use-package mo-git-blame
2760 :ensure mo-git-blame
2761 :commands (mo-git-blame-current
2765 (setq mo-git-blame-blame-window-width 25)))
2769 [2013-04-08 Mon 23:57]
2770 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2771 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2772 #+BEGIN_SRC emacs-lisp :tangle yes
2773 (use-package multiple-cursors
2774 :ensure multiple-cursors
2776 :commands (mc/remove-fake-cursors
2777 mc/create-fake-cursor-at-point
2778 mc/pop-state-from-overlay
2779 mc/maybe-multiple-cursors-mode)
2780 :defines (multiple-cursors-mode
2782 mc--read-quoted-char
2783 rectangular-region-mode)
2784 :bind (("C-S-c C-S-c" . mc/edit-lines)
2785 ("C->" . mc/mark-next-like-this)
2786 ("C-<" . mc/mark-previous-like-this)
2787 ("C-c C-<" . mc/mark-all-like-this)
2788 ("C-c i" . mc/insert-numbers))
2791 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
2792 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
2793 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
2794 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
2795 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
2796 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
2799 [2014-08-27 Wed 17:15]
2801 #+BEGIN_SRC emacs-lisp :tangle yes
2802 (use-package neotree
2805 :bind (("<f8>" . neotree-toggle))
2806 :commands (neotree-find
2811 (setq neo-smart-open t))
2814 (bind-key "^" 'neotree-select-up-node neotree-mode-map)))
2817 [2013-05-22 Wed 22:02]
2818 nxml-mode is a major mode for editing XML.
2819 #+BEGIN_SRC emacs-lisp :tangle yes
2824 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2827 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2828 (fset 'xml-mode 'nxml-mode)
2829 (setq nxml-slash-auto-complete-flag t)
2831 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2832 (defun pp-xml-region (begin end)
2833 "Pretty format XML markup in region. The function inserts
2834 linebreaks to separate tags that have nothing but whitespace
2835 between them. It then indents the markup by using nxml's
2841 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2842 (backward-char) (insert "\n"))
2843 (indent-region begin end)))
2845 ;;----------------------------------------------------------------------------
2846 ;; Integration with tidy for html + xml
2847 ;;----------------------------------------------------------------------------
2848 ;; tidy is autoloaded
2849 (eval-after-load 'tidy
2851 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2852 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2857 *** General settings
2858 [2013-04-28 So 17:06]
2860 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
2861 it is quite extensive. Nevertheless, it starts out small, loading it.
2862 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2866 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
2867 that we need org-protocol.
2868 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2869 (require 'org-protocol)
2874 My current =org-agenda-files= variable only includes a set of
2876 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2877 (setq org-agenda-files (quote ("~/org/"
2883 (setq org-default-notes-file "~/org/notes.org")
2885 =org-mode= manages the =org-agenda-files= variable automatically using
2886 =C-c [= and =C-c ]= to add and remove files respectively. However,
2887 this replaces my directory list with a list of explicit filenames
2888 instead and is not what I want. If this occurs then adding a new org
2889 file to any of the above directories will not contribute to my agenda
2890 and I will probably miss something important.
2892 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
2893 prevent messing up my list of directories in the =org-agenda-files=
2894 variable. I just add and remove directories manually here. Changing
2895 the list of directories in =org-agenda-files= happens very rarely
2896 since new files in existing directories are automatically picked up.
2898 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2899 ;; Keep tasks with dates on the global todo lists
2900 (setq org-agenda-todo-ignore-with-date nil)
2902 ;; Keep tasks with deadlines on the global todo lists
2903 (setq org-agenda-todo-ignore-deadlines nil)
2905 ;; Keep tasks with scheduled dates on the global todo lists
2906 (setq org-agenda-todo-ignore-scheduled nil)
2908 ;; Keep tasks with timestamps on the global todo lists
2909 (setq org-agenda-todo-ignore-timestamp nil)
2911 ;; Remove completed deadline tasks from the agenda view
2912 (setq org-agenda-skip-deadline-if-done t)
2914 ;; Remove completed scheduled tasks from the agenda view
2915 (setq org-agenda-skip-scheduled-if-done t)
2917 ;; Remove completed items from search results
2918 (setq org-agenda-skip-timestamp-if-done t)
2920 ;; Include agenda archive files when searching for things
2921 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
2923 ;; Show all future entries for repeating tasks
2924 (setq org-agenda-repeating-timestamp-show-all t)
2926 ;; Show all agenda dates - even if they are empty
2927 (setq org-agenda-show-all-dates t)
2929 ;; Sorting order for tasks on the agenda
2930 (setq org-agenda-sorting-strategy
2931 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
2932 (todo category-up priority-down effort-up)
2933 (tags category-up priority-down effort-up)
2934 (search category-up))))
2936 ;; Start the weekly agenda on Monday
2937 (setq org-agenda-start-on-weekday 1)
2939 ;; Enable display of the time grid so we can see the marker for the current time
2940 (setq org-agenda-time-grid (quote ((daily today remove-match)
2941 #("----------------" 0 16 (org-heading t))
2942 (0800 1000 1200 1400 1500 1700 1900 2100))))
2944 ;; Display tags farther right
2945 (setq org-agenda-tags-column -102)
2947 ; position the habit graph on the agenda to the right of the default
2948 (setq org-habit-graph-column 50)
2950 ; turn habits back on
2951 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
2954 ;; Agenda sorting functions
2956 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
2959 (setq org-deadline-warning-days 30)
2961 ;; Always hilight the current agenda line
2962 (add-hook 'org-agenda-mode-hook
2963 '(lambda () (hl-line-mode 1))
2967 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2968 (setq org-agenda-persistent-filter t)
2969 (add-hook 'org-agenda-mode-hook
2970 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
2973 (add-hook 'org-agenda-mode-hook
2974 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
2977 (add-hook 'org-agenda-mode-hook
2978 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
2981 (add-hook 'org-agenda-mode-hook
2982 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
2985 (add-hook 'org-agenda-mode-hook
2986 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
2989 ; Rebuild the reminders everytime the agenda is displayed
2990 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
2992 ;(if (file-exists-p "~/org/refile.org")
2993 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
2995 ; Activate appointments so we get notifications
2998 (setq org-agenda-log-mode-items (quote (closed clock state)))
2999 (if (> emacs-major-version 23)
3000 (setq org-agenda-span 3)
3001 (setq org-agenda-ndays 3))
3003 (setq org-agenda-show-all-dates t)
3004 (setq org-agenda-start-on-weekday nil)
3005 (setq org-deadline-warning-days 14)
3008 *** Global keybindings.
3009 Start off by defining a series of keybindings.
3011 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
3012 setup manually, not by org-mode. Also turn off =C-c ;=, which
3013 comments headlines - a function never used.
3014 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3015 (add-hook 'org-mode-hook
3017 (org-defkey org-mode-map "\C-c[" 'undefined)
3018 (org-defkey org-mode-map "\C-c]" 'undefined)
3019 (org-defkey org-mode-map "\C-c;" 'undefined))
3023 And now a largish set of keybindings...
3024 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3025 (bind-key "C-c l" 'org-store-link)
3026 (bind-key "C-c a" 'org-agenda)
3027 ;(bind-key "C-c b" 'org-iswitchb)
3028 (define-key mode-specific-map [?a] 'org-agenda)
3030 (bind-key "<f12>" 'org-agenda)
3031 (bind-key "<f5>" 'bh/org-todo)
3032 (bind-key "<S-f5>" 'bh/widen)
3033 (bind-key "<f7>" 'bh/set-truncate-lines)
3034 ;(bind-key "<f8>" 'org-cycle-agenda-files)
3036 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
3037 (bind-key "<f9> b" 'bbdb)
3038 (bind-key "<f9> c" 'calendar)
3039 (bind-key "<f9> f" 'boxquote-insert-file)
3040 (bind-key "<f9> h" 'bh/hide-other)
3041 (bind-key "<f9> n" 'org-narrow-to-subtree)
3042 (bind-key "<f9> w" 'widen)
3043 (bind-key "<f9> u" 'bh/narrow-up-one-level)
3044 (bind-key "<f9> I" 'bh/punch-in)
3045 (bind-key "<f9> O" 'bh/punch-out)
3046 (bind-key "<f9> H" 'jj/punch-in-hw)
3047 (bind-key "<f9> W" 'jj/punch-out-hw)
3048 (bind-key "<f9> o" 'bh/make-org-scratch)
3049 (bind-key "<f9> p" 'bh/phone-call)
3050 (bind-key "<f9> r" 'boxquote-region)
3051 (bind-key "<f9> s" 'bh/switch-to-scratch)
3052 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
3053 (bind-key "<f9> T" 'tabify)
3054 (bind-key "<f9> U" 'untabify)
3055 (bind-key "<f9> v" 'visible-mode)
3056 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
3057 (bind-key "C-<f9>" 'previous-buffer)
3058 (bind-key "C-<f10>" 'next-buffer)
3059 (bind-key "M-<f9>" 'org-toggle-inline-images)
3060 ;(bind-key "C-x n r" 'narrow-to-region)
3061 (bind-key "<f11>" 'org-clock-goto)
3062 (bind-key "C-<f11>" 'org-clock-in)
3063 (bind-key "C-M-r" 'org-capture)
3064 (bind-key "C-c r" 'org-capture)
3065 (bind-key "C-S-<f12>" 'bh/save-then-publish)
3066 ;(bind-key "C-k" 'jj-org-kill-line org-mode-map)
3070 *** Tasks, States, Todo fun
3072 First we define the global todo keywords.
3073 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3074 (setq org-todo-keywords
3075 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
3076 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
3078 (setq org-todo-keyword-faces
3079 (quote (("TODO" :foreground "red" :weight bold)
3080 ("NEXT" :foreground "light blue" :weight bold)
3081 ("DONE" :foreground "forest green" :weight bold)
3082 ("WAITING" :foreground "orange" :weight bold)
3083 ("HOLD" :foreground "orange" :weight bold)
3084 ("DELEGATED" :foreground "yellow" :weight bold)
3085 ("CANCELLED" :foreground "dark green" :weight bold)
3086 ("PHONE" :foreground "dark green" :weight bold))))
3089 **** Fast Todo Selection
3090 Fast todo selection allows changing from any task todo state to any
3091 other state directly by selecting the appropriate key from the fast
3092 todo selection key menu.
3093 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3094 (setq org-use-fast-todo-selection t)
3096 Changing a task state is done with =C-c C-t KEY=
3098 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
3101 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3102 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
3104 allows changing todo states with S-left and S-right skipping all of
3105 the normal processing when entering or leaving a todo state. This
3106 cycles through the todo states but skips setting timestamps and
3107 entering notes which is very convenient when all you want to do is fix
3108 up the status of an entry.
3110 **** Todo State Triggers
3111 I have a few triggers that automatically assign tags to tasks based on
3112 state changes. If a task moves to =CANCELLED= state then it gets a
3113 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
3114 =CANCELLED= tag. These are used for filtering tasks in agenda views
3115 which I'll talk about later.
3117 The triggers break down to the following rules:
3119 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
3120 - Moving a task to =WAITING= adds a =WAITING= tag
3121 - Moving a task to =HOLD= adds a =WAITING= tag
3122 - Moving a task to a done state removes a =WAITING= tag
3123 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
3124 - Moving a task to =NEXT= removes a =WAITING= tag
3125 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
3127 The tags are used to filter tasks in the agenda views conveniently.
3128 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3129 (setq org-todo-state-tags-triggers
3130 (quote (("CANCELLED" ("CANCELLED" . t))
3131 ("WAITING" ("WAITING" . t))
3132 ("HOLD" ("WAITING" . t) ("HOLD" . t))
3133 (done ("WAITING") ("HOLD"))
3134 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
3135 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
3136 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
3139 *** Capturing new tasks
3140 Org capture replaces the old remember mode.
3141 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3142 (setq org-directory "~/org")
3143 (setq org-default-notes-file "~/org/refile.org")
3145 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
3146 ;; see http://orgmode.org/manual/Template-elements.html
3147 (setq org-capture-templates
3148 (quote (("t" "todo" entry (file "~/org/refile.org")
3149 "* TODO %?\nAdded: %U\n"
3150 :clock-in t :clock-resume t)
3151 ("l" "linktodo" entry (file "~/org/refile.org")
3152 "* TODO %?\nAdded: %U\n%a\n"
3153 :clock-in t :clock-resume t)
3154 ("r" "respond" entry (file "~/org/refile.org")
3155 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
3156 :clock-in t :clock-resume t :immediate-finish t)
3157 ("n" "note" entry (file "~/org/refile.org")
3158 "* %? :NOTE:\nAdded: %U\n%a\n"
3159 :clock-in t :clock-resume t)
3160 ("d" "Delegated" entry (file "~/org/refile.org")
3161 "* DELEGATED %?\nAdded: %U\n%a\n"
3162 :clock-in t :clock-resume t)
3163 ("j" "Journal" entry (file+datetree "~/org/diary.org")
3165 :clock-in t :clock-resume t)
3166 ("w" "org-protocol" entry (file "~/org/refile.org")
3167 "* TODO Review %c\nAdded: %U\n"
3168 :immediate-finish t)
3169 ("p" "Phone call" entry (file "~/org/refile.org")
3170 "* PHONE %? :PHONE:\nAdded: %U"
3171 :clock-in t :clock-resume t)
3172 ("x" "Bookmark link" entry (file "~/org/refile.org")
3173 "* Bookmark: %c\n%i\nAdded: %U\n"
3174 :immediate-finish t)
3175 ("h" "Habit" entry (file "~/org/refile.org")
3176 "* 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")
3180 Capture mode now handles automatically clocking in and out of a
3181 capture task. This all works out of the box now without special hooks.
3182 When I start a capture mode task the task is clocked in as specified
3183 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
3184 resumes on the original clocking task.
3186 The quick clocking in and out of capture mode tasks (often it takes
3187 less than a minute to capture some new task details) can leave
3188 empty clock drawers in my tasks which aren't really useful.
3189 The following prevents this.
3190 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3191 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
3195 All my newly captured entries end up in =refile.org= and want to be
3196 moved over to the right place. The following is the setup for it.
3197 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3198 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
3199 (setq org-refile-targets (quote ((nil :maxlevel . 9)
3200 (org-agenda-files :maxlevel . 9))))
3202 ; Use full outline paths for refile targets - we file directly with IDO
3203 (setq org-refile-use-outline-path t)
3205 ; Targets complete directly with IDO
3206 (setq org-outline-path-complete-in-steps nil)
3208 ; Allow refile to create parent tasks with confirmation
3209 (setq org-refile-allow-creating-parent-nodes (quote confirm))
3211 ; Use IDO for both buffer and file completion and ido-everywhere to t
3212 (setq org-completion-use-ido t)
3213 (setq org-completion-use-iswitchb nil)
3214 :; Use IDO for both buffer and file completion and ido-everywhere to t
3215 ;(setq ido-everywhere t)
3216 ;(setq ido-max-directory-size 100000)
3217 ;(ido-mode (quote both))
3218 ; Use the current window when visiting files and buffers with ido
3219 (setq ido-default-file-method 'selected-window)
3220 (setq ido-default-buffer-method 'selected-window)
3222 ;;;; Refile settings
3223 (setq org-refile-target-verify-function 'bh/verify-refile-target)
3227 Agenda view is the central place for org-mode interaction...
3228 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3229 ;; Do not dim blocked tasks
3230 (setq org-agenda-dim-blocked-tasks nil)
3231 ;; Compact the block agenda view
3232 (setq org-agenda-compact-blocks t)
3234 ;; Custom agenda command definitions
3235 (setq org-agenda-custom-commands
3236 (quote (("N" "Notes" tags "NOTE"
3237 ((org-agenda-overriding-header "Notes")
3238 (org-tags-match-list-sublevels t)))
3239 ("h" "Habits" tags-todo "STYLE=\"habit\""
3240 ((org-agenda-overriding-header "Habits")
3241 (org-agenda-sorting-strategy
3242 '(todo-state-down effort-up category-keep))))
3246 ((org-agenda-overriding-header "Tasks to Refile")
3247 (org-tags-match-list-sublevels nil)))
3248 (tags-todo "-HOLD-CANCELLED/!"
3249 ((org-agenda-overriding-header "Projects")
3250 (org-agenda-skip-function 'bh/skip-non-projects)
3251 (org-agenda-sorting-strategy
3253 (tags-todo "-CANCELLED/!"
3254 ((org-agenda-overriding-header "Stuck Projects")
3255 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3256 (tags-todo "-WAITING-CANCELLED/!NEXT"
3257 ((org-agenda-overriding-header "Next Tasks")
3258 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3259 (org-agenda-todo-ignore-scheduled t)
3260 (org-agenda-todo-ignore-deadlines t)
3261 (org-agenda-todo-ignore-with-date t)
3262 (org-tags-match-list-sublevels t)
3263 (org-agenda-sorting-strategy
3264 '(todo-state-down effort-up category-keep))))
3265 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3266 ((org-agenda-overriding-header "Tasks")
3267 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3268 (org-agenda-todo-ignore-scheduled t)
3269 (org-agenda-todo-ignore-deadlines t)
3270 (org-agenda-todo-ignore-with-date t)
3271 (org-agenda-sorting-strategy
3273 (tags-todo "-CANCELLED+WAITING/!"
3274 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
3275 (org-agenda-skip-function 'bh/skip-stuck-projects)
3276 (org-tags-match-list-sublevels nil)
3277 (org-agenda-todo-ignore-scheduled 'future)
3278 (org-agenda-todo-ignore-deadlines 'future)))
3280 ((org-agenda-overriding-header "Tasks to Archive")
3281 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3282 (org-tags-match-list-sublevels nil))))
3284 ("r" "Tasks to Refile" tags "REFILE"
3285 ((org-agenda-overriding-header "Tasks to Refile")
3286 (org-tags-match-list-sublevels nil)))
3287 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
3288 ((org-agenda-overriding-header "Stuck Projects")
3289 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3290 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
3291 ((org-agenda-overriding-header "Next Tasks")
3292 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3293 (org-agenda-todo-ignore-scheduled t)
3294 (org-agenda-todo-ignore-deadlines t)
3295 (org-agenda-todo-ignore-with-date t)
3296 (org-tags-match-list-sublevels t)
3297 (org-agenda-sorting-strategy
3298 '(todo-state-down effort-up category-keep))))
3299 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3300 ((org-agenda-overriding-header "Tasks")
3301 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3302 (org-agenda-sorting-strategy
3304 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
3305 ((org-agenda-overriding-header "Projects")
3306 (org-agenda-skip-function 'bh/skip-non-projects)
3307 (org-agenda-sorting-strategy
3309 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
3310 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
3311 (org-tags-match-list-sublevels nil))
3312 ("A" "Tasks to Archive" tags "-REFILE/"
3313 ((org-agenda-overriding-header "Tasks to Archive")
3314 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3315 (org-tags-match-list-sublevels nil))))))
3317 ; Overwrite the current window with the agenda
3318 (setq org-agenda-window-setup 'current-window)
3323 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3325 ;; Resume clocking task when emacs is restarted
3326 (org-clock-persistence-insinuate)
3328 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
3329 (setq org-clock-history-length 36)
3330 ;; Resume clocking task on clock-in if the clock is open
3331 (setq org-clock-in-resume t)
3332 ;; Change tasks to NEXT when clocking in
3333 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
3334 ;; Separate drawers for clocking and logs
3335 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
3336 ;; Save clock data and state changes and notes in the LOGBOOK drawer
3337 (setq org-clock-into-drawer t)
3338 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
3339 (setq org-clock-out-remove-zero-time-clocks t)
3340 ;; Clock out when moving task to a done state
3341 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
3342 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
3343 (setq org-clock-persist t)
3344 ;; Do not prompt to resume an active clock
3345 (setq org-clock-persist-query-resume nil)
3346 ;; Enable auto clock resolution for finding open clocks
3347 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
3348 ;; Include current clocking task in clock reports
3349 (setq org-clock-report-include-clocking-task t)
3351 ; use discrete minute intervals (no rounding) increments
3352 (setq org-time-stamp-rounding-minutes (quote (1 1)))
3354 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
3356 (setq bh/keep-clock-running nil)
3358 (setq org-agenda-clock-consistency-checks
3359 (quote (:max-duration "4:00"
3362 :gap-ok-around ("4:00"))))
3366 **** Setting a default clock task
3367 Per default the =** Organization= task in my tasks.org file receives
3368 misc clock time. This is the task I clock in on when I punch in at the
3369 start of my work day with =F9-I=. Punching-in anywhere clocks in this
3370 Organization task as the default task.
3372 If I want to change the default clocking task I just visit the
3373 new task in any org buffer and clock it in with =C-u C-u C-c C-x
3374 C-i=. Now this new task that collects miscellaneous clock
3375 minutes when the clock would normally stop.
3377 You can quickly clock in the default clocking task with =C-u C-c
3378 C-x C-i d=. Another option is to repeatedly clock out so the
3379 clock moves up the project tree until you clock out the
3380 top-level task and the clock moves to the default task.
3383 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3384 ;; Agenda clock report parameters
3385 (setq org-agenda-clockreport-parameter-plist
3386 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
3388 ;; Agenda log mode items to display (closed and state changes by default)
3389 (setq org-agenda-log-mode-items (quote (closed state)))
3391 **** Task estimates, column view
3392 Setup column view globally with the following headlines
3393 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3394 ; Set default column view headings: Task Effort Clock_Summary
3395 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
3397 Setup the estimate for effort values.
3398 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3399 ; global Effort estimate values
3400 ; global STYLE property values for completion
3401 (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")
3402 ("STYLE_ALL" . "habit"))))
3406 Tags are mostly used for filtering inside the agenda.
3407 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3408 ; Tags with fast selection keys
3409 (setq org-tag-alist (quote ((:startgroup)
3427 ; Allow setting single tags without the menu
3428 (setq org-fast-tag-selection-single-key (quote expert))
3430 ; For tag searches ignore tasks with scheduled and deadline dates
3431 (setq org-agenda-tags-todo-honor-ignore-options t)
3435 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3436 (setq org-archive-mark-done nil)
3437 (setq org-archive-location "%s_archive::* Archived Tasks")
3441 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3442 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
3443 (setq org-plantuml-jar-path "~/java/plantuml.jar")
3445 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
3447 ; Make babel results blocks lowercase
3448 (setq org-babel-results-keyword "results")
3450 (org-babel-do-load-languages
3451 (quote org-babel-load-languages)
3452 (quote ((emacs-lisp . t)
3471 ; Do not prompt to confirm evaluation
3472 ; This may be dangerous - make sure you understand the consequences
3473 ; of setting this -- see the docstring for details
3474 (setq org-confirm-babel-evaluate nil)
3476 ; Use fundamental mode when editing plantuml blocks with C-c '
3477 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
3480 #+BEGIN_SRC emacs-lisp :tangle yes
3481 ;; Don't have images visible on startup, breaks on console
3482 (setq org-startup-with-inline-images nil)
3485 #+BEGIN_SRC emacs-lisp :tangle yes
3486 (add-to-list 'org-structure-template-alist
3487 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
3488 "<comment>\n?\n</comment>"))
3490 **** ditaa, graphviz, etc
3491 Those are all nice tools. Look at
3492 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
3495 *** Publishing and exporting
3498 Org-mode can export to a variety of publishing formats including (but not limited to)
3501 (plain text - but not the original org-mode file)
3505 which enables getting to lots of other formats like ODF, XML, etc
3507 via LaTeX or Docbook
3510 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
3512 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3513 ;; Explicitly load required exporters
3517 ;; FIXME, check the following two
3518 ;(require 'ox-icalendar)
3521 ; experimenting with docbook exports - not finished
3522 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
3523 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
3525 ;; define categories that should be excluded
3526 (setq org-export-exclude-category (list "google" "google"))
3527 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
3529 ; define how the date strings look
3530 (setq org-export-date-timestamp-format "%Y-%m-%d")
3531 ; Inline images in HTML instead of producting links to the image
3532 (setq org-html-inline-images t)
3533 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
3534 (setq org-export-with-sub-superscripts nil)
3536 (setq org-html-head-extra (concat
3537 "<link rel=\"stylesheet\" href=\"http://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
3539 (setq org-html-head-include-default-style nil)
3540 ; Do not generate internal css formatting for HTML exports
3541 (setq org-export-htmlize-output-type (quote css))
3542 ; Export with LaTeX fragments
3543 (setq org-export-with-LaTeX-fragments t)
3544 ; Increase default number of headings to export
3545 (setq org-export-headline-levels 6)
3548 (setq org-publish-project-alist
3551 :base-directory "~/.emacs.d/"
3552 :base-extension "org"
3554 :publishing-directory "/develop/www/emacs"
3556 :publishing-function org-html-publish-to-html
3557 :headline-levels 4 ; Just the default for this project.
3563 :base-directory "~/.emacs.d/"
3564 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
3565 :publishing-directory "/develop/www/emacs"
3566 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
3568 :publishing-function org-publish-attachment
3570 ("inherit-org-info-js"
3571 :base-directory "/develop/vcs/org-info-js/"
3573 :base-extension "js"
3574 :publishing-directory "/develop/www/"
3575 :publishing-function org-publish-attachment
3577 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
3582 (setq org-export-with-timestamps nil)
3587 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3588 (setq org-latex-to-pdf-process
3589 '("xelatex -interaction nonstopmode %f"
3590 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
3591 (setq org-export-latex-listings 'minted)
3592 (setq org-latex-listings t)
3594 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
3595 ;; but adapted to use latexmk 4.20 or higher.
3596 (defun my-auto-tex-cmd ()
3597 "When exporting from .org with latex, automatically run latex,
3598 pdflatex, or xelatex as appropriate, using latexmk."
3600 ;; default command: oldstyle latex via dvi
3601 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
3603 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
3604 (setq texcmd "latexmk -pdf -quiet %f"))
3606 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3607 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
3608 ;; LaTeX compilation command
3609 (setq org-latex-to-pdf-process (list texcmd)))
3611 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
3613 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
3614 (setq org-export-latex-packages-alist
3616 ("" "longtable" nil)
3621 (defun my-auto-tex-parameters ()
3622 "Automatically select the tex packages to include."
3623 ;; default packages for ordinary latex or pdflatex export
3624 (setq org-export-latex-default-packages-alist
3625 '(("AUTO" "inputenc" t)
3635 ("" "hyperref" nil)))
3637 ;; Packages to include when xelatex is used
3638 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3639 (setq org-export-latex-default-packages-alist
3644 ("german" "babel" t)
3645 ("babel" "csquotes" t)
3647 ("xetex" "hyperref" nil)
3650 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
3651 (setq org-export-latex-classes
3653 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
3654 ("\\section{%s}" . "\\section*{%s}")
3655 ("\\subsection{%s}" . "\\subsection*{%s}")
3656 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
3657 ("\\paragraph{%s}" . "\\paragraph*{%s}")
3658 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
3659 org-export-latex-classes))))
3661 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
3664 *** Prevent editing invisible text
3665 The following setting prevents accidentally editing hidden text when
3666 the point is inside a folded region. This can happen if you are in
3667 the body of a heading and globally fold the org-file with =S-TAB=
3669 I find invisible edits (and undo's) hard to deal with so now I can't
3670 edit invisible text. =C-c C-r= (org-reveal) will display where the
3671 point is if it is buried in invisible text to allow editing again.
3673 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3674 (setq org-catch-invisible-edits 'error)
3678 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3679 ;; disable the default org-mode stuck projects agenda view
3680 (setq org-stuck-projects (quote ("" nil nil "")))
3682 ; force showing the next headline.
3683 (setq org-show-entry-below (quote ((default))))
3685 (setq org-show-following-heading t)
3686 (setq org-show-hierarchy-above t)
3687 (setq org-show-siblings (quote ((default))))
3689 (setq org-special-ctrl-a/e t)
3690 (setq org-special-ctrl-k t)
3691 (setq org-yank-adjusted-subtrees t)
3693 (setq org-table-export-default-format "orgtbl-to-csv")
3697 The following setting adds alphabetical lists like
3701 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3702 (if (> emacs-major-version 23)
3703 (setq org-list-allow-alphabetical t)
3704 (setq org-alphabetical-lists t))
3707 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3708 (setq org-remove-highlights-with-change nil)
3710 (setq org-list-demote-modify-bullet (quote (("+" . "-")
3717 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
3720 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
3721 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
3726 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3727 ;; Enable abbrev-mode
3728 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
3729 (setq org-startup-indented t)
3730 (setq org-startup-folded t)
3731 (setq org-cycle-separator-lines 0)
3734 I find extra blank lines in lists and headings a bit of a nuisance.
3735 To get a body after a list you need to include a blank line between
3736 the list entry and the body -- and indent the body appropriately.
3737 Most of my lists have no body detail so I like the look of collapsed
3738 lists with no blank lines better.
3740 The following setting prevents creating blank lines before headings
3741 but allows list items to adapt to existing blank lines around the items:
3742 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3743 (setq org-blank-before-new-entry (quote ((heading)
3744 (plain-list-item . auto))))
3747 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3748 (setq org-reverse-note-order nil)
3749 (setq org-default-notes-file "~/notes.org")
3752 Enforce task blocking. Tasks can't go done when there is any subtask
3753 still open. Unless they have a property of =NOBLOCKING: t=
3754 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3755 (setq org-enforce-todo-checkbox-dependencies t)
3756 (setq org-enforce-todo-dependencies t)
3759 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3760 (setq org-fast-tag-selection-single-key (quote expert))
3761 (setq org-footnote-auto-adjust t)
3762 (setq org-hide-block-startup t)
3763 (setq org-icalendar-alarm-time 15)
3764 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
3765 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
3766 (setq org-icalendar-honor-noexport-tag t)
3767 (setq org-icalendar-include-bbdb-anniversaries nil)
3768 (setq org-icalendar-include-body 200)
3769 (setq org-icalendar-include-todo nil)
3770 (setq org-icalendar-store-UID t)
3771 (setq org-icalendar-timezone "Europe/Berlin")
3772 (setq org-insert-mode-line-in-empty-file t)
3773 (setq org-log-done (quote note))
3774 (setq org-log-into-drawer t)
3775 (setq org-log-state-notes-insert-after-drawers nil)
3776 (setq org-log-reschedule (quote time))
3777 (setq org-log-states-order-reversed t)
3778 (setq org-mobile-agendas (quote all))
3779 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
3780 (setq org-mobile-inbox-for-pull "~/org/refile.org")
3781 (setq org-remember-store-without-prompt t)
3782 (setq org-return-follows-link t)
3783 (setq org-reverse-note-order t)
3785 ; regularly save our org-mode buffers
3786 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
3788 (setq org-log-done t)
3790 (setq org-enable-priority-commands t)
3791 (setq org-default-priority ?E)
3792 (setq org-lowest-priority ?E)
3797 Speed commands enable single-letter commands in Org-mode files when
3798 the point is at the beginning of a headline, or at the beginning of a
3801 See the `=org-speed-commands-default=' variable for a list of the keys
3802 and commands enabled at the beginning of headlines. All code blocks
3803 are available at the beginning of a code block, the following key
3804 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
3805 display a list of the code blocks commands and their related keys.
3807 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3808 (setq org-use-speed-commands nil)
3809 (setq org-speed-commands-user (quote (("0" . ignore)
3822 ("h" . bh/hide-other)
3825 (call-interactively 'org-insert-heading-respect-content))
3826 ("k" . org-kill-note-or-show-branches)
3829 ("q" . bh/show-org-agenda)
3831 ("s" . org-save-all-org-buffers)
3835 ("z" . org-add-note)
3840 ("F" . bh/restrict-to-file-or-follow)
3843 ("J" . org-clock-goto)
3847 ("N" . bh/narrow-to-org-subtree)
3848 ("P" . bh/narrow-to-org-project)
3853 ("U" . bh/narrow-up-one-org-level)
3860 (add-hook 'org-agenda-mode-hook
3862 (define-key org-agenda-mode-map "q" 'bury-buffer))
3865 (defvar bh/current-view-project nil)
3866 (add-hook 'org-agenda-mode-hook
3867 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
3872 The following displays the contents of code blocks in Org-mode files
3873 using the major-mode of the code. It also changes the behavior of
3874 =TAB= to as if it were used in the appropriate major mode. This means
3875 that reading and editing code form inside of your Org-mode files is
3876 much more like reading and editing of code using its major mode.
3878 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3879 (setq org-src-fontify-natively t)
3880 (setq org-src-tab-acts-natively t)
3883 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3884 (setq org-src-preserve-indentation nil)
3885 (setq org-edit-src-content-indentation 0)
3889 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3890 (setq org-attach-directory "~/org/data/")
3892 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3893 (setq org-agenda-sticky t)
3896 **** Checklist handling
3897 [2013-05-11 Sat 22:15]
3899 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3900 (require 'org-checklist)
3904 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
3906 #+BEGIN_SRC emacs-lisp :tangle yes
3907 (use-package cperl-mode
3908 :commands cperl-mode
3911 (defalias 'perl-mode 'cperl-mode)
3912 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
3913 (add-auto-mode 'pod-mode "\\.pod$")
3914 (add-auto-mode 'tt-mode "\\.tt$")
3915 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
3916 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
3917 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
3921 (setq cperl-invalid-face nil
3922 cperl-close-paren-offset -4
3923 cperl-continued-statement-offset 0
3924 cperl-indent-level 4
3925 cperl-indent-parens-as-block t
3927 cperl-electric-keywords t
3928 cperl-electric-lbrace-space t
3929 cperl-electric-parens nil
3930 cperl-highlight-variables-indiscriminately t
3931 cperl-imenu-addback t
3932 cperl-invalid-face (quote underline)
3933 cperl-lazy-help-time 5
3934 cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$"
3935 cperl-syntaxify-by-font-lock t
3936 cperl-use-syntax-table-text-property-for-tags t)
3938 ;; And have cperl mode give ElDoc a useful string
3939 (defun my-cperl-eldoc-documentation-function ()
3940 "Return meaningful doc string for `eldoc-mode'."
3942 (let ((cperl-message-on-help-error nil))
3944 (add-hook 'cperl-mode-hook
3946 (set (make-local-variable 'eldoc-documentation-function)
3947 'my-cperl-eldoc-documentation-function)
3952 [2014-05-22 Thu 00:05]
3953 #+BEGIN_SRC emacs-lisp :tangle yes
3954 (use-package puppet-mode
3955 :mode ("\\.pp\\'" . puppet-mode)
3956 :commands puppet-mode
3959 (defun my-puppet-mode-hook ()
3960 (setq require-final-newline nil))
3961 (add-hook 'puppet-mode-hook 'my-puppet-mode-hook))
3964 (use-package puppet-ext
3967 (bind-key "C-x ?" 'puppet-set-anchor puppet-mode-map)
3968 (bind-key "C-c C-r" 'puppet-create-require puppet-mode-map)))))
3972 Use elpy for the emacs python fun, but dont let it initialize all the
3973 various variables. Elpy author may like them, but I'm not him...
3974 #+BEGIN_SRC emacs-lisp :tangle yes
3977 :mode ("\.py" . python-mode)
3980 (safe-load (concat jj-elisp-dir "/elpy/elpy-autoloads.el"))
3987 :commands (nosetests-all nosetests-module nosetests-one
3988 nosetests-failed nosetests-pdb-all
3989 nosetests-pdb-module nosetests-pdb-one)
3994 :commands (pyvenv-activate pyvenv-deactivate pyvenv-mode pyvenv-restart-python)
3997 (use-package idomenu
4002 (use-package highlight-indentation
4004 :commands (highlight-indentation-mode))
4006 (use-package find-file-in-project
4008 :commands (find-file-in-project ffip-project-files ffip ))
4013 ;; Local variables in `python-mode'. This is not removed when Elpy
4014 ;; is disabled, which can cause some confusion.
4015 (add-hook 'python-mode-hook 'elpy-initialize-local-variables)
4017 (defun my-python-mode-hook ()
4018 (setq require-final-newline nil)
4019 (setq mode-require-final-newline))
4020 (add-hook 'python-mode-hook 'my-python-mode-hook)
4022 ;; Flymake support using flake8, including warning faces.
4023 (when (and (executable-find "flake8")
4024 (not (executable-find python-check-command)))
4025 (setq python-check-command "flake8"))
4027 ;; `flymake-no-changes-timeout': The original value of 0.5 is too
4028 ;; short for Python code, as that will result in the current line to
4029 ;; be highlighted most of the time, and that's annoying. This value
4030 ;; might be on the long side, but at least it does not, in general,
4031 ;; interfere with normal interaction.
4032 (setq flymake-no-changes-timeout 60)
4034 ;; `flymake-start-syntax-check-on-newline': This should be nil for
4035 ;; Python, as;; most lines with a colon at the end will mean the next
4036 ;; line is always highlighted as error, which is not helpful and
4038 (setq flymake-start-syntax-check-on-newline nil)
4040 ;; `ac-auto-show-menu': Short timeout because the menu is great.
4041 (setq ac-auto-show-menu 0.4)
4043 ;; `ac-quick-help-delay': I'd like to show the menu right with the
4044 ;; completions, but this value should be greater than
4045 ;; `ac-auto-show-menu' to show help for the first entry as well.
4046 (setq ac-quick-help-delay 0.5)
4048 ;; `yas-trigger-key': TAB, as is the default, conflicts with the
4049 ;; autocompletion. We also need to tell yasnippet about the new
4050 ;; binding. This is a bad interface to set the trigger key. Stop
4052 (let ((old (when (boundp 'yas-trigger-key)
4054 (setq yas-trigger-key "C-c C-i")
4055 (when (fboundp 'yas--trigger-key-reload)
4056 (yas--trigger-key-reload old)))
4058 ;; yas-snippet-dirs can be a string for a single directory. Make
4059 ;; sure it's a list in that case so we can add our own entry.
4060 (when (not (listp yas-snippet-dirs))
4061 (setq yas-snippet-dirs (list yas-snippet-dirs)))
4062 (add-to-list 'yas-snippet-dirs
4063 (concat (file-name-directory (locate-library "elpy"))
4067 ;; Now load yasnippets.
4070 (elpy-use-ipython)))
4075 #+BEGIN_SRC emacs-lisp :tangle no
4076 (autoload 'python-mode "python-mode" "Python Mode." t)
4077 (add-auto-mode 'python-mode "\\.py\\'")
4078 (add-auto-mode 'python-mode "\\.py$")
4079 (add-auto-mode 'python-mode "SConstruct\\'")
4080 (add-auto-mode 'python-mode "SConscript\\'")
4081 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
4084 (set-variable 'py-indent-offset 4)
4085 (set-variable 'py-smart-indentation nil)
4086 (set-variable 'indent-tabs-mode nil)
4087 (define-key python-mode-map "\C-m" 'newline-and-indent)
4088 (turn-on-eldoc-mode)
4089 (defun python-auto-fill-comments-only ()
4091 (set (make-local-variable 'fill-nobreak-predicate)
4093 (not (python-in-string/comment)))))
4094 (add-hook 'python-mode-hook
4096 (python-auto-fill-comments-only)))
4098 (autoload 'pymacs-apply "pymacs")
4099 (autoload 'pymacs-call "pymacs")
4100 (autoload 'pymacs-eval "pymacs" nil t)
4101 (autoload 'pymacs-exec "pymacs" nil t)
4102 (autoload 'pymacs-load "pymacs" nil t))
4105 If an =ipython= executable is on the path, then assume that IPython is
4106 the preferred method python evaluation.
4107 #+BEGIN_SRC emacs-lisp :tangle no
4108 (when (executable-find "ipython")
4110 (setq org-babel-python-mode 'python-mode))
4112 (setq python-shell-interpreter "ipython")
4113 (setq python-shell-interpreter-args "")
4114 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
4115 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
4116 (setq python-shell-completion-setup-code
4117 "from IPython.core.completerlib import module_completion")
4118 (setq python-shell-completion-module-string-code
4119 "';'.join(module_completion('''%s'''))\n")
4120 (setq python-shell-completion-string-code
4121 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
4123 ** rainbow-delimiters
4124 [2013-04-09 Di 23:38]
4125 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
4126 which highlights parens, brackets, and braces according to their
4127 depth. Each successive level is highlighted a different color. This
4128 makes it easy to spot matching delimiters, orient yourself in the code,
4129 and tell which statements are at the same depth.
4130 #+BEGIN_SRC emacs-lisp :tangle yes
4131 (use-package rainbow-delimiters
4132 :ensure rainbow-delimiters
4133 :commands rainbow-delimiters-mode
4135 (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
4138 #+BEGIN_SRC emacs-lisp :tangle yes
4139 (use-package rainbow-mode
4140 :ensure rainbow-mode
4142 :diminish rainbow-mode)
4147 #+BEGIN_SRC emacs-lisp :tangle yes
4148 (use-package re-builder
4149 :commands re-builder
4152 (setq reb-re-syntax 'string))
4155 [2014-05-19 Mo 22:56]
4156 Recentf is a minor mode that builds a list of recently opened
4157 files. This list is is automatically saved across Emacs sessions.
4158 #+BEGIN_SRC emacs-lisp :tangle yes
4159 (use-package recentf
4160 :if (not noninteractive)
4161 :bind ("C-x C-r" . recentf-open-files)
4166 (setq recentf-max-menu-items 25)
4167 (setq recentf-save-file (expand-file-name ".recentf" jj-cache-dir))
4169 (defun recentf-add-dired-directory ()
4170 (if (and dired-directory
4171 (file-directory-p dired-directory)
4172 (not (string= "/" dired-directory)))
4173 (let ((last-idx (1- (length dired-directory))))
4175 (if (= ?/ (aref dired-directory last-idx))
4176 (substring dired-directory 0 last-idx)
4177 dired-directory)))))
4179 (add-hook 'dired-mode-hook 'recentf-add-dired-directory)))
4181 ** Region bindings mode
4182 [2013-05-01 Wed 22:51]
4183 This mode allows to have keybindings that are only alive when the
4184 region is active. Helpful for things that only do any useful action
4185 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
4186 #+BEGIN_SRC emacs-lisp :tangle yes
4187 (use-package region-bindings-mode
4188 :ensure region-bindings-mode
4190 (region-bindings-mode-enable))
4193 [2013-05-22 Wed 22:33]
4194 Programming in ruby...
4197 #+BEGIN_SRC emacs-lisp :tangle yes
4198 (add-auto-mode 'ruby-mode
4199 "Rakefile\\'" "\\.rake\\'" "\.rxml\\'"
4200 "\\.rjs\\'" ".irbrc\\'" "\.builder\\'" "\\.ru\\'"
4201 "\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
4205 #+BEGIN_SRC emacs-lisp :tangle yes
4206 (use-package ruby-mode
4207 :mode ("\\.rb\\'" . ruby-mode)
4208 :interpreter ("ruby" . ruby-mode)
4215 (defvar yari-helm-source-ri-pages
4216 '((name . "RI documentation")
4217 (candidates . (lambda () (yari-ruby-obarray)))
4218 (action ("Show with Yari" . yari))
4219 (candidate-number-limit . 300)
4220 (requires-pattern . 2)
4221 "Source for completing RI documentation."))
4223 (defun helm-yari (&optional rehash)
4224 (interactive (list current-prefix-arg))
4225 (when current-prefix-arg (yari-ruby-obarray rehash))
4226 (helm 'yari-helm-source-ri-pages (yari-symbol-at-point)))))
4228 (defun my-ruby-smart-return ()
4230 (when (memq (char-after) '(?\| ?\" ?\'))
4232 (call-interactively 'newline-and-indent))
4234 (use-package ruby-hash-syntax
4235 :ensure ruby-hash-syntax)
4237 (use-package inf-ruby
4239 :commands inf-ruby-minor-mode
4242 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)
4243 (bind-key "<return>" 'my-ruby-smart-return ruby-mode-map)
4244 ;(bind-key "<tab>" 'indent-for-tab-command ruby-mode-map)
4247 (set (make-local-variable 'yas-fallback-behavior)
4248 '(apply ruby-indent-command . nil))
4249 (bind-key "<tab>" 'yas-expand-from-trigger-key ruby-mode-map)))
4251 ;; Stupidly the non-bundled ruby-mode isn't a derived mode of
4252 ;; prog-mode: we run the latter's hooks anyway in that case.
4253 (add-hook 'ruby-mode-hook
4255 (unless (derived-mode-p 'prog-mode)
4256 (run-hooks 'prog-mode-hook))))
4260 [2013-05-22 Wed 22:40]
4261 Save and restore the desktop
4262 #+BEGIN_SRC emacs-lisp :tangle yes
4263 (setq desktop-path (list jj-cache-dir))
4264 (desktop-save-mode 1)
4265 (defadvice desktop-read (around trace-desktop-errors activate)
4266 (let ((debug-on-error t))
4269 ;;----------------------------------------------------------------------------
4270 ;; Restore histories and registers after saving
4271 ;;----------------------------------------------------------------------------
4272 (use-package session
4273 :if (not noninteractive)
4274 :load-path "site-lisp/session/lisp/"
4277 (setq session-save-file (expand-file-name "session" jj-cache-dir))
4278 (setq desktop-globals-to-save
4279 (append '((extended-command-history . 30)
4280 (file-name-history . 100)
4282 (compile-history . 30)
4283 (minibuffer-history . 50)
4284 (query-replace-history . 60)
4285 (read-expression-history . 60)
4286 (regexp-history . 60)
4287 (regexp-search-ring . 20)
4289 (comint-input-ring . 50)
4290 (shell-command-history . 50)
4292 desktop-missing-file-warning
4296 (session-initialize)
4298 (defun remove-session-use-package-from-settings ()
4299 (when (string= (file-name-nondirectory (buffer-file-name)) "settings.el")
4301 (goto-char (point-min))
4302 (when (re-search-forward "^ '(session-use-package " nil t)
4303 (delete-region (line-beginning-position)
4304 (1+ (line-end-position)))))))
4306 (add-hook 'before-save-hook 'remove-session-use-package-from-settings)
4308 ;; expanded folded secitons as required
4309 (defun le::maybe-reveal ()
4310 (when (and (or (memq major-mode '(org-mode outline-mode))
4311 (and (boundp 'outline-minor-mode)
4312 outline-minor-mode))
4313 (outline-invisible-p))
4314 (if (eq major-mode 'org-mode)
4318 (add-hook 'session-after-jump-to-last-change-hook
4321 (defun save-information ()
4322 (with-temp-message "Saving Emacs information..."
4325 (loop for func in kill-emacs-hook
4326 unless (memq func '(exit-gnus-on-exit server-force-stop))
4329 (unless (or noninteractive
4330 (eq 'listen (process-status server-process)))
4333 (run-with-idle-timer 300 t 'save-information)
4336 (add-hook 'after-init-hook 'session-initialize t))))
4340 [2013-04-21 So 20:25]
4341 Save a bit of history
4342 #+BEGIN_SRC emacs-lisp tangle no
4344 (setq savehist-additional-variables
4345 '(search ring regexp-search-ring kill-ring compile-history))
4346 ;; save every minute
4347 (setq savehist-autosave-interval 60)
4348 (setq savehist-file (expand-file-name "savehist" jj-cache-dir))
4353 Store at which point I have been in files.
4354 #+BEGIN_SRC emacs-lisp :tangle yes
4355 (setq-default save-place t)
4356 (require 'saveplace)
4357 (setq save-place-file (expand-file-name "saved-places" jj-cache-dir))
4360 [2014-06-10 Tue 22:05]
4361 #+BEGIN_SRC emacs-lisp :tangle yes
4362 (use-package simple-httpd
4363 :ensure simple-httpd
4364 :commands (httpd-start httpd-stop)
4367 (setq httpd-root "/srv/www")
4372 Settings for shell scripts
4373 #+BEGIN_SRC emacs-lisp :tangle yes
4374 (use-package sh-script
4378 (defvar sh-script-initialized nil)
4379 (defun initialize-sh-script ()
4380 (unless sh-script-initialized
4381 (setq sh-script-initialized t)
4382 (setq sh-indent-comment t)
4383 (info-lookup-add-help :mode 'shell-script-mode
4386 '(("(bash)Index")))))
4388 (add-hook 'shell-mode-hook 'initialize-sh-script)))
4391 #+BEGIN_SRC emacs-lisp :tangle yes
4392 (use-package sh-toggle
4393 :bind ("C-. C-z" . shell-toggle))
4396 [2015-02-24 Tue 23:35]
4397 Make =M-n= and =M-p= go forward/backword to the symbol at point.
4398 #+BEGIN_SRC emacs-lisp :tangle yes
4399 (use-package smartscan
4402 :idle (global-smartscan-mode t))
4405 By default, Emacs can update the time stamp for the following two
4406 formats if one exists in the first 8 lines of the file.
4409 #+BEGIN_SRC emacs-lisp :tangle yes
4410 (use-package time-stamp
4411 :commands time-stamp
4414 (add-hook 'write-file-hooks 'time-stamp)
4415 (setq time-stamp-active t))
4418 (setq time-stamp-format "%02H:%02M:%02S (%z) - %02d.%02m.%:y from %u (%U) on %s")
4419 (setq time-stamp-old-format-warn nil)
4420 (setq time-stamp-time-zone nil)))
4424 We configure only a bit of the tiny-tools to load when I should need
4425 them. I don't need much actually, but these things are nice to have.
4427 #+BEGIN_SRC emacs-lisp :tangle yes
4428 (autoload 'turn-on-tinyperl-mode "tinyperl" "" t)
4429 (add-hook 'perl-mode-hook 'turn-on-tinyperl-mode)
4430 (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode)
4432 (autoload 'tinycomment-indent-for-comment "tinycomment" "" t)
4433 (autoload 'tinyeat-forward-preserve "tinyeat" "" t)
4434 (autoload 'tinyeat-backward-preserve "tinyeat" "" t)
4435 (autoload 'tinyeat-kill-line-backward "tinyeat" "" t)
4437 *** Keyboard changes for tiny-tools
4438 #+BEGIN_SRC emacs-lisp :tangle yes
4439 (bind-key "\M-;" 'tinycomment-indent-for-comment)
4440 (bind-key "ESC C-k" 'tinyeat-kill-line-backward)
4441 (bind-key "ESC d" 'tinyeat-forward-preserve)
4442 (bind-key "<M-backspace>" 'tinyeat-backward-preserve)
4443 (bind-key "<S-backspace>" 'tinyeat-delete-whole-word)
4446 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
4447 #+BEGIN_SRC emacs-lisp :tangle yes
4452 (setq tramp-persistency-file-name (expand-file-name "tramp" jj-cache-dir))
4453 (setq shell-prompt-pattern "^[^a-zA-Z].*[#$%>] *")
4454 (add-to-list 'tramp-default-method-alist '("\\`localhost\\'" "\\`root\\'" "su"))
4455 (setq tramp-debug-buffer nil)
4456 (setq tramp-default-method "sshx")
4457 (tramp-set-completion-function "ssh"
4458 '((tramp-parse-sconfig "/etc/ssh_config")
4459 (tramp-parse-sconfig "~/.ssh/config")))
4460 (setq tramp-verbose 5)
4465 For some reason I prefer this mode more than the way without. I want to
4466 see the marked region.
4467 #+BEGIN_SRC emacs-lisp :tangle yes
4468 (transient-mark-mode 1)
4469 (make-variable-buffer-local 'transient-mark-mode)
4470 (put 'transient-mark-mode 'permanent-local t)
4471 (setq-default transient-mark-mode t)
4474 [2013-04-21 So 11:07]
4475 Emacs undo is pretty powerful - but can also be confusing. There are
4476 tons of modes available to change it, even downgrade it to the very
4477 crappy ways one usually knows from other systems which lose
4478 information. undo-tree is different - it helps keeping you sane while
4479 keeping the full power of emacs undo/redo.
4480 #+BEGIN_SRC emacs-lisp :tangle yes
4481 (use-package undo-tree
4483 :diminish undo-tree-mode
4486 (global-undo-tree-mode)
4487 (setq undo-tree-visualizer-timestamps t)
4488 (setq undo-tree-visualizer-diff t)
4489 ;; Keep region when undoing in region
4490 (defadvice undo-tree-undo (around keep-region activate)
4492 (let ((m (set-marker (make-marker) (mark)))
4493 (p (set-marker (make-marker) (point))))
4502 Always have unique buffernames. See [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html][Uniquify - GNU Emacs Manual]]
4503 #+BEGIN_SRC emacs-lisp :tangle yes
4504 (use-package uniquify
4507 (setq uniquify-buffer-name-style 'post-forward)
4508 (setq uniquify-after-kill-buffer-p t)
4509 (setq uniquify-ignore-buffers-re "^\\*")))
4513 url contains code to parse and handle URLs - who would have thought? I
4514 set it to send Accept-language header and tell it to not send email,
4515 operating system or location info.
4516 #+BEGIN_SRC emacs-lisp :tangle yes
4517 (setq url-mime-language-string "de,en")
4518 (setq url-privacy-level (quote (email os lastloc)))
4521 [2014-06-01 Sun 21:38]
4522 visual-regexp for Emacs is like replace-regexp, but with live visual
4523 feedback directly in the buffer
4524 #+BEGIN_SRC emacs-lisp :tangle yes
4525 (use-package visual-regexp
4526 :ensure visual-regexp
4527 :bind (("C-M-%" . vr/replace)
4528 ("M-%" . vr/query-replace)
4529 ("C-c m" . vr/mc-mark))
4532 ** volatile highlights
4533 [2013-04-21 So 20:31]
4534 VolatileHighlights highlights changes to the buffer caused by commands
4535 such as ‘undo’, ‘yank’/’yank-pop’, etc. The highlight disappears at the
4536 next command. The highlighting gives useful visual feedback for what
4537 your operation actually changed in the buffer.
4538 #+BEGIN_SRC emacs-lisp :tangle yes
4539 (use-package volatile-highlights
4540 :ensure volatile-highlights
4542 (volatile-highlights-mode t)
4543 :diminish volatile-highlights-mode)
4546 [2015-02-23 Mon 14:38]
4547 Easily move between splitted windows.
4548 #+BEGIN_SRC emacs-lisp :tangle yes
4549 (use-package windmove
4552 (windmove-default-keybindings)
4554 ;(setq org-replace-disputed-keys t)
4557 ** winner mode - undo and redo window configuration
4558 [2015-02-24 Tue 23:11]
4559 =winner-mode= lets you use =C-c <left>= and =C-c <right>= to switch between
4560 window configurations. This is handy when something has popped up a
4561 buffer that you want to look at briefly before returning to whatever
4562 you were working on. When you're done, press =C-c <left>=.
4563 #+BEGIN_SRC emacs-lisp :tangle yes
4567 :idle (winner-mode 1))
4570 This highlights some /weaselwords/, a mode to /aid in finding common
4571 writing problems/...
4572 [2013-04-27 Sa 23:29]
4573 #+BEGIN_SRC emacs-lisp :tangle no
4574 (use-package writegood-mode
4575 :ensure writegood-mode
4578 (bind-key "C-c g" 'writegood-mode))
4581 [2014-06-01 Sun 22:48]
4582 #+BEGIN_SRC emacs-lisp :tangle yes
4583 (use-package web-mode
4586 :mode (("\\.phtml\\'" . web-mode)
4587 ("\\.tpl\\.php\\'" . web-mode)
4588 ("\\.jsp\\'" . web-mode)
4589 ("\\.as[cp]x\\'" . web-mode)
4590 ("\\.erb\\'" . web-mode)
4591 ("\\.mustache\\'" . web-mode)
4592 ("\\.html\\'" . web-mode)
4593 ("\\.css\\'" . web-mode)
4594 ("\\.djhtml\\'" . web-mode))
4597 (add-hook 'web-mode-hook
4599 (setq web-mode-markup-indent-offset 2)
4600 (setq web-mode-css-indent-offset 2)
4601 (setq web-mode-code-indent-offset 2)
4602 (setq web-mode-enable-css-colorization t)
4603 (setq web-mode-enable-comment-keywords t)
4604 (setq web-mode-enable-current-element-highlight t))))
4607 (setq web-mode-enable-current-element-highlight t)
4608 (setq web-mode-ac-sources-alist
4609 '(("css" . (ac-source-css-property))
4610 ("html" . (ac-source-words-in-buffer ac-source-abbrev))))
4611 (use-package impatient-mode
4612 :ensure impatient-mode
4614 :commands impatient-mode))
4619 Yet another folding extension for the Emacs editor. Unlike many
4620 others, this one works by just using the existing indentation of the
4621 file, so basically works in every halfway structured file.
4622 #+BEGIN_SRC emacs-lisp :tangle yes
4623 (use-package yafolding
4624 :bind (("C-#" . yafolding)
4625 ("C-c C-f" . yafolding-toggle-all-by-current-level))
4626 :commands (yafolding yafolding-toggle-all-by-current-level)
4630 [2013-04-28 So 01:13]
4631 YAML is a nice format for data, which is both, human and machine
4632 readable/editable without getting a big headache.
4633 #+BEGIN_SRC emacs-lisp :tangle yes
4634 (use-package yaml-mode
4636 :mode ("\\.ya?ml\\'" . yaml-mode)
4638 (bind-key "C-m" 'newline-and-indent yaml-mode-map ))
4642 [2013-04-27 Sa 23:16]
4643 Yasnippet is a template system. Type an abbreviation, expand it into
4644 whatever the snippet holds.
4645 #+BEGIN_SRC emacs-lisp :tangle yes
4646 (setq yas-snippet-dirs (expand-file-name "yasnippet/snippets" jj-elisp-dir))
4647 (use-package yasnippet
4650 :diminish yas-minor-mode
4651 :commands yas-global-mode
4654 ;; Integrate hippie-expand with ya-snippet
4655 (add-to-list 'hippie-expand-try-functions-list
4656 'yas-hippie-try-expand)
4658 (setq yas-expand-only-for-last-commands '(self-insert-command))
4659 (bind-key "\t" 'hippie-expand yas-minor-mode-map)
4663 And thats it for this file, control passes "back" to [[file:../initjj.org][initjj.org/el]]
4664 which then may load more files.