1 #+TITLE: emacs.org - Ganneffs emacs configuration
2 #+DESCRIPTION: My current Emacs configuration
3 #+KEYWORDS: org-mode Emacs configuration
4 #+STARTUP: align fold nodlcheck hidestars oddeven lognotestate
5 #+SETUPFILE: ~/.emacs.d/elisp/org-templates/level-0.org
11 :ID: b6e6cf73-9802-4a7b-bd65-fdb6f9745319
13 The following functions are used throughout my config, and so I load
16 safe-load does not break emacs initialization, should a file be
17 unreadable while emacs boots up.
18 #+BEGIN_SRC emacs-lisp
19 (defvar safe-load-error-list ""
20 "*List of files that reported errors when loaded via safe-load")
22 (defun safe-load (file &optional noerror nomessage nosuffix)
23 "Load a file. If error on load, report back, wait for
24 a key stroke then continue on"
26 (condition-case nil (load file noerror nomessage nosuffix)
29 (setq safe-load-error-list (concat safe-load-error-list " " file))
30 (message "****** [Return to continue] Error loading %s" safe-load-error-list )
34 (defun safe-load-check ()
35 "Check for any previous safe-load loading errors. (safe-load.el)"
37 (if (string-equal safe-load-error-list "") ()
38 (message (concat "****** error loading: " safe-load-error-list))))
41 I have some stuff put away in my local dir. I don't want to load it all
42 at startup time, so it is using the autoload feature. For that to work
43 load the loaddefs, so autoload knows where to grab stuff
44 #+BEGIN_SRC emacs-lisp
45 (safe-load (concat jj-elisp-dir "/tiny/loaddefs.el"))
46 (safe-load (concat jj-elisp-local-dir "/loaddefs.el"))
49 Handier way to add modes to auto-mode-alist
50 #+BEGIN_SRC emacs-lisp
51 (defun add-auto-mode (mode &rest patterns)
52 "Add entries to `auto-mode-alist' to use `MODE' for all given file `PATTERNS'."
53 (dolist (pattern patterns)
54 (add-to-list 'auto-mode-alist (cons pattern mode))))
56 *** config helpers use-package/bind-key
57 Helpers for the config
58 https://github.com/jwiegley/use-package
59 #+BEGIN_SRC emacs-lisp
60 (require 'use-package)
64 [2014-05-20 Tue 22:36]
65 #+BEGIN_SRC emacs-lisp
66 (defmacro hook-into-modes (func modes)
67 `(dolist (mode-hook ,modes)
68 (add-hook mode-hook ,func)))
72 The Emacs Lisp Package Archive contains things I want.
73 #+BEGIN_SRC emacs-lisp
74 (when (> emacs-major-version 23)
76 (setq package-user-dir (expand-file-name "elpa" jj-elisp-dir))
77 (dolist (source '(("melpa" . "http://melpa.org/packages/")
78 ("melpa-stable" . "http://stable.melpa.org/packages/")
79 ("marmalade" . "http://marmalade-repo.org/packages/")
80 ("elpy" . "http://jorgenschaefer.github.io/packages/")
81 ("elpa" . "http://elpa.gnu.org/packages/")
83 (add-to-list 'package-archives source t))
90 We need to define the load-path. As I have lots of things I add
91 locally, its getting a few entries. I disliked the repeated
92 /add-to-list/ lines, so I now just take all subdirectories of
93 jj-elisp-dir and add them.
95 #+BEGIN_SRC emacs-lisp
97 (project (directory-files jj-elisp-dir t "\\w+"))
98 (when (file-directory-p project)
99 (if (string= project "emacs23")
100 (when (version< emacs-version "24")
101 (add-to-list 'load-path project))
102 (add-to-list 'load-path project))
103 ;(byte-recompile-directory project 0)
108 Help emacs to find the info files
109 #+BEGIN_SRC emacs-lisp :tangle no
110 (setq Info-directory-list (cons jj-info-dir
111 '("/usr/local/share/info/"
113 "/usr/local/gnu/info/"
114 "/usr/local/gnu/lib/info/"
115 "/usr/local/gnu/lib/emacs/info/"
116 "/usr/local/emacs/info/"
117 "/usr/local/lib/info/"
118 "/usr/local/lib/emacs/info/"
119 "/usr/share/info/emacs-23"
121 "/usr/share/info/")))
122 (setq Info-default-directory-list
123 (cons jj-info-dir Info-default-directory-list))
129 :ID: 0a1560d9-7e55-47ab-be52-b3a8b8eea4aa
131 I dislike the startup message
132 #+BEGIN_SRC emacs-lisp
133 (setq inhibit-splash-screen t)
134 (setq inhibit-startup-message t)
137 Usually I want the lines to break at 72 characters.
138 #+BEGIN_SRC emacs-lisp
139 (setq fill-column 72)
142 And it is nice to have a final newline in files.
143 (Now off, ethan-wspace is doing it better).
144 #+BEGIN_SRC emacs-lisp
145 (setq require-final-newline nil)
146 (setq mode-require-final-newline nil)
149 After I typed 300 characters or took a break for more than a minute it
150 would be nice of emacs to save whatever I am on in one of its auto-save
151 backups. See [[info:emacs#Auto%20Save%20Control][info:emacs#Auto Save Control]] for more details.
152 #+BEGIN_SRC emacs-lisp
153 (setq auto-save-interval 300)
154 (setq auto-save-timeout 60)
157 Set my full name and my default mail address - for whatever wants to use
158 it later. Also, I am using gnus.
159 #+BEGIN_SRC emacs-lisp
160 (setq user-full-name "Joerg Jaspert")
161 (setq user-mail-address "joerg@ganneff.de")
162 (setq mail-user-agent (quote gnus-user-agent))
165 My default mail server. Well, simply a localhost, I have a forwarder that
166 puts mail off the right way, no need for emacs to have any further
168 #+BEGIN_SRC emacs-lisp
169 (setq smtpmail-default-smtp-server "localhost")
170 (setq smtpmail-smtp-server "localhost")
173 Enable automatic handling of compressed files.
174 #+BEGIN_SRC emacs-lisp
175 (auto-compression-mode 1)
178 Emacs forbids a certain set of commands, as they can be very confusing
179 for new users. Enable them.
180 #+BEGIN_SRC emacs-lisp
181 (put 'narrow-to-region 'disabled nil)
182 (put 'narrow-to-page 'disabled nil)
183 (put 'narrow-to-defun 'disabled nil)
184 (put 'upcase-region 'disabled nil)
185 (put 'downcase-region 'disabled nil)
189 I've tried various different fonts and while I like the Terminus font
190 most for my shells, in Emacs Inconsolata clearly wins.
191 #+BEGIN_SRC emacs-lisp
192 (set-frame-font "Inconsolata-14")
195 I always use dark backgrounds, so tell Emacs about it. No need to
197 #+BEGIN_SRC emacs-lisp
198 (setq-default frame-background-mode jj-color-style)
201 And I always liked dark backgrounds with colors setup for them. So I
202 switched through multiple themes doing it in emacs too, but never
203 entirely liked it. Until I found solarized, which is now not only my
204 emacs theme, but also for most of my other software too, especially my
205 shell. Consistent look is great.
206 #+BEGIN_SRC emacs-lisp :tangle no
207 (if (or (> emacs-major-version 23) (boundp 'custom-theme-load-path))
209 (defun jj-init-theme ()
211 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
212 (load-theme 'solarized-light t))
213 (set-face-attribute 'org-date nil :underline nil)
214 (message "Initializing theme solarized-dark")
216 (add-to-list 'custom-theme-load-path jj-theme-dir)
217 (add-hook 'after-init-hook 'jj-init-theme)
219 (add-to-list 'load-path (expand-file-name "emacs-color-theme-solarized" jj-elisp-dir))
220 (require 'color-theme-solarized)
221 (color-theme-solarized-dark)
224 #+BEGIN_SRC emacs-lisp
225 (use-package solarized
226 :load-path "elisp/solarized-emacs"
229 (defun jj-init-theme ()
231 ;; ;; make the fringe stand out from the background
232 (setq solarized-distinct-fringe-background t)
234 ;; ;; Don't change the font for some headings and titles
235 ;; (setq solarized-use-variable-pitch nil)
237 ;; ;; make the modeline high contrast
238 ;; (setq solarized-high-contrast-mode-line t)
240 ;; ;; Use less bolding
241 ;; (setq solarized-use-less-bold t)
243 ;; ;; Use more italics
244 ;; (setq solarized-use-more-italic t)
246 ;; ;; Use less colors for indicators such as git:gutter, flycheck and similar
247 ;; (setq solarized-emphasize-indicators nil)
249 ;; ;; Don't change size of org-mode headlines (but keep other size-changes)
250 ;; (setq solarized-scale-org-headlines nil)
252 ;; ;; Avoid all font-size changes
253 ;; (setq solarized-height-minus-1 1)
254 ;; (setq solarized-height-plus-1 1)
255 ;; (setq solarized-height-plus-2 1)
256 ;; (setq solarized-height-plus-3 1)
257 ;; (setq solarized-height-plus-4 1)
258 (setq x-underline-at-descent-line t)
260 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
261 (load-theme 'solarized-light t))
262 (set-face-attribute 'org-date nil :underline nil)
263 (message "Initializing theme solarized-dark")
265 (add-to-list 'custom-theme-load-path jj-theme-dir)
266 (add-hook 'after-init-hook 'jj-init-theme)
270 Make the fringe (gutter) smaller, the argument is a width in pixels (the default is 8)
271 #+BEGIN_SRC emacs-lisp
272 (if (fboundp 'fringe-mode)
276 A bit more spacing between buffer lines
277 #+BEGIN_SRC emacs-lisp
278 (setq-default line-spacing 0.1)
281 [2013-04-21 So 20:54]
282 I do not want my cursor to blink.
283 #+BEGIN_SRC emacs-lisp
284 (blink-cursor-mode -1)
286 *** Menu, Tool and Scrollbar
287 I don't want to see the menu-bar, tool-bar or scrollbar.
288 #+BEGIN_SRC emacs-lisp
290 (dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode))
291 (when (fboundp mode) (funcall mode -1))))
293 **** When using emacs in daemon mode
294 Emacs has a very nice mode where it detaches itself and runs as daemon -
295 and you can just open /frames/ (windows) from it by using [[http://www.emacswiki.org/emacs/EmacsClient][Emacs
296 Client]]. It's fast, it's nice, it's convinient.
298 Except that Emacs behaves stupid when you do that and ignores your
299 menu/tool/scrollbar settings. Sucks.
301 For them to work even then, we have to do two things.
302 1. We have to set the frame alist. We simple set both,
303 =initial-frame-alist= and =default-frame-alist= to the same value here.
304 #+BEGIN_SRC emacs-lisp
305 (setq initial-frame-alist '(
306 (horizontal-scroll-bars . nil)
307 (vertical-scroll-bars . nil)
310 (setq default-frame-alist (copy-alist initial-frame-alist))
312 2. We have to disable the toolbar using the customize interface, so you
313 can find that in the [[id:0102208d-fdf6-4928-9e40-7e341bd3aa3a][Customized variables]] section.
315 *** Hilight current line in buffer
316 As it says, it does a hilight of the current line.
317 #+BEGIN_SRC emacs-lisp
318 (global-hl-line-mode +1)
320 *** Allow recursive minibuffers
321 This allows (additional) minibuffer commands while in the minibuffer.
322 #+BEGIN_SRC emacs-lisp
323 (setq enable-recursive-minibuffers 't)
326 *** Modeline related changes
327 I want to see line and column numbers, so turn them on.
328 Size indication lets me know how far I am in a buffer.
330 And modeline-posn is great. It will hilight the column number in the
331 modeline in red as soon as you are over the defined limit.
334 #+BEGIN_SRC emacs-lisp
336 (column-number-mode 1)
337 (size-indication-mode 1)
338 (display-time-mode 1)
339 (setq display-time-day-and-date nil)
340 (setq display-time-default-load-average nil)
341 (setq display-time-24hr-format t)
342 (setq modelinepos-column-limit 72)
344 (use-package modeline-posn
345 :ensure modeline-posn
348 (set-face-foreground 'modelinepos-column-warning "grey20")
349 (set-face-background 'modelinepos-column-warning "red")
350 (setq modelinepos-column-limit 72))
355 [2013-04-22 Mon 11:27]
356 The modeline is easily cluttered up with stuff I don't really need to
357 see. So lets hide those. There are two ways, one of them uses diminish
358 to get entirely rid of some modes, the other is a function taken from
359 "Mastering Emacs" which replaces the modes text with an own (set of)
361 #+BEGIN_SRC emacs-lisp
363 (diminish 'auto-fill-function)
364 (defvar mode-line-cleaner-alist
365 `((auto-complete-mode . " α")
366 (yas-minor-mode . " y")
367 (paredit-mode . " π")
371 (lisp-interaction-mode . "λ")
374 (emacs-lisp-mode . "EL")
376 (org-indent-mode . "")
381 "Alist for `clean-mode-line'.
383 When you add a new element to the alist, keep in mind that you
384 must pass the correct minor/major mode symbol and a string you
385 want to use in the modeline *in lieu of* the original.
387 Want some symbols? Go:
389 ;ςερτζθιοπασδφγηξκλυχψωβνμ
390 :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
391 @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
395 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
398 Unfortunately icicles breaks this with the way it adds/removes itself,
399 so take it our for now...
402 Back when I started with text-mode. But nowadays I want default mode to
403 be org-mode - it is just so much better to use. And does sensible things
404 with many README files out there, and various other "crap" you get to
406 #+BEGIN_SRC emacs-lisp :tangle yes
407 (setq-default major-mode 'org-mode)
409 #+BEGIN_SRC emacs-lisp :tangle no
410 (setq initial-major-mode 'org-mode)
414 [2013-04-23 Tue 16:43]
415 Shell. zsh in my case.
416 #+BEGIN_SRC emacs-lisp
417 (setq shell-file-name "zsh")
418 (setq shell-command-switch "-c")
419 (setq explicit-shell-file-name shell-file-name)
420 (setenv "SHELL" shell-file-name)
421 (setq explicit-sh-args '("-login" "-i"))
422 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
423 (setq comint-scroll-to-bottom-on-input t) ; always insert at the bottom
424 (setq comint-scroll-to-bottom-on-output t) ; always add output at the bottom
425 (setq comint-scroll-show-maximum-output t) ; scroll to show max possible output
426 (setq comint-completion-autolist t) ; show completion list when ambiguous
427 (setq comint-input-ignoredups t) ; no duplicates in command history
428 (setq comint-completion-addsuffix t) ; insert space/slash after file completion
429 (setq comint-buffer-maximum-size 20000) ; max lenght of the buffer in lines
430 (setq comint-prompt-read-only nil) ; if this is t, it breaks shell-command
434 ** Miscellaneous stuff
435 Searches and matches should ignore case.
436 #+BEGIN_SRC emacs-lisp
437 (setq-default case-fold-search t)
440 Which buffers to get rid off at midnight.
441 #+BEGIN_SRC emacs-lisp
442 (setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
443 "*Man " "*Buffer List*"
449 "*magit" "*Calendar")))
452 Don't display a cursor in non-selected windows.
453 #+BEGIN_SRC emacs-lisp
454 (setq-default cursor-in-non-selected-windows nil)
457 What should be displayed in the mode-line for files with those types
459 #+BEGIN_SRC emacs-lisp
460 (setq eol-mnemonic-dos "(DOS)")
461 (setq eol-mnemonic-mac "(Mac)")
464 Much larger threshold for garbage collection prevents it to run too often.
465 #+BEGIN_SRC emacs-lisp
466 (setq gc-cons-threshold 48000000)
469 #+BEGIN_SRC emacs-lisp
470 (setq max-lisp-eval-depth 1000)
471 (setq max-specpdl-size 3000)
475 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
476 #+BEGIN_SRC emacs-lisp
477 (defun unfill-paragraph ()
478 "Takes a multi-line paragraph and makes it into a single line of text."
480 (let ((fill-column (point-max)))
481 (fill-paragraph nil)))
482 (bind-key "H-u" 'unfill-paragraph)
485 #+BEGIN_SRC emacs-lisp
486 (setq-default indicate-empty-lines t)
487 (setq sentence-end-double-space nil)
490 Hilight annotations in comments, like FIXME/TODO/...
491 #+BEGIN_SRC emacs-lisp
492 (add-hook 'prog-mode-hook 'font-lock-comment-annotations)
496 #+BEGIN_SRC emacs-lisp
497 (setq browse-url-browser-function (quote browse-url-generic))
498 (setq browse-url-generic-program "/usr/bin/x-www-browser")
501 *** When saving a script - make it executable
502 #+BEGIN_SRC emacs-lisp
503 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
507 #+BEGIN_SRC emacs-lisp
511 (add-hook 'after-init-hook 'server-start)))
514 ** Customized variables
515 [2013-05-02 Thu 22:14]
516 The following contains a set of variables i may reasonably want to
517 change on other systems - which don't affect the init file loading
518 process. So I *can* use the customization interface for it...
519 #+BEGIN_SRC emacs-lisp
520 (defgroup ganneff nil
521 "Modify ganneffs settings"
524 (defgroup ganneff-org-mode nil
525 "Ganneffs org-mode settings"
526 :tag "Ganneffs org-mode settings"
528 :link '(custom-group-link "ganneff"))
530 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
531 "ID of the organization task."
532 :tag "Organization Task ID"
534 :group 'ganneff-org-mode)
536 (defcustom org-my-archive-expiry-days 2
537 "The number of days after which a completed task should be auto-archived.
538 This can be 0 for immediate, or a floating point value."
539 :tag "Archive expiry days"
541 :group 'ganneff-org-mode)
546 [2013-05-21 Tue 23:22]
547 Restore removed var alias, used by ruby-electric-brace and others
548 #+BEGIN_SRC emacs-lisp
549 (unless (boundp 'last-command-char)
550 (defvaralias 'last-command-char 'last-command-event))
552 * Customized variables
554 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
556 Of course I want to be able to use the customize interface, and some
557 things can only be set via it (or so they say). I usually prefer to put
558 things I keep for a long while into statements somewhere else, not just
559 custom-set here, but we need it anyways.
561 #+BEGIN_SRC emacs-lisp
562 (setq custom-file jj-custom-file)
563 (safe-load custom-file)
566 The source of this is:
567 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
568 * Extra modes and their configuration
570 A defined abbrev is a word which expands, if you insert it, into some
571 different text. Abbrevs are defined by the user to expand in specific
573 #+BEGIN_SRC emacs-lisp
575 :commands abbrev-mode
576 :diminish abbrev-mode
578 (hook-into-modes #'abbrev-mode '(text-mode-hook))
581 (setq save-abbrevs 'silently)
582 (setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
583 (if (file-exists-p abbrev-file-name)
584 (quietly-read-abbrev-file))
586 (add-hook 'expand-load-hook
588 (add-hook 'expand-expand-hook 'indent-according-to-mode)
589 (add-hook 'expand-jump-hook 'indent-according-to-mode)))))
592 [2013-04-28 So 11:26]
593 Quickly move around in buffers.
594 #+BEGIN_SRC emacs-lisp
595 (use-package ace-jump-mode
596 :ensure ace-jump-mode
597 :commands ace-jump-mode
598 :bind ("H-SPC" . ace-jump-mode))
601 [2013-04-21 So 20:27]
602 Use H-w to switch windows
603 #+BEGIN_SRC emacs-lisp
604 (use-package ace-window
607 :bind ("H-w" . ace-window))
610 [2014-10-27 Mon 13:08]
611 electric-indent-mode is enough to keep your code nicely aligned when
612 all you do is type. However, once you start shifting blocks around,
613 transposing lines, or slurping and barfing sexps, indentation is bound
616 aggressive-indent-mode is a minor mode that keeps your code always
617 indented. It reindents after every command, making it more reliable
618 than electric-indent-mode.
619 #+BEGIN_SRC emacs-lisp
620 (use-package aggressive-indent
621 :ensure aggressive-indent
622 :commands (aggressive-indent-mode global-aggressive-indent-mode)
625 (global-aggressive-indent-mode 0)
626 (setq aggressive-indent-comments-too 0)
627 (add-to-list 'aggressive-indent-excluded-modes 'html-mode)
631 [2014-06-01 Sun 23:02]
632 Provides a minor mode which displays current match and total matches
633 information in the mode-line in various search modes.
634 #+BEGIN_SRC emacs-lisp
641 (global-anzu-mode 1))
644 (setq anzu-search-threshold 1000)
645 (set-face-attribute 'anzu-mode-line nil :foreground "yellow" :weight 'bold)))
648 [2014-05-21 Wed 00:33]
649 #+BEGIN_SRC emacs-lisp
651 :commands (ascii-on ascii-toggle ascii-display)
652 :bind (("C-c e A" . ascii-toggle))
655 (defun ascii-toggle ()
657 (defvar ascii-display nil)
662 (bind-key "C-c e A" 'ascii-toggle)))
665 #+BEGIN_SRC emacs-lisp
666 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
667 (setq TeX-auto-save t)
668 (setq TeX-parse-self t)
669 (setq TeX-PDF-mode t)
671 ** auto-complete mode
672 [2013-04-27 Sa 16:33]
673 And aren't we all lazy? I definitely am, and I like my emacs doing as
674 much possible work for me as it can.
675 So here, auto-complete-mode, which lets emacs do this, based on what I
677 #+BEGIN_SRC emacs-lisp
678 (use-package auto-complete-config
679 :ensure auto-complete
684 ;; hook AC into completion-at-point
685 (defun sanityinc/auto-complete-at-point ()
686 (when (and (not (minibufferp))
687 (fboundp 'auto-complete-mode)
690 (defun set-auto-complete-as-completion-at-point-function ()
691 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
692 ;; Exclude very large buffers from dabbrev
693 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
694 (< (buffer-size other-buffer) (* 1 1024 1024)))
699 ;; custom keybindings to use tab, enter and up and down arrows
700 (bind-key "\t" 'ac-expand ac-complete-mode-map)
701 (bind-key "\r" 'ac-complete ac-complete-mode-map)
702 (bind-key "M-n" 'ac-next ac-complete-mode-map)
703 (bind-key "M-p" 'ac-previous ac-complete-mode-map)
704 (bind-key "C-s" 'ac-isearch ac-completing-map)
705 (bind-key "M-TAB" 'auto-complete ac-mode-map)
707 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
708 (setq ac-use-comphist t)
709 (setq ac-expand-on-auto-complete nil)
711 (setq ac-auto-start 3)
713 (setq ac-menu-height 15)
714 (setq ac-quick-help-delay 0.5)
715 (setq ac-use-fuzzy t)
717 (ac-flyspell-workaround)
719 ;; use 't when auto-complete is disabled
720 (setq tab-always-indent 'complete)
721 (add-to-list 'completion-styles 'initials t)
723 ;; Use space and punctuation to accept the current the most likely completion.
724 (setq auto-completion-syntax-alist (quote (global accept . word)))
725 ;; Avoid completion for short trivial words.
726 (setq auto-completion-min-chars (quote (global . 3)))
727 (setq completion-use-dynamic t)
729 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
731 ;; Exclude very large buffers from dabbrev
732 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
734 (use-package ac-dabbrev
737 (set-default 'ac-sources
740 ac-source-words-in-buffer
741 ac-source-words-in-same-mode-buffers
742 ; ac-source-words-in-all-buffer
745 (dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
746 sass-mode yaml-mode csv-mode espresso-mode haskell-mode
747 html-mode nxml-mode sh-mode smarty-mode clojure-mode
748 lisp-mode textile-mode markdown-mode tuareg-mode python-mode
749 js3-mode css-mode less-css-mode sql-mode ielm-mode))
750 (add-to-list 'ac-modes mode))
752 (add-hook 'latex-mode-hook 'auto-complete-mode)
753 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
754 (add-hook 'prog-mode-hook 'auto-complete-mode)
755 (add-hook 'org-mode-hook 'auto-complete-mode)))
760 When files change outside emacs for whatever reason I want emacs to deal
761 with it. Not to have to revert buffers myself
762 #+BEGIN_SRC emacs-lisp
763 (use-package autorevert
764 :commands auto-revert-mode
765 :diminish auto-revert-mode
768 (setq global-auto-revert-mode t)
769 (setq global-auto-revert-non-file-buffers t)
770 (global-auto-revert-mode)))
774 Emacs should keep backup copies of files I edit, but I do not want them
775 to clutter up the filesystem everywhere. So I put them into one defined
776 place, backup-directory, which even contains my username (for systems
777 where =temporary-file-directory= is not inside my home).
778 #+BEGIN_SRC emacs-lisp
779 (use-package backups-mode
780 :load-path "elisp/backups-mode"
781 :bind (("\C-cv" . save-version)
782 ("\C-cb" . list-backups)
783 ("\C-ck" . kill-buffer-prompt)
784 ("\C-cw" . backup-walker-start))
787 (setq backup-directory jj-backup-directory)
788 ;(setq tramp-backup-directory (concat jj-backup-directory "/tramp"))
789 ;(if (not (file-exists-p tramp-backup-directory))
790 ; (make-directory tramp-backup-directory))
791 ;(setq tramp-backup-directory-alist `((".*" . ,tramp-backup-directory)))
792 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
793 (setq auto-save-list-file-prefix (concat jj-backup-directory ".auto-saves-"))
794 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
796 (setq version-control t) ;; Use version numbers for backups
797 (setq kept-new-versions 10) ;; Number of newest versions to keep
798 (setq kept-old-versions 2) ;; Number of oldest versions to keep
799 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
800 (setq backup-by-copying t)
801 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
802 (setq make-backup-files t)
804 (defadvice kill-buffer (around kill-buffer)
805 "Always save before killing a file buffer"
806 (when (and (buffer-modified-p)
808 (file-exists-p (buffer-file-name)))
811 (ad-activate 'kill-buffer)
813 (defadvice save-buffers-kill-emacs (around save-buffers-kill-emacs)
814 "Always save before killing emacs"
815 (save-some-buffers t)
817 (ad-activate 'save-buffers-kill-emacs)
819 (defun kill-buffer-prompt ()
820 "Allows one to kill a buffer without saving it.
821 This is necessary since once you start backups-mode all file based buffers
822 are saved automatically when they are killed"
824 (if (and (buffer-modified-p) (buffer-file-name) (file-exists-p (buffer-file-name)) (y-or-n-p "Save buffer?"))
826 (set-buffer-modified-p nil))
829 (setq backup-enable-predicate
831 (and (normal-backup-enable-predicate name)
833 (let ((method (file-remote-p name 'method)))
834 (when (stringp method)
835 (member method '("su" "sudo"))))))))))
839 [2014-12-11 Thu 11:31]
840 #+BEGIN_SRC emacs-lisp
841 (use-package browse-kill-ring
842 :commands (browse-kill-ring browse-kill-ring-mode)
843 :bind ("M-y" . browse-kill-ring)
847 [2014-06-10 Tue 22:20]
848 #+BEGIN_SRC emacs-lisp
850 :commands (cal/insert)
851 :bind ("C-c c" . cal/insert)
854 ; Weeks start on Monday, not sunday.
855 (setq calendar-week-start-day 1)
857 ; Display ISO week numbers in Calendar Mode
858 (copy-face font-lock-constant-face 'calendar-iso-week-face)
859 (set-face-attribute 'calendar-iso-week-face nil :height 0.7)
860 (setq calendar-intermonth-text
864 (calendar-iso-from-absolute
865 (calendar-absolute-from-gregorian (list month day year)))))
866 'font-lock-face 'calendar-iso-week-face))
867 (copy-face 'default 'calendar-iso-week-header-face)
868 (set-face-attribute 'calendar-iso-week-header-face nil :height 0.7)
869 (setq calendar-intermonth-header
870 (propertize "Wk" ; or e.g. "KW" in Germany
871 'font-lock-face 'calendar-iso-week-header-face))))
876 [2013-05-21 Tue 23:18]
877 #+BEGIN_SRC emacs-lisp
878 (use-package crontab-mode
880 :commands crontab-mode
881 :mode ("\\.?cron\\(tab\\)?\\'" . crontab-mode))
885 web-mode takes over, see [[*web-mode][web-mode]]
886 #+BEGIN_SRC emacs-lisp :tangle no
887 (use-package css-mode
888 :mode ("\\.css\\'" . css-mode)
893 (use-package flymake-css
897 (defun maybe-flymake-css-load ()
898 "Activate flymake-css as necessary, but not in derived modes."
899 (when (eq major-mode 'css-mode)
901 (add-hook 'css-mode-hook 'maybe-flymake-css-load)))
902 ;;; Auto-complete CSS keywords
903 (eval-after-load 'auto-complete
905 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
906 (add-hook hook 'ac-css-mode-setup))))))
910 I know that this lets it look "more like windows", but I don't much care
911 about its paste/copy/cut keybindings, the really nice part is the great
912 support for rectangular regions, which I started to use a lot since I
913 know this mode. The normal keybindings for those are just to useless.
914 #+BEGIN_SRC emacs-lisp
916 (setq cua-enable-cua-keys (quote shift))
919 Luckily cua-mode easily supports this, with the following line I just
920 get the CUA selection and rectangle stuff, not the keybindings. Yes,
921 even though the above =cua-enable-cua-keys= setting would only enable
922 them if the selection is done when the region was marked with a shifted
924 #+BEGIN_SRC emacs-lisp
925 (cua-selection-mode t)
929 #+BEGIN_SRC emacs-lisp
930 (require 'dpkg-dev-el-loaddefs nil 'noerror)
931 (require 'debian-el-loaddefs nil 'noerror)
933 (setq debian-changelog-full-name "Joerg Jaspert")
934 (setq debian-changelog-mailing-address "joerg@debian.org")
938 #+BEGIN_SRC emacs-lisp
939 (use-package diff-mode
941 :mode (("\\.diff" . diff-mode))
943 (use-package diff-mode-))
947 #+BEGIN_SRC emacs-lisp
949 :commands (dired dired-other-window dired-other-frame dired-noselect
950 dired-mode dired-jump)
951 :defines (dired-omit-regexp-orig)
954 (setq diredp-hide-details-initially-flag nil))
957 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
958 (setq dired-dwim-target t)
959 (setq dired-listing-switches "-alh")
960 (setq dired-listing-switches "-alXh --group-directories-first")
961 (setq dired-recursive-copies (quote top))
962 (setq dired-recursive-deletes (quote top))
963 (setq dired-guess-shell-alist-user
964 '(("\\.pdf\\'" "mupdf" "evince")
965 ("\\.\\(?:djvu\\|eps\\)\\'" "evince")
966 ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "eog")
967 ("\\.\\(?:xcf\\)\\'" "gimp")
968 ("\\.csv\\'" "libreoffice")
969 ("\\.tex\\'" "pdflatex" "latex")
970 ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\)\\(?:\\.part\\)?\\'" "vlc")
971 ("\\.html?\\'" "conkeror")))
973 (bind-key "F" 'find-name-dired dired-mode-map)
978 (use-package dired-x)
980 (use-package dired-single
984 (bind-key "<return>" 'dired-single-buffer dired-mode-map)
985 (bind-key "<mouse-1>" 'dired-single-buffer-mouse dired-mode-map)
988 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
994 (setq wdired-allow-to-change-permissions t)
995 (bind-key "r" 'wdired-change-to-wdired-mode dired-mode-map)))
997 (use-package gnus-dired
998 :commands (gnus-dired-attach gnus-dired-mode)
1001 ;;(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
1002 (bind-key "a" 'gnus-dired-attach dired-mode-map)))
1007 (defvar mark-files-cache (make-hash-table :test #'equal))
1009 (defun mark-similar-versions (name)
1011 (if (string-match "^\\(.+?\\)-[0-9._-]+$" pat)
1012 (setq pat (match-string 1 pat)))
1013 (or (gethash pat mark-files-cache)
1014 (ignore (puthash pat t mark-files-cache)))))
1016 (defun dired-mark-similar-version ()
1018 (setq mark-files-cache (make-hash-table :test #'equal))
1019 (dired-mark-sexp '(mark-similar-versions name)))
1021 (defun dired-package-initialize ()
1022 (unless (featurep 'runner)
1023 (bind-key "M-!" 'async-shell-command dired-mode-map)
1024 (unbind-key "M-s f" dired-mode-map)
1026 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1027 "Make sure to remove \"Omit\" from the modeline."
1028 (diminish 'dired-omit-mode) dired-mode-map)
1030 ;; Omit files that Git would ignore
1031 (defun dired-omit-regexp ()
1032 (let ((file (expand-file-name ".git"))
1034 (while (and (not (file-exists-p file))
1037 (file-name-directory
1038 (directory-file-name
1039 (file-name-directory file))))
1040 ;; Give up if we are already at the root dir.
1041 (not (string= (file-name-directory file)
1043 ;; Move up to the parent dir and try again.
1044 (setq file (expand-file-name ".git" parent-dir)))
1045 ;; If we found a change log in a parent, use that.
1046 (if (file-exists-p file)
1047 (let ((regexp (funcall dired-omit-regexp-orig))
1049 (shell-command-to-string "git clean -d -x -n")))
1050 (if (= 0 (length omitted-files))
1054 (if (> (length regexp) 0)
1063 (if (= ?/ (aref str (1- (length str))))
1067 (split-string omitted-files "\n" t)
1070 (funcall dired-omit-regexp-orig))))))
1072 (add-hook 'dired-mode-hook 'dired-package-initialize)
1074 (defun dired-double-jump (first-dir second-dir)
1076 (list (read-directory-name "First directory: "
1077 (expand-file-name "~")
1078 nil nil "/Downloads/")
1079 (read-directory-name "Second directory: "
1080 (expand-file-name "~")
1083 (dired-other-window second-dir))
1084 (bind-key "C-c J" 'dired-double-jump)
1086 (defun dired-back-to-top ()
1088 (goto-char (point-min))
1089 (dired-next-line 4))
1091 (define-key dired-mode-map
1092 (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
1094 (defun dired-jump-to-bottom ()
1096 (goto-char (point-max))
1097 (dired-next-line -1))
1099 (define-key dired-mode-map
1100 (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)))
1103 ** discover-my-major
1104 [2014-06-01 Sun 23:32]
1105 Discover key bindings and their meaning for the current Emacs major mode.
1106 #+BEGIN_SRC emacs-lisp
1107 (use-package discover-my-major
1108 :ensure discover-my-major
1109 :commands discover-my-major
1110 :bind ("C-h C-m" . discover-my-major))
1113 EasyPG is a GnuPG interface for Emacs.
1114 Bookmark: [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1115 #+BEGIN_SRC emacs-lisp
1116 (use-package epa-file
1120 ;; I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1121 (defadvice epg--start (around advice-epg-disable-agent disable)
1122 "Don't allow epg--start to use gpg-agent in plain text
1124 (if (display-graphic-p)
1126 (let ((agent (getenv "GPG_AGENT_INFO")))
1127 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
1129 (setenv "GPG_AGENT_INFO" agent))))
1130 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
1131 (ad-activate 'epg--start)
1135 [2013-04-21 So 20:36]
1136 ediff - don't start another frame
1137 #+BEGIN_SRC emacs-lisp
1141 (defvar ctl-period-equals-map)
1142 (define-prefix-command 'ctl-period-equals-map)
1143 (bind-key "C-. =" 'ctl-period-equals-map)
1144 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
1146 :bind (("C-. = b" . ediff-buffers)
1147 ("C-. = B" . ediff-buffers3)
1148 ("C-. = =" . ediff-files)
1149 ("C-. = f" . ediff-files)
1150 ("C-. = F" . ediff-files3)
1151 ("C-. = r" . ediff-revision)
1152 ("C-. = p" . ediff-patch-file)
1153 ("C-. = P" . ediff-patch-buffer)
1154 ("C-. = l" . ediff-regions-linewise)
1155 ("C-. = w" . ediff-regions-wordwise))
1157 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1158 (setq ediff-split-window-function 'split-window-horizontally)
1164 EMMS is the Emacs Multimedia System.
1165 #+BEGIN_SRC emacs-lisp :tangle no
1166 (require 'emms-source-file)
1167 (require 'emms-source-playlist)
1168 (require 'emms-info)
1169 (require 'emms-cache)
1170 (require 'emms-playlist-mode)
1171 (require 'emms-playing-time)
1172 (require 'emms-player-mpd)
1173 (require 'emms-playlist-sort)
1174 (require 'emms-mark)
1175 (require 'emms-browser)
1176 (require 'emms-lyrics)
1177 (require 'emms-last-played)
1178 (require 'emms-score)
1179 (require 'emms-tag-editor)
1180 (require 'emms-history)
1181 (require 'emms-i18n)
1183 (setq emms-playlist-default-major-mode 'emms-playlist-mode)
1184 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
1185 (emms-playing-time 1)
1187 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
1188 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
1190 (when (fboundp 'emms-cache) ; work around compiler warning
1192 (setq emms-score-default-score 3)
1194 (defun emms-mpd-init ()
1195 "Connect Emms to mpd."
1197 (emms-player-mpd-connect))
1200 (require 'emms-player-mpd)
1201 (setq emms-player-mpd-server-name "localhost")
1202 (setq emms-player-mpd-server-port "6600")
1203 (add-to-list 'emms-info-functions 'emms-info-mpd)
1204 (add-to-list 'emms-player-list 'emms-player-mpd)
1205 (setq emms-volume-change-function 'emms-volume-mpd-change)
1206 (setq emms-player-mpd-sync-playlist t)
1208 (setq emms-source-file-default-directory "/var/lib/mpd/music")
1209 (setq emms-player-mpd-music-directory "/var/lib/mpd/music")
1210 (setq emms-info-auto-update t)
1211 (setq emms-lyrics-scroll-p t)
1212 (setq emms-lyrics-display-on-minibuffer t)
1213 (setq emms-lyrics-display-on-modeline nil)
1214 (setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
1216 (setq emms-last-played-format-alist
1217 '(((emms-last-played-seconds-today) . "%H:%M")
1218 (604800 . "%a %H:%M") ; this week
1219 ((emms-last-played-seconds-month) . "%d.%m.%Y")
1220 ((emms-last-played-seconds-year) . "%d.%m.%Y")
1221 (t . "Never played")))
1224 (defun my-describe (track)
1225 (let* ((empty "...")
1226 (name (emms-track-name track))
1227 (type (emms-track-type track))
1228 (short-name (file-name-nondirectory name))
1229 (play-count (or (emms-track-get track 'play-count) 0))
1230 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
1231 (artist (or (emms-track-get track 'info-artist) empty))
1232 (year (emms-track-get track 'info-year))
1233 (playing-time (or (emms-track-get track 'info-playing-time) 0))
1234 (min (/ playing-time 60))
1235 (sec (% playing-time 60))
1236 (album (or (emms-track-get track 'info-album) empty))
1237 (tracknumber (emms-track-get track 'info-tracknumber))
1238 (short-name (file-name-sans-extension
1239 (file-name-nondirectory name)))
1240 (title (or (emms-track-get track 'info-title) short-name))
1241 (rating (emms-score-get-score name))
1244 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
1245 (emms-last-played-format-date last-played)
1249 (if (and tracknumber ; tracknumber
1250 (not (zerop (string-to-number tracknumber))))
1251 (format "%02d" (string-to-number tracknumber))
1255 (make-string rating rate-char)))
1258 (setq emms-track-description-function 'my-describe)
1260 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
1261 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
1262 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
1263 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
1264 (global-set-key (kbd "H-<f9> x") 'emms-start)
1265 (global-set-key (kbd "H-<f9> v") 'emms-stop)
1266 (global-set-key (kbd "H-<f9> n") 'emms-next)
1267 (global-set-key (kbd "H-<f9> p") 'emms-previous)
1268 (global-set-key (kbd "H-<f9> o") 'emms-show)
1269 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
1270 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
1271 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
1272 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
1273 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
1275 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
1276 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
1277 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
1278 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
1280 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
1281 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
1282 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
1283 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
1285 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
1286 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
1287 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
1288 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
1290 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
1291 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
1292 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
1293 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
1294 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
1295 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
1297 (define-key emms-playlist-mode-map "x" 'emms-start)
1298 (define-key emms-playlist-mode-map "v" 'emms-stop)
1299 (define-key emms-playlist-mode-map "n" 'emms-next)
1300 (define-key emms-playlist-mode-map "p" 'emms-previous)
1302 (setq emms-playlist-buffer-name "*EMMS Playlist*"
1303 emms-playlist-mode-open-playlists t)
1309 'emms-browser-artist-face nil
1314 (setq emms-player-mpd-supported-regexp
1315 (or (emms-player-mpd-get-supported-regexp)
1316 (concat "\\`http://\\|"
1317 (emms-player-simple-regexp
1318 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
1319 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
1323 Basic settings for emacs integrated shell
1324 #+BEGIN_SRC emacs-lisp :tangle no
1330 (defun eshell-initialize ()
1331 (defun eshell-spawn-external-command (beg end)
1332 "Parse and expand any history references in current input."
1335 (when (looking-back "&!" beg)
1336 (delete-region (match-beginning 0) (match-end 0))
1338 (insert "spawn "))))
1339 (add-hook 'eshell-expand-input-functions 'eshell-spawn-external-command)
1340 (eval-after-load "em-unix"
1342 (unintern 'eshell/su)
1343 (unintern 'eshell/sudo))))
1344 (add-hook 'eshell-first-time-mode-hook 'eshell-initialize)
1348 (defalias 'emacs 'find-file)
1349 (defalias 'ec 'find-file)
1350 (defalias 'e 'find-file)
1354 (use-package 'em-cmpl)
1355 (use-package 'em-prompt)
1356 (use-package 'em-term)
1358 (setq eshell-cmpl-cycle-completions nil
1359 eshell-save-history-on-exit t
1360 eshell-buffer-maximum-lines 20000
1361 eshell-history-size 350
1362 eshell-buffer-shorthand t
1363 eshell-highlight-prompt t
1364 eshell-plain-echo-behavior t
1365 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
1367 (setenv "PAGER" "cat")
1368 (setq eshell-visual-commands
1369 '("less" "tmux" "htop" "top" "bash" "zsh" "tail"))
1370 (setq eshell-visual-subcommands
1371 '(("git" "log" "l" "diff" "show")))
1373 (add-to-list 'eshell-command-completions-alist
1374 '("gunzip" "gz\\'"))
1375 (add-to-list 'eshell-command-completions-alist
1376 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
1378 (when (not (functionp 'eshell/rgrep))
1379 (defun eshell/rgrep (&rest args)
1380 "Use Emacs grep facility instead of calling external grep."
1381 (eshell-grep "rgrep" args t)))
1383 ;(set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
1384 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
1385 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
1386 (add-hook 'eshell-preoutput-filter-functions
1387 'ansi-color-filter-apply)
1388 ;; Prompt with a bit of help from http://www.emacswiki.org/emacs/EshellPrompt
1390 (defmacro with-face (str &rest properties)
1391 `(propertize ,str 'face (list ,@properties)))
1393 (defun eshell/abbr-pwd ()
1394 (let ((home (getenv "HOME"))
1395 (path (eshell/pwd)))
1397 ((string-equal home path) "~")
1398 ((f-ancestor-of? home path) (concat "~/" (f-relative path home)))
1401 (defun eshell/my-prompt ()
1402 (let ((header-bg "#161616"))
1404 (with-face user-login-name :foreground "cyan")
1405 (with-face (concat "@" hostname) :foreground "white")
1407 (with-face (eshell/abbr-pwd) :foreground "#009900")
1408 (if (= (user-uid) 0)
1409 (with-face "#" :foreground "red")
1410 (with-face "$" :foreground "#69b7f0"))
1413 (use-package eshell-prompt-extras
1417 (setq eshell-highlight-prompt nil
1418 ;; epe-git-dirty-char "Ϟ"
1419 epe-git-dirty-char "*"
1420 eshell-prompt-function 'epe-theme-dakrone)))
1422 (defun eshell/magit ()
1423 "Function to open magit-status for the current directory"
1425 (magit-status default-directory)
1428 (setq eshell-prompt-function 'eshell/my-prompt)
1429 (setq eshell-highlight-prompt nil)
1430 (setq eshell-prompt-regexp "^[^#$\n]+[#$] ")))
1435 Incremental search is great, but annoyingly you need to type whatever
1436 you want. If you want to search for just the next (or previous)
1437 occurence of what is at your cursor position use the following.
1438 *C-x* will insert the current word while *M-up* and *M-down* will just
1439 jump to the next/previous occurence of it.
1440 #+BEGIN_SRC emacs-lisp
1441 (bind-key "C-x" 'sacha/isearch-yank-current-word isearch-mode-map)
1442 (bind-key* "<M-up>" 'sacha/search-word-backward)
1443 (bind-key* "<M-down>" 'sacha/search-word-forward)
1446 *** Frame configuration
1447 I want to see the buffername and its size, not the host I am on in my
1449 #+BEGIN_SRC emacs-lisp
1450 (setq frame-title-format "%b (%i)")
1453 *** Protect some buffers
1454 I don't want some buffers to be killed, **scratch** for example.
1455 In the past I had a long function that just recreated them, but the
1456 =keep-buffers= package is easier.
1457 #+BEGIN_SRC emacs-lisp
1458 (use-package keep-buffers
1461 (keep-buffers-mode 1)
1462 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
1463 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
1464 (push '("\\`*Group" . nil) keep-buffers-protected-alist)
1469 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
1471 #+BEGIN_SRC emacs-lisp
1472 (defalias 'yes-or-no-p 'y-or-n-p)
1475 *** Language/i18n stuff
1476 In this day and age, UTF-8 is the way to go.
1477 #+BEGIN_SRC emacs-lisp
1478 (set-language-environment 'utf-8)
1479 (set-default-coding-systems 'utf-8)
1480 (set-terminal-coding-system 'utf-8)
1481 (set-keyboard-coding-system 'utf-8)
1482 (set-clipboard-coding-system 'utf-8)
1483 (prefer-coding-system 'utf-8)
1484 (set-charset-priority 'unicode)
1485 (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
1486 (when (display-graphic-p)
1487 (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
1490 *** Hilight matching parentheses
1491 While I do have the nifty shortcut to jump to the other parentheses,
1492 hilighting them makes it obvious where they are.
1493 #+BEGIN_SRC emacs-lisp
1494 (use-package mic-paren
1498 *** Kill other buffers
1499 While many editors allow you to close "all the other files, not the one
1500 you are in", emacs doesn't have this... Except, now it will.
1501 (Update 30.05.2014: Not used ever, deactivated)
1502 #+BEGIN_SRC emacs-lisp :tangle no
1503 (bind-key "C-c k" 'prelude-kill-other-buffers)
1506 Default scrolling behaviour in emacs is a bit annoying, who wants to
1508 #+BEGIN_SRC emacs-lisp
1509 (setq scroll-margin 0)
1510 (setq scroll-conservatively 100000)
1511 (setq scroll-up-aggressively 0.0)
1512 (setq scroll-down-aggressively 0.0)
1513 (setq scroll-preserve-screen-position t)
1516 *** Copy/Paste with X
1517 [2013-04-09 Di 23:31]
1518 The default how emacs handles cutting/pasting with the primary selection
1519 changed in emacs24. I am used to the old way, so get it back.
1520 #+BEGIN_SRC emacs-lisp
1521 (setq select-enable-primary t)
1522 (setq select-enable-clipboard nil)
1523 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
1524 (setq mouse-drag-copy-region t)
1526 *** Global keyboard changes not directly related to a mode
1527 Disable /suspend_frame/ function, I dislike it.
1528 #+BEGIN_SRC emacs-lisp
1530 (unbind-key "C-x C-z")
1533 http://endlessparentheses.com/kill-entire-line-with-prefix-argument.html?source=rss
1534 #+BEGIN_SRC emacs-lisp
1535 (defmacro bol-with-prefix (function)
1536 "Define a new function which calls FUNCTION.
1537 Except it moves to beginning of line before calling FUNCTION when
1538 called with a prefix argument. The FUNCTION still receives the
1540 (let ((name (intern (format "endless/%s-BOL" function))))
1544 "Call `%s', but move to BOL when called with a prefix argument."
1549 (call-interactively ',function))
1552 (global-set-key [remap paredit-kill] (bol-with-prefix paredit-kill))
1553 (global-set-key [remap org-kill-line] (bol-with-prefix org-kill-line))
1554 (global-set-key [remap kill-line] (bol-with-prefix kill-line))
1557 Default of *C-k* is to kill from the point to the end of line. If
1558 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
1559 set, including newline. But to kill the entire line, one still needs a
1560 *C-a* in front of it. So I change it, by defining a function to do just this for
1562 #+BEGIN_SRC emacs-lisp :tangle no
1563 (defun kill-entire-line ()
1564 "Kill this entire line (including newline), regardless of where point is within the line."
1568 (back-to-indentation))
1570 (bind-key* "C-k" 'kill-entire-line)
1571 (global-set-key [remap kill-whole-line] 'kill-entire-line)
1574 And the same is true when I'm in org-mode, which has an own kill function...
1575 (the keybinding happens later, after org-mode is loaded fully)
1576 #+BEGIN_SRC emacs-lisp :tangle no
1577 (defun jj-org-kill-line (&optional arg)
1578 "Kill the entire line, regardless of where point is within the line, org-mode-version"
1582 (back-to-indentation)
1586 I really hate tabs, so I don't want any indentation to try using them.
1587 And in case a project really needs them, I can change it just for that
1588 file/project, but luckily none of those I work in is as broken.
1589 #+BEGIN_SRC emacs-lisp
1590 (setq-default indent-tabs-mode nil)
1593 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
1594 #+BEGIN_SRC emacs-lisp
1595 (bind-key* "M-5" 'match-paren)
1598 Instead of the default "mark-defun" I want a more readline-like setting.
1599 #+BEGIN_SRC emacs-lisp
1600 (bind-key "C-M-h" 'backward-kill-word)
1603 Align whatever with a regexp.
1604 #+BEGIN_SRC emacs-lisp
1605 (bind-key "C-x \\" 'align-regexp)
1609 #+BEGIN_SRC emacs-lisp
1610 (bind-key "C-+" 'text-scale-increase)
1611 (bind-key "C--" 'text-scale-decrease)
1614 Regexes are too useful, so use the regex search by default.
1615 #+begin_src emacs-lisp
1616 (bind-key "C-s" 'isearch-forward-regexp)
1617 (bind-key "C-r" 'isearch-backward-regexp)
1618 (bind-key "C-M-s" 'isearch-forward)
1619 (bind-key "C-M-r" 'isearch-backward)
1622 Rgrep is infinitely useful in multi-file projects.
1623 #+begin_src emacs-lisp
1624 (bind-key "C-x C-g" 'rgrep)
1627 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
1628 AKA transpose lines.
1629 #+BEGIN_SRC emacs-lisp
1630 (bind-key "<M-S-up>" 'move-line-up)
1631 (bind-key "<M-S-down>" 'move-line-down)
1634 "Pull" lines up, join them
1635 #+BEGIN_SRC emacs-lisp
1636 (defun join-line-or-lines-in-region ()
1637 "Join this line or the lines in the selected region.
1638 Joins single lines in reverse order to the default, ie. pulls the next one up."
1640 (cond ((region-active-p)
1641 (let ((min (line-number-at-pos (region-beginning))))
1642 (goto-char (region-end))
1643 (while (> (line-number-at-pos) min)
1645 (t (let ((current-prefix-arg '(4)))
1646 (call-interactively 'join-line)))))
1647 (bind-key "M-j" 'join-line-or-lines-in-region)
1650 When I press Enter I almost always want to go to the right indentation on the next line.
1651 #+BEGIN_SRC emacs-lisp
1652 (bind-key "RET" 'newline-and-indent)
1655 Easier undo, and i don't need suspend-frame
1656 #+BEGIN_SRC emacs-lisp
1657 (bind-key "C-z" 'undo)
1660 Window switching, go backwards. (C-x o goes to the next window)
1661 #+BEGIN_SRC emacs-lisp
1662 (bind-key "C-x O" (lambda ()
1668 #+BEGIN_SRC emacs-lisp
1669 (bind-key "C-x C-r" 'prelude-sudo-edit)
1672 M-space is bound to just-one-space, which is great for programming. What
1673 it does is remove all spaces around the cursor, except for one. But to
1674 be really useful, it also should include newlines. It doesn’t do this by
1675 default. Rather, you have to call it with a negative argument. Sure
1677 #+BEGIN_SRC emacs-lisp
1678 (bind-key "M-SPC" 'just-one-space-with-newline)
1681 Count which commands I use how often.
1682 #+BEGIN_SRC emacs-lisp
1683 (use-package keyfreq
1687 (setq keyfreq-file (expand-file-name "keyfreq" jj-cache-dir))
1688 (setq keyfreq-file-lock (expand-file-name "keyfreq.lock" jj-cache-dir))
1690 (keyfreq-autosave-mode 1)))
1693 Duplicate current line
1694 #+BEGIN_SRC emacs-lisp
1695 (defun duplicate-line ()
1696 "Insert a copy of the current line after the current line."
1699 (let ((line-text (buffer-substring-no-properties
1700 (line-beginning-position)
1701 (line-end-position))))
1702 (move-end-of-line 1)
1704 (insert line-text))))
1706 (bind-key "C-c p" 'duplicate-line)
1709 Smarter move to the beginning of the line. That is, it first moves to
1710 the beginning of the line - and on second keypress it goes to the
1711 first character on line.
1712 #+BEGIN_SRC emacs-lisp
1713 (defun smarter-move-beginning-of-line (arg)
1714 "Move point back to indentation of beginning of line.
1716 Move point to the first non-whitespace character on this line.
1717 If point is already there, move to the beginning of the line.
1718 Effectively toggle between the first non-whitespace character and
1719 the beginning of the line.
1721 If ARG is not nil or 1, move forward ARG - 1 lines first. If
1722 point reaches the beginning or end of the buffer, stop there."
1724 (setq arg (or arg 1))
1728 (let ((line-move-visual nil))
1729 (forward-line (1- arg))))
1731 (let ((orig-point (point)))
1732 (back-to-indentation)
1733 (when (= orig-point (point))
1734 (move-beginning-of-line 1))))
1736 ;; remap C-a to `smarter-move-beginning-of-line'
1737 (global-set-key [remap move-beginning-of-line]
1738 'smarter-move-beginning-of-line)
1742 Easily copy characters from the previous nonblank line, starting just
1743 above point. With a prefix argument, only copy ARG characters (never
1744 past EOL), no argument copies rest of line.
1745 #+BEGIN_SRC emacs-lisp
1747 (bind-key "H-y" 'copy-from-above-command)
1750 Open a new X Terminal pointing to the directory of the current
1752 #+BEGIN_SRC emacs-lisp
1753 (bind-key "H-t" 'jj-open-shell)
1757 #+BEGIN_SRC emacs-lisp
1758 (bind-key "H-a" 'align-code)
1762 #+BEGIN_SRC emacs-lisp
1763 (bind-key "C-c d" 'insert-date)
1766 Another key for indenting
1767 #+BEGIN_SRC emacs-lisp
1768 (bind-key "H-i" 'indent-region)
1771 Clean all whitespace stuff
1772 #+BEGIN_SRC emacs-lisp
1773 (bind-key "H-w" 'whitespace-cleanup)
1777 #+BEGIN_SRC emacs-lisp
1778 (bind-key "H-c" 'comment-dwim)
1781 Show keystrokes in progress
1782 #+BEGIN_SRC emacs-lisp
1783 (setq echo-keystrokes 0.1)
1786 Usually you can press the *Ins*ert key, to get into overwrite mode. I
1787 don't like that, have broken much with it and so just forbid it by
1789 #+BEGIN_SRC emacs-lisp
1790 (unbind-key "<insert>")
1791 (unbind-key "<kp-insert>")
1794 *** Easily navigate sillyCased words
1795 #+BEGIN_SRC emacs-lisp
1796 (global-subword-mode 1)
1798 *** Delete file of current buffer, then kill buffer
1799 [2014-06-14 Sat 23:03]
1800 #+BEGIN_SRC emacs-lisp
1801 (defun delete-current-buffer-file ()
1802 "Removes file connected to current buffer and kills buffer."
1804 (let ((filename (buffer-file-name))
1805 (buffer (current-buffer))
1806 (name (buffer-name)))
1807 (if (not (and filename (file-exists-p filename)))
1809 (when (yes-or-no-p "Are you sure you want to remove this file? ")
1810 (delete-file filename)
1811 (kill-buffer buffer)
1812 (message "File '%s' successfully removed" filename)))))
1814 (global-set-key (kbd "C-x C-k") 'delete-current-buffer-file)
1816 *** Rename file of current buffer
1817 [2014-06-14 Sat 23:04]
1818 #+BEGIN_SRC emacs-lisp
1819 (defun rename-current-buffer-file ()
1820 "Renames current buffer and file it is visiting."
1822 (let ((name (buffer-name))
1823 (filename (buffer-file-name)))
1824 (if (not (and filename (file-exists-p filename)))
1825 (error "Buffer '%s' is not visiting a file!" name)
1826 (let ((new-name (read-file-name "New name: " filename)))
1827 (if (get-buffer new-name)
1828 (error "A buffer named '%s' already exists!" new-name)
1829 (rename-file filename new-name 1)
1830 (rename-buffer new-name)
1831 (set-visited-file-name new-name)
1832 (set-buffer-modified-p nil)
1833 (message "File '%s' successfully renamed to '%s'"
1834 name (file-name-nondirectory new-name)))))))
1836 (global-set-key (kbd "C-x C-S-r") 'rename-current-buffer-file)
1838 *** Quickly find emacs lisp sources
1839 [2014-06-22 Sun 23:05]
1840 #+BEGIN_SRC emacs-lisp
1841 (bind-key "C-l" 'find-library 'help-command)
1842 (bind-key "C-f" 'find-function 'help-command)
1843 (bind-key "C-k" 'find-function-on-key 'help-command)
1844 (bind-key "C-v" 'find-variable 'help-command)
1847 [2015-01-26 Mon 16:01]
1848 #+BEGIN_SRC emacs-lisp
1849 (bind-key "M-s o" 'occur-dwim)
1853 [2014-06-01 Sun 15:00]
1854 Proper whitespace handling
1855 #+BEGIN_SRC emacs-lisp
1856 (use-package ethan-wspace
1857 :ensure ethan-wspace
1858 :diminish (ethan-wspace-mode . "ew")
1860 (global-ethan-wspace-mode 1))
1864 [2014-06-01 Sun 15:16]
1865 #+BEGIN_SRC emacs-lisp
1866 (use-package expand-region
1867 :ensure expand-region
1868 :bind ("C-M-+" . er/expand-region)
1869 :commands er/expand-region)
1872 [2013-05-02 Thu 00:04]
1873 Filladapt by KyleJones enhances Emacs’ fill functions by guessing a
1874 fill prefix, such as a comment sequence in program code, and handling
1875 bullet points like “1.” or “*”.
1876 #+BEGIN_SRC emacs-lisp
1877 (use-package filladapt
1878 :diminish filladapt-mode
1880 (setq-default filladapt-mode t))
1883 [2013-04-28 So 22:21]
1884 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
1885 As the one time I tried Flymake i wasn't happy, thats easy to
1887 #+BEGIN_SRC emacs-lisp
1888 (use-package flycheck
1890 :diminish flycheck-mode
1891 :bind (("M-n" . next-error)
1892 ("M-p" . previous-error))
1895 (add-hook 'find-file-hook
1897 (when (not (equal 'emacs-lisp-mode major-mode))
1901 (use-package flycheck-color-mode-line
1902 :ensure flycheck-color-mode-line)
1903 (setq flycheck-highlighting-mode nil)
1904 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
1908 Obviously emacs can do syntax hilighting. For more things than you ever
1910 And I want to have it everywhere.
1911 #+BEGIN_SRC emacs-lisp
1912 (use-package font-lock
1915 (global-font-lock-mode 1)
1916 (setq font-lock-maximum-decoration t)))
1919 #+BEGIN_SRC emacs-lisp
1920 (use-package git-commit-mode
1921 :ensure git-commit-mode
1922 :commands git-commit-mode
1923 :mode ("COMMIT_EDITMSG" . git-commit-mode))
1927 #+BEGIN_SRC emacs-lisp
1928 (use-package git-rebase-mode
1929 :ensure git-rebase-mode
1930 :commands git-rebase-mode
1931 :mode ("git-rebase-todo" . git-rebase-mode))
1934 [2014-05-21 Wed 22:56]
1935 #+BEGIN_SRC emacs-lisp
1936 (use-package git-gutter+
1938 :diminish git-gutter+-mode
1939 :bind (("C-x n" . git-gutter+-next-hunk)
1940 ("C-x p" . git-gutter+-previous-hunk)
1941 ("C-x v =" . git-gutter+-show-hunk)
1942 ("C-x r" . git-gutter+-revert-hunks)
1943 ("C-x s" . git-gutter+-stage-hunks)
1944 ("C-x c" . git-gutter+-commit)
1948 (setq git-gutter+-disabled-modes '(org-mode))
1949 (global-git-gutter+-mode 1))
1952 (use-package git-gutter-fringe+
1953 :ensure git-gutter-fringe+
1956 (setq git-gutter-fr+-side 'right-fringe)
1957 ;(git-gutter-fr+-minimal)
1962 [2015-02-22 Sun 14:00]
1963 Provides function that popup commit message at current line. This is
1964 useful when you want to know why this line was changed.
1965 #+BEGIN_SRC emacs-lisp
1966 (use-package git-messenger
1967 :ensure git-messenger
1968 :commands (git-messenger:popup-message)
1969 :bind (("C-x v p" . git-messenger:popup-message))
1972 (bind-key "m" 'git-messenger:copy-message git-messenger-map)
1973 (add-hook 'git-messenger:popup-buffer-hook 'magit-commit-mode)
1974 (setq git-messenger:show-detail t)))
1977 [2014-07-23 Mi 12:57]
1978 Browse historic versions of a file with p (previous) and n (next).
1979 #+BEGIN_SRC emacs-lisp
1980 (use-package git-timemachine
1981 :ensure git-timemachine
1982 :commands git-timemachine)
1985 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
1986 what I want every emacs to know.
1987 #+BEGIN_SRC emacs-lisp
1988 (bind-key "C-c g" 'gnus) ; Start gnus with M-n
1994 [2015-02-20 Fri 16:27]
1995 When working with many windows at the same time, each window has a
1996 size that is not convenient for editing.
1998 golden-ratio helps on this issue by resizing automatically the windows
1999 you are working on to the size specified in the "Golden Ratio". The
2000 window that has the main focus will have the perfect size for editing,
2001 while the ones that are not being actively edited will be re-sized to
2002 a smaller size that doesn't get in the way, but at the same time will
2003 be readable enough to know it's content.
2004 #+BEGIN_SRC emacs-lisp
2005 (use-package golden-ratio
2006 :ensure golden-ratio
2007 :diminish golden-ratio-mode
2010 (golden-ratio-mode 1)
2011 (setq golden-ratio-exclude-buffer-names '("*LV*" "*guide-key*"))
2012 (setq golden-ratio-exclude-modes '("calendar-mode" "gnus-summary-mode"
2013 "gnus-article-mode" "calc-mode" "calc-trail-mode"
2018 [2015-02-22 Sun 13:28]
2019 Move point through buffer-undo-list positions.
2020 #+BEGIN_SRC emacs-lisp
2021 (use-package goto-last-change
2022 :commands (goto-last-change)
2023 :bind (("M-g l" . goto-last-change))
2027 [2014-06-11 Wed 22:27]
2028 guide-key.el displays the available key bindings automatically and
2031 For whatever reason I like this more than icicles <backtab> completion
2033 #+BEGIN_SRC emacs-lisp
2034 (use-package guide-key
2036 :diminish guide-key-mode
2039 (setq guide-key/guide-key-sequence '("C-x" "C-c" "M-g"))
2041 (setq guide-key/recursive-key-sequence-flag t)
2042 (setq guide-key/popup-window-position 'bottom)
2043 (setq guide-key/idle-delay 0.5)))
2048 [2014-05-21 Wed 23:51]
2049 #+BEGIN_SRC emacs-lisp
2050 (use-package hi-lock
2051 :bind (("M-o l" . highlight-lines-matching-regexp)
2052 ("M-o r" . highlight-regexp)
2053 ("M-o w" . highlight-phrase)))
2055 (use-package hilit-chg
2056 :bind ("M-o C" . highlight-changes-mode))
2060 Crazy way of completion. It looks at the word before point and then
2061 tries to expand it in various ways.
2062 #+BEGIN_SRC emacs-lisp
2063 (use-package hippie-exp
2064 :bind ("M-/" . hippie-expand)
2065 :commands hippie-expand
2068 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
2069 try-expand-dabbrev-all-buffers
2070 try-expand-dabbrev-from-kill
2071 try-complete-file-name-partially
2072 try-complete-file-name
2073 try-expand-all-abbrevs try-expand-list
2075 try-complete-lisp-symbol-partially
2076 try-complete-lisp-symbol))))
2079 Replaced by web-mode [[*web-mode][web-mode]]
2080 #+BEGIN_SRC emacs-lisp :tangle no
2081 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
2082 (add-auto-mode 'html-helper-mode "\\.html$")
2083 (add-auto-mode 'html-helper-mode "\\.asp$")
2084 (add-auto-mode 'html-helper-mode "\\.phtml$")
2085 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
2086 (defalias 'html-mode 'html-helper-mode)
2089 [2015-01-26 Mon 15:50]
2090 This is a package for GNU Emacs that can be used to tie related
2091 commands into a family of short bindings with a common prefix - a
2094 Once you summon the Hydra through the prefixed binding (the body + any
2095 one head), all heads can be called in succession with only a short
2098 The Hydra is vanquished once Hercules, any binding that isn't the
2099 Hydra's head, arrives. Note that Hercules, besides vanquishing the
2100 Hydra, will still serve his orignal purpose, calling his proper
2101 command. This makes the Hydra very seamless, it's like a minor mode
2102 that disables itself auto-magically.
2103 #+BEGIN_SRC emacs-lisp
2108 (setq hydra-is-helpful t)
2111 (defhydra hydra-zoom (:color red)
2113 ("g" text-scale-increase "in")
2114 ("l" text-scale-decrease "out")
2116 (bind-key "<F2>" 'hydra-zoom/toggle)
2118 (defhydra hydra-error (:color red)
2120 ("h" first-error "first")
2121 ("j" next-error "next")
2122 ("k" previous-error "prev")
2123 ("v" recenter-top-bottom "recenter")
2125 (bind-key "M-g e" 'hydra-error/body)
2127 (defhydra hydra-gnus (:color red)
2129 ("m" gnus-uu-mark-thread "mark thread")
2130 ("d" gnus-summary-delete-article "delete article(s)")
2131 ("r" gnus-summary-mark-as-read-forward "mark read")
2132 ("n" gnus-summary-next-thread "next thread")
2133 ("p" gnus-summary-prev-thread "previous thread")
2134 ("g" gnus-summary-next-group "next group")
2135 ("l" gnus-recenter "recenter")
2136 ("x" gnus-summary-limit-to-unread "unread")
2138 (bind-key "C-c h" 'hydra-gnus/body)
2140 (defhydra hydra-launcher (:color blue)
2143 ("r" (browse-url "http://www.reddit.com/r/emacs/") "reddit")
2144 ("w" (browse-url "http://www.emacswiki.org/") "emacswiki")
2147 (bind-key "C-c r" 'hydra-launcher/body)
2149 ; whitespace mode gets loaded late, so variable may not be there yet. Workaround...
2150 (defvar whitespace-mode nil)
2151 (defhydra hydra-toggle (:color pink)
2153 _a_ abbrev-mode: % 4`abbrev-mode^^^^ _f_ auto-fill-mode: %`auto-fill-function
2154 _c_ auto-complete-mode: % 4`auto-complete-mode _r_ auto-revert-mode: %`auto-revert-mode
2155 _d_ debug-on-error: % 4`debug-on-error^ _t_ truncate-lines: %`truncate-lines
2156 _w_ whitespace-mode: % 4`whitespace-mode _g_ golden-ratio-mode: %`golden-ratio-mode
2157 _l_ linum-mode: % 4`linum-mode _k_ linum relative: %`linum-format
2160 ("a" abbrev-mode nil)
2161 ("c" auto-complete-mode nil)
2162 ("i" aggressive-indent-mode nil)
2163 ("d" toggle-debug-on-error nil)
2164 ("f" auto-fill-mode nil)
2165 ("g" golden-ratio-mode nil)
2166 ("t" toggle-truncate-lines nil)
2167 ("w" whitespace-mode nil)
2168 ("r" auto-revert-mode nil)
2169 ("l" linum-mode nil)
2170 ("k" linum-relative-toggle nil)
2172 (bind-key "C-c C-v" 'hydra-toggle/body)
2178 [2014-05-21 Wed 23:54]
2179 #+BEGIN_SRC emacs-lisp
2180 (use-package ibuffer
2182 :bind (("C-h h" . ibuffer)
2183 ("C-x C-b" . ibuffer)
2184 ("<XF86WebCam>" . ibuffer)
2187 :defines (ibuffer-filtering-alist
2188 ibuffer-filter-groups ibuffer-compile-formats ibuffer-git-column-length
2189 ibuffer-show-empty-filter-groups ibuffer-saved-filter-groups)
2192 (defvar my-ibufffer-separator " • ")
2193 (setq ibuffer-filter-group-name-face 'variable-pitch
2194 ibuffer-use-header-line t
2195 ibuffer-old-time 12)
2196 (unbind-key "M-o" ibuffer-mode-map)
2197 (bind-key "s" 'isearch-forward-regexp ibuffer-mode-map)
2198 (bind-key "." 'ibuffer-invert-sorting ibuffer-mode-map)
2203 (use-package ibuffer-vc
2206 (ibuffer-vc-set-filter-groups-by-vc-root
2207 ibuffer-vc-generate-filter-groups-by-vc-root))
2209 (use-package ibuffer-tramp
2211 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
2212 ibuffer-tramp-set-filter-groups-by-tramp-connection))
2213 ;; Switching to ibuffer puts the cursor on the most recent buffer
2214 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
2215 "Open ibuffer with cursor pointed to most recent buffer name"
2216 (let ((recent-buffer-name (buffer-name)))
2218 (ibuffer-update nil t)
2219 (unless (string= recent-buffer-name "*Ibuffer*")
2220 (ibuffer-jump-to-buffer recent-buffer-name))))
2222 (defun ibuffer-magit-status ()
2224 (--when-let (get-buffer "*Ibuffer*")
2225 (with-current-buffer it
2226 (let* ((selected-buffer (ibuffer-current-buffer))
2227 (buffer-path (with-current-buffer
2229 (or (buffer-file-name)
2230 list-buffers-directory
2231 default-directory)))
2233 (if (file-regular-p buffer-path)
2234 (file-name-directory buffer-path)
2236 (magit-status default-directory)))))
2237 (bind-key "i" 'ibuffer-magit-status ibuffer-mode-map)
2238 (bind-key "G" 'ibuffer-magit-status ibuffer-mode-map)
2240 (setq ibuffer-directory-abbrev-alist
2245 (cons (f-slash (f-expand (cdr it))) my-ibufffer-separator)
2246 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
2248 ("dak" . "/develop/dak/")
2250 ("config" . "~/.emacs.d/config/")
2252 ("systmp" . "/tmp/")
2253 ("puppet" . "~/git/puppet")
2257 (use-package ibuffer-git
2259 (use-package ibuffer-vc
2262 (define-ibuffer-column size-h
2263 (:name "Size" :inline t)
2265 ((> (buffer-size) 1000)
2266 (format "%7.1fk" (/ (buffer-size) 1000.0)))
2267 ((> (buffer-size) 1000000)
2268 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
2270 (format "%8d" (buffer-size)))))
2272 (use-package ibuf-ext)
2273 (define-ibuffer-filter filename2
2274 "Toggle current view to buffers with filename matching QUALIFIER."
2275 (:description "filename2"
2276 :reader (read-from-minibuffer "Filter by filename (regexp): "))
2277 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
2278 (ibuffer-awhen (with-current-buffer buf
2279 (or buffer-file-name
2281 (string-match qualifier it)))
2283 (defvar ibuffer-magit-filter-groups nil)
2284 (defun ibuffer-magit-define-filter-groups ()
2285 (when (and (not ibuffer-magit-filter-groups)
2286 (boundp 'magit-repo-dirs))
2287 (setq ibuffer-magit-filter-groups
2290 (file-name-nondirectory (directory-file-name it)))
2292 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
2294 (defun ibuffer-set-filter-groups-by-root ()
2296 ;; (ibuffer-projectile-define-filter-groups)
2297 ;; (ibuffer-magit-define-filter-groups)
2298 (setq ibuffer-filter-groups
2300 ;; ibuffer-projectile-filter-groups
2301 ibuffer-magit-filter-groups
2304 (or (mode . magit-log-edit-mode)
2305 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2306 (name . "^\\*Pymacs\\*$")
2307 (name . "^\\*helm.*\\*")
2308 (name . "^\\*Compile-log\\*$")
2309 (name . "^\\*Ido Completions\\*$")
2310 (name . "^\\*magit-\\(process\\)\\*$")
2314 (name . "^\\*scratch")
2315 (name . "^\\*Messages")
2318 (ibuffer-vc-generate-filter-groups-by-vc-root)
2319 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
2321 (defun toggle-ibuffer-filter-groups ()
2324 (let ((ibuf (get-buffer "*Ibuffer*")))
2326 (with-current-buffer ibuf
2327 (let ((selected-buffer (ibuffer-current-buffer)))
2328 (if (not ibuffer-filter-groups)
2329 (ibuffer-set-filter-groups-by-root)
2330 (setq ibuffer-filter-groups nil))
2331 (pop-to-buffer ibuf)
2332 (ibuffer-update nil t)
2333 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
2335 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
2337 (defun ibuffer-back-to-top ()
2339 (beginning-of-buffer)
2342 (defun ibuffer-jump-to-bottom ()
2348 (define-key ibuffer-mode-map
2349 (vector 'remap 'end-of-buffer) 'ibuffer-jump-to-bottom)
2350 (define-key ibuffer-mode-map
2351 (vector 'remap 'beginning-of-buffer) 'ibuffer-back-to-top)
2353 (setq ibuffer-default-sorting-mode 'recency
2354 ibuffer-eliding-string "…"
2355 ibuffer-compile-formats t
2356 ibuffer-git-column-length 6
2357 ibuffer-show-empty-filter-groups nil
2358 ibuffer-default-directory "~/"
2361 (setq ibuffer-formats '((mark vc-status-mini
2363 (git-status 8 8 :left)
2367 (name 18 18 :left :elide)
2369 (size-h 9 -1 :right)
2371 (mode 16 16 :left :elide)
2372 " " filename-and-process)
2374 (git-status 8 8 :left)
2380 (setq ibuffer-saved-filter-groups
2383 ("dired" (mode . dired-mode))
2384 ("perl" (mode . cperl-mode))
2386 (mode . puppet-mode)
2387 (mode . yaml-mode)))
2388 ("ruby" (mode . ruby-mode))
2390 (name . "^\\*scratch\\*$")
2391 (name . "^\\*Compile-log\\*$")
2392 (name . "^\\*Completions\\*$")
2393 (name . "^\\*Messages\\*$")
2394 (name . "^\\*Backtrace\\*$")
2395 (name . "^\\*Packages*\\*$")
2396 (name . "^\\*Help*\\*$")
2399 (mode . message-mode)
2402 (mode . gnus-group-mode)
2403 (mode . gnus-summary-mode)
2404 (mode . gnus-article-mode)
2405 (name . "^\\.bbdb$")
2406 (name . "^\\.newsrc-dribble")))
2408 (filename . ".*/org/.*")
2409 (mode . org-agenda-mode)
2410 (name . "^diary$")))
2412 (mode . magit-log-edit-mode)
2413 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
2415 ;; -------------------------------------------------
2416 ;; programming languages #1
2418 (mode . emacs-lisp-mode)
2419 (mode . python-mode)
2421 (mode . coffee-mode)
2424 (mode . actionscript-mode)
2427 (mode . haskell-mode)
2433 ;; -------------------------------------------------
2434 ;; configuration/data files
2438 (mode . conf-mode)))
2439 ;; -------------------------------------------------
2440 ;; text/notetaking/org
2441 ("org agenda" (mode . org-agenda-mode))
2444 (name . "^\\*Calendar\\*$")
2445 (name . "^diary$")))
2449 (mode . markdown-mode)))
2450 ;; -------------------------------------------------
2453 (mode . image-mode)))
2454 ;; -------------------------------------------------
2456 ("w3m" (mode . w3m-mode))
2458 (mode . magit-status-mode)
2459 (mode . magit-log-mode)
2460 (mode . vc-annotate-mode)))
2461 ("dired" (mode . dired-mode))
2466 (name . "^\\*Personal Keybindings\\*$")))
2467 ;; -------------------------------------------------
2469 ("MORE" (or (mode . magit-log-edit-mode)
2470 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2471 (name . "^\\*Pymacs\\*$")
2472 (name . "^\\*Compile-log\\*$")
2473 (name . "^\\*Completions\\*$")
2474 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
2476 ("*buffer*" (name . "\\*.*\\*"))))))
2478 (add-hook 'ibuffer-mode-hook
2480 (ibuffer-auto-mode 1)
2481 (ibuffer-switch-to-saved-filter-groups "default")))
2483 ;; Unless you turn this variable on you will be prompted every time
2484 ;; you want to delete a buffer, even unmodified ones, which is way
2485 ;; too cautious for most people. You’ll still be prompted for
2486 ;; confirmation when deleting modified buffers after the option has
2488 (setq ibuffer-expert t)
2493 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
2494 ‘TAB’ completion is to typing things manually every time.”]]
2495 #+BEGIN_SRC emacs-lisp
2496 (use-package icicles
2497 :load-path "elisp/icicle/"
2502 Incremental mini-buffer completion preview: Type in the minibuffer,
2503 list of matching commands is echoed
2504 #+BEGIN_SRC emacs-lisp
2508 [2014-05-26 Mon 22:49]
2509 #+BEGIN_SRC emacs-lisp
2512 :commands (iedit-mode)
2514 :bind (("C-;" . iedit-mode)
2515 ("C-," . iedit-mode-toggle-on-function))
2520 [2014-05-20 Tue 23:35]
2521 #+BEGIN_SRC emacs-lisp
2523 :bind ("C-h C-i" . info-lookup-symbol)
2524 :commands info-lookup-symbol
2527 ;; (defadvice info-setup (after load-info+ activate)
2528 ;; (use-package info+))
2530 (defadvice Info-exit (after remove-info-window activate)
2531 "When info mode is quit, remove the window."
2532 (if (> (length (window-list)) 1)
2535 (use-package info-look
2536 :commands info-lookup-add-help)
2538 ** linum (line number)
2539 Various modes should have line numbers in front of each line.
2541 But then there are some where it would just be deadly - like org-mode,
2542 gnus, so we have a list of modes where we don't want to see it.
2543 #+BEGIN_SRC emacs-lisp
2545 :diminish linum-mode
2548 (setq linum-format "%3d ")
2549 (setq linum-mode-inhibit-modes-list '(org-mode
2556 (defadvice linum-on (around linum-on-inhibit-for-modes)
2557 "Stop the load of linum-mode for some major modes."
2558 (unless (member major-mode linum-mode-inhibit-modes-list)
2561 (ad-activate 'linum-on)
2563 (use-package linum-relative
2564 :ensure linum-relative
2567 (setq linum-format 'dynamic)
2570 (global-linum-mode 1))
2573 ** lisp editing stuff
2575 [2013-04-21 So 21:00]
2576 I'm not doing much of it, except for my emacs and gnus configs, but
2577 then I like it nice too...
2578 #+BEGIN_SRC emacs-lisp
2579 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
2581 (defun remove-elc-on-save ()
2582 "If you're saving an elisp file, likely the .elc is no longer valid."
2583 (make-local-variable 'after-save-hook)
2584 (add-hook 'after-save-hook
2586 (if (file-exists-p (concat buffer-file-name "c"))
2587 (delete-file (concat buffer-file-name "c"))))))
2589 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
2590 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
2592 (use-package paredit
2594 :diminish paredit-mode " π")
2596 (setq lisp-coding-hook 'lisp-coding-defaults)
2597 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2599 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2600 (add-hook 'emacs-lisp-mode-hook (lambda ()
2601 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2603 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
2605 (after "elisp-slime-nav"
2606 '(diminish 'elisp-slime-nav-mode))
2607 (after "rainbow-mode"
2608 '(diminish 'rainbow-mode))
2610 '(diminish 'eldoc-mode))
2613 [2013-04-21 So 20:48]
2614 magit is a mode for interacting with git.
2615 #+BEGIN_SRC emacs-lisp
2618 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
2619 magit-git-repo-p magit-list-repos)
2621 :bind (("C-x g" . magit-status)
2622 ("C-x G" . magit-status-with-prefix))
2625 (setq magit-commit-signoff t
2626 magit-repo-dirs '("~/git"
2630 magit-repo-dirs-depth 4
2631 magit-log-auto-more t)
2633 (use-package magit-blame
2634 :commands magit-blame-mode
2637 (use-package magit-svn
2639 :commands (magit-svn-mode
2643 (add-hook 'magit-mode-hook 'hl-line-mode)
2644 (defun magit-status-with-prefix ()
2646 (let ((current-prefix-arg '(4)))
2647 (call-interactively 'magit-status)))
2651 (setenv "GIT_PAGER" "")
2653 (unbind-key "M-h" magit-mode-map)
2654 (unbind-key "M-s" magit-mode-map)
2656 (use-package magit-find-file
2657 :ensure magit-find-file
2658 :commands (magit-find-file-completing-read)
2662 (bind-key "C-x C-f" 'magit-find-file-completing-read magit-mode-map)))
2664 (add-hook 'magit-log-edit-mode-hook
2666 (set-fill-column 72)
2669 (defadvice magit-status (around magit-fullscreen activate)
2670 (window-configuration-to-register :magit-fullscreen)
2672 (delete-other-windows))
2674 (defun magit-quit-session ()
2675 "Restores the previous window configuration and kills the magit buffer"
2678 (jump-to-register :magit-fullscreen))
2680 (bind-key "q" 'magit-quit-session magit-status-mode-map)
2684 [2014-05-20 Tue 23:04]
2685 #+BEGIN_SRC emacs-lisp
2686 (use-package markdown-mode
2687 :mode (("\\.md\\'" . markdown-mode)
2688 ("\\.mdwn\\'" . markdown-mode))
2692 #+BEGIN_SRC emacs-lisp
2693 (use-package message
2696 (setq message-kill-buffer-on-exit t)))
2699 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2701 I want to access it from anywhere using =F6=.
2702 #+BEGIN_SRC emacs-lisp
2703 (use-package mingus-stays-home
2704 :bind ( "<f6>" . mingus)
2708 (setq mingus-dired-add-keys t)
2709 (setq mingus-mode-always-modeline nil)
2710 (setq mingus-mode-line-show-elapsed-percentage nil)
2711 (setq mingus-mode-line-show-volume nil)
2712 (setq mingus-mpd-config-file "/etc/mpd.conf")
2713 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2714 (setq mingus-mpd-root "/share/music/")))
2718 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
2719 #+BEGIN_SRC emacs-lisp
2720 (use-package miniedit
2725 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
2726 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
2727 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
2728 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
2733 [2013-05-21 Tue 23:39]
2734 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
2735 coexist in one buffer.
2736 #+BEGIN_SRC emacs-lisp :tangle no
2737 (use-package mmm-auto
2741 (setq mmm-global-mode 'buffers-with-submode-classes)
2742 (setq mmm-submode-decoration-level 2)
2743 (eval-after-load 'mmm-vars
2749 :face mmm-code-submode-face
2750 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
2751 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
2752 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2753 @ "\n" _ "\n" @ "</script>" @)))
2756 :face mmm-code-submode-face
2757 :front "<style[^>]*>[ \t]*\n?"
2758 :back "[ \t]*</style>"
2759 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2760 @ "\n" _ "\n" @ "</style>" @)))
2763 :face mmm-code-submode-face
2766 (dolist (mode (list 'html-mode 'nxml-mode))
2767 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
2768 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
2773 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2775 #+BEGIN_SRC emacs-lisp
2776 (use-package mo-git-blame
2777 :ensure mo-git-blame
2778 :commands (mo-git-blame-current
2782 (setq mo-git-blame-blame-window-width 25)))
2786 [2013-04-08 Mon 23:57]
2787 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2788 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2789 #+BEGIN_SRC emacs-lisp
2790 (use-package multiple-cursors
2791 :ensure multiple-cursors
2793 :commands (mc/remove-fake-cursors
2794 mc/create-fake-cursor-at-point
2795 mc/pop-state-from-overlay
2796 mc/maybe-multiple-cursors-mode)
2797 :defines (multiple-cursors-mode
2799 mc--read-quoted-char
2800 rectangular-region-mode)
2801 :bind (("C-S-c C-S-c" . mc/edit-lines)
2802 ("C->" . mc/mark-next-like-this)
2803 ("C-<" . mc/mark-previous-like-this)
2804 ("C-c C-<" . mc/mark-all-like-this)
2805 ("C-c i" . mc/insert-numbers))
2808 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
2809 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
2810 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
2811 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
2812 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
2813 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
2816 [2014-08-27 Wed 17:15]
2818 #+BEGIN_SRC emacs-lisp
2819 (use-package neotree
2822 :bind (("<f8>" . neotree-toggle))
2823 :commands (neotree-find
2828 (setq neo-smart-open t))
2831 (bind-key "^" 'neotree-select-up-node neotree-mode-map)))
2834 [2013-05-22 Wed 22:02]
2835 nxml-mode is a major mode for editing XML.
2836 #+BEGIN_SRC emacs-lisp
2841 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2844 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2845 (fset 'xml-mode 'nxml-mode)
2846 (setq nxml-slash-auto-complete-flag t)
2848 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2849 (defun pp-xml-region (begin end)
2850 "Pretty format XML markup in region. The function inserts
2851 linebreaks to separate tags that have nothing but whitespace
2852 between them. It then indents the markup by using nxml's
2858 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2859 (backward-char) (insert "\n"))
2860 (indent-region begin end)))
2862 ;;----------------------------------------------------------------------------
2863 ;; Integration with tidy for html + xml
2864 ;;----------------------------------------------------------------------------
2865 ;; tidy is autoloaded
2866 (eval-after-load 'tidy
2868 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2869 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2874 *** General settings
2875 [2013-04-28 So 17:06]
2877 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
2878 it is quite extensive. Nevertheless, it starts out small, loading it.
2879 #+BEGIN_SRC emacs-lisp
2883 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
2884 that we need org-protocol.
2885 #+BEGIN_SRC emacs-lisp
2886 (require 'org-protocol)
2891 My current =org-agenda-files= variable only includes a set of
2893 #+BEGIN_SRC emacs-lisp
2894 (setq org-agenda-files (quote ("~/org/"
2900 (setq org-default-notes-file "~/org/notes.org")
2902 =org-mode= manages the =org-agenda-files= variable automatically using
2903 =C-c [= and =C-c ]= to add and remove files respectively. However,
2904 this replaces my directory list with a list of explicit filenames
2905 instead and is not what I want. If this occurs then adding a new org
2906 file to any of the above directories will not contribute to my agenda
2907 and I will probably miss something important.
2909 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
2910 prevent messing up my list of directories in the =org-agenda-files=
2911 variable. I just add and remove directories manually here. Changing
2912 the list of directories in =org-agenda-files= happens very rarely
2913 since new files in existing directories are automatically picked up.
2915 #+BEGIN_SRC emacs-lisp
2916 ;; Keep tasks with dates on the global todo lists
2917 (setq org-agenda-todo-ignore-with-date nil)
2919 ;; Keep tasks with deadlines on the global todo lists
2920 (setq org-agenda-todo-ignore-deadlines nil)
2922 ;; Keep tasks with scheduled dates on the global todo lists
2923 (setq org-agenda-todo-ignore-scheduled nil)
2925 ;; Keep tasks with timestamps on the global todo lists
2926 (setq org-agenda-todo-ignore-timestamp nil)
2928 ;; Remove completed deadline tasks from the agenda view
2929 (setq org-agenda-skip-deadline-if-done t)
2931 ;; Remove completed scheduled tasks from the agenda view
2932 (setq org-agenda-skip-scheduled-if-done t)
2934 ;; Remove completed items from search results
2935 (setq org-agenda-skip-timestamp-if-done t)
2937 ;; Include agenda archive files when searching for things
2938 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
2940 ;; Show all future entries for repeating tasks
2941 (setq org-agenda-repeating-timestamp-show-all t)
2943 ;; Show all agenda dates - even if they are empty
2944 (setq org-agenda-show-all-dates t)
2946 ;; Sorting order for tasks on the agenda
2947 (setq org-agenda-sorting-strategy
2948 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
2949 (todo category-up priority-down effort-up)
2950 (tags category-up priority-down effort-up)
2951 (search category-up))))
2953 ;; Start the weekly agenda on Monday
2954 (setq org-agenda-start-on-weekday 1)
2956 ;; Enable display of the time grid so we can see the marker for the current time
2957 (setq org-agenda-time-grid (quote ((daily today remove-match)
2958 #("----------------" 0 16 (org-heading t))
2959 (0800 1000 1200 1400 1500 1700 1900 2100))))
2961 ;; Display tags farther right
2962 (setq org-agenda-tags-column -102)
2964 ; position the habit graph on the agenda to the right of the default
2965 (setq org-habit-graph-column 50)
2967 ; turn habits back on
2968 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
2971 ;; Agenda sorting functions
2973 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
2976 (setq org-deadline-warning-days 30)
2978 ;; Always hilight the current agenda line
2979 (add-hook 'org-agenda-mode-hook
2980 '(lambda () (hl-line-mode 1))
2984 #+BEGIN_SRC emacs-lisp
2985 (setq org-agenda-persistent-filter t)
2986 (add-hook 'org-agenda-mode-hook
2987 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
2990 (add-hook 'org-agenda-mode-hook
2991 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
2994 (add-hook 'org-agenda-mode-hook
2995 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
2998 (add-hook 'org-agenda-mode-hook
2999 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
3002 (add-hook 'org-agenda-mode-hook
3003 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
3006 ; Rebuild the reminders everytime the agenda is displayed
3007 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
3009 ;(if (file-exists-p "~/org/refile.org")
3010 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
3012 ; Activate appointments so we get notifications
3015 (setq org-agenda-log-mode-items (quote (closed clock state)))
3016 (if (> emacs-major-version 23)
3017 (setq org-agenda-span 3)
3018 (setq org-agenda-ndays 3))
3020 (setq org-agenda-show-all-dates t)
3021 (setq org-agenda-start-on-weekday nil)
3022 (setq org-deadline-warning-days 14)
3025 *** Global keybindings.
3026 Start off by defining a series of keybindings.
3028 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
3029 setup manually, not by org-mode. Also turn off =C-c ;=, which
3030 comments headlines - a function never used.
3031 #+BEGIN_SRC emacs-lisp
3032 (add-hook 'org-mode-hook
3034 (org-defkey org-mode-map "\C-c[" 'undefined)
3035 (org-defkey org-mode-map "\C-c]" 'undefined)
3036 (org-defkey org-mode-map "\C-c;" 'undefined))
3040 And now a largish set of keybindings...
3041 #+BEGIN_SRC emacs-lisp
3042 (bind-key "C-c l" 'org-store-link)
3043 (bind-key "C-c a" 'org-agenda)
3044 ;(bind-key "C-c b" 'org-iswitchb)
3045 (define-key mode-specific-map [?a] 'org-agenda)
3047 (bind-key "<f12>" 'org-agenda)
3048 (bind-key "<f5>" 'bh/org-todo)
3049 (bind-key "<S-f5>" 'bh/widen)
3050 (bind-key "<f7>" 'bh/set-truncate-lines)
3051 ;(bind-key "<f8>" 'org-cycle-agenda-files)
3053 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
3054 (bind-key "<f9> b" 'bbdb)
3055 (bind-key "<f9> c" 'calendar)
3056 (bind-key "<f9> f" 'boxquote-insert-file)
3057 (bind-key "<f9> h" 'bh/hide-other)
3058 (bind-key "<f9> n" 'org-narrow-to-subtree)
3059 (bind-key "<f9> w" 'widen)
3060 (bind-key "<f9> u" 'bh/narrow-up-one-level)
3061 (bind-key "<f9> I" 'bh/punch-in)
3062 (bind-key "<f9> O" 'bh/punch-out)
3063 (bind-key "<f9> H" 'jj/punch-in-hw)
3064 (bind-key "<f9> W" 'jj/punch-out-hw)
3065 (bind-key "<f9> o" 'bh/make-org-scratch)
3066 (bind-key "<f9> p" 'bh/phone-call)
3067 (bind-key "<f9> r" 'boxquote-region)
3068 (bind-key "<f9> s" 'bh/switch-to-scratch)
3069 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
3070 (bind-key "<f9> T" 'tabify)
3071 (bind-key "<f9> U" 'untabify)
3072 (bind-key "<f9> v" 'visible-mode)
3073 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
3074 (bind-key "C-<f9>" 'previous-buffer)
3075 (bind-key "C-<f10>" 'next-buffer)
3076 (bind-key "M-<f9>" 'org-toggle-inline-images)
3077 ;(bind-key "C-x n r" 'narrow-to-region)
3078 (bind-key "<f11>" 'org-clock-goto)
3079 (bind-key "C-<f11>" 'org-clock-in)
3080 (bind-key "C-M-r" 'org-capture)
3081 (bind-key "C-c r" 'org-capture)
3082 (bind-key "C-S-<f12>" 'bh/save-then-publish)
3083 ;(bind-key "C-k" 'jj-org-kill-line org-mode-map)
3087 *** Tasks, States, Todo fun
3089 First we define the global todo keywords.
3090 #+BEGIN_SRC emacs-lisp
3091 (setq org-todo-keywords
3092 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
3093 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
3095 (setq org-todo-keyword-faces
3096 (quote (("TODO" :foreground "red" :weight bold)
3097 ("NEXT" :foreground "light blue" :weight bold)
3098 ("DONE" :foreground "forest green" :weight bold)
3099 ("WAITING" :foreground "orange" :weight bold)
3100 ("HOLD" :foreground "orange" :weight bold)
3101 ("DELEGATED" :foreground "yellow" :weight bold)
3102 ("CANCELLED" :foreground "dark green" :weight bold)
3103 ("PHONE" :foreground "dark green" :weight bold))))
3106 **** Fast Todo Selection
3107 Fast todo selection allows changing from any task todo state to any
3108 other state directly by selecting the appropriate key from the fast
3109 todo selection key menu.
3110 #+BEGIN_SRC emacs-lisp
3111 (setq org-use-fast-todo-selection t)
3113 Changing a task state is done with =C-c C-t KEY=
3115 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
3118 #+BEGIN_SRC emacs-lisp
3119 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
3121 allows changing todo states with S-left and S-right skipping all of
3122 the normal processing when entering or leaving a todo state. This
3123 cycles through the todo states but skips setting timestamps and
3124 entering notes which is very convenient when all you want to do is fix
3125 up the status of an entry.
3127 **** Todo State Triggers
3128 I have a few triggers that automatically assign tags to tasks based on
3129 state changes. If a task moves to =CANCELLED= state then it gets a
3130 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
3131 =CANCELLED= tag. These are used for filtering tasks in agenda views
3132 which I'll talk about later.
3134 The triggers break down to the following rules:
3136 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
3137 - Moving a task to =WAITING= adds a =WAITING= tag
3138 - Moving a task to =HOLD= adds a =WAITING= tag
3139 - Moving a task to a done state removes a =WAITING= tag
3140 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
3141 - Moving a task to =NEXT= removes a =WAITING= tag
3142 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
3144 The tags are used to filter tasks in the agenda views conveniently.
3145 #+BEGIN_SRC emacs-lisp
3146 (setq org-todo-state-tags-triggers
3147 (quote (("CANCELLED" ("CANCELLED" . t))
3148 ("WAITING" ("WAITING" . t))
3149 ("HOLD" ("WAITING" . t) ("HOLD" . t))
3150 (done ("WAITING") ("HOLD"))
3151 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
3152 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
3153 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
3156 *** Capturing new tasks
3157 Org capture replaces the old remember mode.
3158 #+BEGIN_SRC emacs-lisp
3159 (setq org-directory "~/org")
3160 (setq org-default-notes-file "~/org/refile.org")
3162 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
3163 ;; see http://orgmode.org/manual/Template-elements.html
3164 (setq org-capture-templates
3165 (quote (("t" "todo" entry (file "~/org/refile.org")
3166 "* TODO %?\nAdded: %U\n"
3167 :clock-in t :clock-resume t)
3168 ("l" "linktodo" entry (file "~/org/refile.org")
3169 "* TODO %?\nAdded: %U\n%a\n"
3170 :clock-in t :clock-resume t)
3171 ("r" "respond" entry (file "~/org/refile.org")
3172 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
3173 :clock-in t :clock-resume t :immediate-finish t)
3174 ("n" "note" entry (file "~/org/refile.org")
3175 "* %? :NOTE:\nAdded: %U\n%a\n"
3176 :clock-in t :clock-resume t)
3177 ("d" "Delegated" entry (file "~/org/refile.org")
3178 "* DELEGATED %?\nAdded: %U\n%a\n"
3179 :clock-in t :clock-resume t)
3180 ("j" "Journal" entry (file+datetree "~/org/diary.org")
3182 :clock-in t :clock-resume t)
3183 ("w" "org-protocol" entry (file "~/org/refile.org")
3184 "* TODO Review %c\nAdded: %U\n"
3185 :immediate-finish t)
3186 ("p" "Phone call" entry (file "~/org/refile.org")
3187 "* PHONE %? :PHONE:\nAdded: %U"
3188 :clock-in t :clock-resume t)
3189 ("x" "Bookmark link" entry (file "~/org/refile.org")
3190 "* Bookmark: %c\n%i\nAdded: %U\n"
3191 :immediate-finish t)
3192 ("h" "Habit" entry (file "~/org/refile.org")
3193 "* 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")
3197 Capture mode now handles automatically clocking in and out of a
3198 capture task. This all works out of the box now without special hooks.
3199 When I start a capture mode task the task is clocked in as specified
3200 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
3201 resumes on the original clocking task.
3203 The quick clocking in and out of capture mode tasks (often it takes
3204 less than a minute to capture some new task details) can leave
3205 empty clock drawers in my tasks which aren't really useful.
3206 The following prevents this.
3207 #+BEGIN_SRC emacs-lisp
3208 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
3212 All my newly captured entries end up in =refile.org= and want to be
3213 moved over to the right place. The following is the setup for it.
3214 #+BEGIN_SRC emacs-lisp
3215 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
3216 (setq org-refile-targets (quote ((nil :maxlevel . 9)
3217 (org-agenda-files :maxlevel . 9))))
3219 ; Use full outline paths for refile targets - we file directly with IDO
3220 (setq org-refile-use-outline-path t)
3222 ; Targets complete directly with IDO
3223 (setq org-outline-path-complete-in-steps nil)
3225 ; Allow refile to create parent tasks with confirmation
3226 (setq org-refile-allow-creating-parent-nodes (quote confirm))
3228 ; Use IDO for both buffer and file completion and ido-everywhere to t
3229 (setq org-completion-use-ido t)
3230 (setq org-completion-use-iswitchb nil)
3231 :; Use IDO for both buffer and file completion and ido-everywhere to t
3232 ;(setq ido-everywhere t)
3233 ;(setq ido-max-directory-size 100000)
3234 ;(ido-mode (quote both))
3235 ; Use the current window when visiting files and buffers with ido
3236 (setq ido-default-file-method 'selected-window)
3237 (setq ido-default-buffer-method 'selected-window)
3239 ;;;; Refile settings
3240 (setq org-refile-target-verify-function 'bh/verify-refile-target)
3244 Agenda view is the central place for org-mode interaction...
3245 #+BEGIN_SRC emacs-lisp
3246 ;; Do not dim blocked tasks
3247 (setq org-agenda-dim-blocked-tasks nil)
3248 ;; Compact the block agenda view
3249 (setq org-agenda-compact-blocks t)
3251 ;; Custom agenda command definitions
3252 (setq org-agenda-custom-commands
3253 (quote (("N" "Notes" tags "NOTE"
3254 ((org-agenda-overriding-header "Notes")
3255 (org-tags-match-list-sublevels t)))
3256 ("h" "Habits" tags-todo "STYLE=\"habit\""
3257 ((org-agenda-overriding-header "Habits")
3258 (org-agenda-sorting-strategy
3259 '(todo-state-down effort-up category-keep))))
3263 ((org-agenda-overriding-header "Tasks to Refile")
3264 (org-tags-match-list-sublevels nil)))
3265 (tags-todo "-HOLD-CANCELLED/!"
3266 ((org-agenda-overriding-header "Projects")
3267 (org-agenda-skip-function 'bh/skip-non-projects)
3268 (org-agenda-sorting-strategy
3270 (tags-todo "-CANCELLED/!"
3271 ((org-agenda-overriding-header "Stuck Projects")
3272 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3273 (tags-todo "-WAITING-CANCELLED/!NEXT"
3274 ((org-agenda-overriding-header "Next Tasks")
3275 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3276 (org-agenda-todo-ignore-scheduled t)
3277 (org-agenda-todo-ignore-deadlines t)
3278 (org-agenda-todo-ignore-with-date t)
3279 (org-tags-match-list-sublevels t)
3280 (org-agenda-sorting-strategy
3281 '(todo-state-down effort-up category-keep))))
3282 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3283 ((org-agenda-overriding-header "Tasks")
3284 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3285 (org-agenda-todo-ignore-scheduled t)
3286 (org-agenda-todo-ignore-deadlines t)
3287 (org-agenda-todo-ignore-with-date t)
3288 (org-agenda-sorting-strategy
3290 (tags-todo "-CANCELLED+WAITING/!"
3291 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
3292 (org-agenda-skip-function 'bh/skip-stuck-projects)
3293 (org-tags-match-list-sublevels nil)
3294 (org-agenda-todo-ignore-scheduled 'future)
3295 (org-agenda-todo-ignore-deadlines 'future)))
3297 ((org-agenda-overriding-header "Tasks to Archive")
3298 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3299 (org-tags-match-list-sublevels nil))))
3301 ("r" "Tasks to Refile" tags "REFILE"
3302 ((org-agenda-overriding-header "Tasks to Refile")
3303 (org-tags-match-list-sublevels nil)))
3304 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
3305 ((org-agenda-overriding-header "Stuck Projects")
3306 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3307 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
3308 ((org-agenda-overriding-header "Next Tasks")
3309 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3310 (org-agenda-todo-ignore-scheduled t)
3311 (org-agenda-todo-ignore-deadlines t)
3312 (org-agenda-todo-ignore-with-date t)
3313 (org-tags-match-list-sublevels t)
3314 (org-agenda-sorting-strategy
3315 '(todo-state-down effort-up category-keep))))
3316 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3317 ((org-agenda-overriding-header "Tasks")
3318 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3319 (org-agenda-sorting-strategy
3321 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
3322 ((org-agenda-overriding-header "Projects")
3323 (org-agenda-skip-function 'bh/skip-non-projects)
3324 (org-agenda-sorting-strategy
3326 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
3327 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
3328 (org-tags-match-list-sublevels nil))
3329 ("A" "Tasks to Archive" tags "-REFILE/"
3330 ((org-agenda-overriding-header "Tasks to Archive")
3331 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3332 (org-tags-match-list-sublevels nil))))))
3334 ; Overwrite the current window with the agenda
3335 (setq org-agenda-window-setup 'current-window)
3340 #+BEGIN_SRC emacs-lisp
3342 ;; Resume clocking task when emacs is restarted
3343 (org-clock-persistence-insinuate)
3345 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
3346 (setq org-clock-history-length 36)
3347 ;; Resume clocking task on clock-in if the clock is open
3348 (setq org-clock-in-resume t)
3349 ;; Change tasks to NEXT when clocking in
3350 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
3351 ;; Separate drawers for clocking and logs
3352 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
3353 ;; Save clock data and state changes and notes in the LOGBOOK drawer
3354 (setq org-clock-into-drawer t)
3355 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
3356 (setq org-clock-out-remove-zero-time-clocks t)
3357 ;; Clock out when moving task to a done state
3358 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
3359 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
3360 (setq org-clock-persist t)
3361 ;; Do not prompt to resume an active clock
3362 (setq org-clock-persist-query-resume nil)
3363 ;; Enable auto clock resolution for finding open clocks
3364 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
3365 ;; Include current clocking task in clock reports
3366 (setq org-clock-report-include-clocking-task t)
3368 ; use discrete minute intervals (no rounding) increments
3369 (setq org-time-stamp-rounding-minutes (quote (1 1)))
3371 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
3373 (setq bh/keep-clock-running nil)
3375 (setq org-agenda-clock-consistency-checks
3376 (quote (:max-duration "4:00"
3379 :gap-ok-around ("4:00"))))
3383 **** Setting a default clock task
3384 Per default the =** Organization= task in my tasks.org file receives
3385 misc clock time. This is the task I clock in on when I punch in at the
3386 start of my work day with =F9-I=. Punching-in anywhere clocks in this
3387 Organization task as the default task.
3389 If I want to change the default clocking task I just visit the
3390 new task in any org buffer and clock it in with =C-u C-u C-c C-x
3391 C-i=. Now this new task that collects miscellaneous clock
3392 minutes when the clock would normally stop.
3394 You can quickly clock in the default clocking task with =C-u C-c
3395 C-x C-i d=. Another option is to repeatedly clock out so the
3396 clock moves up the project tree until you clock out the
3397 top-level task and the clock moves to the default task.
3400 #+BEGIN_SRC emacs-lisp
3401 ;; Agenda clock report parameters
3402 (setq org-agenda-clockreport-parameter-plist
3403 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
3405 ;; Agenda log mode items to display (closed and state changes by default)
3406 (setq org-agenda-log-mode-items (quote (closed state)))
3408 **** Task estimates, column view
3409 Setup column view globally with the following headlines
3410 #+BEGIN_SRC emacs-lisp
3411 ; Set default column view headings: Task Effort Clock_Summary
3412 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
3414 Setup the estimate for effort values.
3415 #+BEGIN_SRC emacs-lisp
3416 ; global Effort estimate values
3417 ; global STYLE property values for completion
3418 (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")
3419 ("STYLE_ALL" . "habit"))))
3423 Tags are mostly used for filtering inside the agenda.
3424 #+BEGIN_SRC emacs-lisp
3425 ; Tags with fast selection keys
3426 (setq org-tag-alist (quote ((:startgroup)
3444 ; Allow setting single tags without the menu
3445 (setq org-fast-tag-selection-single-key (quote expert))
3447 ; For tag searches ignore tasks with scheduled and deadline dates
3448 (setq org-agenda-tags-todo-honor-ignore-options t)
3452 #+BEGIN_SRC emacs-lisp
3453 (setq org-archive-mark-done nil)
3454 (setq org-archive-location "%s_archive::* Archived Tasks")
3458 #+BEGIN_SRC emacs-lisp
3459 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
3460 (setq org-plantuml-jar-path "~/java/plantuml.jar")
3462 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
3464 ; Make babel results blocks lowercase
3465 (setq org-babel-results-keyword "results")
3467 (org-babel-do-load-languages
3468 (quote org-babel-load-languages)
3469 (quote ((emacs-lisp . t)
3488 ; Do not prompt to confirm evaluation
3489 ; This may be dangerous - make sure you understand the consequences
3490 ; of setting this -- see the docstring for details
3491 (setq org-confirm-babel-evaluate nil)
3493 ; Use fundamental mode when editing plantuml blocks with C-c '
3494 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
3497 #+BEGIN_SRC emacs-lisp
3498 ;; Don't have images visible on startup, breaks on console
3499 (setq org-startup-with-inline-images nil)
3502 #+BEGIN_SRC emacs-lisp
3503 (add-to-list 'org-structure-template-alist
3504 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
3505 "<comment>\n?\n</comment>"))
3507 **** ditaa, graphviz, etc
3508 Those are all nice tools. Look at
3509 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
3512 *** Publishing and exporting
3515 Org-mode can export to a variety of publishing formats including (but not limited to)
3518 (plain text - but not the original org-mode file)
3522 which enables getting to lots of other formats like ODF, XML, etc
3524 via LaTeX or Docbook
3527 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
3529 #+BEGIN_SRC emacs-lisp
3530 ;; Explicitly load required exporters
3534 ;; FIXME, check the following two
3535 ;(require 'ox-icalendar)
3538 ; experimenting with docbook exports - not finished
3539 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
3540 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
3542 ;; define categories that should be excluded
3543 (setq org-export-exclude-category (list "google" "google"))
3544 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
3546 ; define how the date strings look
3547 (setq org-export-date-timestamp-format "%Y-%m-%d")
3548 ; Inline images in HTML instead of producting links to the image
3549 (setq org-html-inline-images t)
3550 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
3551 (setq org-export-with-sub-superscripts nil)
3553 (setq org-html-head-extra (concat
3554 "<link rel=\"stylesheet\" href=\"https://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
3556 (setq org-html-head-include-default-style nil)
3557 ; Do not generate internal css formatting for HTML exports
3558 (setq org-export-htmlize-output-type (quote css))
3559 ; Export with LaTeX fragments
3560 (setq org-export-with-LaTeX-fragments t)
3561 ; Increase default number of headings to export
3562 (setq org-export-headline-levels 6)
3565 (setq org-publish-project-alist
3568 :base-directory "~/.emacs.d/"
3569 :base-extension "org"
3571 :publishing-directory "/develop/www/emacs"
3573 :publishing-function org-html-publish-to-html
3574 :headline-levels 4 ; Just the default for this project.
3580 :base-directory "~/.emacs.d/"
3581 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
3582 :publishing-directory "/develop/www/emacs"
3583 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
3585 :publishing-function org-publish-attachment
3587 ("inherit-org-info-js"
3588 :base-directory "/develop/vcs/org-info-js/"
3590 :base-extension "js"
3591 :publishing-directory "/develop/www/"
3592 :publishing-function org-publish-attachment
3594 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
3599 (setq org-export-with-timestamps nil)
3604 #+BEGIN_SRC emacs-lisp
3605 (setq org-latex-to-pdf-process
3606 '("xelatex -interaction nonstopmode %f"
3607 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
3608 (setq org-export-latex-listings 'minted)
3609 (setq org-latex-listings t)
3611 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
3612 ;; but adapted to use latexmk 4.20 or higher.
3613 (defun my-auto-tex-cmd ()
3614 "When exporting from .org with latex, automatically run latex,
3615 pdflatex, or xelatex as appropriate, using latexmk."
3617 ;; default command: oldstyle latex via dvi
3618 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
3620 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
3621 (setq texcmd "latexmk -pdf -quiet %f"))
3623 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3624 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
3625 ;; LaTeX compilation command
3626 (setq org-latex-to-pdf-process (list texcmd)))
3628 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
3630 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
3631 (setq org-export-latex-packages-alist
3633 ("" "longtable" nil)
3638 (defun my-auto-tex-parameters ()
3639 "Automatically select the tex packages to include."
3640 ;; default packages for ordinary latex or pdflatex export
3641 (setq org-export-latex-default-packages-alist
3642 '(("AUTO" "inputenc" t)
3652 ("" "hyperref" nil)))
3654 ;; Packages to include when xelatex is used
3655 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3656 (setq org-export-latex-default-packages-alist
3661 ("german" "babel" t)
3662 ("babel" "csquotes" t)
3664 ("xetex" "hyperref" nil)
3667 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
3668 (setq org-export-latex-classes
3670 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
3671 ("\\section{%s}" . "\\section*{%s}")
3672 ("\\subsection{%s}" . "\\subsection*{%s}")
3673 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
3674 ("\\paragraph{%s}" . "\\paragraph*{%s}")
3675 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
3676 org-export-latex-classes))))
3678 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
3681 *** Prevent editing invisible text
3682 The following setting prevents accidentally editing hidden text when
3683 the point is inside a folded region. This can happen if you are in
3684 the body of a heading and globally fold the org-file with =S-TAB=
3686 I find invisible edits (and undo's) hard to deal with so now I can't
3687 edit invisible text. =C-c C-r= (org-reveal) will display where the
3688 point is if it is buried in invisible text to allow editing again.
3690 #+BEGIN_SRC emacs-lisp
3691 (setq org-catch-invisible-edits 'error)
3695 #+BEGIN_SRC emacs-lisp
3696 ;; disable the default org-mode stuck projects agenda view
3697 (setq org-stuck-projects (quote ("" nil nil "")))
3699 ; force showing the next headline.
3700 (setq org-show-entry-below (quote ((default))))
3702 (setq org-show-following-heading t)
3703 (setq org-show-hierarchy-above t)
3704 (setq org-show-siblings (quote ((default))))
3706 (setq org-special-ctrl-a/e t)
3707 (setq org-special-ctrl-k t)
3708 (setq org-yank-adjusted-subtrees t)
3710 (setq org-table-export-default-format "orgtbl-to-csv")
3714 The following setting adds alphabetical lists like
3718 #+BEGIN_SRC emacs-lisp
3719 (if (> emacs-major-version 23)
3720 (setq org-list-allow-alphabetical t)
3721 (setq org-alphabetical-lists t))
3724 #+BEGIN_SRC emacs-lisp
3725 (setq org-remove-highlights-with-change nil)
3727 (setq org-list-demote-modify-bullet (quote (("+" . "-")
3734 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
3737 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
3738 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
3743 #+BEGIN_SRC emacs-lisp
3744 ;; Enable abbrev-mode
3745 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
3746 (setq org-startup-indented t)
3747 (setq org-startup-folded t)
3748 (setq org-cycle-separator-lines 0)
3751 I find extra blank lines in lists and headings a bit of a nuisance.
3752 To get a body after a list you need to include a blank line between
3753 the list entry and the body -- and indent the body appropriately.
3754 Most of my lists have no body detail so I like the look of collapsed
3755 lists with no blank lines better.
3757 The following setting prevents creating blank lines before headings
3758 but allows list items to adapt to existing blank lines around the items:
3759 #+BEGIN_SRC emacs-lisp
3760 (setq org-blank-before-new-entry (quote ((heading)
3761 (plain-list-item . auto))))
3764 #+BEGIN_SRC emacs-lisp
3765 (setq org-reverse-note-order nil)
3766 (setq org-default-notes-file "~/notes.org")
3769 Enforce task blocking. Tasks can't go done when there is any subtask
3770 still open. Unless they have a property of =NOBLOCKING: t=
3771 #+BEGIN_SRC emacs-lisp
3772 (setq org-enforce-todo-checkbox-dependencies t)
3773 (setq org-enforce-todo-dependencies t)
3776 #+BEGIN_SRC emacs-lisp
3777 (setq org-fast-tag-selection-single-key (quote expert))
3778 (setq org-footnote-auto-adjust t)
3779 (setq org-hide-block-startup t)
3780 (setq org-icalendar-alarm-time 15)
3781 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
3782 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
3783 (setq org-icalendar-honor-noexport-tag t)
3784 (setq org-icalendar-include-bbdb-anniversaries nil)
3785 (setq org-icalendar-include-body 200)
3786 (setq org-icalendar-include-todo nil)
3787 (setq org-icalendar-store-UID t)
3788 (setq org-icalendar-timezone "Europe/Berlin")
3789 (setq org-insert-mode-line-in-empty-file t)
3790 (setq org-log-done (quote note))
3791 (setq org-log-into-drawer t)
3792 (setq org-log-state-notes-insert-after-drawers nil)
3793 (setq org-log-reschedule (quote time))
3794 (setq org-log-states-order-reversed t)
3795 (setq org-mobile-agendas (quote all))
3796 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
3797 (setq org-mobile-inbox-for-pull "~/org/refile.org")
3798 (setq org-remember-store-without-prompt t)
3799 (setq org-return-follows-link t)
3800 (setq org-reverse-note-order t)
3802 ; regularly save our org-mode buffers
3803 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
3805 (setq org-log-done t)
3807 (setq org-enable-priority-commands t)
3808 (setq org-default-priority ?E)
3809 (setq org-lowest-priority ?E)
3814 Speed commands enable single-letter commands in Org-mode files when
3815 the point is at the beginning of a headline, or at the beginning of a
3818 See the `=org-speed-commands-default=' variable for a list of the keys
3819 and commands enabled at the beginning of headlines. All code blocks
3820 are available at the beginning of a code block, the following key
3821 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
3822 display a list of the code blocks commands and their related keys.
3824 #+BEGIN_SRC emacs-lisp
3825 (setq org-use-speed-commands nil)
3826 (setq org-speed-commands-user (quote (("0" . ignore)
3839 ("h" . bh/hide-other)
3842 (call-interactively 'org-insert-heading-respect-content))
3843 ("k" . org-kill-note-or-show-branches)
3846 ("q" . bh/show-org-agenda)
3848 ("s" . org-save-all-org-buffers)
3852 ("z" . org-add-note)
3857 ("F" . bh/restrict-to-file-or-follow)
3860 ("J" . org-clock-goto)
3864 ("N" . bh/narrow-to-org-subtree)
3865 ("P" . bh/narrow-to-org-project)
3870 ("U" . bh/narrow-up-one-org-level)
3877 (add-hook 'org-agenda-mode-hook
3879 (define-key org-agenda-mode-map "q" 'bury-buffer))
3882 (defvar bh/current-view-project nil)
3883 (add-hook 'org-agenda-mode-hook
3884 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
3889 The following displays the contents of code blocks in Org-mode files
3890 using the major-mode of the code. It also changes the behavior of
3891 =TAB= to as if it were used in the appropriate major mode. This means
3892 that reading and editing code form inside of your Org-mode files is
3893 much more like reading and editing of code using its major mode.
3895 #+BEGIN_SRC emacs-lisp
3896 (setq org-src-fontify-natively t)
3897 (setq org-src-tab-acts-natively t)
3900 #+BEGIN_SRC emacs-lisp
3901 (setq org-src-preserve-indentation nil)
3902 (setq org-edit-src-content-indentation 0)
3906 #+BEGIN_SRC emacs-lisp
3907 (setq org-attach-directory "~/org/data/")
3909 #+BEGIN_SRC emacs-lisp
3910 (setq org-agenda-sticky t)
3913 **** Checklist handling
3914 [2013-05-11 Sat 22:15]
3916 #+BEGIN_SRC emacs-lisp
3917 ;(require 'org-checklist)
3921 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
3923 #+BEGIN_SRC emacs-lisp
3924 (use-package cperl-mode
3925 :commands cperl-mode
3928 (defalias 'perl-mode 'cperl-mode)
3929 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
3930 (add-auto-mode 'pod-mode "\\.pod$")
3931 (add-auto-mode 'tt-mode "\\.tt$")
3932 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
3933 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
3934 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
3938 (setq cperl-invalid-face nil
3939 cperl-close-paren-offset -4
3940 cperl-continued-statement-offset 0
3941 cperl-indent-level 4
3942 cperl-indent-parens-as-block t
3944 cperl-electric-keywords t
3945 cperl-electric-lbrace-space t
3946 cperl-electric-parens nil
3947 cperl-highlight-variables-indiscriminately t
3948 cperl-imenu-addback t
3949 cperl-invalid-face (quote underline)
3950 cperl-lazy-help-time 5
3951 cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$"
3952 cperl-syntaxify-by-font-lock t
3953 cperl-use-syntax-table-text-property-for-tags t)
3955 ;; And have cperl mode give ElDoc a useful string
3956 (defun my-cperl-eldoc-documentation-function ()
3957 "Return meaningful doc string for `eldoc-mode'."
3959 (let ((cperl-message-on-help-error nil))
3961 (add-hook 'cperl-mode-hook
3963 (set (make-local-variable 'eldoc-documentation-function)
3964 'my-cperl-eldoc-documentation-function)
3969 [2014-05-22 Thu 00:05]
3970 #+BEGIN_SRC emacs-lisp
3971 (use-package puppet-mode
3972 :mode ("\\.pp\\'" . puppet-mode)
3973 :commands puppet-mode
3976 (defun my-puppet-mode-hook ()
3977 (setq require-final-newline nil))
3978 (add-hook 'puppet-mode-hook 'my-puppet-mode-hook))
3981 (use-package puppet-ext
3984 (bind-key "C-x ?" 'puppet-set-anchor puppet-mode-map)
3985 (bind-key "C-c C-r" 'puppet-create-require puppet-mode-map)))))
3989 Use elpy for the emacs python fun, but dont let it initialize all the
3990 various variables. Elpy author may like them, but I'm not him...
3991 #+BEGIN_SRC emacs-lisp
3994 :mode ("\.py" . python-mode)
3997 (safe-load (concat jj-elisp-dir "/elpy/elpy-autoloads.el"))
4004 :commands (nosetests-all nosetests-module nosetests-one
4005 nosetests-failed nosetests-pdb-all
4006 nosetests-pdb-module nosetests-pdb-one)
4011 :commands (pyvenv-activate pyvenv-deactivate pyvenv-mode pyvenv-restart-python)
4014 (use-package idomenu
4019 (use-package highlight-indentation
4021 :commands (highlight-indentation-mode))
4023 (use-package find-file-in-project
4025 :commands (find-file-in-project ffip-project-files ffip ))
4030 ;; Local variables in `python-mode'. This is not removed when Elpy
4031 ;; is disabled, which can cause some confusion.
4032 (add-hook 'python-mode-hook 'elpy-initialize-local-variables)
4034 (defun my-python-mode-hook ()
4035 (setq require-final-newline nil)
4036 (setq mode-require-final-newline))
4037 (add-hook 'python-mode-hook 'my-python-mode-hook)
4039 ;; Flymake support using flake8, including warning faces.
4040 (when (and (executable-find "flake8")
4041 (not (executable-find python-check-command)))
4042 (setq python-check-command "flake8"))
4044 ;; `flymake-no-changes-timeout': The original value of 0.5 is too
4045 ;; short for Python code, as that will result in the current line to
4046 ;; be highlighted most of the time, and that's annoying. This value
4047 ;; might be on the long side, but at least it does not, in general,
4048 ;; interfere with normal interaction.
4049 (setq flymake-no-changes-timeout 60)
4051 ;; `flymake-start-syntax-check-on-newline': This should be nil for
4052 ;; Python, as;; most lines with a colon at the end will mean the next
4053 ;; line is always highlighted as error, which is not helpful and
4055 (setq flymake-start-syntax-check-on-newline nil)
4057 ;; `ac-auto-show-menu': Short timeout because the menu is great.
4058 (setq ac-auto-show-menu 0.4)
4060 ;; `ac-quick-help-delay': I'd like to show the menu right with the
4061 ;; completions, but this value should be greater than
4062 ;; `ac-auto-show-menu' to show help for the first entry as well.
4063 (setq ac-quick-help-delay 0.5)
4065 ;; `yas-trigger-key': TAB, as is the default, conflicts with the
4066 ;; autocompletion. We also need to tell yasnippet about the new
4067 ;; binding. This is a bad interface to set the trigger key. Stop
4069 (let ((old (when (boundp 'yas-trigger-key)
4071 (setq yas-trigger-key "C-c C-i")
4072 (when (fboundp 'yas--trigger-key-reload)
4073 (yas--trigger-key-reload old)))
4075 ;; yas-snippet-dirs can be a string for a single directory. Make
4076 ;; sure it's a list in that case so we can add our own entry.
4077 (when (not (listp yas-snippet-dirs))
4078 (setq yas-snippet-dirs (list yas-snippet-dirs)))
4079 (add-to-list 'yas-snippet-dirs
4080 (concat (file-name-directory (locate-library "elpy"))
4084 ;; Now load yasnippets.
4087 (elpy-use-ipython)))
4092 #+BEGIN_SRC emacs-lisp :tangle no
4093 (autoload 'python-mode "python-mode" "Python Mode." t)
4094 (add-auto-mode 'python-mode "\\.py\\'")
4095 (add-auto-mode 'python-mode "\\.py$")
4096 (add-auto-mode 'python-mode "SConstruct\\'")
4097 (add-auto-mode 'python-mode "SConscript\\'")
4098 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
4101 (set-variable 'py-indent-offset 4)
4102 (set-variable 'py-smart-indentation nil)
4103 (set-variable 'indent-tabs-mode nil)
4104 (define-key python-mode-map "\C-m" 'newline-and-indent)
4105 (turn-on-eldoc-mode)
4106 (defun python-auto-fill-comments-only ()
4108 (set (make-local-variable 'fill-nobreak-predicate)
4110 (not (python-in-string/comment)))))
4111 (add-hook 'python-mode-hook
4113 (python-auto-fill-comments-only)))
4115 (autoload 'pymacs-apply "pymacs")
4116 (autoload 'pymacs-call "pymacs")
4117 (autoload 'pymacs-eval "pymacs" nil t)
4118 (autoload 'pymacs-exec "pymacs" nil t)
4119 (autoload 'pymacs-load "pymacs" nil t))
4122 If an =ipython= executable is on the path, then assume that IPython is
4123 the preferred method python evaluation.
4124 #+BEGIN_SRC emacs-lisp :tangle no
4125 (when (executable-find "ipython")
4127 (setq org-babel-python-mode 'python-mode))
4129 (setq python-shell-interpreter "ipython")
4130 (setq python-shell-interpreter-args "")
4131 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
4132 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
4133 (setq python-shell-completion-setup-code
4134 "from IPython.core.completerlib import module_completion")
4135 (setq python-shell-completion-module-string-code
4136 "';'.join(module_completion('''%s'''))\n")
4137 (setq python-shell-completion-string-code
4138 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
4140 ** rainbow-delimiters
4141 [2013-04-09 Di 23:38]
4142 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
4143 which highlights parens, brackets, and braces according to their
4144 depth. Each successive level is highlighted a different color. This
4145 makes it easy to spot matching delimiters, orient yourself in the code,
4146 and tell which statements are at the same depth.
4147 #+BEGIN_SRC emacs-lisp
4148 (use-package rainbow-delimiters
4149 :ensure rainbow-delimiters
4150 :commands rainbow-delimiters-mode
4152 (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
4155 #+BEGIN_SRC emacs-lisp
4156 (use-package rainbow-mode
4157 :ensure rainbow-mode
4159 :diminish rainbow-mode)
4164 #+BEGIN_SRC emacs-lisp
4165 (use-package re-builder
4166 :commands re-builder
4169 (setq reb-re-syntax 'string))
4172 [2014-05-19 Mo 22:56]
4173 Recentf is a minor mode that builds a list of recently opened
4174 files. This list is is automatically saved across Emacs sessions.
4175 #+BEGIN_SRC emacs-lisp
4176 (use-package recentf
4177 :if (not noninteractive)
4178 :bind ("C-x C-r" . recentf-open-files)
4183 (setq recentf-max-menu-items 25)
4184 (setq recentf-save-file (expand-file-name ".recentf" jj-cache-dir))
4186 (defun recentf-add-dired-directory ()
4187 (if (and dired-directory
4188 (file-directory-p dired-directory)
4189 (not (string= "/" dired-directory)))
4190 (let ((last-idx (1- (length dired-directory))))
4192 (if (= ?/ (aref dired-directory last-idx))
4193 (substring dired-directory 0 last-idx)
4194 dired-directory)))))
4196 (add-hook 'dired-mode-hook 'recentf-add-dired-directory)))
4198 ** Region bindings mode
4199 [2013-05-01 Wed 22:51]
4200 This mode allows to have keybindings that are only alive when the
4201 region is active. Helpful for things that only do any useful action
4202 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
4203 #+BEGIN_SRC emacs-lisp
4204 (use-package region-bindings-mode
4205 :ensure region-bindings-mode
4207 (region-bindings-mode-enable))
4210 [2013-05-22 Wed 22:33]
4211 Programming in ruby...
4214 #+BEGIN_SRC emacs-lisp
4215 (add-auto-mode 'ruby-mode
4216 "Rakefile\\'" "\\.rake\\'" "\.rxml\\'"
4217 "\\.rjs\\'" ".irbrc\\'" "\.builder\\'" "\\.ru\\'"
4218 "\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
4222 #+BEGIN_SRC emacs-lisp
4223 (use-package ruby-mode
4224 :mode ("\\.rb\\'" . ruby-mode)
4225 :interpreter ("ruby" . ruby-mode)
4232 (defvar yari-helm-source-ri-pages
4233 '((name . "RI documentation")
4234 (candidates . (lambda () (yari-ruby-obarray)))
4235 (action ("Show with Yari" . yari))
4236 (candidate-number-limit . 300)
4237 (requires-pattern . 2)
4238 "Source for completing RI documentation."))
4240 (defun helm-yari (&optional rehash)
4241 (interactive (list current-prefix-arg))
4242 (when current-prefix-arg (yari-ruby-obarray rehash))
4243 (helm 'yari-helm-source-ri-pages (yari-symbol-at-point)))))
4245 (defun my-ruby-smart-return ()
4247 (when (memq (char-after) '(?\| ?\" ?\'))
4249 (call-interactively 'newline-and-indent))
4251 (use-package ruby-hash-syntax
4252 :ensure ruby-hash-syntax)
4254 (use-package inf-ruby
4256 :commands inf-ruby-minor-mode
4259 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)
4260 (bind-key "<return>" 'my-ruby-smart-return ruby-mode-map)
4261 ;(bind-key "<tab>" 'indent-for-tab-command ruby-mode-map)
4264 (set (make-local-variable 'yas-fallback-behavior)
4265 '(apply ruby-indent-command . nil))
4266 (bind-key "<tab>" 'yas-expand-from-trigger-key ruby-mode-map)))
4268 ;; Stupidly the non-bundled ruby-mode isn't a derived mode of
4269 ;; prog-mode: we run the latter's hooks anyway in that case.
4270 (add-hook 'ruby-mode-hook
4272 (unless (derived-mode-p 'prog-mode)
4273 (run-hooks 'prog-mode-hook))))
4277 [2013-05-22 Wed 22:40]
4278 Save and restore the desktop
4279 #+BEGIN_SRC emacs-lisp
4280 (setq desktop-path (list jj-cache-dir))
4281 (desktop-save-mode 1)
4282 (defadvice desktop-read (around trace-desktop-errors activate)
4283 (let ((debug-on-error t))
4286 ;;----------------------------------------------------------------------------
4287 ;; Restore histories and registers after saving
4288 ;;----------------------------------------------------------------------------
4289 (use-package session
4290 :if (not noninteractive)
4291 :load-path "site-lisp/session/lisp/"
4294 (setq session-save-file (expand-file-name "session" jj-cache-dir))
4295 (setq desktop-globals-to-save
4296 (append '((extended-command-history . 30)
4297 (file-name-history . 100)
4299 (compile-history . 30)
4300 (minibuffer-history . 50)
4301 (query-replace-history . 60)
4302 (read-expression-history . 60)
4303 (regexp-history . 60)
4304 (regexp-search-ring . 20)
4306 (comint-input-ring . 50)
4307 (shell-command-history . 50)
4309 desktop-missing-file-warning
4313 (session-initialize)
4315 (defun remove-session-use-package-from-settings ()
4316 (when (string= (file-name-nondirectory (buffer-file-name)) "settings.el")
4318 (goto-char (point-min))
4319 (when (re-search-forward "^ '(session-use-package " nil t)
4320 (delete-region (line-beginning-position)
4321 (1+ (line-end-position)))))))
4323 (add-hook 'before-save-hook 'remove-session-use-package-from-settings)
4325 ;; expanded folded secitons as required
4326 (defun le::maybe-reveal ()
4327 (when (and (or (memq major-mode '(org-mode outline-mode))
4328 (and (boundp 'outline-minor-mode)
4329 outline-minor-mode))
4330 (outline-invisible-p))
4331 (if (eq major-mode 'org-mode)
4335 (add-hook 'session-after-jump-to-last-change-hook
4338 (defun save-information ()
4339 (with-temp-message "Saving Emacs information..."
4342 (loop for func in kill-emacs-hook
4343 unless (memq func '(exit-gnus-on-exit server-force-stop))
4346 (unless (or noninteractive
4347 (eq 'listen (process-status server-process)))
4350 (run-with-idle-timer 300 t 'save-information)
4353 (add-hook 'after-init-hook 'session-initialize t))))
4357 [2013-04-21 So 20:25]
4358 Save a bit of history
4359 #+BEGIN_SRC emacs-lisp tangle no
4361 (setq savehist-additional-variables
4362 '(search ring regexp-search-ring kill-ring compile-history))
4363 ;; save every minute
4364 (setq savehist-autosave-interval 60)
4365 (setq savehist-file (expand-file-name "savehist" jj-cache-dir))
4370 Store at which point I have been in files.
4371 #+BEGIN_SRC emacs-lisp
4372 (setq-default save-place t)
4373 (require 'saveplace)
4374 (setq save-place-file (expand-file-name "saved-places" jj-cache-dir))
4377 [2014-06-10 Tue 22:05]
4378 #+BEGIN_SRC emacs-lisp
4379 (use-package simple-httpd
4380 :ensure simple-httpd
4381 :commands (httpd-start httpd-stop)
4384 (setq httpd-root "/srv/www")
4389 Settings for shell scripts
4390 #+BEGIN_SRC emacs-lisp
4391 (use-package sh-script
4395 (defvar sh-script-initialized nil)
4396 (defun initialize-sh-script ()
4397 (unless sh-script-initialized
4398 (setq sh-script-initialized t)
4399 (setq sh-indent-comment t)
4400 (info-lookup-add-help :mode 'shell-script-mode
4403 '(("(bash)Index")))))
4405 (add-hook 'shell-mode-hook 'initialize-sh-script)))
4408 #+BEGIN_SRC emacs-lisp
4409 (use-package sh-toggle
4410 :bind ("C-. C-z" . shell-toggle))
4413 [2015-02-24 Tue 23:35]
4414 Make =M-n= and =M-p= go forward/backword to the symbol at point.
4415 #+BEGIN_SRC emacs-lisp
4416 (use-package smartscan
4419 :idle (global-smartscan-mode t))
4422 By default, Emacs can update the time stamp for the following two
4423 formats if one exists in the first 8 lines of the file.
4426 #+BEGIN_SRC emacs-lisp
4427 (use-package time-stamp
4428 :commands time-stamp
4431 (add-hook 'write-file-hooks 'time-stamp)
4432 (setq time-stamp-active t))
4435 (setq time-stamp-format "%02H:%02M:%02S (%z) - %02d.%02m.%:y from %u (%U) on %s")
4436 (setq time-stamp-old-format-warn nil)
4437 (setq time-stamp-time-zone nil)))
4441 We configure only a bit of the tiny-tools to load when I should need
4442 them. I don't need much actually, but these things are nice to have.
4444 #+BEGIN_SRC emacs-lisp
4445 (autoload 'turn-on-tinyperl-mode "tinyperl" "" t)
4446 (add-hook 'perl-mode-hook 'turn-on-tinyperl-mode)
4447 (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode)
4449 (autoload 'tinycomment-indent-for-comment "tinycomment" "" t)
4450 (autoload 'tinyeat-forward-preserve "tinyeat" "" t)
4451 (autoload 'tinyeat-backward-preserve "tinyeat" "" t)
4452 (autoload 'tinyeat-kill-line-backward "tinyeat" "" t)
4454 *** Keyboard changes for tiny-tools
4455 #+BEGIN_SRC emacs-lisp
4456 (bind-key "\M-;" 'tinycomment-indent-for-comment)
4457 (bind-key "ESC C-k" 'tinyeat-kill-line-backward)
4458 (bind-key "ESC d" 'tinyeat-forward-preserve)
4459 (bind-key "<M-backspace>" 'tinyeat-backward-preserve)
4460 (bind-key "<S-backspace>" 'tinyeat-delete-whole-word)
4463 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
4464 #+BEGIN_SRC emacs-lisp
4469 (setq tramp-persistency-file-name (expand-file-name "tramp" jj-cache-dir))
4470 (setq shell-prompt-pattern "^[^a-zA-Z].*[#$%>] *")
4471 (add-to-list 'tramp-default-method-alist '("\\`localhost\\'" "\\`root\\'" "su"))
4472 (setq tramp-debug-buffer nil)
4473 (setq tramp-default-method "sshx")
4474 (tramp-set-completion-function "ssh"
4475 '((tramp-parse-sconfig "/etc/ssh_config")
4476 (tramp-parse-sconfig "~/.ssh/config")))
4477 (setq tramp-verbose 5)
4482 For some reason I prefer this mode more than the way without. I want to
4483 see the marked region.
4484 #+BEGIN_SRC emacs-lisp
4485 (transient-mark-mode 1)
4486 (make-variable-buffer-local 'transient-mark-mode)
4487 (put 'transient-mark-mode 'permanent-local t)
4488 (setq-default transient-mark-mode t)
4491 [2013-04-21 So 11:07]
4492 Emacs undo is pretty powerful - but can also be confusing. There are
4493 tons of modes available to change it, even downgrade it to the very
4494 crappy ways one usually knows from other systems which lose
4495 information. undo-tree is different - it helps keeping you sane while
4496 keeping the full power of emacs undo/redo.
4497 #+BEGIN_SRC emacs-lisp
4498 (use-package undo-tree
4500 :diminish undo-tree-mode
4503 (global-undo-tree-mode)
4504 (setq undo-tree-visualizer-timestamps t)
4505 (setq undo-tree-visualizer-diff t)
4506 ;; Keep region when undoing in region
4507 (defadvice undo-tree-undo (around keep-region activate)
4509 (let ((m (set-marker (make-marker) (mark)))
4510 (p (set-marker (make-marker) (point))))
4519 Always have unique buffernames. See [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html][Uniquify - GNU Emacs Manual]]
4520 #+BEGIN_SRC emacs-lisp
4521 (use-package uniquify
4524 (setq uniquify-buffer-name-style 'post-forward)
4525 (setq uniquify-after-kill-buffer-p t)
4526 (setq uniquify-ignore-buffers-re "^\\*")))
4530 url contains code to parse and handle URLs - who would have thought? I
4531 set it to send Accept-language header and tell it to not send email,
4532 operating system or location info.
4533 #+BEGIN_SRC emacs-lisp
4534 (setq url-mime-language-string "de,en")
4535 (setq url-privacy-level (quote (email os lastloc)))
4538 [2014-06-01 Sun 21:38]
4539 visual-regexp for Emacs is like replace-regexp, but with live visual
4540 feedback directly in the buffer
4541 #+BEGIN_SRC emacs-lisp
4542 (use-package visual-regexp
4543 :ensure visual-regexp
4544 :bind (("C-M-%" . vr/replace)
4545 ("M-%" . vr/query-replace)
4546 ("C-c m" . vr/mc-mark))
4549 ** volatile highlights
4550 [2013-04-21 So 20:31]
4551 VolatileHighlights highlights changes to the buffer caused by commands
4552 such as ‘undo’, ‘yank’/’yank-pop’, etc. The highlight disappears at the
4553 next command. The highlighting gives useful visual feedback for what
4554 your operation actually changed in the buffer.
4555 #+BEGIN_SRC emacs-lisp
4556 (use-package volatile-highlights
4557 :ensure volatile-highlights
4559 (volatile-highlights-mode t)
4560 :diminish volatile-highlights-mode)
4563 [2015-02-23 Mon 14:38]
4564 Easily move between splitted windows.
4565 #+BEGIN_SRC emacs-lisp
4566 (use-package windmove
4569 (windmove-default-keybindings)
4571 ;(setq org-replace-disputed-keys t)
4574 ** winner mode - undo and redo window configuration
4575 [2015-02-24 Tue 23:11]
4576 =winner-mode= lets you use =C-c <left>= and =C-c <right>= to switch between
4577 window configurations. This is handy when something has popped up a
4578 buffer that you want to look at briefly before returning to whatever
4579 you were working on. When you're done, press =C-c <left>=.
4580 #+BEGIN_SRC emacs-lisp
4584 :idle (winner-mode 1))
4587 This highlights some /weaselwords/, a mode to /aid in finding common
4588 writing problems/...
4589 [2013-04-27 Sa 23:29]
4590 #+BEGIN_SRC emacs-lisp :tangle no
4591 (use-package writegood-mode
4592 :ensure writegood-mode
4595 (bind-key "C-c g" 'writegood-mode))
4598 [2014-06-01 Sun 22:48]
4599 #+BEGIN_SRC emacs-lisp
4600 (use-package web-mode
4603 :mode (("\\.phtml\\'" . web-mode)
4604 ("\\.tpl\\.php\\'" . web-mode)
4605 ("\\.jsp\\'" . web-mode)
4606 ("\\.as[cp]x\\'" . web-mode)
4607 ("\\.erb\\'" . web-mode)
4608 ("\\.mustache\\'" . web-mode)
4609 ("\\.html\\'" . web-mode)
4610 ("\\.css\\'" . web-mode)
4611 ("\\.djhtml\\'" . web-mode))
4614 (add-hook 'web-mode-hook
4616 (setq web-mode-markup-indent-offset 2)
4617 (setq web-mode-css-indent-offset 2)
4618 (setq web-mode-code-indent-offset 2)
4619 (setq web-mode-enable-css-colorization t)
4620 (setq web-mode-enable-comment-keywords t)
4621 (setq web-mode-enable-current-element-highlight t))))
4624 (setq web-mode-enable-current-element-highlight t)
4625 (setq web-mode-ac-sources-alist
4626 '(("css" . (ac-source-css-property))
4627 ("html" . (ac-source-words-in-buffer ac-source-abbrev))))
4628 (use-package impatient-mode
4629 :ensure impatient-mode
4631 :commands impatient-mode))
4636 Yet another folding extension for the Emacs editor. Unlike many
4637 others, this one works by just using the existing indentation of the
4638 file, so basically works in every halfway structured file.
4639 #+BEGIN_SRC emacs-lisp
4640 (use-package yafolding
4641 :bind (("C-#" . yafolding)
4642 ("C-c C-f" . yafolding-toggle-all-by-current-level))
4643 :commands (yafolding yafolding-toggle-all-by-current-level)
4647 [2013-04-28 So 01:13]
4648 YAML is a nice format for data, which is both, human and machine
4649 readable/editable without getting a big headache.
4650 #+BEGIN_SRC emacs-lisp
4651 (use-package yaml-mode
4653 :mode ("\\.ya?ml\\'" . yaml-mode)
4655 (bind-key "C-m" 'newline-and-indent yaml-mode-map ))
4659 [2013-04-27 Sa 23:16]
4660 Yasnippet is a template system. Type an abbreviation, expand it into
4661 whatever the snippet holds.
4662 #+BEGIN_SRC emacs-lisp
4663 (setq yas-snippet-dirs (expand-file-name "yasnippet/snippets" jj-elisp-dir))
4664 (use-package yasnippet
4667 :diminish yas-minor-mode
4668 :commands yas-global-mode
4671 ;; Integrate hippie-expand with ya-snippet
4672 (add-to-list 'hippie-expand-try-functions-list
4673 'yas-hippie-try-expand)
4675 (setq yas-expand-only-for-last-commands '(self-insert-command))
4676 (bind-key "\t" 'hippie-expand yas-minor-mode-map)
4680 And thats it for this file, control passes "back" to [[file:../initjj.org][initjj.org/el]]
4681 which then may load more files.