1 #+TITLE: emacs.org - Ganneffs emacs configuration
2 #+DESCRIPTION: My current Emacs configuration
3 #+KEYWORDS: org-mode Emacs configuration
4 #+STARTUP: align fold nodlcheck hidestars oddeven lognotestate
5 #+SETUPFILE: ~/.emacs.d/elisp/org-templates/level-0.org
11 :ID: b6e6cf73-9802-4a7b-bd65-fdb6f9745319
13 The following functions are used throughout my config, and so I load
16 safe-load does not break emacs initialization, should a file be
17 unreadable while emacs boots up.
18 #+BEGIN_SRC emacs-lisp :tangle yes
19 (defvar safe-load-error-list ""
20 "*List of files that reported errors when loaded via safe-load")
22 (defun safe-load (file &optional noerror nomessage nosuffix)
23 "Load a file. If error on load, report back, wait for
24 a key stroke then continue on"
26 (condition-case nil (load file noerror nomessage nosuffix)
29 (setq safe-load-error-list (concat safe-load-error-list " " file))
30 (message "****** [Return to continue] Error loading %s" safe-load-error-list )
34 (defun safe-load-check ()
35 "Check for any previous safe-load loading errors. (safe-load.el)"
37 (if (string-equal safe-load-error-list "") ()
38 (message (concat "****** error loading: " safe-load-error-list))))
41 I have some stuff put away in my local dir. I don't want to load it all
42 at startup time, so it is using the autoload feature. For that to work
43 load the loaddefs, so autoload knows where to grab stuff
44 #+BEGIN_SRC emacs-lisp :tangle yes
45 (safe-load (concat jj-elisp-dir "/tiny/loaddefs.el"))
46 (safe-load (concat jj-elisp-local-dir "/loaddefs.el"))
48 *** Keep *scratch* around
49 Always ensure to have a scratch buffer around.
50 #+BEGIN_SRC emacs-lisp :tangle yes
51 (with-current-buffer (get-buffer-create "*scratch*")
52 (lisp-interaction-mode)
53 (make-local-variable 'kill-buffer-query-functions)
54 (add-hook 'kill-buffer-query-functions 'kill-scratch-buffer))
57 Handier way to add modes to auto-mode-alist
58 #+BEGIN_SRC emacs-lisp :tangle yes
59 (defun add-auto-mode (mode &rest patterns)
60 "Add entries to `auto-mode-alist' to use `MODE' for all given file `PATTERNS'."
61 (dolist (pattern patterns)
62 (add-to-list 'auto-mode-alist (cons pattern mode))))
64 *** config helpers use-package/bind-key
65 Helpers for the config
66 https://github.com/jwiegley/use-package
67 #+BEGIN_SRC emacs-lisp :tangle yes
68 (require 'use-package)
72 [2014-05-20 Tue 22:36]
73 #+BEGIN_SRC emacs-lisp :tangle yes
74 (defmacro hook-into-modes (func modes)
75 `(dolist (mode-hook ,modes)
76 (add-hook mode-hook ,func)))
80 The Emacs Lisp Package Archive contains things I want.
81 #+BEGIN_SRC emacs-lisp :tangle yes
82 (when (> emacs-major-version 23)
84 (setq package-user-dir (expand-file-name "elpa" jj-elisp-dir))
85 (dolist (source '(("melpa" . "http://melpa.milkbox.net/packages/")
86 ("melpa-stable" . "http://melpa-stable.milkbox.net/packages/")
87 ("marmalade" . "http://marmalade-repo.org/packages/")
88 ("elpy" . "http://jorgenschaefer.github.io/packages/")
89 ("elpa" . "http://tromey.com/elpa/")))
90 (add-to-list 'package-archives source t))
96 We need to define the load-path. As I have lots of things I add
97 locally, its getting a few entries. I disliked the repeated
98 /add-to-list/ lines, so I now just take all subdirectories of
99 jj-elisp-dir and add them.
101 Additionally I also ensure that files in there are recompiled, when
103 #+BEGIN_SRC emacs-lisp :tangle yes
105 (project (directory-files jj-elisp-dir t "\\w+"))
106 (when (file-directory-p project)
107 (if (string= project "emacs23")
108 (when (version< emacs-version "24")
109 (add-to-list 'load-path project))
110 (add-to-list 'load-path project))
111 ;(byte-recompile-directory project 0)
116 Help emacs to find the info files
117 #+BEGIN_SRC emacs-lisp :tangle no
118 (setq Info-directory-list '("~/emacs/info"
119 "/usr/local/share/info/"
121 "/usr/local/gnu/info/"
122 "/usr/local/gnu/lib/info/"
123 "/usr/local/gnu/lib/emacs/info/"
124 "/usr/local/emacs/info/"
125 "/usr/local/lib/info/"
126 "/usr/local/lib/emacs/info/"
127 "/usr/share/info/emacs-23"
130 (setq Info-default-directory-list
131 (cons "~/emacs/info" Info-default-directory-list))
137 :ID: 0a1560d9-7e55-47ab-be52-b3a8b8eea4aa
139 I dislike the startup message
140 #+BEGIN_SRC emacs-lisp :tangle yes
141 (setq inhibit-splash-screen t)
142 (setq inhibit-startup-message t)
145 Usually I want the lines to break at 72 characters.
146 #+BEGIN_SRC emacs-lisp :tangle yes
147 (setq fill-column 72)
150 And it is nice to have a final newline in files.
151 (Now off, ethan-wspace is doing it better).
152 #+BEGIN_SRC emacs-lisp :tangle yes
153 (setq require-final-newline nil)
154 (setq mode-require-final-newline nil)
157 After I typed 300 characters or took a break for more than a minute it
158 would be nice of emacs to save whatever I am on in one of its auto-save
159 backups. See [[info:emacs#Auto%20Save%20Control][info:emacs#Auto Save Control]] for more details.
160 #+BEGIN_SRC emacs-lisp :tangle yes
161 (setq auto-save-interval 300)
162 (setq auto-save-timeout 60)
165 Set my full name and my default mail address - for whatever wants to use
166 it later. Also, I am using gnus.
167 #+BEGIN_SRC emacs-lisp :tangle yes
168 (setq user-full-name "Joerg Jaspert")
169 (setq user-mail-address "joerg@ganneff.de")
170 (setq mail-user-agent (quote gnus-user-agent))
173 My default mail server. Well, simply a localhost, I have a forwarder that
174 puts mail off the right way, no need for emacs to have any further
176 #+BEGIN_SRC emacs-lisp :tangle yes
177 (setq smtpmail-default-smtp-server "localhost")
178 (setq smtpmail-smtp-server "localhost")
181 Enable automatic handling of compressed files.
182 #+BEGIN_SRC emacs-lisp :tangle yes
183 (auto-compression-mode 1)
186 Emacs forbids a certain set of commands, as they can be very confusing
187 for new users. Enable them.
188 #+BEGIN_SRC emacs-lisp :tangle yes
189 (put 'narrow-to-region 'disabled nil)
190 (put 'narrow-to-page 'disabled nil)
191 (put 'narrow-to-defun 'disabled nil)
192 (put 'upcase-region 'disabled nil)
193 (put 'downcase-region 'disabled nil)
197 I've tried various different fonts and while I like the Terminus font
198 most for my shells, in Emacs Inconsolata clearly wins.
199 #+BEGIN_SRC emacs-lisp :tangle yes
200 (set-frame-font "Inconsolata-14")
203 I always use dark backgrounds, so tell Emacs about it. No need to
205 #+BEGIN_SRC emacs-lisp :tangle yes
206 (setq-default frame-background-mode jj-color-style)
209 And I always liked dark backgrounds with colors setup for them. So I
210 switched through multiple themes doing it in emacs too, but never
211 entirely liked it. Until I found solarized, which is now not only my
212 emacs theme, but also for most of my other software too, especially my
213 shell. Consistent look is great.
214 #+BEGIN_SRC emacs-lisp :tangle no
215 (if (or (> emacs-major-version 23) (boundp 'custom-theme-load-path))
217 (defun jj-init-theme ()
219 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
220 (load-theme 'solarized-light t))
221 (set-face-attribute 'org-date nil :underline nil)
222 (message "Initializing theme solarized-dark")
224 (add-to-list 'custom-theme-load-path jj-theme-dir)
225 (add-hook 'after-init-hook 'jj-init-theme)
227 (add-to-list 'load-path (expand-file-name "emacs-color-theme-solarized" jj-elisp-dir))
228 (require 'color-theme-solarized)
229 (color-theme-solarized-dark)
232 #+BEGIN_SRC emacs-lisp :tangle yes
233 (use-package solarized
234 :load-path "elisp/emacs-color-theme-solarized"
237 (defun jj-init-theme ()
239 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
240 (load-theme 'solarized-light t))
241 (set-face-attribute 'org-date nil :underline nil)
242 (message "Initializing theme solarized-dark")
244 (add-to-list 'custom-theme-load-path jj-theme-dir)
245 (add-hook 'after-init-hook 'jj-init-theme)
249 Make the fringe (gutter) smaller, the argument is a width in pixels (the default is 8)
250 #+BEGIN_SRC emacs-lisp :tangle yes
251 (if (fboundp 'fringe-mode)
255 A bit more spacing between buffer lines
256 #+BEGIN_SRC emacs-lisp :tangle yes
257 (setq-default line-spacing 0.1)
260 [2013-04-21 So 20:54]
261 I do not want my cursor to blink.
262 #+BEGIN_SRC emacs-lisp :tangle yes
263 (blink-cursor-mode -1)
265 *** Menu, Tool and Scrollbar
266 I don't want to see the menu-bar, tool-bar or scrollbar.
267 #+BEGIN_SRC emacs-lisp :tangle yes
269 (dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode))
270 (when (fboundp mode) (funcall mode -1))))
272 **** When using emacs in daemon mode
273 Emacs has a very nice mode where it detaches itself and runs as daemon -
274 and you can just open /frames/ (windows) from it by using [[http://www.emacswiki.org/emacs/EmacsClient][Emacs
275 Client]]. It's fast, it's nice, it's convinient.
277 Except that Emacs behaves stupid when you do that and ignores your
278 menu/tool/scrollbar settings. Sucks.
280 For them to work even then, we have to do two things.
281 1. We have to set the frame alist. We simple set both,
282 =initial-frame-alist= and =default-frame-alist= to the same value here.
283 #+BEGIN_SRC emacs-lisp :tangle yes
284 (setq initial-frame-alist '(
285 (horizontal-scroll-bars . nil)
286 (vertical-scroll-bars . nil)
289 (setq default-frame-alist (copy-alist initial-frame-alist))
291 2. We have to disable the toolbar using the customize interface, so you
292 can find that in the [[id:0102208d-fdf6-4928-9e40-7e341bd3aa3a][Customized variables]] section.
294 *** Hilight current line in buffer
295 As it says, it does a hilight of the current line.
296 #+BEGIN_SRC emacs-lisp :tangle yes
297 (global-hl-line-mode +1)
299 *** Allow recursive minibuffers
300 This allows (additional) minibuffer commands while in the minibuffer.
301 #+BEGIN_SRC emacs-lisp :tangle yes
302 (setq enable-recursive-minibuffers 't)
305 *** Modeline related changes
306 I want to see line and column numbers, so turn them on.
307 Size indication lets me know how far I am in a buffer.
309 And modeline-posn is great. It will hilight the column number in the
310 modeline in red as soon as you are over the defined limit.
312 #+BEGIN_SRC emacs-lisp :tangle yes
314 (column-number-mode 1)
315 (size-indication-mode 1)
316 (display-time-mode 1)
317 (setq display-time-day-and-date nil)
318 (setq display-time-default-load-average nil)
319 (setq display-time-24hr-format t)
320 (setq modelinepos-column-limit 72)
322 (use-package modeline-posn
323 :ensure modeline-posn
326 (set-face-foreground 'modelinepos-column-warning "grey20")
327 (set-face-background 'modelinepos-column-warning "red")
328 (setq modelinepos-column-limit 72))
333 [2013-04-22 Mon 11:27]
334 The modeline is easily cluttered up with stuff I don't really need to
335 see. So lets hide those. There are two ways, one of them uses diminish
336 to get entirely rid of some modes, the other is a function taken from
337 "Mastering Emacs" which replaces the modes text with an own (set of)
339 #+BEGIN_SRC emacs-lisp :tangle yes
341 (diminish 'auto-fill-function)
342 (defvar mode-line-cleaner-alist
343 `((auto-complete-mode . " α")
344 (yas-minor-mode . " y")
345 (paredit-mode . " π")
349 (lisp-interaction-mode . "λ")
352 (emacs-lisp-mode . "EL")
354 (org-indent-mode . "")
359 "Alist for `clean-mode-line'.
361 When you add a new element to the alist, keep in mind that you
362 must pass the correct minor/major mode symbol and a string you
363 want to use in the modeline *in lieu of* the original.
365 Want some symbols? Go:
367 ;ςερτζθιοπασδφγηξκλυχψωβνμ
368 :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
369 @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
373 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
376 Unfortunately icicles breaks this with the way it adds/removes itself,
377 so take it our for now...
380 Back when I started with text-mode. But nowadays I want default mode to
381 be org-mode - it is just so much better to use. And does sensible things
382 with many README files out there, and various other "crap" you get to
384 #+BEGIN_SRC emacs-lisp :tangle yes
385 (setq major-mode 'org-mode)
386 (setq initial-major-mode 'org-mode)
390 [2013-04-23 Tue 16:43]
391 Shell. zsh in my case.
392 #+BEGIN_SRC emacs-lisp :tangle yes
393 (setq shell-file-name "zsh")
394 (setq shell-command-switch "-c")
395 (setq explicit-shell-file-name shell-file-name)
396 (setenv "SHELL" shell-file-name)
397 (setq explicit-sh-args '("-login" "-i"))
398 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
399 (setq comint-scroll-to-bottom-on-input t) ; always insert at the bottom
400 (setq comint-scroll-to-bottom-on-output t) ; always add output at the bottom
401 (setq comint-scroll-show-maximum-output t) ; scroll to show max possible output
402 (setq comint-completion-autolist t) ; show completion list when ambiguous
403 (setq comint-input-ignoredups t) ; no duplicates in command history
404 (setq comint-completion-addsuffix t) ; insert space/slash after file completion
408 Basic settings for emacs integrated shell
409 #+BEGIN_SRC emacs-lisp :tangle yes
414 (defun eshell-initialize ()
415 (defun eshell-spawn-external-command (beg end)
416 "Parse and expand any history references in current input."
419 (when (looking-back "&!" beg)
420 (delete-region (match-beginning 0) (match-end 0))
423 (add-hook 'eshell-expand-input-functions 'eshell-spawn-external-command)
424 (eval-after-load "em-unix"
426 (unintern 'eshell/su)
427 (unintern 'eshell/sudo))))
428 (add-hook 'eshell-first-time-mode-hook 'eshell-initialize)
438 (setq eshell-cmpl-cycle-completions nil
439 eshell-save-history-on-exit t
440 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
441 (setenv "PAGER" "cat")
442 (setq eshell-visual-commands
443 '("less" "tmux" "htop" "top" "bash" "zsh" "tail"))
444 (setq eshell-visual-subcommands
445 '(("git" "log" "l" "diff" "show")))
447 (add-to-list 'eshell-command-completions-alist
449 (add-to-list 'eshell-command-completions-alist
450 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
452 ;(set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
453 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
454 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
455 (add-hook 'eshell-preoutput-filter-functions
456 'ansi-color-filter-apply)
457 ;; Prompt with a bit of help from http://www.emacswiki.org/emacs/EshellPrompt
459 (defmacro with-face (str &rest properties)
460 `(propertize ,str 'face (list ,@properties)))
462 (defun eshell/abbr-pwd ()
463 (let ((home (getenv "HOME"))
466 ((string-equal home path) "~")
467 ((f-ancestor-of? home path) (concat "~/" (f-relative path home)))
470 (defun eshell/my-prompt ()
471 (let ((header-bg "#161616"))
473 (with-face user-login-name :foreground "cyan")
474 (with-face (concat "@" hostname) :foreground "white")
476 (with-face (eshell/abbr-pwd) :foreground "#009900")
478 (with-face "#" :foreground "red")
479 (with-face "$" :foreground "#69b7f0"))
482 (setq eshell-prompt-function 'eshell/my-prompt)
483 (setq eshell-highlight-prompt nil)
484 (setq eshell-prompt-regexp "^[^#$\n]+[#$] ")))
488 Incremental search is great, but annoyingly you need to type whatever
489 you want. If you want to search for just the next (or previous)
490 occurence of what is at your cursor position use the following.
491 *C-x* will insert the current word while *M-up* and *M-down* will just
492 jump to the next/previous occurence of it.
493 #+BEGIN_SRC emacs-lisp :tangle yes
494 (bind-key "C-x" 'sacha/isearch-yank-current-word isearch-mode-map)
495 (bind-key* "<M-up>" 'sacha/search-word-backward)
496 (bind-key* "<M-down>" 'sacha/search-word-forward)
499 *** Frame configuration
500 I want to see the buffername and its size, not the host I am on in my
502 #+BEGIN_SRC emacs-lisp :tangle yes
503 (setq frame-title-format "%b (%i)")
506 *** Protect some buffers
507 I don't want some buffers to be killed, **scratch** for example.
508 In the past I had a long function that just recreated them, but the
509 =keep-buffers= package is easier.
510 #+BEGIN_SRC emacs-lisp :tangle yes
511 (use-package keep-buffers
514 (keep-buffers-mode 1)
515 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
516 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
517 (push '("\\`*Group" . nil) keep-buffers-protected-alist)
522 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
524 #+BEGIN_SRC emacs-lisp :tangle yes
525 (defalias 'yes-or-no-p 'y-or-n-p)
528 *** Language/i18n stuff
529 In this day and age, UTF-8 is the way to go.
530 #+BEGIN_SRC emacs-lisp :tangle yes
531 (set-language-environment 'utf-8)
532 (set-default-coding-systems 'utf-8)
533 (set-terminal-coding-system 'utf-8)
534 (set-keyboard-coding-system 'utf-8)
535 (set-clipboard-coding-system 'utf-8)
536 (prefer-coding-system 'utf-8)
537 (set-charset-priority 'unicode)
538 (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
541 *** Hilight matching parentheses
542 While I do have the nifty shortcut to jump to the other parentheses,
543 hilighting them makes it obvious where they are.
544 #+BEGIN_SRC emacs-lisp :tangle yes
546 (use-package mic-paren
554 (setq show-paren-style 'parenthesis)
559 *** Kill other buffers
560 While many editors allow you to close "all the other files, not the one
561 you are in", emacs doesn't have this... Except, now it will.
562 (Update 30.05.2014: Not used ever, deactivated)
563 #+BEGIN_SRC emacs-lisp :tangle no
564 (bind-key "C-c k" 'prelude-kill-other-buffers)
567 Default scrolling behaviour in emacs is a bit annoying, who wants to
569 #+BEGIN_SRC emacs-lisp :tangle yes
570 (setq scroll-margin 0)
571 (setq scroll-conservatively 100000)
572 (setq scroll-up-aggressively 0.0)
573 (setq scroll-down-aggressively 0.0)
574 (setq scroll-preserve-screen-position t)
577 *** Copy/Paste with X
578 [2013-04-09 Di 23:31]
579 The default how emacs handles cutting/pasting with the primary selection
580 changed in emacs24. I am used to the old way, so get it back.
581 #+BEGIN_SRC emacs-lisp :tangle yes
582 (setq x-select-enable-primary t)
583 (setq x-select-enable-clipboard t ;; copy-paste should work ...
584 interprogram-paste-function ;; ...with...
585 'x-cut-buffer-or-selection-value) ;; ...other X clients
589 *** Global keyboard changes not directly related to a mode
590 Disable /suspend_frame/ function, I dislike it.
591 #+BEGIN_SRC emacs-lisp :tangle yes
593 (unbind-key "C-x C-z")
596 http://endlessparentheses.com/kill-entire-line-with-prefix-argument.html?source=rss
597 #+BEGIN_SRC emacs-lisp :tangle yes
598 (defmacro bol-with-prefix (function)
599 "Define a new function which calls FUNCTION.
600 Except it moves to beginning of line before calling FUNCTION when
601 called with a prefix argument. The FUNCTION still receives the
603 (let ((name (intern (format "endless/%s-BOL" function))))
607 "Call `%s', but move to BOL when called with a prefix argument."
612 (call-interactively ',function))
615 (global-set-key [remap paredit-kill] (bol-with-prefix paredit-kill))
616 (global-set-key [remap org-kill-line] (bol-with-prefix org-kill-line))
617 (global-set-key [remap kill-line] (bol-with-prefix kill-line))
620 Default of *C-k* is to kill from the point to the end of line. If
621 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
622 set, including newline. But to kill the entire line, one still needs a
623 *C-a* in front of it. So I change it, by defining a function to do just this for
625 #+BEGIN_SRC emacs-lisp :tangle no
626 (defun kill-entire-line ()
627 "Kill this entire line (including newline), regardless of where point is within the line."
631 (back-to-indentation))
633 (bind-key* "C-k" 'kill-entire-line)
634 (global-set-key [remap kill-whole-line] 'kill-entire-line)
637 And the same is true when I'm in org-mode, which has an own kill function...
638 (the keybinding happens later, after org-mode is loaded fully)
639 #+BEGIN_SRC emacs-lisp :tangle no
640 (defun jj-org-kill-line (&optional arg)
641 "Kill the entire line, regardless of where point is within the line, org-mode-version"
645 (back-to-indentation)
649 I really hate tabs, so I don't want any indentation to try using them.
650 And in case a project really needs them, I can change it just for that
651 file/project, but luckily none of those I work in is as broken.
652 #+BEGIN_SRC emacs-lisp :tangle yes
653 (setq-default indent-tabs-mode nil)
656 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
657 #+BEGIN_SRC emacs-lisp :tangle yes
658 (bind-key* "M-5" 'match-paren)
661 Instead of the default "mark-defun" I want a more readline-like setting.
662 #+BEGIN_SRC emacs-lisp :tangle yes
663 (bind-key "C-M-h" 'backward-kill-word)
666 Align whatever with a regexp.
667 #+BEGIN_SRC emacs-lisp :tangle yes
668 (bind-key "C-x \\" 'align-regexp)
672 #+BEGIN_SRC emacs-lisp :tangle yes
673 (bind-key "C-+" 'text-scale-increase)
674 (bind-key "C--" 'text-scale-decrease)
677 Regexes are too useful, so use the regex search by default.
678 #+begin_src emacs-lisp
679 (bind-key "C-s" 'isearch-forward-regexp)
680 (bind-key "C-r" 'isearch-backward-regexp)
681 (bind-key "C-M-s" 'isearch-forward)
682 (bind-key "C-M-r" 'isearch-backward)
685 Rgrep is infinitely useful in multi-file projects.
686 #+begin_src emacs-lisp
687 (bind-key "C-x C-g" 'rgrep)
690 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
692 #+BEGIN_SRC emacs-lisp :tangle yes
693 (bind-key "<M-S-up>" 'move-line-up)
694 (bind-key "<M-S-down>" 'move-line-down)
697 "Pull" lines up, join them
698 #+BEGIN_SRC emacs-lisp :tangle yes
699 (defun join-line-or-lines-in-region ()
700 "Join this line or the lines in the selected region.
701 Joins single lines in reverse order to the default, ie. pulls the next one up."
703 (cond ((region-active-p)
704 (let ((min (line-number-at-pos (region-beginning))))
705 (goto-char (region-end))
706 (while (> (line-number-at-pos) min)
708 (t (let ((current-prefix-arg '(4)))
709 (call-interactively 'join-line)))))
710 (bind-key "M-j" 'join-line-or-lines-in-region)
713 When I press Enter I almost always want to go to the right indentation on the next line.
714 #+BEGIN_SRC emacs-lisp :tangle yes
715 (bind-key "RET" 'newline-and-indent)
718 Easier undo, and i don't need suspend-frame
719 #+BEGIN_SRC emacs-lisp :tangle yes
720 (bind-key "C-z" 'undo)
723 Window switching, go backwards. (C-x o goes to the next window)
724 #+BEGIN_SRC emacs-lisp :tangle yes
725 (bind-key "C-x O" (lambda ()
731 #+BEGIN_SRC emacs-lisp :tangle yes
732 (bind-key "C-x C-r" 'prelude-sudo-edit)
735 M-space is bound to just-one-space, which is great for programming. What
736 it does is remove all spaces around the cursor, except for one. But to
737 be really useful, it also should include newlines. It doesn’t do this by
738 default. Rather, you have to call it with a negative argument. Sure
740 #+BEGIN_SRC emacs-lisp :tangle yes
741 (bind-key "M-SPC" 'just-one-space-with-newline)
744 Count which commands I use how often.
745 #+BEGIN_SRC emacs-lisp :tangle yes
750 (setq keyfreq-file (expand-file-name "keyfreq" jj-cache-dir))
751 (setq keyfreq-file-lock (expand-file-name "keyfreq.lock" jj-cache-dir))
753 (keyfreq-autosave-mode 1)))
756 Duplicate current line
757 #+BEGIN_SRC emacs-lisp :tangle yes
758 (defun duplicate-line ()
759 "Insert a copy of the current line after the current line."
762 (let ((line-text (buffer-substring-no-properties
763 (line-beginning-position)
764 (line-end-position))))
767 (insert line-text))))
769 (bind-key "C-c p" 'duplicate-line)
772 Smarter move to the beginning of the line. That is, it first moves to
773 the beginning of the line - and on second keypress it goes to the
774 first character on line.
775 #+BEGIN_SRC emacs-lisp :tangle yes
776 (defun smarter-move-beginning-of-line (arg)
777 "Move point back to indentation of beginning of line.
779 Move point to the first non-whitespace character on this line.
780 If point is already there, move to the beginning of the line.
781 Effectively toggle between the first non-whitespace character and
782 the beginning of the line.
784 If ARG is not nil or 1, move forward ARG - 1 lines first. If
785 point reaches the beginning or end of the buffer, stop there."
787 (setq arg (or arg 1))
791 (let ((line-move-visual nil))
792 (forward-line (1- arg))))
794 (let ((orig-point (point)))
795 (back-to-indentation)
796 (when (= orig-point (point))
797 (move-beginning-of-line 1))))
799 ;; remap C-a to `smarter-move-beginning-of-line'
800 (global-set-key [remap move-beginning-of-line]
801 'smarter-move-beginning-of-line)
805 Easily copy characters from the previous nonblank line, starting just
806 above point. With a prefix argument, only copy ARG characters (never
807 past EOL), no argument copies rest of line.
808 #+BEGIN_SRC emacs-lisp :tangle yes
810 (bind-key "H-y" 'copy-from-above-command)
813 Open a new X Terminal pointing to the directory of the current
815 #+BEGIN_SRC emacs-lisp :tangle yes
816 (bind-key "H-t" 'jj-open-shell)
820 #+BEGIN_SRC emacs-lisp :tangle yes
821 (bind-key "H-a" 'align-code)
825 #+BEGIN_SRC emacs-lisp :tangle yes
826 (bind-key "C-c d" 'insert-date)
829 Another key for indenting
830 #+BEGIN_SRC emacs-lisp :tangle yes
831 (bind-key "H-i" 'indent-region)
834 Clean all whitespace stuff
835 #+BEGIN_SRC emacs-lisp :tangle yes
836 (bind-key "H-w" 'whitespace-cleanup)
840 #+BEGIN_SRC emacs-lisp :tangle yes
841 (bind-key "H-c" 'comment-dwim)
844 Show keystrokes in progress
845 #+BEGIN_SRC emacs-lisp :tangle yes
846 (setq echo-keystrokes 0.1)
849 Usually you can press the *Ins*ert key, to get into overwrite mode. I
850 don't like that, have broken much with it and so just forbid it by
852 #+BEGIN_SRC emacs-lisp :tangle yes
853 (unbind-key "<insert>")
854 (unbind-key "<kp-insert>")
857 *** Easily navigate sillyCased words
858 #+BEGIN_SRC emacs-lisp :tangle yes
859 (global-subword-mode 1)
861 *** Delete file of current buffer, then kill buffer
862 [2014-06-14 Sat 23:03]
863 #+BEGIN_SRC emacs-lisp :tangle yes
864 (defun delete-current-buffer-file ()
865 "Removes file connected to current buffer and kills buffer."
867 (let ((filename (buffer-file-name))
868 (buffer (current-buffer))
869 (name (buffer-name)))
870 (if (not (and filename (file-exists-p filename)))
872 (when (yes-or-no-p "Are you sure you want to remove this file? ")
873 (delete-file filename)
875 (message "File '%s' successfully removed" filename)))))
877 (global-set-key (kbd "C-x C-k") 'delete-current-buffer-file)
879 *** Rename file of current buffer
880 [2014-06-14 Sat 23:04]
881 #+BEGIN_SRC emacs-lisp :tangle yes
882 (defun rename-current-buffer-file ()
883 "Renames current buffer and file it is visiting."
885 (let ((name (buffer-name))
886 (filename (buffer-file-name)))
887 (if (not (and filename (file-exists-p filename)))
888 (error "Buffer '%s' is not visiting a file!" name)
889 (let ((new-name (read-file-name "New name: " filename)))
890 (if (get-buffer new-name)
891 (error "A buffer named '%s' already exists!" new-name)
892 (rename-file filename new-name 1)
893 (rename-buffer new-name)
894 (set-visited-file-name new-name)
895 (set-buffer-modified-p nil)
896 (message "File '%s' successfully renamed to '%s'"
897 name (file-name-nondirectory new-name)))))))
899 (global-set-key (kbd "C-x C-S-r") 'rename-current-buffer-file)
901 *** Quickly find emacs lisp sources
902 [2014-06-22 Sun 23:05]
903 #+BEGIN_SRC emacs-lisp :tangle yes
904 (bind-key "C-l" 'find-library 'help-command)
905 (bind-key "C-f" 'find-function 'help-command)
906 (bind-key "C-k" 'find-function-on-key 'help-command)
907 (bind-key "C-v" 'find-variable 'help-command)
909 ** Miscellaneous stuff
911 Searches and matches should ignore case.
912 #+BEGIN_SRC emacs-lisp :tangle yes
913 (setq-default case-fold-search t)
916 Which buffers to get rid off at midnight.
917 #+BEGIN_SRC emacs-lisp :tangle yes
918 (setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
919 "*Man " "*Buffer List*"
925 "*magit" "*Calendar")))
928 Don't display a cursor in non-selected windows.
929 #+BEGIN_SRC emacs-lisp :tangle yes
930 (setq-default cursor-in-non-selected-windows nil)
933 What should be displayed in the mode-line for files with those types
935 #+BEGIN_SRC emacs-lisp :tangle yes
936 (setq eol-mnemonic-dos "(DOS)")
937 (setq eol-mnemonic-mac "(Mac)")
940 Much larger threshold for garbage collection prevents it to run too often.
941 #+BEGIN_SRC emacs-lisp :tangle yes
942 (setq gc-cons-threshold 48000000)
945 #+BEGIN_SRC emacs-lisp :tangle yes
946 (setq max-lisp-eval-depth 1000)
947 (setq max-specpdl-size 3000)
951 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
952 #+BEGIN_SRC emacs-lisp :tangle yes
953 (defun unfill-paragraph ()
954 "Takes a multi-line paragraph and makes it into a single line of text."
956 (let ((fill-column (point-max)))
957 (fill-paragraph nil)))
958 (bind-key "H-u" 'unfill-paragraph)
961 #+BEGIN_SRC emacs-lisp :tangle yes
962 (setq-default indicate-empty-lines t)
963 (setq sentence-end-double-space nil)
966 Hilight annotations in comments, like FIXME/TODO/...
967 #+BEGIN_SRC emacs-lisp :tangle yes
968 (add-hook 'prog-mode-hook 'font-lock-comment-annotations)
972 #+BEGIN_SRC emacs-lisp :tangle yes
973 (setq browse-url-browser-function (quote browse-url-generic))
974 (setq browse-url-generic-program "/usr/bin/x-www-browser")
977 *** When saving a script - make it executable
978 #+BEGIN_SRC emacs-lisp :tangle yes
979 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
983 #+BEGIN_SRC emacs-lisp :tangle yes
987 (add-hook 'after-init-hook 'server-start)))
990 ** Customized variables
991 [2013-05-02 Thu 22:14]
992 The following contains a set of variables i may reasonably want to
993 change on other systems - which don't affect the init file loading
994 process. So I *can* use the customization interface for it...
995 #+BEGIN_SRC emacs-lisp :tangle yes
996 (defgroup ganneff nil
997 "Modify ganneffs settings"
1000 (defgroup ganneff-org-mode nil
1001 "Ganneffs org-mode settings"
1002 :tag "Ganneffs org-mode settings"
1004 :link '(custom-group-link "ganneff"))
1006 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
1007 "ID of the organization task."
1008 :tag "Organization Task ID"
1010 :group 'ganneff-org-mode)
1012 (defcustom org-my-archive-expiry-days 2
1013 "The number of days after which a completed task should be auto-archived.
1014 This can be 0 for immediate, or a floating point value."
1015 :tag "Archive expiry days"
1017 :group 'ganneff-org-mode)
1022 [2013-05-21 Tue 23:22]
1023 Restore removed var alias, used by ruby-electric-brace and others
1024 #+BEGIN_SRC emacs-lisp :tangle yes
1025 (unless (boundp 'last-command-char)
1026 (defvaralias 'last-command-char 'last-command-event))
1028 * Customized variables
1030 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
1032 Of course I want to be able to use the customize interface, and some
1033 things can only be set via it (or so they say). I usually prefer to put
1034 things I keep for a long while into statements somewhere else, not just
1035 custom-set here, but we need it anyways.
1037 #+BEGIN_SRC emacs-lisp :tangle yes
1038 (setq custom-file jj-custom-file)
1039 (safe-load custom-file)
1042 The source of this is:
1043 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
1046 * Extra modes and their configuration
1048 A defined abbrev is a word which expands, if you insert it, into some
1049 different text. Abbrevs are defined by the user to expand in specific
1051 #+BEGIN_SRC emacs-lisp :tangle yes
1053 :commands abbrev-mode
1054 :diminish abbrev-mode
1056 (hook-into-modes #'abbrev-mode '(text-mode-hook))
1059 (setq save-abbrevs 'silently)
1060 (setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
1061 (if (file-exists-p abbrev-file-name)
1062 (quietly-read-abbrev-file))
1064 (add-hook 'expand-load-hook
1066 (add-hook 'expand-expand-hook 'indent-according-to-mode)
1067 (add-hook 'expand-jump-hook 'indent-according-to-mode)))))
1070 [2013-04-28 So 11:26]
1071 Quickly move around in buffers.
1072 #+BEGIN_SRC emacs-lisp :tangle yes
1073 (use-package ace-jump-mode
1074 :ensure ace-jump-mode
1075 :commands ace-jump-mode
1076 :bind ("H-SPC" . ace-jump-mode))
1079 [2013-04-21 So 20:27]
1080 Use H-w to switch windows
1081 #+BEGIN_SRC emacs-lisp :tangle yes
1082 (use-package ace-window
1084 :commands ace-window
1085 :bind ("H-w" . ace-window))
1087 ** aggressive-indent
1088 [2014-10-27 Mon 13:08]
1089 electric-indent-mode is enough to keep your code nicely aligned when
1090 all you do is type. However, once you start shifting blocks around,
1091 transposing lines, or slurping and barfing sexps, indentation is bound
1094 aggressive-indent-mode is a minor mode that keeps your code always
1095 indented. It reindents after every command, making it more reliable
1096 than electric-indent-mode.
1097 #+BEGIN_SRC emacs-lisp :tangle yes
1098 (use-package aggressive-indent
1099 :ensure aggressive-indent
1102 (global-aggressive-indent-mode 1)
1103 (setq aggressive-indent-comments-too 1)
1104 (add-to-list 'aggressive-indent-excluded-modes 'html-mode)
1108 [2014-06-01 Sun 23:02]
1109 #+BEGIN_SRC emacs-lisp :tangle yes
1115 (global-anzu-mode 1))
1118 (setq anzu-search-threshold 1000)
1119 (set-face-attribute 'anzu-mode-line nil :foreground "yellow" :weight 'bold)))
1122 [2014-05-21 Wed 00:33]
1123 #+BEGIN_SRC emacs-lisp :tangle yes
1125 :commands (ascii-on ascii-display ascii-toggle)
1128 (defun ascii-toggle ()
1134 (bind-key "C-c e A" 'ascii-toggle)))
1137 #+BEGIN_SRC emacs-lisp :tangle yes
1138 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
1139 (setq TeX-auto-save t)
1140 (setq TeX-parse-self t)
1141 (setq TeX-PDF-mode t)
1143 ** auto-complete mode
1144 [2013-04-27 Sa 16:33]
1145 And aren't we all lazy? I definitely am, and I like my emacs doing as
1146 much possible work for me as it can.
1147 So here, auto-complete-mode, which lets emacs do this, based on what I
1149 #+BEGIN_SRC emacs-lisp :tangle yes
1150 (use-package auto-complete-config
1151 :ensure auto-complete
1154 (use-package pos-tip
1160 ;; hook AC into completion-at-point
1161 (defun sanityinc/auto-complete-at-point ()
1162 (when (and (not (minibufferp))
1163 (fboundp 'auto-complete-mode)
1166 (defun set-auto-complete-as-completion-at-point-function ()
1167 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
1168 ;; Exclude very large buffers from dabbrev
1169 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
1170 (< (buffer-size other-buffer) (* 1 1024 1024)))
1172 ;; custom keybindings to use tab, enter and up and down arrows
1173 (bind-key "\t" 'ac-expand ac-complete-mode-map)
1174 (bind-key "\r" 'ac-complete ac-complete-mode-map)
1175 (bind-key "M-n" 'ac-next ac-complete-mode-map)
1176 (bind-key "M-p" 'ac-previous ac-complete-mode-map)
1177 (bind-key "C-s" 'ac-isearch ac-completing-map)
1178 (bind-key "M-TAB" 'auto-complete ac-mode-map)
1180 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
1181 (setq ac-use-comphist t)
1182 (setq ac-expand-on-auto-complete nil)
1184 (setq ac-auto-start 3)
1186 (setq ac-menu-height 15)
1187 (setq ac-quick-help-delay 0.5)
1188 (setq ac-use-fuzzy t)
1190 (ac-flyspell-workaround)
1192 ;; use 't when auto-complete is disabled
1193 (setq tab-always-indent 'complete)
1194 (add-to-list 'completion-styles 'initials t)
1196 ;; Use space and punctuation to accept the current the most likely completion.
1197 (setq auto-completion-syntax-alist (quote (global accept . word)))
1198 ;; Avoid completion for short trivial words.
1199 (setq auto-completion-min-chars (quote (global . 3)))
1200 (setq completion-use-dynamic t)
1202 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
1204 ;; Exclude very large buffers from dabbrev
1205 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
1207 (use-package ac-dabbrev
1210 (set-default 'ac-sources
1212 ac-source-dictionary
1213 ac-source-words-in-buffer
1214 ac-source-words-in-same-mode-buffers
1215 ; ac-source-words-in-all-buffer
1218 (dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
1219 sass-mode yaml-mode csv-mode espresso-mode haskell-mode
1220 html-mode nxml-mode sh-mode smarty-mode clojure-mode
1221 lisp-mode textile-mode markdown-mode tuareg-mode python-mode
1222 js3-mode css-mode less-css-mode sql-mode ielm-mode))
1223 (add-to-list 'ac-modes mode))
1225 (add-hook 'latex-mode-hook 'auto-complete-mode)
1226 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
1227 (add-hook 'prog-mode-hook 'auto-complete-mode)
1228 (add-hook 'org-mode-hook 'auto-complete-mode)))
1233 When files change outside emacs for whatever reason I want emacs to deal
1234 with it. Not to have to revert buffers myself
1235 #+BEGIN_SRC emacs-lisp :tangle yes
1236 (use-package autorevert
1237 :commands auto-revert-mode
1238 :diminish auto-revert-mode
1241 (setq global-auto-revert-mode t)
1242 (setq global-auto-revert-non-file-buffers t)
1243 (global-auto-revert-mode)))
1247 Emacs should keep backup copies of files I edit, but I do not want them
1248 to clutter up the filesystem everywhere. So I put them into one defined
1249 place, backup-directory, which even contains my username (for systems
1250 where =temporary-file-directory= is not inside my home).
1251 #+BEGIN_SRC emacs-lisp :tangle yes
1252 (use-package backups-mode
1253 :load-path "elisp/backups-mode"
1254 :bind (("\C-cv" . save-version)
1255 ("\C-cb" . list-backups)
1256 ("\C-ck" . kill-buffer-prompt)
1257 ("\C-cw" . backup-walker-start))
1260 (setq backup-directory jj-backup-directory)
1261 ;(setq tramp-backup-directory (concat jj-backup-directory "/tramp"))
1262 ;(if (not (file-exists-p tramp-backup-directory))
1263 ; (make-directory tramp-backup-directory))
1264 ;(setq tramp-backup-directory-alist `((".*" . ,tramp-backup-directory)))
1265 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
1266 (setq auto-save-list-file-prefix (concat jj-backup-directory ".auto-saves-"))
1267 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
1269 (setq version-control t) ;; Use version numbers for backups
1270 (setq kept-new-versions 10) ;; Number of newest versions to keep
1271 (setq kept-old-versions 2) ;; Number of oldest versions to keep
1272 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
1273 (setq backup-by-copying t)
1274 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
1275 (setq make-backup-files t)
1277 (defadvice kill-buffer (around kill-buffer)
1278 "Always save before killing a file buffer"
1279 (when (and (buffer-modified-p)
1281 (file-exists-p (buffer-file-name)))
1284 (ad-activate 'kill-buffer)
1286 (defadvice save-buffers-kill-emacs (around save-buffers-kill-emacs)
1287 "Always save before killing emacs"
1288 (save-some-buffers t)
1290 (ad-activate 'save-buffers-kill-emacs)
1292 (defun kill-buffer-prompt ()
1293 "Allows one to kill a buffer without saving it.
1294 This is necessary since once you start backups-mode all file based buffers
1295 are saved automatically when they are killed"
1297 (if (and (buffer-modified-p) (buffer-file-name) (file-exists-p (buffer-file-name)) (y-or-n-p "Save buffer?"))
1299 (set-buffer-modified-p nil))
1302 (setq backup-enable-predicate
1304 (and (normal-backup-enable-predicate name)
1306 (let ((method (file-remote-p name 'method)))
1307 (when (stringp method)
1308 (member method '("su" "sudo"))))))))))
1312 [2014-06-10 Tue 22:20]
1313 #+BEGIN_SRC emacs-lisp :tangle yes
1315 :commands (cal/insert)
1316 :bind ("C-c c" . cal/insert))
1319 Weeks start on Monday, not sunday.
1320 #+BEGIN_SRC emacs-lisp :tangle yes
1321 (setq calendar-week-start-day 1)
1324 Display ISO week numbers in Calendar Mode
1325 #+BEGIN_SRC emacs-lisp :tangle yes
1326 (copy-face font-lock-constant-face 'calendar-iso-week-face)
1327 (set-face-attribute 'calendar-iso-week-face nil
1329 (setq calendar-intermonth-text
1333 (calendar-iso-from-absolute
1334 (calendar-absolute-from-gregorian (list month day year)))))
1335 'font-lock-face 'calendar-iso-week-face))
1336 (copy-face 'default 'calendar-iso-week-header-face)
1337 (set-face-attribute 'calendar-iso-week-header-face nil
1339 (setq calendar-intermonth-header
1340 (propertize "Wk" ; or e.g. "KW" in Germany
1341 'font-lock-face 'calendar-iso-week-header-face))
1345 [2013-05-21 Tue 23:18]
1346 #+BEGIN_SRC emacs-lisp :tangle yes
1347 (use-package crontab-mode
1348 :ensure crontab-mode
1349 :commands crontab-mode
1350 :mode ("\\.?cron\\(tab\\)?\\'" . crontab-mode))
1354 web-mode takes over, see [[*web-mode][web-mode]]
1355 #+BEGIN_SRC emacs-lisp :tangle no
1356 (use-package css-mode
1357 :mode ("\\.css\\'" . css-mode)
1362 (use-package flymake-css
1366 (defun maybe-flymake-css-load ()
1367 "Activate flymake-css as necessary, but not in derived modes."
1368 (when (eq major-mode 'css-mode)
1369 (flymake-css-load)))
1370 (add-hook 'css-mode-hook 'maybe-flymake-css-load)))
1371 ;;; Auto-complete CSS keywords
1372 (eval-after-load 'auto-complete
1374 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
1375 (add-hook hook 'ac-css-mode-setup))))))
1379 I know that this lets it look "more like windows", but I don't much care
1380 about its paste/copy/cut keybindings, the really nice part is the great
1381 support for rectangular regions, which I started to use a lot since I
1382 know this mode. The normal keybindings for those are just to useless.
1383 #+BEGIN_SRC emacs-lisp :tangle yes
1385 (setq cua-enable-cua-keys (quote shift))
1388 Luckily cua-mode easily supports this, with the following line I just
1389 get the CUA selection and rectangle stuff, not the keybindings. Yes,
1390 even though the above =cua-enable-cua-keys= setting would only enable
1391 them if the selection is done when the region was marked with a shifted
1393 #+BEGIN_SRC emacs-lisp :tangle yes
1394 (cua-selection-mode t)
1398 #+BEGIN_SRC emacs-lisp :tangle yes
1399 (require 'dpkg-dev-el-loaddefs nil 'noerror)
1400 (require 'debian-el-loaddefs nil 'noerror)
1402 (setq debian-changelog-full-name "Joerg Jaspert")
1403 (setq debian-changelog-mailing-address "joerg@debian.org")
1407 #+BEGIN_SRC emacs-lisp :tangle yes
1408 (use-package diff-mode
1410 :mode (("\\.diff" . diff-mode))
1412 (use-package diff-mode-))
1417 I like dired and work a lot with it, but it tends to leave lots of
1419 dired-single to the rescue.
1420 #+BEGIN_SRC emacs-lisp :tangle yes
1422 :commands (dired dired-other-window dired-other-frame dired-noselect
1423 dired-mode dired-jump)
1428 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
1429 (setq dired-dwim-target t)
1430 (setq dired-listing-switches "-alh")
1431 (setq dired-recursive-copies (quote top))
1432 (setq dired-recursive-deletes (quote top))
1434 (defvar mark-files-cache (make-hash-table :test #'equal))
1436 (defun mark-similar-versions (name)
1438 (if (string-match "^\\(.+?\\)-[0-9._-]+$" pat)
1439 (setq pat (match-string 1 pat)))
1440 (or (gethash pat mark-files-cache)
1441 (ignore (puthash pat t mark-files-cache)))))
1443 (defun dired-mark-similar-version ()
1445 (setq mark-files-cache (make-hash-table :test #'equal))
1446 (dired-mark-sexp '(mark-similar-versions name)))
1451 :pre-load (setq diredp-hide-details-initially-flag nil))
1453 (use-package dired-single
1454 :ensure dired-single
1457 (bind-key "<return>" 'dired-single-buffer dired-mode-map)
1458 (bind-key "<mouse-1>" 'dired-single-buffer-mouse dired-mode-map)
1461 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
1467 (setq wdired-allow-to-change-permissions t)
1468 (bind-key "r" 'wdired-change-to-wdired-mode dired-mode-map)))
1470 (use-package gnus-dired
1471 :commands (gnus-dired-attach gnus-dired-mode)
1474 ;;(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
1475 (bind-key "a" 'gnus-dired-attach dired-mode-map)))
1477 (defun dired-package-initialize ()
1478 (unless (featurep 'runner)
1479 (use-package dired-x)
1483 (bind-key "M-!" 'async-shell-command dired-mode-map)
1484 (unbind-key "M-s f" dired-mode-map)
1486 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1487 "Make sure to remove \"Omit\" from the modeline."
1488 (diminish 'dired-omit-mode) dired-mode-map)
1490 ;; Omit files that Git would ignore
1491 (defun dired-omit-regexp ()
1492 (let ((file (expand-file-name ".git"))
1494 (while (and (not (file-exists-p file))
1497 (file-name-directory
1498 (directory-file-name
1499 (file-name-directory file))))
1500 ;; Give up if we are already at the root dir.
1501 (not (string= (file-name-directory file)
1503 ;; Move up to the parent dir and try again.
1504 (setq file (expand-file-name ".git" parent-dir)))
1505 ;; If we found a change log in a parent, use that.
1506 (if (file-exists-p file)
1507 (let ((regexp (funcall dired-omit-regexp-orig))
1509 (shell-command-to-string "git clean -d -x -n")))
1510 (if (= 0 (length omitted-files))
1514 (if (> (length regexp) 0)
1523 (if (= ?/ (aref str (1- (length str))))
1527 (split-string omitted-files "\n" t)
1530 (funcall dired-omit-regexp-orig))))))
1532 (add-hook 'dired-mode-hook 'dired-package-initialize)
1534 (defun dired-double-jump (first-dir second-dir)
1536 (list (read-directory-name "First directory: "
1537 (expand-file-name "~")
1538 nil nil "/Downloads/")
1539 (read-directory-name "Second directory: "
1540 (expand-file-name "~")
1543 (dired-other-window second-dir))
1544 (bind-key "C-c J" 'dired-double-jump)
1546 (defun dired-back-to-top ()
1548 (beginning-of-buffer)
1549 (dired-next-line 4))
1551 (define-key dired-mode-map
1552 (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
1554 (defun dired-jump-to-bottom ()
1557 (dired-next-line -1))
1559 (define-key dired-mode-map
1560 (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)))
1563 ** discover-my-major
1564 [2014-06-01 Sun 23:32]
1565 Discover key bindings and their meaning for the current Emacs major mode.
1566 #+BEGIN_SRC emacs-lisp :tangle yes
1567 (use-package discover-my-major
1568 :ensure discover-my-major
1569 :bind ("C-h C-m" . discover-my-major))
1572 EasyPG is a GnuPG interface for Emacs.
1573 Bookmark: [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1574 #+BEGIN_SRC emacs-lisp :tangle yes
1575 (use-package epa-file
1579 ;; I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1580 (defadvice epg--start (around advice-epg-disable-agent disable)
1581 "Don't allow epg--start to use gpg-agent in plain text
1583 (if (display-graphic-p)
1585 (let ((agent (getenv "GPG_AGENT_INFO")))
1586 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
1588 (setenv "GPG_AGENT_INFO" agent))))
1589 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
1590 (ad-activate 'epg--start)
1594 [2013-04-21 So 20:36]
1595 ediff - don't start another frame
1596 #+BEGIN_SRC emacs-lisp :tangle yes
1600 (defvar ctl-period-equals-map)
1601 (define-prefix-command 'ctl-period-equals-map)
1602 (bind-key "C-. =" 'ctl-period-equals-map)
1604 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
1606 :bind (("C-. = b" . ediff-buffers)
1607 ("C-. = B" . ediff-buffers3)
1608 ("C-. = =" . ediff-files)
1609 ("C-. = f" . ediff-files)
1610 ("C-. = F" . ediff-files3)
1611 ("C-. = r" . ediff-revision)
1612 ("C-. = p" . ediff-patch-file)
1613 ("C-. = P" . ediff-patch-buffer)
1614 ("C-. = l" . ediff-regions-linewise)
1615 ("C-. = w" . ediff-regions-wordwise)))
1618 EMMS is the Emacs Multimedia System.
1619 #+BEGIN_SRC emacs-lisp :tangle no
1620 (require 'emms-source-file)
1621 (require 'emms-source-playlist)
1622 (require 'emms-info)
1623 (require 'emms-cache)
1624 (require 'emms-playlist-mode)
1625 (require 'emms-playing-time)
1626 (require 'emms-player-mpd)
1627 (require 'emms-playlist-sort)
1628 (require 'emms-mark)
1629 (require 'emms-browser)
1630 (require 'emms-lyrics)
1631 (require 'emms-last-played)
1632 (require 'emms-score)
1633 (require 'emms-tag-editor)
1634 (require 'emms-history)
1635 (require 'emms-i18n)
1637 (setq emms-playlist-default-major-mode 'emms-playlist-mode)
1638 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
1639 (emms-playing-time 1)
1641 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
1642 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
1644 (when (fboundp 'emms-cache) ; work around compiler warning
1646 (setq emms-score-default-score 3)
1648 (defun emms-mpd-init ()
1649 "Connect Emms to mpd."
1651 (emms-player-mpd-connect))
1654 (require 'emms-player-mpd)
1655 (setq emms-player-mpd-server-name "localhost")
1656 (setq emms-player-mpd-server-port "6600")
1657 (add-to-list 'emms-info-functions 'emms-info-mpd)
1658 (add-to-list 'emms-player-list 'emms-player-mpd)
1659 (setq emms-volume-change-function 'emms-volume-mpd-change)
1660 (setq emms-player-mpd-sync-playlist t)
1662 (setq emms-source-file-default-directory "/var/lib/mpd/music")
1663 (setq emms-player-mpd-music-directory "/var/lib/mpd/music")
1664 (setq emms-info-auto-update t)
1665 (setq emms-lyrics-scroll-p t)
1666 (setq emms-lyrics-display-on-minibuffer t)
1667 (setq emms-lyrics-display-on-modeline nil)
1668 (setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
1670 (setq emms-last-played-format-alist
1671 '(((emms-last-played-seconds-today) . "%H:%M")
1672 (604800 . "%a %H:%M") ; this week
1673 ((emms-last-played-seconds-month) . "%d.%m.%Y")
1674 ((emms-last-played-seconds-year) . "%d.%m.%Y")
1675 (t . "Never played")))
1678 (defun my-describe (track)
1679 (let* ((empty "...")
1680 (name (emms-track-name track))
1681 (type (emms-track-type track))
1682 (short-name (file-name-nondirectory name))
1683 (play-count (or (emms-track-get track 'play-count) 0))
1684 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
1685 (artist (or (emms-track-get track 'info-artist) empty))
1686 (year (emms-track-get track 'info-year))
1687 (playing-time (or (emms-track-get track 'info-playing-time) 0))
1688 (min (/ playing-time 60))
1689 (sec (% playing-time 60))
1690 (album (or (emms-track-get track 'info-album) empty))
1691 (tracknumber (emms-track-get track 'info-tracknumber))
1692 (short-name (file-name-sans-extension
1693 (file-name-nondirectory name)))
1694 (title (or (emms-track-get track 'info-title) short-name))
1695 (rating (emms-score-get-score name))
1698 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
1699 (emms-last-played-format-date last-played)
1703 (if (and tracknumber ; tracknumber
1704 (not (zerop (string-to-number tracknumber))))
1705 (format "%02d" (string-to-number tracknumber))
1709 (make-string rating rate-char)))
1712 (setq emms-track-description-function 'my-describe)
1714 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
1715 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
1716 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
1717 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
1718 (global-set-key (kbd "H-<f9> x") 'emms-start)
1719 (global-set-key (kbd "H-<f9> v") 'emms-stop)
1720 (global-set-key (kbd "H-<f9> n") 'emms-next)
1721 (global-set-key (kbd "H-<f9> p") 'emms-previous)
1722 (global-set-key (kbd "H-<f9> o") 'emms-show)
1723 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
1724 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
1725 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
1726 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
1727 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
1729 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
1730 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
1731 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
1732 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
1734 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
1735 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
1736 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
1737 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
1739 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
1740 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
1741 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
1742 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
1744 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
1745 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
1746 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
1747 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
1748 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
1749 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
1751 (define-key emms-playlist-mode-map "x" 'emms-start)
1752 (define-key emms-playlist-mode-map "v" 'emms-stop)
1753 (define-key emms-playlist-mode-map "n" 'emms-next)
1754 (define-key emms-playlist-mode-map "p" 'emms-previous)
1756 (setq emms-playlist-buffer-name "*EMMS Playlist*"
1757 emms-playlist-mode-open-playlists t)
1763 'emms-browser-artist-face nil
1768 (setq emms-player-mpd-supported-regexp
1769 (or (emms-player-mpd-get-supported-regexp)
1770 (concat "\\`http://\\|"
1771 (emms-player-simple-regexp
1772 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
1773 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
1777 [2014-06-01 Sun 15:00]
1778 Proper whitespace handling
1779 #+BEGIN_SRC emacs-lisp :tangle yes
1780 (use-package ethan-wspace
1781 :ensure ethan-wspace
1782 :diminish (ethan-wspace-mode . "ew")
1784 (global-ethan-wspace-mode 1))
1788 [2014-06-01 Sun 15:16]
1789 #+BEGIN_SRC emacs-lisp :tangle yes
1790 (use-package expand-region
1791 :ensure expand-region
1792 :bind ("C-M-+" . er/expand-region))
1795 [2013-05-02 Thu 00:04]
1796 Filladapt by KyleJones enhances Emacs’ fill functions by guessing a
1797 fill prefix, such as a comment sequence in program code, and handling
1798 bullet points like “1.” or “*”.
1799 #+BEGIN_SRC emacs-lisp :tangle yes
1800 (use-package filladapt
1801 :diminish filladapt-mode
1803 (setq-default filladapt-mode t))
1806 [2013-04-28 So 22:21]
1807 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
1808 As the one time I tried Flymake i wasn't happy, thats easy to
1810 #+BEGIN_SRC emacs-lisp :tangle yes
1811 (use-package flycheck
1813 :diminish flycheck-mode
1814 :bind (("M-n" . next-error)
1815 ("M-p" . previous-error))
1818 (add-hook 'find-file-hook
1820 (when (not (equal 'emacs-lisp-mode major-mode))
1824 (use-package flycheck-color-mode-line
1825 :ensure flycheck-color-mode-line)
1826 (setq flycheck-highlighting-mode nil)
1827 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
1831 Obviously emacs can do syntax hilighting. For more things than you ever
1833 And I want to have it everywhere.
1834 #+BEGIN_SRC emacs-lisp :tangle yes
1835 (use-package font-lock
1838 (global-font-lock-mode 1)
1839 (setq font-lock-maximum-decoration t)))
1842 #+BEGIN_SRC emacs-lisp :tangle yes
1843 (use-package git-commit-mode
1844 :ensure git-commit-mode
1845 :commands git-commit-mode
1846 :mode ("COMMIT_EDITMSG" . git-commit-mode))
1850 #+BEGIN_SRC emacs-lisp :tangle yes
1851 (use-package git-rebase-mode
1852 :ensure git-rebase-mode
1853 :commands git-rebase-mode
1854 :mode ("git-rebase-todo" . git-rebase-mode))
1857 [2014-05-21 Wed 22:56]
1858 #+BEGIN_SRC emacs-lisp :tangle yes
1859 (use-package git-gutter+
1861 :diminish git-gutter+-mode
1862 :bind (("C-x n" . git-gutter+-next-hunk)
1863 ("C-x p" . git-gutter+-previous-hunk)
1864 ("C-x v =" . git-gutter+-show-hunk)
1865 ("C-x r" . git-gutter+-revert-hunks)
1866 ("C-x s" . git-gutter+-stage-hunks)
1867 ("C-x c" . git-gutter+-commit)
1871 (setq git-gutter+-disabled-modes '(org-mode))
1872 (global-git-gutter+-mode 1))
1875 (use-package git-gutter-fringe+
1876 :ensure git-gutter-fringe+
1879 (setq git-gutter-fr+-side 'right-fringe)
1880 ;(git-gutter-fr+-minimal)
1885 [2014-07-23 Mi 12:57]
1886 Browse historic versions of a file with p (previous) and n (next).
1887 #+BEGIN_SRC emacs-lisp :tangle yes
1888 (use-package git-timemachine
1889 :ensure git-timemachine)
1892 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
1893 what I want every emacs to know.
1894 #+BEGIN_SRC emacs-lisp :tangle yes
1895 (bind-key "C-c g" 'gnus) ; Start gnus with M-n
1901 [2014-06-11 Wed 22:27]
1902 guide-key.el displays the available key bindings automatically and
1905 For whatever reason I like this more than icicles <backtab> completion
1907 #+BEGIN_SRC emacs-lisp :tangle yes
1908 (use-package guide-key
1910 :diminish guide-key-mode
1913 (setq guide-key/guide-key-sequence '("C-x" "C-c"))
1915 (setq guide-key/recursive-key-sequence-flag t)
1916 (setq guide-key/popup-window-position 'bottom)
1917 (setq guide-key/idle-delay 0.5)))
1922 [2014-05-21 Wed 23:51]
1923 #+BEGIN_SRC emacs-lisp :tangle yes
1924 (use-package hi-lock
1925 :bind (("M-o l" . highlight-lines-matching-regexp)
1926 ("M-o r" . highlight-regexp)
1927 ("M-o w" . highlight-phrase)))
1929 (use-package hilit-chg
1930 :bind ("M-o C" . highlight-changes-mode))
1934 Crazy way of completion. It looks at the word before point and then
1935 tries to expand it in various ways.
1936 #+BEGIN_SRC emacs-lisp :tangle yes
1937 (use-package hippie-exp
1938 :bind ("M-/" . hippie-expand)
1941 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
1942 try-expand-dabbrev-all-buffers
1943 try-expand-dabbrev-from-kill
1944 try-complete-file-name-partially
1945 try-complete-file-name
1946 try-expand-all-abbrevs try-expand-list
1948 try-complete-lisp-symbol-partially
1949 try-complete-lisp-symbol))))
1952 Replaced by web-mode [[*web-mode][web-mode]]
1953 #+BEGIN_SRC emacs-lisp :tangle no
1954 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
1955 (add-auto-mode 'html-helper-mode "\\.html$")
1956 (add-auto-mode 'html-helper-mode "\\.asp$")
1957 (add-auto-mode 'html-helper-mode "\\.phtml$")
1958 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
1959 (defalias 'html-mode 'html-helper-mode)
1963 [2014-05-21 Wed 23:54]
1964 #+BEGIN_SRC emacs-lisp :tangle yes
1965 (use-package ibuffer
1967 :bind (("C-h h" . ibuffer)
1968 ("C-x C-b" . ibuffer)
1969 ("<XF86WebCam>" . ibuffer)
1974 (use-package ibuffer-vc
1977 (ibuffer-vc-set-filter-groups-by-vc-root
1978 ibuffer-vc-generate-filter-groups-by-vc-root))
1979 (use-package ibuffer-tramp
1981 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
1982 ibuffer-tramp-set-filter-groups-by-tramp-connection))
1983 ;; Switching to ibuffer puts the cursor on the most recent buffer
1984 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
1985 "Open ibuffer with cursor pointed to most recent buffer name"
1986 (let ((recent-buffer-name (buffer-name)))
1988 (ibuffer-update nil t)
1989 (unless (string= recent-buffer-name "*Ibuffer*")
1990 (ibuffer-jump-to-buffer recent-buffer-name)))))
1993 (defvar my-ibufffer-separator " • ")
1994 (setq ibuffer-filter-group-name-face 'variable-pitch
1995 ibuffer-use-header-line t
1996 ibuffer-old-time 12)
1997 (unbind-key "M-o" ibuffer-mode-map)
1998 (bind-key "s" 'isearch-forward-regexp ibuffer-mode-map)
1999 (bind-key "." 'ibuffer-invert-sorting ibuffer-mode-map)
2001 (defun ibuffer-magit-status ()
2003 (--when-let (get-buffer "*Ibuffer*")
2004 (with-current-buffer it
2005 (let* ((selected-buffer (ibuffer-current-buffer))
2006 (buffer-path (with-current-buffer
2008 (or (buffer-file-name)
2009 list-buffers-directory
2010 default-directory)))
2012 (if (file-regular-p buffer-path)
2013 (file-name-directory buffer-path)
2015 (magit-status default-directory)))))
2016 (bind-key "i" 'ibuffer-magit-status ibuffer-mode-map)
2017 (bind-key "G" 'ibuffer-magit-status ibuffer-mode-map)
2019 (setq ibuffer-directory-abbrev-alist
2024 (cons (f-slash (f-expand (cdr it))) my-ibufffer-separator)
2025 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
2027 ("dak" . "/develop/dak/")
2029 ("config" . "~/.emacs.d/config/")
2031 ("systmp" . "/tmp/")
2032 ("puppet" . "~/git/puppet")
2036 (use-package ibuffer-git
2038 (use-package ibuffer-vc
2041 (define-ibuffer-column size-h
2042 (:name "Size" :inline t)
2044 ((> (buffer-size) 1000)
2045 (format "%7.1fk" (/ (buffer-size) 1000.0)))
2046 ((> (buffer-size) 1000000)
2047 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
2049 (format "%8d" (buffer-size)))))
2051 (use-package ibuf-ext)
2052 (define-ibuffer-filter filename2
2053 "Toggle current view to buffers with filename matching QUALIFIER."
2054 (:description "filename2"
2055 :reader (read-from-minibuffer "Filter by filename (regexp): "))
2056 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
2057 (ibuffer-awhen (with-current-buffer buf
2058 (or buffer-file-name
2060 (string-match qualifier it)))
2062 (defvar ibuffer-magit-filter-groups nil)
2063 (defun ibuffer-magit-define-filter-groups ()
2064 (when (and (not ibuffer-magit-filter-groups)
2065 (boundp 'magit-repo-dirs))
2066 (setq ibuffer-magit-filter-groups
2069 (file-name-nondirectory (directory-file-name it)))
2071 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
2073 (defun ibuffer-set-filter-groups-by-root ()
2075 ;; (ibuffer-projectile-define-filter-groups)
2076 ;; (ibuffer-magit-define-filter-groups)
2077 (setq ibuffer-filter-groups
2079 ;; ibuffer-projectile-filter-groups
2080 ibuffer-magit-filter-groups
2083 (or (mode . magit-log-edit-mode)
2084 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2085 (name . "^\\*Pymacs\\*$")
2086 (name . "^\\*helm.*\\*")
2087 (name . "^\\*Compile-log\\*$")
2088 (name . "^\\*Ido Completions\\*$")
2089 (name . "^\\*magit-\\(process\\)\\*$")
2093 (name . "^\\*scratch")
2094 (name . "^\\*Messages")
2097 (ibuffer-vc-generate-filter-groups-by-vc-root)
2098 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
2100 (defun toggle-ibuffer-filter-groups ()
2103 (let ((ibuf (get-buffer "*Ibuffer*")))
2105 (with-current-buffer ibuf
2106 (let ((selected-buffer (ibuffer-current-buffer)))
2107 (if (not ibuffer-filter-groups)
2108 (ibuffer-set-filter-groups-by-root)
2109 (setq ibuffer-filter-groups nil))
2110 (pop-to-buffer ibuf)
2111 (ibuffer-update nil t)
2112 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
2114 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
2116 (setq ibuffer-default-sorting-mode 'recency
2117 ibuffer-eliding-string "…"
2118 ibuffer-compile-formats t
2119 ibuffer-git-column-length 6
2120 ibuffer-show-empty-filter-groups nil
2121 ibuffer-default-directory "~/"
2123 (setq ibuffer-formats '((mark vc-status-mini
2125 (git-status 8 8 :left)
2129 (name 18 18 :left :elide)
2131 (size-h 9 -1 :right)
2133 (mode 16 16 :left :elide)
2134 " " filename-and-process)
2136 (git-status 8 8 :left)
2142 (setq ibuffer-saved-filter-groups
2145 ("dired" (mode . dired-mode))
2146 ("perl" (mode . cperl-mode))
2148 (mode . puppet-mode)
2149 (mode . yaml-mode)))
2150 ("ruby" (mode . ruby-mode))
2152 (name . "^\\*scratch\\*$")
2153 (name . "^\\*Compile-log\\*$")
2154 (name . "^\\*Completions\\*$")
2155 (name . "^\\*Messages\\*$")
2156 (name . "^\\*Backtrace\\*$")
2157 (name . "^\\*Packages*\\*$")
2158 (name . "^\\*Help*\\*$")
2161 (mode . message-mode)
2164 (mode . gnus-group-mode)
2165 (mode . gnus-summary-mode)
2166 (mode . gnus-article-mode)
2167 (name . "^\\.bbdb$")
2168 (name . "^\\.newsrc-dribble")))
2170 (filename . ".*/org/.*")
2171 (mode . org-agenda-mode)
2172 (name . "^diary$")))
2174 (mode . magit-log-edit-mode)
2175 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
2177 ;; -------------------------------------------------
2178 ;; programming languages #1
2180 (mode . emacs-lisp-mode)
2181 (mode . python-mode)
2183 (mode . coffee-mode)
2186 (mode . actionscript-mode)
2189 (mode . haskell-mode)
2195 ;; -------------------------------------------------
2196 ;; configuration/data files
2200 (mode . conf-mode)))
2201 ;; -------------------------------------------------
2202 ;; text/notetaking/org
2203 ("org agenda" (mode . org-agenda-mode))
2206 (name . "^\\*Calendar\\*$")
2207 (name . "^diary$")))
2211 (mode . markdown-mode)))
2212 ;; -------------------------------------------------
2215 (mode . image-mode)))
2216 ;; -------------------------------------------------
2218 ("w3m" (mode . w3m-mode))
2220 (mode . magit-status-mode)
2221 (mode . magit-log-mode)
2222 (mode . vc-annotate-mode)))
2223 ("dired" (mode . dired-mode))
2228 (name . "^\\*Personal Keybindings\\*$")))
2229 ;; -------------------------------------------------
2231 ("MORE" (or (mode . magit-log-edit-mode)
2232 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2233 (name . "^\\*Pymacs\\*$")
2234 (name . "^\\*Compile-log\\*$")
2235 (name . "^\\*Completions\\*$")
2236 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
2238 ("*buffer*" (name . "\\*.*\\*"))))))
2240 (add-hook 'ibuffer-mode-hook
2242 (ibuffer-auto-mode 1)
2243 (ibuffer-switch-to-saved-filter-groups "default")))
2245 ;; Unless you turn this variable on you will be prompted every time
2246 ;; you want to delete a buffer, even unmodified ones, which is way
2247 ;; too cautious for most people. You’ll still be prompted for
2248 ;; confirmation when deleting modified buffers after the option has
2250 (setq ibuffer-expert t)
2255 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
2256 ‘TAB’ completion is to typing things manually every time.”]]
2257 #+BEGIN_SRC emacs-lisp :tangle yes
2258 (use-package icicles
2259 :load-path "elisp/icicle/"
2264 Incremental mini-buffer completion preview: Type in the minibuffer,
2265 list of matching commands is echoed
2266 #+BEGIN_SRC emacs-lisp :tangle yes
2270 [2014-05-26 Mon 22:49]
2271 #+BEGIN_SRC emacs-lisp :tangle yes
2274 :commands (iedit-mode)
2276 :bind (("C-;" . iedit-mode)
2277 ("C-," . iedit-mode-toggle-on-function))
2282 [2014-05-20 Tue 23:35]
2283 #+BEGIN_SRC emacs-lisp :tangle yes
2285 :bind ("C-h C-i" . info-lookup-symbol)
2289 ;; (defadvice info-setup (after load-info+ activate)
2290 ;; (use-package info+))
2292 (defadvice Info-exit (after remove-info-window activate)
2293 "When info mode is quit, remove the window."
2294 (if (> (length (window-list)) 1)
2297 (use-package info-look
2298 :commands info-lookup-add-help)
2300 ** linum (line number)
2301 Various modes should have line numbers in front of each line.
2303 But then there are some where it would just be deadly - like org-mode,
2304 gnus, so we have a list of modes where we don't want to see it.
2305 #+BEGIN_SRC emacs-lisp :tangle yes
2307 :diminish linum-mode
2310 (setq linum-format "%3d ")
2311 (setq linum-mode-inhibit-modes-list '(org-mode
2318 (defadvice linum-on (around linum-on-inhibit-for-modes)
2319 "Stop the load of linum-mode for some major modes."
2320 (unless (member major-mode linum-mode-inhibit-modes-list)
2323 (ad-activate 'linum-on)
2324 (use-package linum-relative
2325 :ensure linum-relative
2326 :bind ("C-c r" . linum-relative-toggle))
2329 (global-linum-mode 1))
2332 ** lisp editing stuff
2333 [2013-04-21 So 21:00]
2334 I'm not doing much of it, except for my emacs and gnus configs, but
2335 then I like it nice too...
2336 #+BEGIN_SRC emacs-lisp :tangle yes
2337 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
2339 (defun remove-elc-on-save ()
2340 "If you're saving an elisp file, likely the .elc is no longer valid."
2341 (make-local-variable 'after-save-hook)
2342 (add-hook 'after-save-hook
2344 (if (file-exists-p (concat buffer-file-name "c"))
2345 (delete-file (concat buffer-file-name "c"))))))
2347 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
2348 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
2350 (use-package paredit
2352 :diminish paredit-mode " π")
2354 (setq lisp-coding-hook 'lisp-coding-defaults)
2355 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2357 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2358 (add-hook 'emacs-lisp-mode-hook (lambda ()
2359 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2361 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
2363 (after "elisp-slime-nav"
2364 '(diminish 'elisp-slime-nav-mode))
2365 (after "rainbow-mode"
2366 '(diminish 'rainbow-mode))
2368 '(diminish 'eldoc-mode))
2372 [2013-04-21 So 20:48]
2373 magit is a mode for interacting with git.
2374 #+BEGIN_SRC emacs-lisp :tangle yes
2377 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
2378 magit-git-repo-p magit-list-repos)
2380 :bind (("C-x g" . magit-status)
2381 ("C-x G" . magit-status-with-prefix))
2384 (setq magit-commit-signoff t
2385 magit-repo-dirs '("~/git"
2389 magit-repo-dirs-depth 4
2390 magit-log-auto-more t)
2391 (use-package magit-blame
2392 :commands magit-blame-mode)
2394 (use-package magit-svn
2396 :commands (magit-svn-mode
2399 (add-hook 'magit-mode-hook 'hl-line-mode)
2400 (defun magit-status-with-prefix ()
2402 (let ((current-prefix-arg '(4)))
2403 (call-interactively 'magit-status)))
2407 (setenv "GIT_PAGER" "")
2409 (unbind-key "M-h" magit-mode-map)
2410 (unbind-key "M-s" magit-mode-map)
2412 (use-package magit-find-file
2413 :ensure magit-find-file
2414 :commands (magit-find-file-completing-read)
2418 (bind-key "C-x C-f" 'magit-find-file-completing-read magit-mode-map)))
2420 (add-hook 'magit-log-edit-mode-hook
2422 (set-fill-column 72)
2425 (defadvice magit-status (around magit-fullscreen activate)
2426 (window-configuration-to-register :magit-fullscreen)
2428 (delete-other-windows))
2430 (defun magit-quit-session ()
2431 "Restores the previous window configuration and kills the magit buffer"
2434 (jump-to-register :magit-fullscreen))
2436 (bind-key "q" 'magit-quit-session magit-status-mode-map)
2440 [2014-05-20 Tue 23:04]
2441 #+BEGIN_SRC emacs-lisp :tangle yes
2442 (use-package markdown-mode
2443 :mode (("\\.md\\'" . markdown-mode)
2444 ("\\.mdwn\\'" . markdown-mode))
2448 #+BEGIN_SRC emacs-lisp :tangle yes
2450 (setq message-kill-buffer-on-exit t)
2453 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2455 I want to access it from anywhere using =F6=.
2456 #+BEGIN_SRC emacs-lisp :tangle yes
2457 (use-package mingus-stays-home
2458 :bind ( "<f6>" . mingus)
2462 (setq mingus-dired-add-keys t)
2463 (setq mingus-mode-always-modeline nil)
2464 (setq mingus-mode-line-show-elapsed-percentage nil)
2465 (setq mingus-mode-line-show-volume nil)
2466 (setq mingus-mpd-config-file "/etc/mpd.conf")
2467 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2468 (setq mingus-mpd-root "/share/music/")))
2472 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
2473 #+BEGIN_SRC emacs-lisp :tangle yes
2474 (use-package miniedit
2478 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
2479 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
2480 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
2481 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
2487 [2013-05-21 Tue 23:39]
2488 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
2489 coexist in one buffer.
2490 #+BEGIN_SRC emacs-lisp :tangle yes
2491 (use-package mmm-auto
2495 (setq mmm-global-mode 'buffers-with-submode-classes)
2496 (setq mmm-submode-decoration-level 2)
2497 (eval-after-load 'mmm-vars
2503 :face mmm-code-submode-face
2504 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
2505 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
2506 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2507 @ "\n" _ "\n" @ "</script>" @)))
2510 :face mmm-code-submode-face
2511 :front "<style[^>]*>[ \t]*\n?"
2512 :back "[ \t]*</style>"
2513 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2514 @ "\n" _ "\n" @ "</style>" @)))
2517 :face mmm-code-submode-face
2520 (dolist (mode (list 'html-mode 'nxml-mode))
2521 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
2522 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
2527 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2530 #+BEGIN_SRC emacs-lisp :tangle yes
2531 (use-package mo-git-blame
2532 :ensure mo-git-blame
2533 :commands (mo-git-blame-current
2537 (setq mo-git-blame-blame-window-width 25)))
2541 [2013-04-08 Mon 23:57]
2542 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2543 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2544 #+BEGIN_SRC emacs-lisp :tangle yes
2545 (use-package multiple-cursors
2546 :ensure multiple-cursors
2548 :commands (mc/remove-fake-cursors
2549 mc/create-fake-cursor-at-point
2550 mc/pop-state-from-overlay
2551 mc/maybe-multiple-cursors-mode)
2552 :bind (("C-S-c C-S-c" . mc/edit-lines)
2553 ("C->" . mc/mark-next-like-this)
2554 ("C-<" . mc/mark-previous-like-this)
2555 ("C-c C-<" . mc/mark-all-like-this)
2556 ("C-c i" . mc/insert-numbers))
2559 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
2560 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
2561 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
2562 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
2563 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
2564 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
2567 [2014-08-27 Wed 17:15]
2569 #+BEGIN_SRC emacs-lisp :tangle yes
2570 (use-package neotree
2573 :bind (("<f8>" . neotree-toggle))
2574 :commands (neotree-find
2579 (setq neo-smart-open t)))
2582 [2013-05-22 Wed 22:02]
2583 nxml-mode is a major mode for editing XML.
2584 #+BEGIN_SRC emacs-lisp :tangle yes
2589 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2592 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2593 (fset 'xml-mode 'nxml-mode)
2594 (setq nxml-slash-auto-complete-flag t)
2596 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2597 (defun pp-xml-region (begin end)
2598 "Pretty format XML markup in region. The function inserts
2599 linebreaks to separate tags that have nothing but whitespace
2600 between them. It then indents the markup by using nxml's
2606 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2607 (backward-char) (insert "\n"))
2608 (indent-region begin end)))
2610 ;;----------------------------------------------------------------------------
2611 ;; Integration with tidy for html + xml
2612 ;;----------------------------------------------------------------------------
2613 ;; tidy is autoloaded
2614 (eval-after-load 'tidy
2616 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2617 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2622 *** General settings
2623 [2013-04-28 So 17:06]
2625 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
2626 it is quite extensive. Nevertheless, it starts out small, loading it.
2627 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2631 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
2632 that we need org-protocol.
2633 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2634 (require 'org-protocol)
2639 My current =org-agenda-files= variable only includes a set of
2641 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2642 (setq org-agenda-files (quote ("~/org/"
2648 (setq org-default-notes-file "~/org/notes.org")
2650 =org-mode= manages the =org-agenda-files= variable automatically using
2651 =C-c [= and =C-c ]= to add and remove files respectively. However,
2652 this replaces my directory list with a list of explicit filenames
2653 instead and is not what I want. If this occurs then adding a new org
2654 file to any of the above directories will not contribute to my agenda
2655 and I will probably miss something important.
2657 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
2658 prevent messing up my list of directories in the =org-agenda-files=
2659 variable. I just add and remove directories manually here. Changing
2660 the list of directories in =org-agenda-files= happens very rarely
2661 since new files in existing directories are automatically picked up.
2663 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2664 ;; Keep tasks with dates on the global todo lists
2665 (setq org-agenda-todo-ignore-with-date nil)
2667 ;; Keep tasks with deadlines on the global todo lists
2668 (setq org-agenda-todo-ignore-deadlines nil)
2670 ;; Keep tasks with scheduled dates on the global todo lists
2671 (setq org-agenda-todo-ignore-scheduled nil)
2673 ;; Keep tasks with timestamps on the global todo lists
2674 (setq org-agenda-todo-ignore-timestamp nil)
2676 ;; Remove completed deadline tasks from the agenda view
2677 (setq org-agenda-skip-deadline-if-done t)
2679 ;; Remove completed scheduled tasks from the agenda view
2680 (setq org-agenda-skip-scheduled-if-done t)
2682 ;; Remove completed items from search results
2683 (setq org-agenda-skip-timestamp-if-done t)
2685 ;; Include agenda archive files when searching for things
2686 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
2688 ;; Show all future entries for repeating tasks
2689 (setq org-agenda-repeating-timestamp-show-all t)
2691 ;; Show all agenda dates - even if they are empty
2692 (setq org-agenda-show-all-dates t)
2694 ;; Sorting order for tasks on the agenda
2695 (setq org-agenda-sorting-strategy
2696 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
2697 (todo category-up priority-down effort-up)
2698 (tags category-up priority-down effort-up)
2699 (search category-up))))
2701 ;; Start the weekly agenda on Monday
2702 (setq org-agenda-start-on-weekday 1)
2704 ;; Enable display of the time grid so we can see the marker for the current time
2705 (setq org-agenda-time-grid (quote ((daily today remove-match)
2706 #("----------------" 0 16 (org-heading t))
2707 (0800 1000 1200 1400 1500 1700 1900 2100))))
2709 ;; Display tags farther right
2710 (setq org-agenda-tags-column -102)
2712 ; position the habit graph on the agenda to the right of the default
2713 (setq org-habit-graph-column 50)
2715 ; turn habits back on
2716 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
2719 ;; Agenda sorting functions
2721 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
2724 (setq org-deadline-warning-days 30)
2726 ;; Always hilight the current agenda line
2727 (add-hook 'org-agenda-mode-hook
2728 '(lambda () (hl-line-mode 1))
2732 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2733 (setq org-agenda-persistent-filter t)
2734 (add-hook 'org-agenda-mode-hook
2735 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
2738 (add-hook 'org-agenda-mode-hook
2739 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
2742 (add-hook 'org-agenda-mode-hook
2743 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
2746 (add-hook 'org-agenda-mode-hook
2747 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
2750 (add-hook 'org-agenda-mode-hook
2751 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
2754 ; Rebuild the reminders everytime the agenda is displayed
2755 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
2757 ;(if (file-exists-p "~/org/refile.org")
2758 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
2760 ; Activate appointments so we get notifications
2763 (setq org-agenda-log-mode-items (quote (closed clock state)))
2764 (if (> emacs-major-version 23)
2765 (setq org-agenda-span 3)
2766 (setq org-agenda-ndays 3))
2768 (setq org-agenda-show-all-dates t)
2769 (setq org-agenda-start-on-weekday nil)
2770 (setq org-deadline-warning-days 14)
2773 *** Global keybindings.
2774 Start off by defining a series of keybindings.
2776 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
2777 setup manually, not by org-mode. Also turn off =C-c ;=, which
2778 comments headlines - a function never used.
2779 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2780 (add-hook 'org-mode-hook
2782 (org-defkey org-mode-map "\C-c[" 'undefined)
2783 (org-defkey org-mode-map "\C-c]" 'undefined)
2784 (org-defkey org-mode-map "\C-c;" 'undefined))
2788 And now a largish set of keybindings...
2789 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2790 (bind-key "C-c l" 'org-store-link)
2791 (bind-key "C-c a" 'org-agenda)
2792 ;(bind-key "C-c b" 'org-iswitchb)
2793 (define-key mode-specific-map [?a] 'org-agenda)
2795 (bind-key "<f12>" 'org-agenda)
2796 (bind-key "<f5>" 'bh/org-todo)
2797 (bind-key "<S-f5>" 'bh/widen)
2798 (bind-key "<f7>" 'bh/set-truncate-lines)
2799 ;(bind-key "<f8>" 'org-cycle-agenda-files)
2801 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
2802 (bind-key "<f9> b" 'bbdb)
2803 (bind-key "<f9> c" 'calendar)
2804 (bind-key "<f9> f" 'boxquote-insert-file)
2805 (bind-key "<f9> h" 'bh/hide-other)
2806 (bind-key "<f9> n" 'org-narrow-to-subtree)
2807 (bind-key "<f9> w" 'widen)
2808 (bind-key "<f9> u" 'bh/narrow-up-one-level)
2809 (bind-key "<f9> I" 'bh/punch-in)
2810 (bind-key "<f9> O" 'bh/punch-out)
2811 (bind-key "<f9> H" 'jj/punch-in-hw)
2812 (bind-key "<f9> W" 'jj/punch-out-hw)
2813 (bind-key "<f9> o" 'bh/make-org-scratch)
2814 (bind-key "<f9> p" 'bh/phone-call)
2815 (bind-key "<f9> r" 'boxquote-region)
2816 (bind-key "<f9> s" 'bh/switch-to-scratch)
2817 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
2818 (bind-key "<f9> T" 'tabify)
2819 (bind-key "<f9> U" 'untabify)
2820 (bind-key "<f9> v" 'visible-mode)
2821 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
2822 (bind-key "C-<f9>" 'previous-buffer)
2823 (bind-key "C-<f10>" 'next-buffer)
2824 (bind-key "M-<f9>" 'org-toggle-inline-images)
2825 ;(bind-key "C-x n r" 'narrow-to-region)
2826 (bind-key "<f11>" 'org-clock-goto)
2827 (bind-key "C-<f11>" 'org-clock-in)
2828 (bind-key "C-M-r" 'org-capture)
2829 (bind-key "C-c r" 'org-capture)
2830 (bind-key "C-S-<f12>" 'bh/save-then-publish)
2831 ;(bind-key "C-k" 'jj-org-kill-line org-mode-map)
2835 *** Tasks, States, Todo fun
2837 First we define the global todo keywords.
2838 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2839 (setq org-todo-keywords
2840 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
2841 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
2843 (setq org-todo-keyword-faces
2844 (quote (("TODO" :foreground "red" :weight bold)
2845 ("NEXT" :foreground "light blue" :weight bold)
2846 ("DONE" :foreground "forest green" :weight bold)
2847 ("WAITING" :foreground "orange" :weight bold)
2848 ("HOLD" :foreground "orange" :weight bold)
2849 ("DELEGATED" :foreground "yellow" :weight bold)
2850 ("CANCELLED" :foreground "dark green" :weight bold)
2851 ("PHONE" :foreground "dark green" :weight bold))))
2854 **** Fast Todo Selection
2855 Fast todo selection allows changing from any task todo state to any
2856 other state directly by selecting the appropriate key from the fast
2857 todo selection key menu.
2858 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2859 (setq org-use-fast-todo-selection t)
2861 Changing a task state is done with =C-c C-t KEY=
2863 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
2866 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2867 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
2869 allows changing todo states with S-left and S-right skipping all of
2870 the normal processing when entering or leaving a todo state. This
2871 cycles through the todo states but skips setting timestamps and
2872 entering notes which is very convenient when all you want to do is fix
2873 up the status of an entry.
2875 **** Todo State Triggers
2876 I have a few triggers that automatically assign tags to tasks based on
2877 state changes. If a task moves to =CANCELLED= state then it gets a
2878 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
2879 =CANCELLED= tag. These are used for filtering tasks in agenda views
2880 which I'll talk about later.
2882 The triggers break down to the following rules:
2884 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
2885 - Moving a task to =WAITING= adds a =WAITING= tag
2886 - Moving a task to =HOLD= adds a =WAITING= tag
2887 - Moving a task to a done state removes a =WAITING= tag
2888 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
2889 - Moving a task to =NEXT= removes a =WAITING= tag
2890 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
2892 The tags are used to filter tasks in the agenda views conveniently.
2893 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2894 (setq org-todo-state-tags-triggers
2895 (quote (("CANCELLED" ("CANCELLED" . t))
2896 ("WAITING" ("WAITING" . t))
2897 ("HOLD" ("WAITING" . t) ("HOLD" . t))
2898 (done ("WAITING") ("HOLD"))
2899 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
2900 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
2901 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
2904 *** Capturing new tasks
2905 Org capture replaces the old remember mode.
2906 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2907 (setq org-directory "~/org")
2908 (setq org-default-notes-file "~/org/refile.org")
2910 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
2911 ;; see http://orgmode.org/manual/Template-elements.html
2912 (setq org-capture-templates
2913 (quote (("t" "todo" entry (file "~/org/refile.org")
2914 "* TODO %?\nAdded: %U\n"
2915 :clock-in t :clock-resume t)
2916 ("l" "linktodo" entry (file "~/org/refile.org")
2917 "* TODO %?\nAdded: %U\n%a\n"
2918 :clock-in t :clock-resume t)
2919 ("r" "respond" entry (file "~/org/refile.org")
2920 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
2921 :clock-in t :clock-resume t :immediate-finish t)
2922 ("n" "note" entry (file "~/org/refile.org")
2923 "* %? :NOTE:\nAdded: %U\n%a\n"
2924 :clock-in t :clock-resume t)
2925 ("d" "Delegated" entry (file "~/org/refile.org")
2926 "* DELEGATED %?\nAdded: %U\n%a\n"
2927 :clock-in t :clock-resume t)
2928 ("j" "Journal" entry (file+datetree "~/org/diary.org")
2930 :clock-in t :clock-resume t)
2931 ("w" "org-protocol" entry (file "~/org/refile.org")
2932 "* TODO Review %c\nAdded: %U\n"
2933 :immediate-finish t)
2934 ("p" "Phone call" entry (file "~/org/refile.org")
2935 "* PHONE %? :PHONE:\nAdded: %U"
2936 :clock-in t :clock-resume t)
2937 ("x" "Bookmark link" entry (file "~/org/refile.org")
2938 "* Bookmark: %c\n%i\nAdded: %U\n"
2939 :immediate-finish t)
2940 ("h" "Habit" entry (file "~/org/refile.org")
2941 "* 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")
2945 Capture mode now handles automatically clocking in and out of a
2946 capture task. This all works out of the box now without special hooks.
2947 When I start a capture mode task the task is clocked in as specified
2948 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
2949 resumes on the original clocking task.
2951 The quick clocking in and out of capture mode tasks (often it takes
2952 less than a minute to capture some new task details) can leave
2953 empty clock drawers in my tasks which aren't really useful.
2954 The following prevents this.
2955 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2956 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
2960 All my newly captured entries end up in =refile.org= and want to be
2961 moved over to the right place. The following is the setup for it.
2962 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2963 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
2964 (setq org-refile-targets (quote ((nil :maxlevel . 9)
2965 (org-agenda-files :maxlevel . 9))))
2967 ; Use full outline paths for refile targets - we file directly with IDO
2968 (setq org-refile-use-outline-path t)
2970 ; Targets complete directly with IDO
2971 (setq org-outline-path-complete-in-steps nil)
2973 ; Allow refile to create parent tasks with confirmation
2974 (setq org-refile-allow-creating-parent-nodes (quote confirm))
2976 ; Use IDO for both buffer and file completion and ido-everywhere to t
2977 (setq org-completion-use-ido t)
2978 (setq org-completion-use-iswitchb nil)
2979 :; Use IDO for both buffer and file completion and ido-everywhere to t
2980 ;(setq ido-everywhere t)
2981 ;(setq ido-max-directory-size 100000)
2982 ;(ido-mode (quote both))
2983 ; Use the current window when visiting files and buffers with ido
2984 (setq ido-default-file-method 'selected-window)
2985 (setq ido-default-buffer-method 'selected-window)
2987 ;;;; Refile settings
2988 (setq org-refile-target-verify-function 'bh/verify-refile-target)
2992 Agenda view is the central place for org-mode interaction...
2993 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2994 ;; Do not dim blocked tasks
2995 (setq org-agenda-dim-blocked-tasks nil)
2996 ;; Compact the block agenda view
2997 (setq org-agenda-compact-blocks t)
2999 ;; Custom agenda command definitions
3000 (setq org-agenda-custom-commands
3001 (quote (("N" "Notes" tags "NOTE"
3002 ((org-agenda-overriding-header "Notes")
3003 (org-tags-match-list-sublevels t)))
3004 ("h" "Habits" tags-todo "STYLE=\"habit\""
3005 ((org-agenda-overriding-header "Habits")
3006 (org-agenda-sorting-strategy
3007 '(todo-state-down effort-up category-keep))))
3011 ((org-agenda-overriding-header "Tasks to Refile")
3012 (org-tags-match-list-sublevels nil)))
3013 (tags-todo "-HOLD-CANCELLED/!"
3014 ((org-agenda-overriding-header "Projects")
3015 (org-agenda-skip-function 'bh/skip-non-projects)
3016 (org-agenda-sorting-strategy
3018 (tags-todo "-CANCELLED/!"
3019 ((org-agenda-overriding-header "Stuck Projects")
3020 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3021 (tags-todo "-WAITING-CANCELLED/!NEXT"
3022 ((org-agenda-overriding-header "Next Tasks")
3023 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3024 (org-agenda-todo-ignore-scheduled t)
3025 (org-agenda-todo-ignore-deadlines t)
3026 (org-agenda-todo-ignore-with-date t)
3027 (org-tags-match-list-sublevels t)
3028 (org-agenda-sorting-strategy
3029 '(todo-state-down effort-up category-keep))))
3030 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3031 ((org-agenda-overriding-header "Tasks")
3032 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3033 (org-agenda-todo-ignore-scheduled t)
3034 (org-agenda-todo-ignore-deadlines t)
3035 (org-agenda-todo-ignore-with-date t)
3036 (org-agenda-sorting-strategy
3038 (tags-todo "-CANCELLED+WAITING/!"
3039 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
3040 (org-agenda-skip-function 'bh/skip-stuck-projects)
3041 (org-tags-match-list-sublevels nil)
3042 (org-agenda-todo-ignore-scheduled 'future)
3043 (org-agenda-todo-ignore-deadlines 'future)))
3045 ((org-agenda-overriding-header "Tasks to Archive")
3046 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3047 (org-tags-match-list-sublevels nil))))
3049 ("r" "Tasks to Refile" tags "REFILE"
3050 ((org-agenda-overriding-header "Tasks to Refile")
3051 (org-tags-match-list-sublevels nil)))
3052 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
3053 ((org-agenda-overriding-header "Stuck Projects")
3054 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3055 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
3056 ((org-agenda-overriding-header "Next Tasks")
3057 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3058 (org-agenda-todo-ignore-scheduled t)
3059 (org-agenda-todo-ignore-deadlines t)
3060 (org-agenda-todo-ignore-with-date t)
3061 (org-tags-match-list-sublevels t)
3062 (org-agenda-sorting-strategy
3063 '(todo-state-down effort-up category-keep))))
3064 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3065 ((org-agenda-overriding-header "Tasks")
3066 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3067 (org-agenda-sorting-strategy
3069 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
3070 ((org-agenda-overriding-header "Projects")
3071 (org-agenda-skip-function 'bh/skip-non-projects)
3072 (org-agenda-sorting-strategy
3074 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
3075 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
3076 (org-tags-match-list-sublevels nil))
3077 ("A" "Tasks to Archive" tags "-REFILE/"
3078 ((org-agenda-overriding-header "Tasks to Archive")
3079 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3080 (org-tags-match-list-sublevels nil))))))
3082 ; Overwrite the current window with the agenda
3083 (setq org-agenda-window-setup 'current-window)
3088 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3090 ;; Resume clocking task when emacs is restarted
3091 (org-clock-persistence-insinuate)
3093 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
3094 (setq org-clock-history-length 36)
3095 ;; Resume clocking task on clock-in if the clock is open
3096 (setq org-clock-in-resume t)
3097 ;; Change tasks to NEXT when clocking in
3098 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
3099 ;; Separate drawers for clocking and logs
3100 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
3101 ;; Save clock data and state changes and notes in the LOGBOOK drawer
3102 (setq org-clock-into-drawer t)
3103 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
3104 (setq org-clock-out-remove-zero-time-clocks t)
3105 ;; Clock out when moving task to a done state
3106 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
3107 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
3108 (setq org-clock-persist t)
3109 ;; Do not prompt to resume an active clock
3110 (setq org-clock-persist-query-resume nil)
3111 ;; Enable auto clock resolution for finding open clocks
3112 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
3113 ;; Include current clocking task in clock reports
3114 (setq org-clock-report-include-clocking-task t)
3116 ; use discrete minute intervals (no rounding) increments
3117 (setq org-time-stamp-rounding-minutes (quote (1 1)))
3119 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
3121 (setq bh/keep-clock-running nil)
3123 (setq org-agenda-clock-consistency-checks
3124 (quote (:max-duration "4:00"
3127 :gap-ok-around ("4:00"))))
3131 **** Setting a default clock task
3132 Per default the =** Organization= task in my tasks.org file receives
3133 misc clock time. This is the task I clock in on when I punch in at the
3134 start of my work day with =F9-I=. Punching-in anywhere clocks in this
3135 Organization task as the default task.
3137 If I want to change the default clocking task I just visit the
3138 new task in any org buffer and clock it in with =C-u C-u C-c C-x
3139 C-i=. Now this new task that collects miscellaneous clock
3140 minutes when the clock would normally stop.
3142 You can quickly clock in the default clocking task with =C-u C-c
3143 C-x C-i d=. Another option is to repeatedly clock out so the
3144 clock moves up the project tree until you clock out the
3145 top-level task and the clock moves to the default task.
3148 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3149 ;; Agenda clock report parameters
3150 (setq org-agenda-clockreport-parameter-plist
3151 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
3153 ;; Agenda log mode items to display (closed and state changes by default)
3154 (setq org-agenda-log-mode-items (quote (closed state)))
3156 **** Task estimates, column view
3157 Setup column view globally with the following headlines
3158 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3159 ; Set default column view headings: Task Effort Clock_Summary
3160 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
3162 Setup the estimate for effort values.
3163 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3164 ; global Effort estimate values
3165 ; global STYLE property values for completion
3166 (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")
3167 ("STYLE_ALL" . "habit"))))
3171 Tags are mostly used for filtering inside the agenda.
3172 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3173 ; Tags with fast selection keys
3174 (setq org-tag-alist (quote ((:startgroup)
3192 ; Allow setting single tags without the menu
3193 (setq org-fast-tag-selection-single-key (quote expert))
3195 ; For tag searches ignore tasks with scheduled and deadline dates
3196 (setq org-agenda-tags-todo-honor-ignore-options t)
3200 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3201 (setq org-archive-mark-done nil)
3202 (setq org-archive-location "%s_archive::* Archived Tasks")
3206 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3207 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
3208 (setq org-plantuml-jar-path "~/java/plantuml.jar")
3210 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
3212 ; Make babel results blocks lowercase
3213 (setq org-babel-results-keyword "results")
3215 (org-babel-do-load-languages
3216 (quote org-babel-load-languages)
3217 (quote ((emacs-lisp . t)
3236 ; Do not prompt to confirm evaluation
3237 ; This may be dangerous - make sure you understand the consequences
3238 ; of setting this -- see the docstring for details
3239 (setq org-confirm-babel-evaluate nil)
3241 ; Use fundamental mode when editing plantuml blocks with C-c '
3242 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
3245 #+BEGIN_SRC emacs-lisp :tangle yes
3246 ;; Don't have images visible on startup, breaks on console
3247 (setq org-startup-with-inline-images nil)
3250 #+BEGIN_SRC emacs-lisp :tangle yes
3251 (add-to-list 'org-structure-template-alist
3252 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
3253 "<comment>\n?\n</comment>"))
3255 **** ditaa, graphviz, etc
3256 Those are all nice tools. Look at
3257 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
3260 *** Publishing and exporting
3263 Org-mode can export to a variety of publishing formats including (but not limited to)
3266 (plain text - but not the original org-mode file)
3270 which enables getting to lots of other formats like ODF, XML, etc
3272 via LaTeX or Docbook
3275 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
3277 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3278 ;; Explicitly load required exporters
3282 ;; FIXME, check the following two
3283 ;(require 'ox-icalendar)
3286 ; experimenting with docbook exports - not finished
3287 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
3288 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
3290 ;; define categories that should be excluded
3291 (setq org-export-exclude-category (list "google" "google"))
3292 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
3294 ; define how the date strings look
3295 (setq org-export-date-timestamp-format "%Y-%m-%d")
3296 ; Inline images in HTML instead of producting links to the image
3297 (setq org-html-inline-images t)
3298 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
3299 (setq org-export-with-sub-superscripts nil)
3301 (setq org-html-head-extra (concat
3302 "<link rel=\"stylesheet\" href=\"http://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
3304 (setq org-html-head-include-default-style nil)
3305 ; Do not generate internal css formatting for HTML exports
3306 (setq org-export-htmlize-output-type (quote css))
3307 ; Export with LaTeX fragments
3308 (setq org-export-with-LaTeX-fragments t)
3309 ; Increase default number of headings to export
3310 (setq org-export-headline-levels 6)
3313 (setq org-publish-project-alist
3316 :base-directory "~/.emacs.d/"
3317 :base-extension "org"
3319 :publishing-directory "/develop/www/emacs"
3321 :publishing-function org-html-publish-to-html
3322 :headline-levels 4 ; Just the default for this project.
3328 :base-directory "~/.emacs.d/"
3329 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
3330 :publishing-directory "/develop/www/emacs"
3331 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
3333 :publishing-function org-publish-attachment
3335 ("inherit-org-info-js"
3336 :base-directory "/develop/vcs/org-info-js/"
3338 :base-extension "js"
3339 :publishing-directory "/develop/www/"
3340 :publishing-function org-publish-attachment
3342 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
3347 (setq org-export-with-timestamps nil)
3352 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3353 (setq org-latex-to-pdf-process
3354 '("xelatex -interaction nonstopmode %f"
3355 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
3356 (setq org-export-latex-listings 'minted)
3357 (setq org-latex-listings t)
3359 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
3360 ;; but adapted to use latexmk 4.20 or higher.
3361 (defun my-auto-tex-cmd ()
3362 "When exporting from .org with latex, automatically run latex,
3363 pdflatex, or xelatex as appropriate, using latexmk."
3365 ;; default command: oldstyle latex via dvi
3366 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
3368 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
3369 (setq texcmd "latexmk -pdf -quiet %f"))
3371 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3372 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
3373 ;; LaTeX compilation command
3374 (setq org-latex-to-pdf-process (list texcmd)))
3376 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
3378 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
3379 (setq org-export-latex-packages-alist
3381 ("" "longtable" nil)
3386 (defun my-auto-tex-parameters ()
3387 "Automatically select the tex packages to include."
3388 ;; default packages for ordinary latex or pdflatex export
3389 (setq org-export-latex-default-packages-alist
3390 '(("AUTO" "inputenc" t)
3400 ("" "hyperref" nil)))
3402 ;; Packages to include when xelatex is used
3403 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3404 (setq org-export-latex-default-packages-alist
3409 ("german" "babel" t)
3410 ("babel" "csquotes" t)
3412 ("xetex" "hyperref" nil)
3415 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
3416 (setq org-export-latex-classes
3418 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
3419 ("\\section{%s}" . "\\section*{%s}")
3420 ("\\subsection{%s}" . "\\subsection*{%s}")
3421 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
3422 ("\\paragraph{%s}" . "\\paragraph*{%s}")
3423 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
3424 org-export-latex-classes))))
3426 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
3429 *** Prevent editing invisible text
3430 The following setting prevents accidentally editing hidden text when
3431 the point is inside a folded region. This can happen if you are in
3432 the body of a heading and globally fold the org-file with =S-TAB=
3434 I find invisible edits (and undo's) hard to deal with so now I can't
3435 edit invisible text. =C-c C-r= (org-reveal) will display where the
3436 point is if it is buried in invisible text to allow editing again.
3438 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3439 (setq org-catch-invisible-edits 'error)
3443 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3444 ;; disable the default org-mode stuck projects agenda view
3445 (setq org-stuck-projects (quote ("" nil nil "")))
3447 ; force showing the next headline.
3448 (setq org-show-entry-below (quote ((default))))
3450 (setq org-show-following-heading t)
3451 (setq org-show-hierarchy-above t)
3452 (setq org-show-siblings (quote ((default))))
3454 (setq org-special-ctrl-a/e t)
3455 (setq org-special-ctrl-k t)
3456 (setq org-yank-adjusted-subtrees t)
3458 (setq org-table-export-default-format "orgtbl-to-csv")
3462 The following setting adds alphabetical lists like
3466 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3467 (if (> emacs-major-version 23)
3468 (setq org-list-allow-alphabetical t)
3469 (setq org-alphabetical-lists t))
3472 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3473 (setq org-remove-highlights-with-change nil)
3475 (setq org-list-demote-modify-bullet (quote (("+" . "-")
3482 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
3485 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
3486 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
3491 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3492 ;; Enable abbrev-mode
3493 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
3494 (setq org-startup-indented t)
3495 (setq org-startup-folded t)
3496 (setq org-cycle-separator-lines 0)
3499 I find extra blank lines in lists and headings a bit of a nuisance.
3500 To get a body after a list you need to include a blank line between
3501 the list entry and the body -- and indent the body appropriately.
3502 Most of my lists have no body detail so I like the look of collapsed
3503 lists with no blank lines better.
3505 The following setting prevents creating blank lines before headings
3506 but allows list items to adapt to existing blank lines around the items:
3507 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3508 (setq org-blank-before-new-entry (quote ((heading)
3509 (plain-list-item . auto))))
3512 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3513 (setq org-reverse-note-order nil)
3514 (setq org-default-notes-file "~/notes.org")
3517 Enforce task blocking. Tasks can't go done when there is any subtask
3518 still open. Unless they have a property of =NOBLOCKING: t=
3519 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3520 (setq org-enforce-todo-checkbox-dependencies t)
3521 (setq org-enforce-todo-dependencies t)
3524 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3525 (setq org-fast-tag-selection-single-key (quote expert))
3526 (setq org-footnote-auto-adjust t)
3527 (setq org-hide-block-startup t)
3528 (setq org-icalendar-alarm-time 15)
3529 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
3530 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
3531 (setq org-icalendar-honor-noexport-tag t)
3532 (setq org-icalendar-include-bbdb-anniversaries nil)
3533 (setq org-icalendar-include-body 200)
3534 (setq org-icalendar-include-todo nil)
3535 (setq org-icalendar-store-UID t)
3536 (setq org-icalendar-timezone "Europe/Berlin")
3537 (setq org-insert-mode-line-in-empty-file t)
3538 (setq org-log-done (quote note))
3539 (setq org-log-into-drawer t)
3540 (setq org-log-state-notes-insert-after-drawers nil)
3541 (setq org-log-reschedule (quote time))
3542 (setq org-log-states-order-reversed t)
3543 (setq org-mobile-agendas (quote all))
3544 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
3545 (setq org-mobile-inbox-for-pull "~/org/refile.org")
3546 (setq org-remember-store-without-prompt t)
3547 (setq org-return-follows-link t)
3548 (setq org-reverse-note-order t)
3550 ; regularly save our org-mode buffers
3551 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
3553 (setq org-log-done t)
3555 (setq org-enable-priority-commands t)
3556 (setq org-default-priority ?E)
3557 (setq org-lowest-priority ?E)
3562 Speed commands enable single-letter commands in Org-mode files when
3563 the point is at the beginning of a headline, or at the beginning of a
3566 See the `=org-speed-commands-default=' variable for a list of the keys
3567 and commands enabled at the beginning of headlines. All code blocks
3568 are available at the beginning of a code block, the following key
3569 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
3570 display a list of the code blocks commands and their related keys.
3572 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3573 (setq org-use-speed-commands t)
3574 (setq org-speed-commands-user (quote (("0" . ignore)
3587 ("h" . bh/hide-other)
3590 (call-interactively 'org-insert-heading-respect-content))
3591 ("k" . org-kill-note-or-show-branches)
3594 ("q" . bh/show-org-agenda)
3596 ("s" . org-save-all-org-buffers)
3600 ("z" . org-add-note)
3605 ("F" . bh/restrict-to-file-or-follow)
3608 ("J" . org-clock-goto)
3612 ("N" . bh/narrow-to-org-subtree)
3613 ("P" . bh/narrow-to-org-project)
3618 ("U" . bh/narrow-up-one-org-level)
3625 (add-hook 'org-agenda-mode-hook
3627 (define-key org-agenda-mode-map "q" 'bury-buffer))
3630 (defvar bh/current-view-project nil)
3631 (add-hook 'org-agenda-mode-hook
3632 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
3636 The following displays the contents of code blocks in Org-mode files
3637 using the major-mode of the code. It also changes the behavior of
3638 =TAB= to as if it were used in the appropriate major mode. This means
3639 that reading and editing code form inside of your Org-mode files is
3640 much more like reading and editing of code using its major mode.
3642 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3643 (setq org-src-fontify-natively t)
3644 (setq org-src-tab-acts-natively t)
3647 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3648 (setq org-src-preserve-indentation nil)
3649 (setq org-edit-src-content-indentation 0)
3653 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3654 (setq org-attach-directory "~/org/data/")
3656 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3657 (setq org-agenda-sticky t)
3660 **** Checklist handling
3661 [2013-05-11 Sat 22:15]
3663 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3664 (require 'org-checklist)
3668 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
3670 #+BEGIN_SRC emacs-lisp :tangle yes
3671 (use-package cperl-mode
3672 :commands cperl-mode
3675 (defalias 'perl-mode 'cperl-mode)
3676 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
3677 (add-auto-mode 'pod-mode "\\.pod$")
3678 (add-auto-mode 'tt-mode "\\.tt$")
3679 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
3680 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
3681 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
3685 (setq cperl-invalid-face nil
3686 cperl-close-paren-offset -4
3687 cperl-continued-statement-offset 0
3688 cperl-indent-level 4
3689 cperl-indent-parens-as-block t
3691 cperl-electric-keywords t
3692 cperl-electric-lbrace-space t
3693 cperl-electric-parens nil
3694 cperl-highlight-variables-indiscriminately t
3695 cperl-imenu-addback t
3696 cperl-invalid-face (quote underline)
3697 cperl-lazy-help-time 5
3698 cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$"
3699 cperl-syntaxify-by-font-lock t
3700 cperl-use-syntax-table-text-property-for-tags t)
3702 ;; And have cperl mode give ElDoc a useful string
3703 (defun my-cperl-eldoc-documentation-function ()
3704 "Return meaningful doc string for `eldoc-mode'."
3706 (let ((cperl-message-on-help-error nil))
3708 (add-hook 'cperl-mode-hook
3710 (set (make-local-variable 'eldoc-documentation-function)
3711 'my-cperl-eldoc-documentation-function)
3716 [2014-05-22 Thu 00:05]
3717 #+BEGIN_SRC emacs-lisp :tangle yes
3718 (use-package puppet-mode
3719 :mode ("\\.pp\\'" . puppet-mode)
3721 (use-package puppet-ext
3724 (bind-key "C-x ?" 'puppet-set-anchor puppet-mode-map)
3725 (bind-key "C-c C-r" 'puppet-create-require puppet-mode-map)
3726 (defun my-puppet-mode-hook ()
3727 (setq require-final-newline nil))
3728 (add-hook 'puppet-mode-hook 'my-puppet-mode-hook))))
3732 Use elpy for the emacs python fun, but dont let it initialize all the
3733 various variables. Elpy author may like them, but I'm not him...
3734 #+BEGIN_SRC emacs-lisp :tangle yes
3737 :mode ("\.py" . python-mode)
3740 (safe-load (concat jj-elisp-dir "/elpy/elpy-autoloads.el"))
3747 :commands (nosetests-all nosetests-module nosetests-one
3748 nosetests-failed nosetests-pdb-all
3749 nosetests-pdb-module nosetests-pdb-one)
3754 :commands (pyvenv-activate pyvenv-deactivate pyvenv-mode pyvenv-restart-python)
3757 (use-package idomenu
3762 (use-package highlight-indentation
3764 :commands (highlight-indentation-mode))
3766 (use-package find-file-in-project
3768 :commands (find-file-in-project ffip-project-files ffip ))
3773 ;; Local variables in `python-mode'. This is not removed when Elpy
3774 ;; is disabled, which can cause some confusion.
3775 (add-hook 'python-mode-hook 'elpy-initialize-local-variables)
3777 (defun my-python-mode-hook ()
3778 (setq require-final-newline nil)
3779 (setq mode-require-final-newline))
3780 (add-hook 'python-mode-hook 'my-python-mode-hook)
3782 ;; Flymake support using flake8, including warning faces.
3783 (when (and (executable-find "flake8")
3784 (not (executable-find python-check-command)))
3785 (setq python-check-command "flake8"))
3787 ;; `flymake-no-changes-timeout': The original value of 0.5 is too
3788 ;; short for Python code, as that will result in the current line to
3789 ;; be highlighted most of the time, and that's annoying. This value
3790 ;; might be on the long side, but at least it does not, in general,
3791 ;; interfere with normal interaction.
3792 (setq flymake-no-changes-timeout 60)
3794 ;; `flymake-start-syntax-check-on-newline': This should be nil for
3795 ;; Python, as;; most lines with a colon at the end will mean the next
3796 ;; line is always highlighted as error, which is not helpful and
3798 (setq flymake-start-syntax-check-on-newline nil)
3800 ;; `ac-auto-show-menu': Short timeout because the menu is great.
3801 (setq ac-auto-show-menu 0.4)
3803 ;; `ac-quick-help-delay': I'd like to show the menu right with the
3804 ;; completions, but this value should be greater than
3805 ;; `ac-auto-show-menu' to show help for the first entry as well.
3806 (setq ac-quick-help-delay 0.5)
3808 ;; `yas-trigger-key': TAB, as is the default, conflicts with the
3809 ;; autocompletion. We also need to tell yasnippet about the new
3810 ;; binding. This is a bad interface to set the trigger key. Stop
3812 (let ((old (when (boundp 'yas-trigger-key)
3814 (setq yas-trigger-key "C-c C-i")
3815 (when (fboundp 'yas--trigger-key-reload)
3816 (yas--trigger-key-reload old)))
3818 ;; yas-snippet-dirs can be a string for a single directory. Make
3819 ;; sure it's a list in that case so we can add our own entry.
3820 (when (not (listp yas-snippet-dirs))
3821 (setq yas-snippet-dirs (list yas-snippet-dirs)))
3822 (add-to-list 'yas-snippet-dirs
3823 (concat (file-name-directory (locate-library "elpy"))
3827 ;; Now load yasnippets.
3830 (elpy-use-ipython)))
3835 #+BEGIN_SRC emacs-lisp :tangle no
3836 (autoload 'python-mode "python-mode" "Python Mode." t)
3837 (add-auto-mode 'python-mode "\\.py\\'")
3838 (add-auto-mode 'python-mode "\\.py$")
3839 (add-auto-mode 'python-mode "SConstruct\\'")
3840 (add-auto-mode 'python-mode "SConscript\\'")
3841 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
3844 (set-variable 'py-indent-offset 4)
3845 (set-variable 'py-smart-indentation nil)
3846 (set-variable 'indent-tabs-mode nil)
3847 (define-key python-mode-map "\C-m" 'newline-and-indent)
3848 (turn-on-eldoc-mode)
3849 (defun python-auto-fill-comments-only ()
3851 (set (make-local-variable 'fill-nobreak-predicate)
3853 (not (python-in-string/comment)))))
3854 (add-hook 'python-mode-hook
3856 (python-auto-fill-comments-only)))
3858 (autoload 'pymacs-apply "pymacs")
3859 (autoload 'pymacs-call "pymacs")
3860 (autoload 'pymacs-eval "pymacs" nil t)
3861 (autoload 'pymacs-exec "pymacs" nil t)
3862 (autoload 'pymacs-load "pymacs" nil t))
3865 If an =ipython= executable is on the path, then assume that IPython is
3866 the preferred method python evaluation.
3867 #+BEGIN_SRC emacs-lisp :tangle no
3868 (when (executable-find "ipython")
3870 (setq org-babel-python-mode 'python-mode))
3872 (setq python-shell-interpreter "ipython")
3873 (setq python-shell-interpreter-args "")
3874 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
3875 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
3876 (setq python-shell-completion-setup-code
3877 "from IPython.core.completerlib import module_completion")
3878 (setq python-shell-completion-module-string-code
3879 "';'.join(module_completion('''%s'''))\n")
3880 (setq python-shell-completion-string-code
3881 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
3883 ** rainbow-delimiters
3884 [2013-04-09 Di 23:38]
3885 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
3886 which highlights parens, brackets, and braces according to their
3887 depth. Each successive level is highlighted a different color. This
3888 makes it easy to spot matching delimiters, orient yourself in the code,
3889 and tell which statements are at the same depth.
3890 #+BEGIN_SRC emacs-lisp :tangle yes
3891 (use-package rainbow-delimiters
3892 :ensure rainbow-delimiters
3894 (global-rainbow-delimiters-mode))
3897 #+BEGIN_SRC emacs-lisp :tangle yes
3898 (use-package rainbow-mode
3899 :ensure rainbow-mode
3900 :diminish rainbow-mode)
3905 #+BEGIN_SRC emacs-lisp :tangle yes
3906 (use-package re-builder
3910 (setq reb-re-syntax 'string))
3913 [2014-05-19 Mo 22:56]
3914 Recentf is a minor mode that builds a list of recently opened
3915 files. This list is is automatically saved across Emacs sessions.
3916 #+BEGIN_SRC emacs-lisp :tangle yes
3917 (use-package recentf
3918 :if (not noninteractive)
3919 :bind ("C-x C-r" . recentf-open-files)
3923 (setq recentf-max-menu-items 25)
3924 (setq recentf-save-file (expand-file-name ".recentf" jj-cache-dir))
3926 (defun recentf-add-dired-directory ()
3927 (if (and dired-directory
3928 (file-directory-p dired-directory)
3929 (not (string= "/" dired-directory)))
3930 (let ((last-idx (1- (length dired-directory))))
3932 (if (= ?/ (aref dired-directory last-idx))
3933 (substring dired-directory 0 last-idx)
3934 dired-directory)))))
3936 (add-hook 'dired-mode-hook 'recentf-add-dired-directory)))
3938 ** Region bindings mode
3939 [2013-05-01 Wed 22:51]
3940 This mode allows to have keybindings that are only alive when the
3941 region is active. Helpful for things that only do any useful action
3942 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
3943 #+BEGIN_SRC emacs-lisp :tangle yes
3944 (use-package region-bindings-mode
3945 :ensure region-bindings-mode
3947 (region-bindings-mode-enable))
3950 [2013-05-22 Wed 22:33]
3951 Programming in ruby...
3954 #+BEGIN_SRC emacs-lisp :tangle yes
3955 (add-auto-mode 'ruby-mode
3956 "Rakefile\\'" "\\.rake\\'" "\.rxml\\'"
3957 "\\.rjs\\'" ".irbrc\\'" "\.builder\\'" "\\.ru\\'"
3958 "\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
3962 #+BEGIN_SRC emacs-lisp :tangle yes
3963 (use-package ruby-mode
3964 :mode ("\\.rb\\'" . ruby-mode)
3965 :interpreter ("ruby" . ruby-mode)
3972 (defvar yari-helm-source-ri-pages
3973 '((name . "RI documentation")
3974 (candidates . (lambda () (yari-ruby-obarray)))
3975 (action ("Show with Yari" . yari))
3976 (candidate-number-limit . 300)
3977 (requires-pattern . 2)
3978 "Source for completing RI documentation."))
3980 (defun helm-yari (&optional rehash)
3981 (interactive (list current-prefix-arg))
3982 (when current-prefix-arg (yari-ruby-obarray rehash))
3983 (helm 'yari-helm-source-ri-pages (yari-symbol-at-point)))))
3985 (defun my-ruby-smart-return ()
3987 (when (memq (char-after) '(?\| ?\" ?\'))
3989 (call-interactively 'newline-and-indent))
3991 (use-package ruby-hash-syntax
3992 :ensure ruby-hash-syntax)
3994 (use-package inf-ruby
3996 :commands inf-ruby-minor-mode
3999 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)
4000 (bind-key "<return>" 'my-ruby-smart-return ruby-mode-map)
4001 ;(bind-key "<tab>" 'indent-for-tab-command ruby-mode-map)
4004 (set (make-local-variable 'yas-fallback-behavior)
4005 '(apply ruby-indent-command . nil))
4006 (bind-key "<tab>" 'yas-expand-from-trigger-key ruby-mode-map)))
4008 ;; Stupidly the non-bundled ruby-mode isn't a derived mode of
4009 ;; prog-mode: we run the latter's hooks anyway in that case.
4010 (add-hook 'ruby-mode-hook
4012 (unless (derived-mode-p 'prog-mode)
4013 (run-hooks 'prog-mode-hook))))
4017 [2013-05-22 Wed 22:40]
4018 Save and restore the desktop
4019 #+BEGIN_SRC emacs-lisp :tangle yes
4020 (setq desktop-path (list jj-cache-dir))
4021 (desktop-save-mode 1)
4022 (defadvice desktop-read (around trace-desktop-errors activate)
4023 (let ((debug-on-error t))
4026 ;;----------------------------------------------------------------------------
4027 ;; Restore histories and registers after saving
4028 ;;----------------------------------------------------------------------------
4029 (use-package session
4030 :if (not noninteractive)
4031 :load-path "site-lisp/session/lisp/"
4034 (setq session-save-file (expand-file-name "session" jj-cache-dir))
4035 (setq desktop-globals-to-save
4036 (append '((extended-command-history . 30)
4037 (file-name-history . 100)
4039 (compile-history . 30)
4040 (minibuffer-history . 50)
4041 (query-replace-history . 60)
4042 (read-expression-history . 60)
4043 (regexp-history . 60)
4044 (regexp-search-ring . 20)
4046 (comint-input-ring . 50)
4047 (shell-command-history . 50)
4049 desktop-missing-file-warning
4053 (session-initialize)
4055 (defun remove-session-use-package-from-settings ()
4056 (when (string= (file-name-nondirectory (buffer-file-name)) "settings.el")
4058 (goto-char (point-min))
4059 (when (re-search-forward "^ '(session-use-package " nil t)
4060 (delete-region (line-beginning-position)
4061 (1+ (line-end-position)))))))
4063 (add-hook 'before-save-hook 'remove-session-use-package-from-settings)
4065 ;; expanded folded secitons as required
4066 (defun le::maybe-reveal ()
4067 (when (and (or (memq major-mode '(org-mode outline-mode))
4068 (and (boundp 'outline-minor-mode)
4069 outline-minor-mode))
4070 (outline-invisible-p))
4071 (if (eq major-mode 'org-mode)
4075 (add-hook 'session-after-jump-to-last-change-hook
4078 (defun save-information ()
4079 (with-temp-message "Saving Emacs information..."
4082 (loop for func in kill-emacs-hook
4083 unless (memq func '(exit-gnus-on-exit server-force-stop))
4086 (unless (or noninteractive
4087 (eq 'listen (process-status server-process)))
4090 (run-with-idle-timer 300 t 'save-information)
4093 (add-hook 'after-init-hook 'session-initialize t))))
4097 [2013-04-21 So 20:25]
4098 Save a bit of history
4099 #+BEGIN_SRC emacs-lisp tangle no
4101 (setq savehist-additional-variables
4102 '(search ring regexp-search-ring kill-ring compile-history))
4103 ;; save every minute
4104 (setq savehist-autosave-interval 60)
4105 (setq savehist-file (expand-file-name "savehist" jj-cache-dir))
4110 Store at which point I have been in files.
4111 #+BEGIN_SRC emacs-lisp :tangle yes
4112 (setq-default save-place t)
4113 (require 'saveplace)
4114 (setq save-place-file (expand-file-name "saved-places" jj-cache-dir))
4117 [2014-06-10 Tue 22:05]
4118 #+BEGIN_SRC emacs-lisp :tangle yes
4119 (use-package simple-httpd
4120 :ensure simple-httpd
4121 :commands (httpd-start httpd-stop)
4124 (setq httpd-root "/srv/www")
4129 Settings for shell scripts
4130 #+BEGIN_SRC emacs-lisp :tangle yes
4131 (use-package sh-script
4135 (defvar sh-script-initialized nil)
4136 (defun initialize-sh-script ()
4137 (unless sh-script-initialized
4138 (setq sh-script-initialized t)
4139 (setq sh-indent-comment t)
4140 (info-lookup-add-help :mode 'shell-script-mode
4143 '(("(bash)Index")))))
4145 (add-hook 'shell-mode-hook 'initialize-sh-script)))
4148 #+BEGIN_SRC emacs-lisp :tangle yes
4149 (use-package sh-toggle
4150 :bind ("C-. C-z" . shell-toggle))
4153 By default, Emacs can update the time stamp for the following two
4154 formats if one exists in the first 8 lines of the file.
4157 #+BEGIN_SRC emacs-lisp :tangle yes
4158 (use-package time-stamp
4159 :commands time-stamp
4162 (add-hook 'write-file-hooks 'time-stamp)
4163 (setq time-stamp-active t))
4166 (setq time-stamp-format "%02H:%02M:%02S (%z) - %02d.%02m.%:y from %u (%U) on %s")
4167 (setq time-stamp-old-format-warn nil)
4168 (setq time-stamp-time-zone nil)))
4172 We configure only a bit of the tiny-tools to load when I should need
4173 them. I don't need much actually, but these things are nice to have.
4175 #+BEGIN_SRC emacs-lisp :tangle yes
4176 (autoload 'turn-on-tinyperl-mode "tinyperl" "" t)
4177 (add-hook 'perl-mode-hook 'turn-on-tinyperl-mode)
4178 (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode)
4180 (autoload 'tinycomment-indent-for-comment "tinycomment" "" t)
4181 (autoload 'tinyeat-forward-preserve "tinyeat" "" t)
4182 (autoload 'tinyeat-backward-preserve "tinyeat" "" t)
4183 (autoload 'tinyeat-kill-line-backward "tinyeat" "" t)
4185 *** Keyboard changes for tiny-tools
4186 #+BEGIN_SRC emacs-lisp :tangle yes
4187 (bind-key "\M-;" 'tinycomment-indent-for-comment)
4188 (bind-key "ESC C-k" 'tinyeat-kill-line-backward)
4189 (bind-key "ESC d" 'tinyeat-forward-preserve)
4190 (bind-key "<M-backspace>" 'tinyeat-backward-preserve)
4191 (bind-key "<S-backspace>" 'tinyeat-delete-whole-word)
4194 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
4195 #+BEGIN_SRC emacs-lisp :tangle yes