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 yes
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
432 *** Keyboard related changes
434 This lets M-SPC cycle through spacing, that is
435 1. replace all spaces with a single space
437 3. restore the original spacing
438 #+BEGIN_SRC emacs-lisp :tangle yes
439 (bind-key "M-SPC" 'cycle-spacing)
441 **** Toggle/Cycle letter case
442 [2015-05-22 Fri 22:42]
444 This is from [[http://ergoemacs.org/emacs/modernization_upcase-word.html][Emacs: Toggle/Cycle Letter Case]]
446 Emacs has several user level commands for changing letter case. They
447 are: upcase-word 【Alt+u】, downcase-word 【Alt+l】, capitalize-word
450 There are also “region” versions for each: upcase-region 【Ctrl+x
451 Ctrl+u】, downcase-region 【Ctrl+x Ctrl+l】, capitalize-region, and
452 also upcase-initials-region. (Note: for elisp programing, there are
453 also these functions: upcase, capitalize, downcase, upcase-initials.)
455 One problem with these commands is that you need to move your cursor
456 to the beginning of the word first. For example, if you have the text
457 “THat”, and your cursor is on the “a”, and you call downcase-word, but
458 it doesn't do anything because it only start at the cursor point to
459 end of word. It would be nice if it'll just automatically perform the
460 operation on the whole word.
462 Another problem is that it does not consider the final result. For
463 example, if you have “oncE upon a time …”, and you select the whole
464 sentence and call upcase-initials-region, it becomes “OncE Upon A Time
465 …”. Note the capital E is not automatically lowered. For elisp
466 programing, the orthogonal precision is nice, but as user commands, it
467 is better to change the whole sentence.
469 Also, these commands have a “-word” and “-region” variants, great for
470 precision in elisp programing but not smart as user commands. It would
471 be nice if emacs automatically choose the right command depending
472 whether there is text selection.
473 #+BEGIN_SRC emacs-lisp :tangle yes
474 (bind-key "M-c" 'toggle-letter-case)
476 ** Miscellaneous stuff
477 Searches and matches should ignore case.
478 #+BEGIN_SRC emacs-lisp
479 (setq-default case-fold-search t)
482 Which buffers to get rid off at midnight.
483 #+BEGIN_SRC emacs-lisp
484 (setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
485 "*Man " "*Buffer List*"
491 "*magit" "*Calendar")))
494 Don't display a cursor in non-selected windows.
495 #+BEGIN_SRC emacs-lisp
496 (setq-default cursor-in-non-selected-windows nil)
499 What should be displayed in the mode-line for files with those types
501 #+BEGIN_SRC emacs-lisp
502 (setq eol-mnemonic-dos "(DOS)")
503 (setq eol-mnemonic-mac "(Mac)")
506 Much larger threshold for garbage collection prevents it to run too often.
507 #+BEGIN_SRC emacs-lisp
508 (setq gc-cons-threshold 48000000)
511 #+BEGIN_SRC emacs-lisp
512 (setq max-lisp-eval-depth 1000)
513 (setq max-specpdl-size 3000)
517 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
518 #+BEGIN_SRC emacs-lisp
519 (defun unfill-paragraph ()
520 "Takes a multi-line paragraph and makes it into a single line of text."
522 (let ((fill-column (point-max)))
523 (fill-paragraph nil)))
524 (bind-key "H-u" 'unfill-paragraph)
527 #+BEGIN_SRC emacs-lisp
528 (setq-default indicate-empty-lines t)
529 (setq sentence-end-double-space nil)
532 Hilight annotations in comments, like FIXME/TODO/...
533 #+BEGIN_SRC emacs-lisp
534 (add-hook 'prog-mode-hook 'font-lock-comment-annotations)
538 #+BEGIN_SRC emacs-lisp
539 (setq browse-url-browser-function (quote browse-url-generic))
540 (setq browse-url-generic-program "/usr/bin/x-www-browser")
543 *** When saving a script - make it executable
544 #+BEGIN_SRC emacs-lisp
545 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
549 #+BEGIN_SRC emacs-lisp
553 (add-hook 'after-init-hook 'server-start)))
556 ** Customized variables
557 [2013-05-02 Thu 22:14]
558 The following contains a set of variables i may reasonably want to
559 change on other systems - which don't affect the init file loading
560 process. So I *can* use the customization interface for it...
561 #+BEGIN_SRC emacs-lisp
562 (defgroup ganneff nil
563 "Modify ganneffs settings"
566 (defgroup ganneff-org-mode nil
567 "Ganneffs org-mode settings"
568 :tag "Ganneffs org-mode settings"
570 :link '(custom-group-link "ganneff"))
572 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
573 "ID of the organization task."
574 :tag "Organization Task ID"
576 :group 'ganneff-org-mode)
578 (defcustom org-my-archive-expiry-days 2
579 "The number of days after which a completed task should be auto-archived.
580 This can be 0 for immediate, or a floating point value."
581 :tag "Archive expiry days"
583 :group 'ganneff-org-mode)
588 [2013-05-21 Tue 23:22]
589 Restore removed var alias, used by ruby-electric-brace and others
590 #+BEGIN_SRC emacs-lisp
591 (unless (boundp 'last-command-char)
592 (defvaralias 'last-command-char 'last-command-event))
594 * Customized variables
596 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
598 Of course I want to be able to use the customize interface, and some
599 things can only be set via it (or so they say). I usually prefer to put
600 things I keep for a long while into statements somewhere else, not just
601 custom-set here, but we need it anyways.
603 #+BEGIN_SRC emacs-lisp
604 (setq custom-file jj-custom-file)
605 (safe-load custom-file)
608 The source of this is:
609 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
610 * Extra modes and their configuration
612 A defined abbrev is a word which expands, if you insert it, into some
613 different text. Abbrevs are defined by the user to expand in specific
615 #+BEGIN_SRC emacs-lisp
617 :commands abbrev-mode
618 :diminish abbrev-mode
620 (hook-into-modes #'abbrev-mode '(text-mode-hook))
623 (setq save-abbrevs 'silently)
624 (setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
625 (if (file-exists-p abbrev-file-name)
626 (quietly-read-abbrev-file))
628 (add-hook 'expand-load-hook
630 (add-hook 'expand-expand-hook 'indent-according-to-mode)
631 (add-hook 'expand-jump-hook 'indent-according-to-mode)))))
634 [2013-04-28 So 11:26]
635 avy is a GNU Emacs package for jumping to visible text using a char-based decision tree.
636 #+BEGIN_SRC emacs-lisp
639 :commands (avy-goto-char avy-goto-char-2 avy-goto-line avy-goto-word-1 avy-goto-word-0 avy-isearch avy-goto-subword-0 avy-goto-subword-1 avy-copy-line avy-copy-region avy-move-line)
640 :bind (("H-SPC" . avy-goto-char-2)
641 ("M-g g" . avy-goto-line)
645 (setq avy-all-windows 'all-frames)
646 (setq avi-keys '(?a ?s ?d ?e ?f ?h ?j ?k ?l ?n ?m ?v ?r ?u) )
650 (bind-key "C-y" 'avy-isearch isearch-mode-map)
655 [2013-04-21 So 20:27]
656 Use H-w to switch windows
657 #+BEGIN_SRC emacs-lisp
658 (use-package ace-window
661 :bind ("H-w" . ace-window)
664 (setq aw-keys '(?a ?s ?d ?f ?j ?k ?l))
668 [2014-10-27 Mon 13:08]
669 electric-indent-mode is enough to keep your code nicely aligned when
670 all you do is type. However, once you start shifting blocks around,
671 transposing lines, or slurping and barfing sexps, indentation is bound
674 aggressive-indent-mode is a minor mode that keeps your code always
675 indented. It reindents after every command, making it more reliable
676 than electric-indent-mode.
677 #+BEGIN_SRC emacs-lisp
678 (use-package aggressive-indent
679 :ensure aggressive-indent
680 :commands (aggressive-indent-mode global-aggressive-indent-mode)
683 (global-aggressive-indent-mode 0)
684 (setq aggressive-indent-comments-too 0)
685 (add-to-list 'aggressive-indent-excluded-modes 'html-mode)
689 [2014-06-01 Sun 23:02]
690 Provides a minor mode which displays current match and total matches
691 information in the mode-line in various search modes.
692 #+BEGIN_SRC emacs-lisp
699 (global-anzu-mode 1))
702 (setq anzu-search-threshold 1000)
703 (set-face-attribute 'anzu-mode-line nil :foreground "yellow" :weight 'bold)))
706 [2014-05-21 Wed 00:33]
707 #+BEGIN_SRC emacs-lisp
709 :commands (ascii-on ascii-toggle ascii-display)
710 :bind (("C-c e A" . ascii-toggle))
713 (defun ascii-toggle ()
715 (defvar ascii-display nil)
720 (bind-key "C-c e A" 'ascii-toggle)))
723 #+BEGIN_SRC emacs-lisp
724 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
725 (setq TeX-auto-save t)
726 (setq TeX-parse-self t)
727 (setq TeX-PDF-mode t)
729 ** auto-complete mode
730 [2013-04-27 Sa 16:33]
731 And aren't we all lazy? I definitely am, and I like my emacs doing as
732 much possible work for me as it can.
733 So here, auto-complete-mode, which lets emacs do this, based on what I
735 #+BEGIN_SRC emacs-lisp
736 (use-package auto-complete-config
737 :ensure auto-complete
742 ;; hook AC into completion-at-point
743 (defun sanityinc/auto-complete-at-point ()
744 (when (and (not (minibufferp))
745 (fboundp 'auto-complete-mode)
748 (defun set-auto-complete-as-completion-at-point-function ()
749 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
750 ;; Exclude very large buffers from dabbrev
751 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
752 (< (buffer-size other-buffer) (* 1 1024 1024)))
757 ;; custom keybindings to use tab, enter and up and down arrows
758 (bind-key "\t" 'ac-expand ac-complete-mode-map)
759 (bind-key "\r" 'ac-complete ac-complete-mode-map)
760 (bind-key "M-n" 'ac-next ac-complete-mode-map)
761 (bind-key "M-p" 'ac-previous ac-complete-mode-map)
762 (bind-key "C-s" 'ac-isearch ac-completing-map)
763 (bind-key "M-TAB" 'auto-complete ac-mode-map)
765 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
766 (setq ac-use-comphist t)
767 (setq ac-expand-on-auto-complete nil)
769 (setq ac-auto-start 3)
771 (setq ac-menu-height 15)
772 (setq ac-quick-help-delay 0.5)
773 (setq ac-use-fuzzy t)
775 (ac-flyspell-workaround)
777 ;; use 't when auto-complete is disabled
778 (setq tab-always-indent 'complete)
779 (add-to-list 'completion-styles 'initials t)
781 ;; Use space and punctuation to accept the current the most likely completion.
782 (setq auto-completion-syntax-alist (quote (global accept . word)))
783 ;; Avoid completion for short trivial words.
784 (setq auto-completion-min-chars (quote (global . 3)))
785 (setq completion-use-dynamic t)
787 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
789 ;; Exclude very large buffers from dabbrev
790 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
792 (use-package ac-dabbrev
795 (set-default 'ac-sources
798 ac-source-words-in-buffer
799 ac-source-words-in-same-mode-buffers
800 ; ac-source-words-in-all-buffer
803 (dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
804 sass-mode yaml-mode csv-mode espresso-mode haskell-mode
805 html-mode nxml-mode sh-mode smarty-mode clojure-mode
806 lisp-mode textile-mode markdown-mode tuareg-mode python-mode
807 js3-mode css-mode less-css-mode sql-mode ielm-mode))
808 (add-to-list 'ac-modes mode))
810 (add-hook 'latex-mode-hook 'auto-complete-mode)
811 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
812 (add-hook 'prog-mode-hook 'auto-complete-mode)
813 (add-hook 'org-mode-hook 'auto-complete-mode)))
818 When files change outside emacs for whatever reason I want emacs to deal
819 with it. Not to have to revert buffers myself
820 #+BEGIN_SRC emacs-lisp
821 (use-package autorevert
822 :commands auto-revert-mode
823 :diminish auto-revert-mode
826 (setq global-auto-revert-mode t)
827 (setq global-auto-revert-non-file-buffers t)
828 (global-auto-revert-mode)))
832 Emacs should keep backup copies of files I edit, but I do not want them
833 to clutter up the filesystem everywhere. So I put them into one defined
834 place, backup-directory, which even contains my username (for systems
835 where =temporary-file-directory= is not inside my home).
836 #+BEGIN_SRC emacs-lisp
837 (use-package backups-mode
838 :load-path "elisp/backups-mode"
839 :bind (("\C-cv" . save-version)
840 ("\C-cb" . list-backups)
841 ("\C-ck" . kill-buffer-prompt)
842 ("\C-cw" . backup-walker-start))
845 (setq backup-directory jj-backup-directory)
846 (setq tramp-backup-directory (concat jj-backup-directory "/tramp"))
847 (if (not (file-exists-p tramp-backup-directory))
848 (make-directory tramp-backup-directory))
849 (setq tramp-backup-directory-alist `((".*" . ,tramp-backup-directory)))
850 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
851 (setq auto-save-list-file-prefix (concat jj-backup-directory ".auto-saves-"))
852 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
854 (setq version-control t) ;; Use version numbers for backups
855 (setq kept-new-versions 10) ;; Number of newest versions to keep
856 (setq kept-old-versions 2) ;; Number of oldest versions to keep
857 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
858 (setq backup-by-copying t)
859 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
860 (setq make-backup-files t)
862 (defadvice kill-buffer (around kill-buffer)
863 "Always save before killing a file buffer"
864 (when (and (buffer-modified-p)
866 (file-exists-p (buffer-file-name)))
869 (ad-activate 'kill-buffer)
871 (defadvice save-buffers-kill-emacs (around save-buffers-kill-emacs)
872 "Always save before killing emacs"
873 (save-some-buffers t)
875 (ad-activate 'save-buffers-kill-emacs)
877 (defun kill-buffer-prompt ()
878 "Allows one to kill a buffer without saving it.
879 This is necessary since once you start backups-mode all file based buffers
880 are saved automatically when they are killed"
882 (if (and (buffer-modified-p) (buffer-file-name) (file-exists-p (buffer-file-name)) (y-or-n-p "Save buffer?"))
884 (set-buffer-modified-p nil))
887 (setq backup-enable-predicate
889 (and (normal-backup-enable-predicate name)
891 (let ((method (file-remote-p name 'method)))
892 (when (stringp method)
893 (member method '("su" "sudo"))))))))))
897 [2014-12-11 Thu 11:31]
898 #+BEGIN_SRC emacs-lisp
899 (use-package browse-kill-ring
900 :commands (browse-kill-ring browse-kill-ring-mode)
901 :bind ("M-y" . browse-kill-ring)
905 [2014-06-10 Tue 22:20]
906 #+BEGIN_SRC emacs-lisp
908 :commands (cal/insert)
909 :bind ("C-c c" . cal/insert)
912 ; Weeks start on Monday, not sunday.
913 (setq calendar-week-start-day 1)
915 ; Display ISO week numbers in Calendar Mode
916 (copy-face font-lock-constant-face 'calendar-iso-week-face)
917 (set-face-attribute 'calendar-iso-week-face nil :height 0.7)
918 (setq calendar-intermonth-text
922 (calendar-iso-from-absolute
923 (calendar-absolute-from-gregorian (list month day year)))))
924 'font-lock-face 'calendar-iso-week-face))
925 (copy-face 'default 'calendar-iso-week-header-face)
926 (set-face-attribute 'calendar-iso-week-header-face nil :height 0.7)
927 (setq calendar-intermonth-header
928 (propertize "Wk" ; or e.g. "KW" in Germany
929 'font-lock-face 'calendar-iso-week-header-face))))
933 [2015-10-15 Thu 11:34]
934 Corral is a lightweight package that lets you quickly wrap parentheses
935 and other delimiters around text, intuitively surrounding what you
936 want it to using just two commands.
937 #+BEGIN_SRC emacs-lisp
942 ; Interpret # and * as part of the word
943 (setq corral-syntax-entries '((?# "_")
945 (defhydra hydra-corral (:columns 4)
947 ("(" corral-parentheses-backward "Back")
948 (")" corral-parentheses-forward "Forward")
949 ("[" corral-brackets-backward "Back")
950 ("]" corral-brackets-forward "Forward")
951 ("{" corral-braces-backward "Back")
952 ("}" corral-braces-forward "Forward")
953 ("\"" corral-double-quotes-backward "Back")
954 ("2" corral-double-quotes-forward "Forward")
955 ("'" corral-single-quotes-backward "Back")
956 ("#" corral-single-quotes-forward "Forward")
957 ("." hydra-repeat "Repeat"))
958 (bind-key "C-c c" 'hydra-corral/body)
962 [2013-05-21 Tue 23:18]
963 #+BEGIN_SRC emacs-lisp
964 (use-package crontab-mode
966 :commands crontab-mode
967 :mode ("\\.?cron\\(tab\\)?\\'" . crontab-mode))
971 web-mode takes over, see [[*web-mode][web-mode]]
972 #+BEGIN_SRC emacs-lisp :tangle no
973 (use-package css-mode
974 :mode ("\\.css\\'" . css-mode)
979 (use-package flymake-css
983 (defun maybe-flymake-css-load ()
984 "Activate flymake-css as necessary, but not in derived modes."
985 (when (eq major-mode 'css-mode)
987 (add-hook 'css-mode-hook 'maybe-flymake-css-load)))
988 ;;; Auto-complete CSS keywords
989 (eval-after-load 'auto-complete
991 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
992 (add-hook hook 'ac-css-mode-setup))))))
996 I know that this lets it look "more like windows", but I don't much care
997 about its paste/copy/cut keybindings, the really nice part is the great
998 support for rectangular regions, which I started to use a lot since I
999 know this mode. The normal keybindings for those are just to useless.
1000 #+BEGIN_SRC emacs-lisp
1002 (setq cua-enable-cua-keys (quote shift))
1005 Luckily cua-mode easily supports this, with the following line I just
1006 get the CUA selection and rectangle stuff, not the keybindings. Yes,
1007 even though the above =cua-enable-cua-keys= setting would only enable
1008 them if the selection is done when the region was marked with a shifted
1010 #+BEGIN_SRC emacs-lisp
1011 (cua-selection-mode t)
1015 #+BEGIN_SRC emacs-lisp
1016 (require 'dpkg-dev-el-loaddefs nil 'noerror)
1017 (require 'debian-el-loaddefs nil 'noerror)
1019 (setq debian-changelog-full-name "Joerg Jaspert")
1020 (setq debian-changelog-mailing-address "joerg@debian.org")
1024 #+BEGIN_SRC emacs-lisp
1025 (use-package diff-mode
1027 :mode (("\\.diff" . diff-mode))
1029 (use-package diff-mode-))
1033 #+BEGIN_SRC emacs-lisp
1035 :commands (dired dired-other-window dired-other-frame dired-noselect
1036 dired-mode dired-jump)
1037 :defines (dired-omit-regexp-orig)
1040 (setq diredp-hide-details-initially-flag nil))
1043 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
1044 (setq dired-dwim-target t)
1045 (setq dired-listing-switches "-alh")
1046 (setq dired-listing-switches "-alXh --group-directories-first")
1047 (setq dired-recursive-copies (quote top))
1048 (setq dired-recursive-deletes (quote top))
1049 (setq dired-guess-shell-alist-user
1050 '(("\\.pdf\\'" "mupdf")
1051 ("\\.\\(?:djvu\\|eps\\)\\'" "evince")
1052 ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "eog")
1053 ("\\.\\(?:xcf\\)\\'" "gimp")
1054 ("\\.csv\\'" "libreoffice")
1055 ("\\.tex\\'" "pdflatex" "latex")
1056 ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\)\\(?:\\.part\\)?\\'" "vlc")
1057 ("\\.html?\\'" "conkeror")))
1059 (bind-key "F" 'find-name-dired dired-mode-map)
1064 (use-package dired-x)
1066 (use-package dired-single
1067 :ensure dired-single
1070 (bind-key "<return>" 'dired-single-buffer dired-mode-map)
1071 (bind-key "<mouse-1>" 'dired-single-buffer-mouse dired-mode-map)
1074 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
1080 (setq wdired-allow-to-change-permissions t)
1081 (bind-key "r" 'wdired-change-to-wdired-mode dired-mode-map)))
1083 (use-package gnus-dired
1084 :commands (gnus-dired-attach gnus-dired-mode)
1087 ;;(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
1088 (bind-key "a" 'gnus-dired-attach dired-mode-map)))
1093 (defvar mark-files-cache (make-hash-table :test #'equal))
1095 (defun mark-similar-versions (name)
1097 (if (string-match "^\\(.+?\\)-[0-9._-]+$" pat)
1098 (setq pat (match-string 1 pat)))
1099 (or (gethash pat mark-files-cache)
1100 (ignore (puthash pat t mark-files-cache)))))
1102 (defun dired-mark-similar-version ()
1104 (setq mark-files-cache (make-hash-table :test #'equal))
1105 (dired-mark-sexp '(mark-similar-versions name)))
1107 (defun dired-package-initialize ()
1108 (unless (featurep 'runner)
1109 (bind-key "M-!" 'async-shell-command dired-mode-map)
1110 (unbind-key "M-s f" dired-mode-map)
1112 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1113 "Make sure to remove \"Omit\" from the modeline."
1114 (diminish 'dired-omit-mode) dired-mode-map)
1116 ;; Omit files that Git would ignore
1117 (defun dired-omit-regexp ()
1118 (let ((file (expand-file-name ".git"))
1120 (while (and (not (file-exists-p file))
1123 (file-name-directory
1124 (directory-file-name
1125 (file-name-directory file))))
1126 ;; Give up if we are already at the root dir.
1127 (not (string= (file-name-directory file)
1129 ;; Move up to the parent dir and try again.
1130 (setq file (expand-file-name ".git" parent-dir)))
1131 ;; If we found a change log in a parent, use that.
1132 (if (file-exists-p file)
1133 (let ((regexp (funcall dired-omit-regexp-orig))
1135 (shell-command-to-string "git clean -d -x -n")))
1136 (if (= 0 (length omitted-files))
1140 (if (> (length regexp) 0)
1149 (if (= ?/ (aref str (1- (length str))))
1153 (split-string omitted-files "\n" t)
1156 (funcall dired-omit-regexp-orig))))))
1158 (add-hook 'dired-mode-hook 'dired-package-initialize)
1160 (defun dired-double-jump (first-dir second-dir)
1162 (list (read-directory-name "First directory: "
1163 (expand-file-name "~")
1164 nil nil "/Downloads/")
1165 (read-directory-name "Second directory: "
1166 (expand-file-name "~")
1169 (dired-other-window second-dir))
1170 (bind-key "C-c J" 'dired-double-jump)
1172 (defun dired-back-to-top ()
1174 (goto-char (point-min))
1175 (dired-next-line 4))
1177 (define-key dired-mode-map
1178 (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
1180 (defun dired-jump-to-bottom ()
1182 (goto-char (point-max))
1183 (dired-next-line -1))
1185 (define-key dired-mode-map
1186 (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)))
1189 ** discover-my-major
1190 [2014-06-01 Sun 23:32]
1191 Discover key bindings and their meaning for the current Emacs major mode.
1192 #+BEGIN_SRC emacs-lisp
1193 (use-package discover-my-major
1194 :ensure discover-my-major
1195 :commands discover-my-major
1196 :bind ("C-h C-m" . discover-my-major))
1199 EasyPG is a GnuPG interface for Emacs.
1200 Bookmark: [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1201 #+BEGIN_SRC emacs-lisp
1202 (use-package epa-file
1206 ;; I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1207 (defadvice epg--start (around advice-epg-disable-agent disable)
1208 "Don't allow epg--start to use gpg-agent in plain text
1210 (if (display-graphic-p)
1212 (let ((agent (getenv "GPG_AGENT_INFO")))
1213 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
1215 (setenv "GPG_AGENT_INFO" agent))))
1216 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
1217 (ad-activate 'epg--start)
1221 [2013-04-21 So 20:36]
1222 ediff - don't start another frame
1223 #+BEGIN_SRC emacs-lisp
1227 (defvar ctl-period-equals-map)
1228 (define-prefix-command 'ctl-period-equals-map)
1229 (bind-key "C-. =" 'ctl-period-equals-map)
1230 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
1232 :bind (("C-. = b" . ediff-buffers)
1233 ("C-. = B" . ediff-buffers3)
1234 ("C-. = =" . ediff-files)
1235 ("C-. = f" . ediff-files)
1236 ("C-. = F" . ediff-files3)
1237 ("C-. = r" . ediff-revision)
1238 ("C-. = p" . ediff-patch-file)
1239 ("C-. = P" . ediff-patch-buffer)
1240 ("C-. = l" . ediff-regions-linewise)
1241 ("C-. = w" . ediff-regions-wordwise))
1243 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1244 (setq ediff-split-window-function 'split-window-horizontally)
1250 EMMS is the Emacs Multimedia System.
1251 #+BEGIN_SRC emacs-lisp :tangle no
1252 (require 'emms-source-file)
1253 (require 'emms-source-playlist)
1254 (require 'emms-info)
1255 (require 'emms-cache)
1256 (require 'emms-playlist-mode)
1257 (require 'emms-playing-time)
1258 (require 'emms-player-mpd)
1259 (require 'emms-playlist-sort)
1260 (require 'emms-mark)
1261 (require 'emms-browser)
1262 (require 'emms-lyrics)
1263 (require 'emms-last-played)
1264 (require 'emms-score)
1265 (require 'emms-tag-editor)
1266 (require 'emms-history)
1267 (require 'emms-i18n)
1269 (setq emms-playlist-default-major-mode 'emms-playlist-mode)
1270 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
1271 (emms-playing-time 1)
1273 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
1274 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
1276 (when (fboundp 'emms-cache) ; work around compiler warning
1278 (setq emms-score-default-score 3)
1280 (defun emms-mpd-init ()
1281 "Connect Emms to mpd."
1283 (emms-player-mpd-connect))
1286 (require 'emms-player-mpd)
1287 (setq emms-player-mpd-server-name "localhost")
1288 (setq emms-player-mpd-server-port "6600")
1289 (add-to-list 'emms-info-functions 'emms-info-mpd)
1290 (add-to-list 'emms-player-list 'emms-player-mpd)
1291 (setq emms-volume-change-function 'emms-volume-mpd-change)
1292 (setq emms-player-mpd-sync-playlist t)
1294 (setq emms-source-file-default-directory "/var/lib/mpd/music")
1295 (setq emms-player-mpd-music-directory "/var/lib/mpd/music")
1296 (setq emms-info-auto-update t)
1297 (setq emms-lyrics-scroll-p t)
1298 (setq emms-lyrics-display-on-minibuffer t)
1299 (setq emms-lyrics-display-on-modeline nil)
1300 (setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
1302 (setq emms-last-played-format-alist
1303 '(((emms-last-played-seconds-today) . "%H:%M")
1304 (604800 . "%a %H:%M") ; this week
1305 ((emms-last-played-seconds-month) . "%d.%m.%Y")
1306 ((emms-last-played-seconds-year) . "%d.%m.%Y")
1307 (t . "Never played")))
1310 (defun my-describe (track)
1311 (let* ((empty "...")
1312 (name (emms-track-name track))
1313 (type (emms-track-type track))
1314 (short-name (file-name-nondirectory name))
1315 (play-count (or (emms-track-get track 'play-count) 0))
1316 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
1317 (artist (or (emms-track-get track 'info-artist) empty))
1318 (year (emms-track-get track 'info-year))
1319 (playing-time (or (emms-track-get track 'info-playing-time) 0))
1320 (min (/ playing-time 60))
1321 (sec (% playing-time 60))
1322 (album (or (emms-track-get track 'info-album) empty))
1323 (tracknumber (emms-track-get track 'info-tracknumber))
1324 (short-name (file-name-sans-extension
1325 (file-name-nondirectory name)))
1326 (title (or (emms-track-get track 'info-title) short-name))
1327 (rating (emms-score-get-score name))
1330 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
1331 (emms-last-played-format-date last-played)
1335 (if (and tracknumber ; tracknumber
1336 (not (zerop (string-to-number tracknumber))))
1337 (format "%02d" (string-to-number tracknumber))
1341 (make-string rating rate-char)))
1344 (setq emms-track-description-function 'my-describe)
1346 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
1347 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
1348 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
1349 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
1350 (global-set-key (kbd "H-<f9> x") 'emms-start)
1351 (global-set-key (kbd "H-<f9> v") 'emms-stop)
1352 (global-set-key (kbd "H-<f9> n") 'emms-next)
1353 (global-set-key (kbd "H-<f9> p") 'emms-previous)
1354 (global-set-key (kbd "H-<f9> o") 'emms-show)
1355 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
1356 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
1357 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
1358 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
1359 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
1361 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
1362 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
1363 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
1364 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
1366 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
1367 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
1368 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
1369 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
1371 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
1372 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
1373 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
1374 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
1376 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
1377 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
1378 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
1379 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
1380 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
1381 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
1383 (define-key emms-playlist-mode-map "x" 'emms-start)
1384 (define-key emms-playlist-mode-map "v" 'emms-stop)
1385 (define-key emms-playlist-mode-map "n" 'emms-next)
1386 (define-key emms-playlist-mode-map "p" 'emms-previous)
1388 (setq emms-playlist-buffer-name "*EMMS Playlist*"
1389 emms-playlist-mode-open-playlists t)
1395 'emms-browser-artist-face nil
1400 (setq emms-player-mpd-supported-regexp
1401 (or (emms-player-mpd-get-supported-regexp)
1402 (concat "\\`http://\\|"
1403 (emms-player-simple-regexp
1404 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
1405 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
1409 Basic settings for emacs integrated shell
1410 #+BEGIN_SRC emacs-lisp :tangle no
1416 (defun eshell-initialize ()
1417 (defun eshell-spawn-external-command (beg end)
1418 "Parse and expand any history references in current input."
1421 (when (looking-back "&!" beg)
1422 (delete-region (match-beginning 0) (match-end 0))
1424 (insert "spawn "))))
1425 (add-hook 'eshell-expand-input-functions 'eshell-spawn-external-command)
1426 (eval-after-load "em-unix"
1428 (unintern 'eshell/su)
1429 (unintern 'eshell/sudo))))
1430 (add-hook 'eshell-first-time-mode-hook 'eshell-initialize)
1434 (defalias 'emacs 'find-file)
1435 (defalias 'ec 'find-file)
1436 (defalias 'e 'find-file)
1440 (use-package 'em-cmpl)
1441 (use-package 'em-prompt)
1442 (use-package 'em-term)
1444 (setq eshell-cmpl-cycle-completions nil
1445 eshell-save-history-on-exit t
1446 eshell-buffer-maximum-lines 20000
1447 eshell-history-size 350
1448 eshell-buffer-shorthand t
1449 eshell-highlight-prompt t
1450 eshell-plain-echo-behavior t
1451 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
1453 (setenv "PAGER" "cat")
1454 (setq eshell-visual-commands
1455 '("less" "tmux" "htop" "top" "bash" "zsh" "tail"))
1456 (setq eshell-visual-subcommands
1457 '(("git" "log" "l" "diff" "show")))
1459 (add-to-list 'eshell-command-completions-alist
1460 '("gunzip" "gz\\'"))
1461 (add-to-list 'eshell-command-completions-alist
1462 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
1464 (when (not (functionp 'eshell/rgrep))
1465 (defun eshell/rgrep (&rest args)
1466 "Use Emacs grep facility instead of calling external grep."
1467 (eshell-grep "rgrep" args t)))
1469 ;(set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
1470 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
1471 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
1472 (add-hook 'eshell-preoutput-filter-functions
1473 'ansi-color-filter-apply)
1474 ;; Prompt with a bit of help from http://www.emacswiki.org/emacs/EshellPrompt
1476 (defmacro with-face (str &rest properties)
1477 `(propertize ,str 'face (list ,@properties)))
1479 (defun eshell/abbr-pwd ()
1480 (let ((home (getenv "HOME"))
1481 (path (eshell/pwd)))
1483 ((string-equal home path) "~")
1484 ((f-ancestor-of? home path) (concat "~/" (f-relative path home)))
1487 (defun eshell/my-prompt ()
1488 (let ((header-bg "#161616"))
1490 (with-face user-login-name :foreground "cyan")
1491 (with-face (concat "@" hostname) :foreground "white")
1493 (with-face (eshell/abbr-pwd) :foreground "#009900")
1494 (if (= (user-uid) 0)
1495 (with-face "#" :foreground "red")
1496 (with-face "$" :foreground "#69b7f0"))
1499 (use-package eshell-prompt-extras
1503 (setq eshell-highlight-prompt nil
1504 ;; epe-git-dirty-char "Ϟ"
1505 epe-git-dirty-char "*"
1506 eshell-prompt-function 'epe-theme-dakrone)))
1508 (defun eshell/magit ()
1509 "Function to open magit-status for the current directory"
1511 (magit-status default-directory)
1514 (setq eshell-prompt-function 'eshell/my-prompt)
1515 (setq eshell-highlight-prompt nil)
1516 (setq eshell-prompt-regexp "^[^#$\n]+[#$] ")))
1521 Incremental search is great, but annoyingly you need to type whatever
1522 you want. If you want to search for just the next (or previous)
1523 occurence of what is at your cursor position use the following.
1524 *C-x* will insert the current word while *M-up* and *M-down* will just
1525 jump to the next/previous occurence of it.
1526 #+BEGIN_SRC emacs-lisp
1527 (bind-key "C-x" 'sacha/isearch-yank-current-word isearch-mode-map)
1528 (bind-key* "<M-up>" 'sacha/search-word-backward)
1529 (bind-key* "<M-down>" 'sacha/search-word-forward)
1532 *** Frame configuration
1533 I want to see the buffername and its size, not the host I am on in my
1535 #+BEGIN_SRC emacs-lisp
1536 (setq frame-title-format "%b (%i)")
1539 *** Protect some buffers
1540 I don't want some buffers to be killed, **scratch** for example.
1541 In the past I had a long function that just recreated them, but the
1542 =keep-buffers= package is easier.
1543 #+BEGIN_SRC emacs-lisp
1544 (use-package keep-buffers
1547 (keep-buffers-mode 1)
1548 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
1549 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
1554 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
1556 #+BEGIN_SRC emacs-lisp
1557 (defalias 'yes-or-no-p 'y-or-n-p)
1560 *** Language/i18n stuff
1561 In this day and age, UTF-8 is the way to go.
1562 #+BEGIN_SRC emacs-lisp
1563 (set-language-environment 'utf-8)
1564 (set-default-coding-systems 'utf-8)
1565 (set-terminal-coding-system 'utf-8)
1566 (set-keyboard-coding-system 'utf-8)
1567 (set-clipboard-coding-system 'utf-8)
1568 (prefer-coding-system 'utf-8)
1569 (set-charset-priority 'unicode)
1570 (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
1571 (when (display-graphic-p)
1572 (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
1575 *** Hilight matching parentheses
1576 While I do have the nifty shortcut to jump to the other parentheses,
1577 hilighting them makes it obvious where they are.
1578 #+BEGIN_SRC emacs-lisp
1579 (use-package mic-paren
1583 *** Kill other buffers
1584 While many editors allow you to close "all the other files, not the one
1585 you are in", emacs doesn't have this... Except, now it will.
1586 (Update 30.05.2014: Not used ever, deactivated)
1587 #+BEGIN_SRC emacs-lisp :tangle no
1588 (bind-key "C-c k" 'prelude-kill-other-buffers)
1591 Default scrolling behaviour in emacs is a bit annoying, who wants to
1593 #+BEGIN_SRC emacs-lisp
1594 (setq scroll-margin 0)
1595 (setq scroll-conservatively 100000)
1596 (setq scroll-up-aggressively 0.0)
1597 (setq scroll-down-aggressively 0.0)
1598 (setq scroll-preserve-screen-position 'always)
1601 *** Copy/Paste with X
1602 [2013-04-09 Di 23:31]
1603 The default how emacs handles cutting/pasting with the primary selection
1604 changed in emacs24. I am used to the old way, so get it back.
1605 #+BEGIN_SRC emacs-lisp
1606 (setq select-enable-primary t)
1607 (setq select-enable-clipboard nil)
1608 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
1609 (setq mouse-drag-copy-region t)
1611 *** Global keyboard changes not directly related to a mode
1612 Disable /suspend_frame/ function, I dislike it.
1613 #+BEGIN_SRC emacs-lisp
1615 (unbind-key "C-x C-z")
1618 http://endlessparentheses.com/kill-entire-line-with-prefix-argument.html?source=rss
1619 #+BEGIN_SRC emacs-lisp
1620 (defmacro bol-with-prefix (function)
1621 "Define a new function which calls FUNCTION.
1622 Except it moves to beginning of line before calling FUNCTION when
1623 called with a prefix argument. The FUNCTION still receives the
1625 (let ((name (intern (format "endless/%s-BOL" function))))
1629 "Call `%s', but move to BOL when called with a prefix argument."
1634 (call-interactively ',function))
1637 (global-set-key [remap paredit-kill] (bol-with-prefix paredit-kill))
1638 (global-set-key [remap org-kill-line] (bol-with-prefix org-kill-line))
1639 (global-set-key [remap kill-line] (bol-with-prefix kill-line))
1642 Default of *C-k* is to kill from the point to the end of line. If
1643 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
1644 set, including newline. But to kill the entire line, one still needs a
1645 *C-a* in front of it. So I change it, by defining a function to do just this for
1647 #+BEGIN_SRC emacs-lisp :tangle no
1648 (defun kill-entire-line ()
1649 "Kill this entire line (including newline), regardless of where point is within the line."
1653 (back-to-indentation))
1655 (bind-key* "C-k" 'kill-entire-line)
1656 (global-set-key [remap kill-whole-line] 'kill-entire-line)
1659 And the same is true when I'm in org-mode, which has an own kill function...
1660 (the keybinding happens later, after org-mode is loaded fully)
1661 #+BEGIN_SRC emacs-lisp :tangle no
1662 (defun jj-org-kill-line (&optional arg)
1663 "Kill the entire line, regardless of where point is within the line, org-mode-version"
1667 (back-to-indentation)
1671 I really hate tabs, so I don't want any indentation to try using them.
1672 And in case a project really needs them, I can change it just for that
1673 file/project, but luckily none of those I work in is as broken.
1674 #+BEGIN_SRC emacs-lisp
1675 (setq-default indent-tabs-mode nil)
1678 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
1679 #+BEGIN_SRC emacs-lisp
1680 (bind-key* "M-5" 'match-paren)
1683 Instead of the default "mark-defun" I want a more readline-like setting.
1684 #+BEGIN_SRC emacs-lisp
1685 (bind-key "C-M-h" 'backward-kill-word)
1688 Align whatever with a regexp.
1689 #+BEGIN_SRC emacs-lisp
1690 (bind-key "C-x \\" 'align-regexp)
1694 #+BEGIN_SRC emacs-lisp
1695 (bind-key "C-+" 'text-scale-increase)
1696 (bind-key "C--" 'text-scale-decrease)
1699 Regexes are too useful, so use the regex search by default.
1700 #+begin_src emacs-lisp
1701 (bind-key "C-s" 'isearch-forward-regexp)
1702 (bind-key "C-r" 'isearch-backward-regexp)
1703 (bind-key "C-M-s" 'isearch-forward)
1704 (bind-key "C-M-r" 'isearch-backward)
1707 Rgrep is infinitely useful in multi-file projects.
1708 #+begin_src emacs-lisp
1709 (bind-key "C-x C-g" 'rgrep)
1712 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
1713 AKA transpose lines.
1714 #+BEGIN_SRC emacs-lisp
1715 (bind-key "<M-S-up>" 'move-line-up)
1716 (bind-key "<M-S-down>" 'move-line-down)
1719 "Pull" lines up, join them
1720 #+BEGIN_SRC emacs-lisp
1721 (defun join-line-or-lines-in-region ()
1722 "Join this line or the lines in the selected region.
1723 Joins single lines in reverse order to the default, ie. pulls the next one up."
1725 (cond ((region-active-p)
1726 (let ((min (line-number-at-pos (region-beginning))))
1727 (goto-char (region-end))
1728 (while (> (line-number-at-pos) min)
1730 (t (let ((current-prefix-arg '(4)))
1731 (call-interactively 'join-line)))))
1732 (bind-key "M-j" 'join-line-or-lines-in-region)
1735 When I press Enter I almost always want to go to the right indentation on the next line.
1736 #+BEGIN_SRC emacs-lisp
1737 (bind-key "RET" 'newline-and-indent)
1740 Easier undo, and i don't need suspend-frame
1741 #+BEGIN_SRC emacs-lisp
1742 (bind-key "C-z" 'undo)
1745 Window switching, go backwards. (C-x o goes to the next window)
1746 #+BEGIN_SRC emacs-lisp
1747 (bind-key "C-x O" (lambda ()
1753 #+BEGIN_SRC emacs-lisp
1754 (bind-key "C-x C-r" 'prelude-sudo-edit)
1757 M-space is bound to just-one-space, which is great for programming. What
1758 it does is remove all spaces around the cursor, except for one. But to
1759 be really useful, it also should include newlines. It doesn’t do this by
1760 default. Rather, you have to call it with a negative argument. Sure
1762 #+BEGIN_SRC emacs-lisp
1763 (bind-key "M-SPC" 'just-one-space-with-newline)
1766 Count which commands I use how often.
1767 #+BEGIN_SRC emacs-lisp
1768 (use-package keyfreq
1772 (setq keyfreq-file (expand-file-name "keyfreq" jj-cache-dir))
1773 (setq keyfreq-file-lock (expand-file-name "keyfreq.lock" jj-cache-dir))
1775 (keyfreq-autosave-mode 1)))
1778 Duplicate current line
1779 #+BEGIN_SRC emacs-lisp
1780 (defun duplicate-line ()
1781 "Insert a copy of the current line after the current line."
1784 (let ((line-text (buffer-substring-no-properties
1785 (line-beginning-position)
1786 (line-end-position))))
1787 (move-end-of-line 1)
1789 (insert line-text))))
1791 (bind-key "C-c p" 'duplicate-line)
1794 Smarter move to the beginning of the line. That is, it first moves to
1795 the beginning of the line - and on second keypress it goes to the
1796 first character on line.
1797 #+BEGIN_SRC emacs-lisp
1798 (defun smarter-move-beginning-of-line (arg)
1799 "Move point back to indentation of beginning of line.
1801 Move point to the first non-whitespace character on this line.
1802 If point is already there, move to the beginning of the line.
1803 Effectively toggle between the first non-whitespace character and
1804 the beginning of the line.
1806 If ARG is not nil or 1, move forward ARG - 1 lines first. If
1807 point reaches the beginning or end of the buffer, stop there."
1809 (setq arg (or arg 1))
1813 (let ((line-move-visual nil))
1814 (forward-line (1- arg))))
1816 (let ((orig-point (point)))
1817 (back-to-indentation)
1818 (when (= orig-point (point))
1819 (move-beginning-of-line 1))))
1821 ;; remap C-a to `smarter-move-beginning-of-line'
1822 (global-set-key [remap move-beginning-of-line]
1823 'smarter-move-beginning-of-line)
1827 Easily copy characters from the previous nonblank line, starting just
1828 above point. With a prefix argument, only copy ARG characters (never
1829 past EOL), no argument copies rest of line.
1830 #+BEGIN_SRC emacs-lisp
1832 (bind-key "H-y" 'copy-from-above-command)
1835 Open a new X Terminal pointing to the directory of the current
1837 #+BEGIN_SRC emacs-lisp
1838 (bind-key "H-t" 'jj-open-shell)
1842 #+BEGIN_SRC emacs-lisp
1843 (bind-key "H-a" 'align-code)
1847 #+BEGIN_SRC emacs-lisp
1848 (bind-key "C-c d" 'insert-date)
1851 Another key for indenting
1852 #+BEGIN_SRC emacs-lisp
1853 (bind-key "H-i" 'indent-region)
1856 Clean all whitespace stuff
1857 #+BEGIN_SRC emacs-lisp
1858 (bind-key "H-w" 'whitespace-cleanup)
1862 #+BEGIN_SRC emacs-lisp
1863 (bind-key "H-c" 'comment-dwim)
1866 Show keystrokes in progress
1867 #+BEGIN_SRC emacs-lisp
1868 (setq echo-keystrokes 0.1)
1871 Usually you can press the *Ins*ert key, to get into overwrite mode. I
1872 don't like that, have broken much with it and so just forbid it by
1874 #+BEGIN_SRC emacs-lisp
1875 (unbind-key "<insert>")
1876 (unbind-key "<kp-insert>")
1879 *** Easily navigate sillyCased words
1880 #+BEGIN_SRC emacs-lisp
1881 (global-subword-mode 1)
1883 *** Delete file of current buffer, then kill buffer
1884 [2014-06-14 Sat 23:03]
1885 #+BEGIN_SRC emacs-lisp
1886 (defun delete-current-buffer-file ()
1887 "Removes file connected to current buffer and kills buffer."
1889 (let ((filename (buffer-file-name))
1890 (buffer (current-buffer))
1891 (name (buffer-name)))
1892 (if (not (and filename (file-exists-p filename)))
1894 (when (yes-or-no-p "Are you sure you want to remove this file? ")
1895 (delete-file filename)
1896 (kill-buffer buffer)
1897 (message "File '%s' successfully removed" filename)))))
1899 (global-set-key (kbd "C-x C-k") 'delete-current-buffer-file)
1901 *** Rename file of current buffer
1902 [2014-06-14 Sat 23:04]
1903 #+BEGIN_SRC emacs-lisp
1904 (defun rename-current-buffer-file ()
1905 "Renames current buffer and file it is visiting."
1907 (let ((name (buffer-name))
1908 (filename (buffer-file-name)))
1909 (if (not (and filename (file-exists-p filename)))
1910 (error "Buffer '%s' is not visiting a file!" name)
1911 (let ((new-name (read-file-name "New name: " filename)))
1912 (if (get-buffer new-name)
1913 (error "A buffer named '%s' already exists!" new-name)
1914 (rename-file filename new-name 1)
1915 (rename-buffer new-name)
1916 (set-visited-file-name new-name)
1917 (set-buffer-modified-p nil)
1918 (message "File '%s' successfully renamed to '%s'"
1919 name (file-name-nondirectory new-name)))))))
1921 (global-set-key (kbd "C-x C-S-r") 'rename-current-buffer-file)
1923 *** Quickly find emacs lisp sources
1924 [2014-06-22 Sun 23:05]
1925 #+BEGIN_SRC emacs-lisp
1926 (bind-key "C-l" 'find-library 'help-command)
1927 (bind-key "C-f" 'find-function 'help-command)
1928 (bind-key "C-k" 'find-function-on-key 'help-command)
1929 (bind-key "C-v" 'find-variable 'help-command)
1932 [2015-01-26 Mon 16:01]
1933 #+BEGIN_SRC emacs-lisp
1934 (bind-key "M-s o" 'occur-dwim)
1938 [2014-06-01 Sun 15:00]
1939 Proper whitespace handling
1940 #+BEGIN_SRC emacs-lisp :tangle no
1941 (use-package ethan-wspace
1942 :ensure ethan-wspace
1943 :diminish (ethan-wspace-mode . "ew")
1945 (global-ethan-wspace-mode 1))
1949 [2014-06-01 Sun 15:16]
1950 #+BEGIN_SRC emacs-lisp
1951 (use-package expand-region
1952 :ensure expand-region
1953 :bind ("C-M-+" . er/expand-region)
1954 :commands er/expand-region)
1957 [2013-05-02 Thu 00:04]
1958 Filladapt by KyleJones enhances Emacs’ fill functions by guessing a
1959 fill prefix, such as a comment sequence in program code, and handling
1960 bullet points like “1.” or “*”.
1961 #+BEGIN_SRC emacs-lisp
1962 (use-package filladapt
1963 :diminish filladapt-mode
1965 (setq-default filladapt-mode t))
1968 [2013-04-28 So 22:21]
1969 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
1970 As the one time I tried Flymake i wasn't happy, thats easy to
1972 #+BEGIN_SRC emacs-lisp
1973 (use-package flycheck
1975 :diminish flycheck-mode
1976 :bind (("M-n" . next-error)
1977 ("M-p" . previous-error))
1980 (add-hook 'find-file-hook
1982 (when (not (equal 'emacs-lisp-mode major-mode))
1986 (use-package flycheck-color-mode-line
1987 :ensure flycheck-color-mode-line)
1988 (setq flycheck-highlighting-mode nil)
1989 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
1993 Obviously emacs can do syntax hilighting. For more things than you ever
1995 And I want to have it everywhere.
1996 #+BEGIN_SRC emacs-lisp
1997 (use-package font-lock
2000 (global-font-lock-mode 1)
2001 (setq font-lock-maximum-decoration t)))
2004 [2015-08-31 Mon 11:27]
2005 Display nice lines instead of page breaks
2006 #+BEGIN_SRC emacs-lisp
2007 (use-package form-feed
2012 #+BEGIN_SRC emacs-lisp :tangle no
2013 (use-package git-commit
2014 :commands git-commit
2015 :mode ("COMMIT_EDITMSG" . git-commit-mode))
2019 #+BEGIN_SRC emacs-lisp :tangle no
2020 (use-package git-rebase
2021 :commands git-rebase
2022 :mode ("git-rebase-todo" . git-rebase-mode))
2025 [2014-05-21 Wed 22:56]
2026 #+BEGIN_SRC emacs-lisp
2027 (use-package git-gutter+
2029 :diminish git-gutter+-mode
2030 :bind (("C-x n" . git-gutter+-next-hunk)
2031 ("C-x p" . git-gutter+-previous-hunk)
2032 ("C-x v =" . git-gutter+-show-hunk)
2033 ("C-x r" . git-gutter+-revert-hunks)
2034 ("C-x s" . git-gutter+-stage-hunks)
2035 ("C-x c" . git-gutter+-commit)
2039 (setq git-gutter+-disabled-modes '(org-mode))
2040 (global-git-gutter+-mode 1))
2043 (use-package git-gutter-fringe+
2044 :ensure git-gutter-fringe+
2047 (setq git-gutter-fr+-side 'right-fringe)
2048 ;(git-gutter-fr+-minimal)
2053 [2015-02-22 Sun 14:00]
2054 Provides function that popup commit message at current line. This is
2055 useful when you want to know why this line was changed.
2056 #+BEGIN_SRC emacs-lisp
2057 (use-package git-messenger
2058 :ensure git-messenger
2059 :commands (git-messenger:popup-message)
2060 :bind (("C-x v p" . git-messenger:popup-message))
2063 (bind-key "m" 'git-messenger:copy-message git-messenger-map)
2064 (add-hook 'git-messenger:popup-buffer-hook 'magit-commit-mode)
2065 (setq git-messenger:show-detail t)))
2068 [2014-07-23 Mi 12:57]
2069 Browse historic versions of a file with p (previous) and n (next).
2070 #+BEGIN_SRC emacs-lisp
2071 (use-package git-timemachine
2072 :ensure git-timemachine
2073 :commands git-timemachine)
2076 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
2077 what I want every emacs to know.
2078 #+BEGIN_SRC emacs-lisp
2079 (bind-key "C-c g" 'gnus) ; Start gnus with M-n
2085 [2015-02-20 Fri 16:27]
2086 When working with many windows at the same time, each window has a
2087 size that is not convenient for editing.
2089 golden-ratio helps on this issue by resizing automatically the windows
2090 you are working on to the size specified in the "Golden Ratio". The
2091 window that has the main focus will have the perfect size for editing,
2092 while the ones that are not being actively edited will be re-sized to
2093 a smaller size that doesn't get in the way, but at the same time will
2094 be readable enough to know it's content.
2095 #+BEGIN_SRC emacs-lisp
2096 (use-package golden-ratio
2097 :ensure golden-ratio
2098 :diminish golden-ratio-mode
2101 (golden-ratio-mode 1)
2102 (setq golden-ratio-exclude-buffer-names '("*LV*" "*guide-key*"))
2103 (setq golden-ratio-exclude-modes '("calendar-mode" "gnus-summary-mode"
2104 "gnus-article-mode" "calc-mode" "calc-trail-mode"
2109 [2015-02-22 Sun 13:28]
2110 Move point through buffer-undo-list positions.
2111 #+BEGIN_SRC emacs-lisp
2112 (use-package goto-last-change
2113 :commands (goto-last-change)
2114 :bind (("M-g l" . goto-last-change))
2118 [2014-06-11 Wed 22:27]
2119 guide-key.el displays the available key bindings automatically and
2122 For whatever reason I like this more than icicles <backtab> completion
2124 #+BEGIN_SRC emacs-lisp
2125 (use-package guide-key
2127 :diminish guide-key-mode
2130 (setq guide-key/guide-key-sequence '("C-x" "C-c" "M-g" "M-s"))
2132 (setq guide-key/recursive-key-sequence-flag t)
2133 (setq guide-key/popup-window-position 'bottom)
2134 (setq guide-key/idle-delay 0.5)))
2139 [2014-05-21 Wed 23:51]
2140 #+BEGIN_SRC emacs-lisp
2141 (use-package hi-lock
2142 :bind (("M-o l" . highlight-lines-matching-regexp)
2143 ("M-o r" . highlight-regexp)
2144 ("M-o w" . highlight-phrase)))
2146 (use-package hilit-chg
2147 :bind ("M-o C" . highlight-changes-mode))
2151 Crazy way of completion. It looks at the word before point and then
2152 tries to expand it in various ways.
2153 #+BEGIN_SRC emacs-lisp
2154 (use-package hippie-exp
2155 :bind ("M-/" . hippie-expand)
2156 :commands hippie-expand
2159 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
2160 try-expand-dabbrev-all-buffers
2161 try-expand-dabbrev-from-kill
2162 try-complete-file-name-partially
2163 try-complete-file-name
2164 try-expand-all-abbrevs try-expand-list
2166 try-complete-lisp-symbol-partially
2167 try-complete-lisp-symbol))))
2170 Replaced by web-mode [[*web-mode][web-mode]]
2171 #+BEGIN_SRC emacs-lisp :tangle no
2172 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
2173 (add-auto-mode 'html-helper-mode "\\.html$")
2174 (add-auto-mode 'html-helper-mode "\\.asp$")
2175 (add-auto-mode 'html-helper-mode "\\.phtml$")
2176 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
2177 (defalias 'html-mode 'html-helper-mode)
2180 [2015-01-26 Mon 15:50]
2181 This is a package for GNU Emacs that can be used to tie related
2182 commands into a family of short bindings with a common prefix - a
2185 Once you summon the Hydra through the prefixed binding (the body + any
2186 one head), all heads can be called in succession with only a short
2189 The Hydra is vanquished once Hercules, any binding that isn't the
2190 Hydra's head, arrives. Note that Hercules, besides vanquishing the
2191 Hydra, will still serve his orignal purpose, calling his proper
2192 command. This makes the Hydra very seamless, it's like a minor mode
2193 that disables itself auto-magically.
2194 #+BEGIN_SRC emacs-lisp
2199 (setq hydra-is-helpful t)
2202 (defhydra hydra-zoom (:color red)
2204 ("g" text-scale-increase "in")
2205 ("l" text-scale-decrease "out")
2207 (bind-key "<F2>" 'hydra-zoom/toggle)
2209 (defhydra hydra-error (:color red)
2211 ("h" first-error "first")
2212 ("j" next-error "next")
2213 ("k" previous-error "prev")
2214 ("v" recenter-top-bottom "recenter")
2216 (bind-key "M-g e" 'hydra-error/body)
2218 (defhydra hydra-gnus (:color red)
2220 ("m" gnus-uu-mark-thread "mark thread")
2221 ("d" gnus-summary-delete-article "delete article(s)")
2222 ("r" gnus-summary-mark-as-read-forward "mark read")
2223 ("n" gnus-summary-next-thread "next thread")
2224 ("p" gnus-summary-prev-thread "previous thread")
2225 ("g" gnus-summary-next-group "next group")
2226 ("l" gnus-recenter "recenter")
2227 ("x" gnus-summary-limit-to-unread "unread")
2229 (bind-key "C-c h" 'hydra-gnus/body)
2231 (defhydra hydra-launcher (:color blue)
2234 ("r" (browse-url "http://www.reddit.com/r/emacs/") "reddit")
2235 ("w" (browse-url "http://www.emacswiki.org/") "emacswiki")
2238 (bind-key "C-c r" 'hydra-launcher/body)
2240 ; whitespace mode gets loaded late, so variable may not be there yet. Workaround...
2241 (defvar whitespace-mode nil)
2242 (defhydra hydra-toggle (:color pink)
2244 _a_ abbrev-mode: % 4`abbrev-mode^^^^ _f_ auto-fill-mode: %`auto-fill-function
2245 _c_ auto-complete-mode: % 4`auto-complete-mode _r_ auto-revert-mode: %`auto-revert-mode
2246 _d_ debug-on-error: % 4`debug-on-error^ _t_ truncate-lines: %`truncate-lines
2247 _w_ whitespace-mode: % 4`whitespace-mode _g_ golden-ratio-mode: %`golden-ratio-mode
2248 _l_ linum-mode: % 4`linum-mode _k_ linum relative: %`linum-format
2251 ("a" abbrev-mode nil)
2252 ("c" auto-complete-mode nil)
2253 ("i" aggressive-indent-mode nil)
2254 ("d" toggle-debug-on-error nil)
2255 ("f" auto-fill-mode nil)
2256 ("g" golden-ratio-mode nil)
2257 ("t" toggle-truncate-lines nil)
2258 ("w" whitespace-mode nil)
2259 ("r" auto-revert-mode nil)
2260 ("l" linum-mode nil)
2261 ("k" linum-relative-toggle nil)
2263 (bind-key "C-c C-v" 'hydra-toggle/body)
2269 [2014-05-21 Wed 23:54]
2270 #+BEGIN_SRC emacs-lisp
2271 (use-package ibuffer
2273 :bind (("C-h h" . ibuffer)
2274 ("C-x C-b" . ibuffer)
2275 ("<XF86WebCam>" . ibuffer)
2278 :defines (ibuffer-filtering-alist
2279 ibuffer-filter-groups ibuffer-compile-formats ibuffer-git-column-length
2280 ibuffer-show-empty-filter-groups ibuffer-saved-filter-groups)
2283 (defvar my-ibufffer-separator " • ")
2284 (setq ibuffer-filter-group-name-face 'variable-pitch
2285 ibuffer-use-header-line t
2286 ibuffer-old-time 12)
2287 (unbind-key "M-o" ibuffer-mode-map)
2288 (bind-key "s" 'isearch-forward-regexp ibuffer-mode-map)
2289 (bind-key "." 'ibuffer-invert-sorting ibuffer-mode-map)
2294 (use-package ibuffer-vc
2297 (ibuffer-vc-set-filter-groups-by-vc-root
2298 ibuffer-vc-generate-filter-groups-by-vc-root))
2300 (use-package ibuffer-tramp
2302 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
2303 ibuffer-tramp-set-filter-groups-by-tramp-connection))
2304 ;; Switching to ibuffer puts the cursor on the most recent buffer
2305 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
2306 "Open ibuffer with cursor pointed to most recent buffer name"
2307 (let ((recent-buffer-name (buffer-name)))
2309 (ibuffer-update nil t)
2310 (unless (string= recent-buffer-name "*Ibuffer*")
2311 (ibuffer-jump-to-buffer recent-buffer-name))))
2313 (defun ibuffer-magit-status ()
2315 (--when-let (get-buffer "*Ibuffer*")
2316 (with-current-buffer it
2317 (let* ((selected-buffer (ibuffer-current-buffer))
2318 (buffer-path (with-current-buffer
2320 (or (buffer-file-name)
2321 list-buffers-directory
2322 default-directory)))
2324 (if (file-regular-p buffer-path)
2325 (file-name-directory buffer-path)
2327 (magit-status default-directory)))))
2328 (bind-key "i" 'ibuffer-magit-status ibuffer-mode-map)
2329 (bind-key "G" 'ibuffer-magit-status ibuffer-mode-map)
2331 (setq ibuffer-directory-abbrev-alist
2336 (cons (f-slash (f-expand (cdr it))) my-ibufffer-separator)
2337 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
2339 ("dak" . "/develop/dak/")
2341 ("config" . "~/.emacs.d/config/")
2343 ("systmp" . "/tmp/")
2344 ("puppet" . "~/git/puppet")
2348 (use-package ibuffer-git
2350 (use-package ibuffer-vc
2353 (define-ibuffer-column size-h
2354 (:name "Size" :inline t)
2356 ((> (buffer-size) 1000)
2357 (format "%7.1fk" (/ (buffer-size) 1000.0)))
2358 ((> (buffer-size) 1000000)
2359 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
2361 (format "%8d" (buffer-size)))))
2363 (use-package ibuf-ext)
2364 (define-ibuffer-filter filename2
2365 "Toggle current view to buffers with filename matching QUALIFIER."
2366 (:description "filename2"
2367 :reader (read-from-minibuffer "Filter by filename (regexp): "))
2368 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
2369 (ibuffer-awhen (with-current-buffer buf
2370 (or buffer-file-name
2372 (string-match qualifier it)))
2374 (defvar ibuffer-magit-filter-groups nil)
2375 (defun ibuffer-magit-define-filter-groups ()
2376 (when (and (not ibuffer-magit-filter-groups)
2377 (boundp 'magit-repo-dirs))
2378 (setq ibuffer-magit-filter-groups
2381 (file-name-nondirectory (directory-file-name it)))
2383 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
2385 (defun ibuffer-set-filter-groups-by-root ()
2387 ;; (ibuffer-projectile-define-filter-groups)
2388 ;; (ibuffer-magit-define-filter-groups)
2389 (setq ibuffer-filter-groups
2391 ;; ibuffer-projectile-filter-groups
2392 ibuffer-magit-filter-groups
2395 (or (mode . magit-log-edit-mode)
2396 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2397 (name . "^\\*Pymacs\\*$")
2398 (name . "^\\*helm.*\\*")
2399 (name . "^\\*Compile-log\\*$")
2400 (name . "^\\*Ido Completions\\*$")
2401 (name . "^\\*magit-\\(process\\)\\*$")
2405 (name . "^\\*scratch")
2406 (name . "^\\*Messages")
2409 (ibuffer-vc-generate-filter-groups-by-vc-root)
2410 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
2412 (defun toggle-ibuffer-filter-groups ()
2415 (let ((ibuf (get-buffer "*Ibuffer*")))
2417 (with-current-buffer ibuf
2418 (let ((selected-buffer (ibuffer-current-buffer)))
2419 (if (not ibuffer-filter-groups)
2420 (ibuffer-set-filter-groups-by-root)
2421 (setq ibuffer-filter-groups nil))
2422 (pop-to-buffer ibuf)
2423 (ibuffer-update nil t)
2424 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
2426 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
2428 (defun ibuffer-back-to-top ()
2430 (beginning-of-buffer)
2433 (defun ibuffer-jump-to-bottom ()
2439 (define-key ibuffer-mode-map
2440 (vector 'remap 'end-of-buffer) 'ibuffer-jump-to-bottom)
2441 (define-key ibuffer-mode-map
2442 (vector 'remap 'beginning-of-buffer) 'ibuffer-back-to-top)
2444 (setq ibuffer-default-sorting-mode 'recency
2445 ibuffer-eliding-string "…"
2446 ibuffer-compile-formats t
2447 ibuffer-git-column-length 6
2448 ibuffer-show-empty-filter-groups nil
2449 ibuffer-default-directory "~/"
2452 (setq ibuffer-formats '((mark vc-status-mini
2454 (git-status 8 8 :left)
2458 (name 18 18 :left :elide)
2460 (size-h 9 -1 :right)
2462 (mode 16 16 :left :elide)
2463 " " filename-and-process)
2465 (git-status 8 8 :left)
2471 (setq ibuffer-saved-filter-groups
2474 ("dired" (mode . dired-mode))
2475 ("perl" (mode . cperl-mode))
2477 (mode . puppet-mode)
2478 (mode . yaml-mode)))
2479 ("ruby" (mode . ruby-mode))
2481 (name . "^\\*scratch\\*$")
2482 (name . "^\\*Compile-log\\*$")
2483 (name . "^\\*Completions\\*$")
2484 (name . "^\\*Messages\\*$")
2485 (name . "^\\*Backtrace\\*$")
2486 (name . "^\\*Packages*\\*$")
2487 (name . "^\\*Help*\\*$")
2490 (mode . message-mode)
2493 (mode . gnus-group-mode)
2494 (mode . gnus-summary-mode)
2495 (mode . gnus-article-mode)
2496 (name . "^\\.bbdb$")
2497 (name . "^\\.newsrc-dribble")))
2499 (filename . ".*/org/.*")
2500 (mode . org-agenda-mode)
2501 (name . "^diary$")))
2503 (mode . magit-log-edit-mode)
2504 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
2506 ;; -------------------------------------------------
2507 ;; programming languages #1
2509 (mode . emacs-lisp-mode)
2510 (mode . python-mode)
2512 (mode . coffee-mode)
2515 (mode . actionscript-mode)
2518 (mode . haskell-mode)
2524 ;; -------------------------------------------------
2525 ;; configuration/data files
2529 (mode . conf-mode)))
2530 ;; -------------------------------------------------
2531 ;; text/notetaking/org
2532 ("org agenda" (mode . org-agenda-mode))
2535 (name . "^\\*Calendar\\*$")
2536 (name . "^diary$")))
2540 (mode . markdown-mode)))
2541 ;; -------------------------------------------------
2544 (mode . image-mode)))
2545 ;; -------------------------------------------------
2547 ("w3m" (mode . w3m-mode))
2549 (mode . magit-status-mode)
2550 (mode . magit-log-mode)
2551 (mode . vc-annotate-mode)))
2552 ("dired" (mode . dired-mode))
2557 (name . "^\\*Personal Keybindings\\*$")))
2558 ;; -------------------------------------------------
2560 ("MORE" (or (mode . magit-log-edit-mode)
2561 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2562 (name . "^\\*Pymacs\\*$")
2563 (name . "^\\*Compile-log\\*$")
2564 (name . "^\\*Completions\\*$")
2565 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
2567 ("*buffer*" (name . "\\*.*\\*"))))))
2569 (add-hook 'ibuffer-mode-hook
2571 (ibuffer-auto-mode 1)
2572 (ibuffer-switch-to-saved-filter-groups "default")))
2574 ;; Unless you turn this variable on you will be prompted every time
2575 ;; you want to delete a buffer, even unmodified ones, which is way
2576 ;; too cautious for most people. You’ll still be prompted for
2577 ;; confirmation when deleting modified buffers after the option has
2579 (setq ibuffer-expert t)
2584 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
2585 ‘TAB’ completion is to typing things manually every time.”]]
2586 #+BEGIN_SRC emacs-lisp
2587 (use-package icicles
2588 :load-path "elisp/icicle/"
2593 Incremental mini-buffer completion preview: Type in the minibuffer,
2594 list of matching commands is echoed
2595 #+BEGIN_SRC emacs-lisp
2599 [2014-05-26 Mon 22:49]
2600 #+BEGIN_SRC emacs-lisp
2603 :commands (iedit-mode)
2605 :bind (("C-;" . iedit-mode)
2606 ("C-," . iedit-mode-toggle-on-function))
2611 [2014-05-20 Tue 23:35]
2612 #+BEGIN_SRC emacs-lisp
2614 :bind ("C-h C-i" . info-lookup-symbol)
2615 :commands info-lookup-symbol
2618 ;; (defadvice info-setup (after load-info+ activate)
2619 ;; (use-package info+))
2621 (defadvice Info-exit (after remove-info-window activate)
2622 "When info mode is quit, remove the window."
2623 (if (> (length (window-list)) 1)
2626 (use-package info-look
2627 :commands info-lookup-add-help)
2629 ** linum (line number)
2630 Various modes should have line numbers in front of each line.
2632 But then there are some where it would just be deadly - like org-mode,
2633 gnus, so we have a list of modes where we don't want to see it.
2634 #+BEGIN_SRC emacs-lisp
2636 :diminish linum-mode
2639 (setq linum-format "%3d ")
2640 (setq linum-mode-inhibit-modes-list '(org-mode
2647 (defadvice linum-on (around linum-on-inhibit-for-modes)
2648 "Stop the load of linum-mode for some major modes."
2649 (unless (member major-mode linum-mode-inhibit-modes-list)
2652 (ad-activate 'linum-on)
2654 (use-package linum-relative
2655 :ensure linum-relative
2658 (setq linum-format 'dynamic)
2661 (global-linum-mode 1))
2664 ** lisp editing stuff
2666 [2013-04-21 So 21:00]
2667 I'm not doing much of it, except for my emacs and gnus configs, but
2668 then I like it nice too...
2669 #+BEGIN_SRC emacs-lisp
2670 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
2672 (defun remove-elc-on-save ()
2673 "If you're saving an elisp file, likely the .elc is no longer valid."
2674 (make-local-variable 'after-save-hook)
2675 (add-hook 'after-save-hook
2677 (if (file-exists-p (concat buffer-file-name "c"))
2678 (delete-file (concat buffer-file-name "c"))))))
2680 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
2681 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
2683 (use-package paredit
2685 :diminish paredit-mode " π")
2687 (setq lisp-coding-hook 'lisp-coding-defaults)
2688 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2690 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2691 (add-hook 'emacs-lisp-mode-hook (lambda ()
2692 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2694 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
2696 (after "elisp-slime-nav"
2697 '(diminish 'elisp-slime-nav-mode))
2698 (after "rainbow-mode"
2699 '(diminish 'rainbow-mode))
2701 '(diminish 'eldoc-mode))
2704 [2013-04-21 So 20:48]
2705 magit is a mode for interacting with git.
2706 #+BEGIN_SRC emacs-lisp
2709 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
2710 magit-git-repo-p magit-list-repos)
2712 :bind (("C-x g" . magit-status)
2713 ("C-x G" . magit-status-with-prefix))
2716 (setq magit-commit-signoff t
2717 magit-repo-dirs '("~/git"
2721 magit-repo-dirs-depth 4
2722 magit-log-auto-more t)
2724 (use-package magit-blame
2725 :commands magit-blame-mode
2728 ; (use-package magit-svn
2730 ; :commands (magit-svn-mode
2731 ; turn-on-magit-svn)
2734 (add-hook 'magit-mode-hook 'hl-line-mode)
2735 (defun magit-status-with-prefix ()
2737 (let ((current-prefix-arg '(4)))
2738 (call-interactively 'magit-status)))
2742 (setenv "GIT_PAGER" "")
2744 (unbind-key "M-h" magit-mode-map)
2745 (unbind-key "M-s" magit-mode-map)
2746 (add-to-list 'magit-no-confirm 'stage-all-changes)
2747 (setq magit-push-always-verify nil)
2748 (setq magit-last-seen-setup-instructions "2.1.0")
2749 ; (use-package magit-find-file
2750 ; :ensure magit-find-file
2751 ; :commands (magit-find-file-completing-read)
2755 ; (bind-key "C-x C-f" 'magit-find-file-completing-read magit-mode-map)))
2757 (add-hook 'magit-log-edit-mode-hook
2759 (set-fill-column 72)
2762 (add-hook 'git-rebase-mode-hook
2766 (defadvice magit-status (around magit-fullscreen activate)
2767 (window-configuration-to-register :magit-fullscreen)
2769 (delete-other-windows))
2771 (defun magit-quit-session ()
2772 "Restores the previous window configuration and kills the magit buffer"
2775 (jump-to-register :magit-fullscreen))
2777 (bind-key "q" 'magit-quit-session magit-status-mode-map)
2779 (defun magit-rebase-unpushed (commit &optional args)
2780 "Start an interactive rebase sequence over all unpushed commits."
2781 (interactive (list (magit-get-tracked-branch)
2782 (magit-rebase-arguments)))
2783 (if (setq commit (magit-rebase-interactive-assert commit))
2784 (magit-run-git-sequencer "rebase" "-i" commit args)
2787 (magit-rebase-interactive (concat commit "^") (list ,@args))))))
2789 (magit-define-popup-action 'magit-rebase-popup ?l "Rebase unpushed" 'magit-rebase-unpushed)
2793 [2014-05-20 Tue 23:04]
2794 #+BEGIN_SRC emacs-lisp
2795 (use-package markdown-mode
2796 :mode (("\\.md\\'" . markdown-mode)
2797 ("\\.mdwn\\'" . markdown-mode))
2801 #+BEGIN_SRC emacs-lisp
2802 (use-package message
2805 (setq message-kill-buffer-on-exit t)))
2808 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2810 I want to access it from anywhere using =F6=.
2811 #+BEGIN_SRC emacs-lisp
2812 (use-package mingus-stays-home
2813 :bind ( "<f6>" . mingus)
2817 (setq mingus-dired-add-keys t)
2818 (setq mingus-mode-always-modeline nil)
2819 (setq mingus-mode-line-show-elapsed-percentage nil)
2820 (setq mingus-mode-line-show-volume nil)
2821 (setq mingus-mpd-config-file "/etc/mpd.conf")
2822 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2823 (setq mingus-mpd-root "/share/music/")))
2827 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
2828 #+BEGIN_SRC emacs-lisp
2829 (use-package miniedit
2834 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
2835 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
2836 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
2837 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
2842 [2013-05-21 Tue 23:39]
2843 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
2844 coexist in one buffer.
2845 #+BEGIN_SRC emacs-lisp :tangle no
2846 (use-package mmm-auto
2850 (setq mmm-global-mode 'buffers-with-submode-classes)
2851 (setq mmm-submode-decoration-level 2)
2852 (eval-after-load 'mmm-vars
2858 :face mmm-code-submode-face
2859 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
2860 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
2861 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2862 @ "\n" _ "\n" @ "</script>" @)))
2865 :face mmm-code-submode-face
2866 :front "<style[^>]*>[ \t]*\n?"
2867 :back "[ \t]*</style>"
2868 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2869 @ "\n" _ "\n" @ "</style>" @)))
2872 :face mmm-code-submode-face
2875 (dolist (mode (list 'html-mode 'nxml-mode))
2876 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
2877 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
2882 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2884 #+BEGIN_SRC emacs-lisp
2885 (use-package mo-git-blame
2886 :ensure mo-git-blame
2887 :commands (mo-git-blame-current
2891 (setq mo-git-blame-blame-window-width 25)))
2895 [2013-04-08 Mon 23:57]
2896 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2897 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2898 #+BEGIN_SRC emacs-lisp
2899 (use-package multiple-cursors
2900 :ensure multiple-cursors
2902 :commands (mc/remove-fake-cursors
2903 mc/create-fake-cursor-at-point
2904 mc/pop-state-from-overlay
2905 mc/maybe-multiple-cursors-mode)
2906 :defines (multiple-cursors-mode
2908 mc--read-quoted-char
2909 rectangular-region-mode)
2910 :bind (("C-S-c C-S-c" . mc/edit-lines)
2911 ("C->" . mc/mark-next-like-this)
2912 ("C-<" . mc/mark-previous-like-this)
2913 ("C-c C-<" . mc/mark-all-like-this)
2914 ("C-c i" . mc/insert-numbers))
2917 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
2918 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
2919 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
2920 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
2921 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
2922 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
2925 [2014-08-27 Wed 17:15]
2927 #+BEGIN_SRC emacs-lisp
2928 (use-package neotree
2931 :bind (("<f8>" . neotree-toggle))
2932 :commands (neotree-find
2937 (setq neo-smart-open t))
2940 (bind-key "^" 'neotree-select-up-node neotree-mode-map)))
2943 [2013-05-22 Wed 22:02]
2944 nxml-mode is a major mode for editing XML.
2945 #+BEGIN_SRC emacs-lisp
2950 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2953 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2954 (fset 'xml-mode 'nxml-mode)
2955 (setq nxml-slash-auto-complete-flag t)
2957 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2958 (defun pp-xml-region (begin end)
2959 "Pretty format XML markup in region. The function inserts
2960 linebreaks to separate tags that have nothing but whitespace
2961 between them. It then indents the markup by using nxml's
2967 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2968 (backward-char) (insert "\n"))
2969 (indent-region begin end)))
2971 ;;----------------------------------------------------------------------------
2972 ;; Integration with tidy for html + xml
2973 ;;----------------------------------------------------------------------------
2974 ;; tidy is autoloaded
2975 (eval-after-load 'tidy
2977 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2978 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2983 *** General settings
2984 [2013-04-28 So 17:06]
2986 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
2987 it is quite extensive. Nevertheless, it starts out small, loading it.
2988 #+BEGIN_SRC emacs-lisp
2992 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
2993 that we need org-protocol.
2994 #+BEGIN_SRC emacs-lisp
2995 (require 'org-protocol)
3000 My current =org-agenda-files= variable only includes a set of
3002 #+BEGIN_SRC emacs-lisp
3003 (setq org-agenda-files (quote ("~/org/"
3009 (setq org-default-notes-file "~/org/notes.org")
3011 =org-mode= manages the =org-agenda-files= variable automatically using
3012 =C-c [= and =C-c ]= to add and remove files respectively. However,
3013 this replaces my directory list with a list of explicit filenames
3014 instead and is not what I want. If this occurs then adding a new org
3015 file to any of the above directories will not contribute to my agenda
3016 and I will probably miss something important.
3018 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
3019 prevent messing up my list of directories in the =org-agenda-files=
3020 variable. I just add and remove directories manually here. Changing
3021 the list of directories in =org-agenda-files= happens very rarely
3022 since new files in existing directories are automatically picked up.
3024 #+BEGIN_SRC emacs-lisp
3025 ;; Keep tasks with dates on the global todo lists
3026 (setq org-agenda-todo-ignore-with-date nil)
3028 ;; Keep tasks with deadlines on the global todo lists
3029 (setq org-agenda-todo-ignore-deadlines nil)
3031 ;; Keep tasks with scheduled dates on the global todo lists
3032 (setq org-agenda-todo-ignore-scheduled nil)
3034 ;; Keep tasks with timestamps on the global todo lists
3035 (setq org-agenda-todo-ignore-timestamp nil)
3037 ;; Remove completed deadline tasks from the agenda view
3038 (setq org-agenda-skip-deadline-if-done t)
3040 ;; Remove completed scheduled tasks from the agenda view
3041 (setq org-agenda-skip-scheduled-if-done t)
3043 ;; Remove completed items from search results
3044 (setq org-agenda-skip-timestamp-if-done t)
3046 ;; Include agenda archive files when searching for things
3047 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
3049 ;; Show all future entries for repeating tasks
3050 (setq org-agenda-repeating-timestamp-show-all t)
3052 ;; Show all agenda dates - even if they are empty
3053 (setq org-agenda-show-all-dates t)
3055 ;; Sorting order for tasks on the agenda
3056 (setq org-agenda-sorting-strategy
3057 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
3058 (todo category-up priority-down effort-up)
3059 (tags category-up priority-down effort-up)
3060 (search category-up))))
3062 ;; Start the weekly agenda on Monday
3063 (setq org-agenda-start-on-weekday 1)
3065 ;; Enable display of the time grid so we can see the marker for the current time
3066 (setq org-agenda-time-grid (quote ((daily today remove-match)
3067 #("----------------" 0 16 (org-heading t))
3068 (0800 1000 1200 1400 1500 1700 1900 2100))))
3070 ;; Display tags farther right
3071 (setq org-agenda-tags-column -102)
3073 ; position the habit graph on the agenda to the right of the default
3074 (setq org-habit-graph-column 50)
3076 ; turn habits back on
3077 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
3080 ;; Agenda sorting functions
3082 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
3085 (setq org-deadline-warning-days 30)
3087 ;; Always hilight the current agenda line
3088 (add-hook 'org-agenda-mode-hook
3089 '(lambda () (hl-line-mode 1))
3093 #+BEGIN_SRC emacs-lisp
3094 (setq org-agenda-persistent-filter t)
3095 (add-hook 'org-agenda-mode-hook
3096 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
3099 (add-hook 'org-agenda-mode-hook
3100 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
3103 (add-hook 'org-agenda-mode-hook
3104 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
3107 (add-hook 'org-agenda-mode-hook
3108 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
3111 (add-hook 'org-agenda-mode-hook
3112 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
3115 ; Rebuild the reminders everytime the agenda is displayed
3116 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
3118 ;(if (file-exists-p "~/org/refile.org")
3119 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
3121 ; Activate appointments so we get notifications
3124 (setq org-agenda-log-mode-items (quote (closed clock state)))
3125 (if (> emacs-major-version 23)
3126 (setq org-agenda-span 3)
3127 (setq org-agenda-ndays 3))
3129 (setq org-agenda-show-all-dates t)
3130 (setq org-agenda-start-on-weekday nil)
3131 (setq org-deadline-warning-days 14)
3134 *** Global keybindings.
3135 Start off by defining a series of keybindings.
3137 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
3138 setup manually, not by org-mode. Also turn off =C-c ;=, which
3139 comments headlines - a function never used.
3140 #+BEGIN_SRC emacs-lisp
3141 (add-hook 'org-mode-hook
3143 (org-defkey org-mode-map "\C-c[" 'undefined)
3144 (org-defkey org-mode-map "\C-c]" 'undefined)
3145 (org-defkey org-mode-map "\C-c;" 'undefined))
3149 And now a largish set of keybindings...
3150 #+BEGIN_SRC emacs-lisp
3151 (bind-key "C-c l" 'org-store-link)
3152 (bind-key "C-c a" 'org-agenda)
3153 ;(bind-key "C-c b" 'org-iswitchb)
3154 (define-key mode-specific-map [?a] 'org-agenda)
3156 (bind-key "<f12>" 'org-agenda)
3157 (bind-key "<f5>" 'bh/org-todo)
3158 (bind-key "<S-f5>" 'bh/widen)
3159 (bind-key "<f7>" 'bh/set-truncate-lines)
3160 ;(bind-key "<f8>" 'org-cycle-agenda-files)
3162 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
3163 (bind-key "<f9> b" 'bbdb)
3164 (bind-key "<f9> c" 'calendar)
3165 (bind-key "<f9> f" 'boxquote-insert-file)
3166 (bind-key "<f9> h" 'bh/hide-other)
3167 (bind-key "<f9> n" 'org-narrow-to-subtree)
3168 (bind-key "<f9> w" 'widen)
3169 (bind-key "<f9> u" 'bh/narrow-up-one-level)
3170 (bind-key "<f9> I" 'bh/punch-in)
3171 (bind-key "<f9> O" 'bh/punch-out)
3172 (bind-key "<f9> H" 'jj/punch-in-hw)
3173 (bind-key "<f9> W" 'jj/punch-out-hw)
3174 (bind-key "<f9> o" 'bh/make-org-scratch)
3175 (bind-key "<f9> p" 'bh/phone-call)
3176 (bind-key "<f9> r" 'boxquote-region)
3177 (bind-key "<f9> s" 'bh/switch-to-scratch)
3178 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
3179 (bind-key "<f9> T" 'tabify)
3180 (bind-key "<f9> U" 'untabify)
3181 (bind-key "<f9> v" 'visible-mode)
3182 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
3183 (bind-key "C-<f9>" 'previous-buffer)
3184 (bind-key "C-<f10>" 'next-buffer)
3185 (bind-key "M-<f9>" 'org-toggle-inline-images)
3186 ;(bind-key "C-x n r" 'narrow-to-region)
3187 (bind-key "<f11>" 'org-clock-goto)
3188 (bind-key "C-<f11>" 'org-clock-in)
3189 (bind-key "C-M-r" 'org-capture)
3190 (bind-key "C-c r" 'org-capture)
3191 (bind-key "C-S-<f12>" 'bh/save-then-publish)
3192 ;(bind-key "C-k" 'jj-org-kill-line org-mode-map)
3196 *** Tasks, States, Todo fun
3198 First we define the global todo keywords.
3199 #+BEGIN_SRC emacs-lisp
3200 (setq org-todo-keywords
3201 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
3202 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
3204 (setq org-todo-keyword-faces
3205 (quote (("TODO" :foreground "red" :weight bold)
3206 ("NEXT" :foreground "light blue" :weight bold)
3207 ("DONE" :foreground "forest green" :weight bold)
3208 ("WAITING" :foreground "orange" :weight bold)
3209 ("HOLD" :foreground "orange" :weight bold)
3210 ("DELEGATED" :foreground "yellow" :weight bold)
3211 ("CANCELLED" :foreground "dark green" :weight bold)
3212 ("PHONE" :foreground "dark green" :weight bold))))
3215 **** Fast Todo Selection
3216 Fast todo selection allows changing from any task todo state to any
3217 other state directly by selecting the appropriate key from the fast
3218 todo selection key menu.
3219 #+BEGIN_SRC emacs-lisp
3220 (setq org-use-fast-todo-selection t)
3222 Changing a task state is done with =C-c C-t KEY=
3224 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
3227 #+BEGIN_SRC emacs-lisp
3228 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
3230 allows changing todo states with S-left and S-right skipping all of
3231 the normal processing when entering or leaving a todo state. This
3232 cycles through the todo states but skips setting timestamps and
3233 entering notes which is very convenient when all you want to do is fix
3234 up the status of an entry.
3236 **** Todo State Triggers
3237 I have a few triggers that automatically assign tags to tasks based on
3238 state changes. If a task moves to =CANCELLED= state then it gets a
3239 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
3240 =CANCELLED= tag. These are used for filtering tasks in agenda views
3241 which I'll talk about later.
3243 The triggers break down to the following rules:
3245 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
3246 - Moving a task to =WAITING= adds a =WAITING= tag
3247 - Moving a task to =HOLD= adds a =WAITING= tag
3248 - Moving a task to a done state removes a =WAITING= tag
3249 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
3250 - Moving a task to =NEXT= removes a =WAITING= tag
3251 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
3253 The tags are used to filter tasks in the agenda views conveniently.
3254 #+BEGIN_SRC emacs-lisp
3255 (setq org-todo-state-tags-triggers
3256 (quote (("CANCELLED" ("CANCELLED" . t))
3257 ("WAITING" ("WAITING" . t))
3258 ("HOLD" ("WAITING" . t) ("HOLD" . t))
3259 (done ("WAITING") ("HOLD"))
3260 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
3261 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
3262 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
3265 *** Capturing new tasks
3266 Org capture replaces the old remember mode.
3267 #+BEGIN_SRC emacs-lisp
3268 (setq org-directory "~/org")
3269 (setq org-default-notes-file "~/org/refile.org")
3271 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
3272 ;; see http://orgmode.org/manual/Template-elements.html
3273 (setq org-capture-templates
3274 (quote (("t" "todo" entry (file "~/org/refile.org")
3275 "* TODO %?\nAdded: %U\n"
3276 :clock-in t :clock-resume t)
3277 ("l" "linktodo" entry (file "~/org/refile.org")
3278 "* TODO %?\nAdded: %U\n%a\n"
3279 :clock-in t :clock-resume t)
3280 ("r" "respond" entry (file "~/org/refile.org")
3281 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
3282 :clock-in t :clock-resume t :immediate-finish t)
3283 ("n" "note" entry (file "~/org/refile.org")
3284 "* %? :NOTE:\nAdded: %U\n%a\n"
3285 :clock-in t :clock-resume t)
3286 ("d" "Delegated" entry (file "~/org/refile.org")
3287 "* DELEGATED %?\nAdded: %U\n%a\n"
3288 :clock-in t :clock-resume t)
3289 ("j" "Journal" entry (file+datetree "~/org/diary.org")
3291 :clock-in t :clock-resume t)
3292 ("w" "org-protocol" entry (file "~/org/refile.org")
3293 "* TODO Review %c\nAdded: %U\n"
3294 :immediate-finish t)
3295 ("p" "Phone call" entry (file "~/org/refile.org")
3296 "* PHONE %? :PHONE:\nAdded: %U"
3297 :clock-in t :clock-resume t)
3298 ("x" "Bookmark link" entry (file "~/org/refile.org")
3299 "* Bookmark: %c\n%i\nAdded: %U\n"
3300 :immediate-finish t)
3301 ("h" "Habit" entry (file "~/org/refile.org")
3302 "* 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")
3306 Capture mode now handles automatically clocking in and out of a
3307 capture task. This all works out of the box now without special hooks.
3308 When I start a capture mode task the task is clocked in as specified
3309 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
3310 resumes on the original clocking task.
3312 The quick clocking in and out of capture mode tasks (often it takes
3313 less than a minute to capture some new task details) can leave
3314 empty clock drawers in my tasks which aren't really useful.
3315 The following prevents this.
3316 #+BEGIN_SRC emacs-lisp
3317 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
3321 All my newly captured entries end up in =refile.org= and want to be
3322 moved over to the right place. The following is the setup for it.
3323 #+BEGIN_SRC emacs-lisp
3324 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
3325 (setq org-refile-targets (quote ((nil :maxlevel . 9)
3326 (org-agenda-files :maxlevel . 9))))
3328 ; Use full outline paths for refile targets - we file directly with IDO
3329 (setq org-refile-use-outline-path t)
3331 ; Targets complete directly with IDO
3332 (setq org-outline-path-complete-in-steps nil)
3334 ; Allow refile to create parent tasks with confirmation
3335 (setq org-refile-allow-creating-parent-nodes (quote confirm))
3337 ; Use IDO for both buffer and file completion and ido-everywhere to t
3338 (setq org-completion-use-ido t)
3339 (setq org-completion-use-iswitchb nil)
3340 :; Use IDO for both buffer and file completion and ido-everywhere to t
3341 ;(setq ido-everywhere t)
3342 ;(setq ido-max-directory-size 100000)
3343 ;(ido-mode (quote both))
3344 ; Use the current window when visiting files and buffers with ido
3345 (setq ido-default-file-method 'selected-window)
3346 (setq ido-default-buffer-method 'selected-window)
3348 ;;;; Refile settings
3349 (setq org-refile-target-verify-function 'bh/verify-refile-target)
3353 Agenda view is the central place for org-mode interaction...
3354 #+BEGIN_SRC emacs-lisp
3355 ;; Do not dim blocked tasks
3356 (setq org-agenda-dim-blocked-tasks nil)
3357 ;; Compact the block agenda view
3358 (setq org-agenda-compact-blocks t)
3360 ;; Custom agenda command definitions
3361 (setq org-agenda-custom-commands
3362 (quote (("N" "Notes" tags "NOTE"
3363 ((org-agenda-overriding-header "Notes")
3364 (org-tags-match-list-sublevels t)))
3365 ("h" "Habits" tags-todo "STYLE=\"habit\""
3366 ((org-agenda-overriding-header "Habits")
3367 (org-agenda-sorting-strategy
3368 '(todo-state-down effort-up category-keep))))
3372 ((org-agenda-overriding-header "Tasks to Refile")
3373 (org-tags-match-list-sublevels nil)))
3374 (tags-todo "-HOLD-CANCELLED/!"
3375 ((org-agenda-overriding-header "Projects")
3376 (org-agenda-skip-function 'bh/skip-non-projects)
3377 (org-agenda-sorting-strategy
3379 (tags-todo "-CANCELLED/!"
3380 ((org-agenda-overriding-header "Stuck Projects")
3381 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3382 (tags-todo "-WAITING-CANCELLED/!NEXT"
3383 ((org-agenda-overriding-header "Next Tasks")
3384 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3385 (org-agenda-todo-ignore-scheduled t)
3386 (org-agenda-todo-ignore-deadlines t)
3387 (org-agenda-todo-ignore-with-date t)
3388 (org-tags-match-list-sublevels t)
3389 (org-agenda-sorting-strategy
3390 '(todo-state-down effort-up category-keep))))
3391 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3392 ((org-agenda-overriding-header "Tasks")
3393 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3394 (org-agenda-todo-ignore-scheduled t)
3395 (org-agenda-todo-ignore-deadlines t)
3396 (org-agenda-todo-ignore-with-date t)
3397 (org-agenda-sorting-strategy
3399 (tags-todo "-CANCELLED+WAITING/!"
3400 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
3401 (org-agenda-skip-function 'bh/skip-stuck-projects)
3402 (org-tags-match-list-sublevels nil)
3403 (org-agenda-todo-ignore-scheduled 'future)
3404 (org-agenda-todo-ignore-deadlines 'future)))
3406 ((org-agenda-overriding-header "Tasks to Archive")
3407 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3408 (org-tags-match-list-sublevels nil))))
3410 ("r" "Tasks to Refile" tags "REFILE"
3411 ((org-agenda-overriding-header "Tasks to Refile")
3412 (org-tags-match-list-sublevels nil)))
3413 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
3414 ((org-agenda-overriding-header "Stuck Projects")
3415 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3416 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
3417 ((org-agenda-overriding-header "Next Tasks")
3418 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3419 (org-agenda-todo-ignore-scheduled t)
3420 (org-agenda-todo-ignore-deadlines t)
3421 (org-agenda-todo-ignore-with-date t)
3422 (org-tags-match-list-sublevels t)
3423 (org-agenda-sorting-strategy
3424 '(todo-state-down effort-up category-keep))))
3425 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3426 ((org-agenda-overriding-header "Tasks")
3427 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3428 (org-agenda-sorting-strategy
3430 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
3431 ((org-agenda-overriding-header "Projects")
3432 (org-agenda-skip-function 'bh/skip-non-projects)
3433 (org-agenda-sorting-strategy
3435 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
3436 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
3437 (org-tags-match-list-sublevels nil))
3438 ("A" "Tasks to Archive" tags "-REFILE/"
3439 ((org-agenda-overriding-header "Tasks to Archive")
3440 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3441 (org-tags-match-list-sublevels nil))))))
3443 ; Overwrite the current window with the agenda
3444 (setq org-agenda-window-setup 'current-window)
3449 #+BEGIN_SRC emacs-lisp
3451 ;; Resume clocking task when emacs is restarted
3452 (org-clock-persistence-insinuate)
3454 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
3455 (setq org-clock-history-length 36)
3456 ;; Resume clocking task on clock-in if the clock is open
3457 (setq org-clock-in-resume t)
3458 ;; Change tasks to NEXT when clocking in
3459 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
3460 ;; Separate drawers for clocking and logs
3461 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
3462 ;; Save clock data and state changes and notes in the LOGBOOK drawer
3463 (setq org-clock-into-drawer t)
3464 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
3465 (setq org-clock-out-remove-zero-time-clocks t)
3466 ;; Clock out when moving task to a done state
3467 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
3468 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
3469 (setq org-clock-persist t)
3470 ;; Do not prompt to resume an active clock
3471 (setq org-clock-persist-query-resume nil)
3472 ;; Enable auto clock resolution for finding open clocks
3473 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
3474 ;; Include current clocking task in clock reports
3475 (setq org-clock-report-include-clocking-task t)
3477 ; use discrete minute intervals (no rounding) increments
3478 (setq org-time-stamp-rounding-minutes (quote (1 1)))
3480 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
3482 (setq bh/keep-clock-running nil)
3484 (setq org-agenda-clock-consistency-checks
3485 (quote (:max-duration "4:00"
3488 :gap-ok-around ("4:00"))))
3492 **** Setting a default clock task
3493 Per default the =** Organization= task in my tasks.org file receives
3494 misc clock time. This is the task I clock in on when I punch in at the
3495 start of my work day with =F9-I=. Punching-in anywhere clocks in this
3496 Organization task as the default task.
3498 If I want to change the default clocking task I just visit the
3499 new task in any org buffer and clock it in with =C-u C-u C-c C-x
3500 C-i=. Now this new task that collects miscellaneous clock
3501 minutes when the clock would normally stop.
3503 You can quickly clock in the default clocking task with =C-u C-c
3504 C-x C-i d=. Another option is to repeatedly clock out so the
3505 clock moves up the project tree until you clock out the
3506 top-level task and the clock moves to the default task.
3509 #+BEGIN_SRC emacs-lisp
3510 ;; Agenda clock report parameters
3511 (setq org-agenda-clockreport-parameter-plist
3512 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
3514 ;; Agenda log mode items to display (closed and state changes by default)
3515 (setq org-agenda-log-mode-items (quote (closed state)))
3517 **** Task estimates, column view
3518 Setup column view globally with the following headlines
3519 #+BEGIN_SRC emacs-lisp
3520 ; Set default column view headings: Task Effort Clock_Summary
3521 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
3523 Setup the estimate for effort values.
3524 #+BEGIN_SRC emacs-lisp
3525 ; global Effort estimate values
3526 ; global STYLE property values for completion
3527 (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")
3528 ("STYLE_ALL" . "habit"))))
3532 Tags are mostly used for filtering inside the agenda.
3533 #+BEGIN_SRC emacs-lisp
3534 ; Tags with fast selection keys
3535 (setq org-tag-alist (quote ((:startgroup)
3553 ; Allow setting single tags without the menu
3554 (setq org-fast-tag-selection-single-key (quote expert))
3556 ; For tag searches ignore tasks with scheduled and deadline dates
3557 (setq org-agenda-tags-todo-honor-ignore-options t)
3561 #+BEGIN_SRC emacs-lisp
3562 (setq org-archive-mark-done nil)
3563 (setq org-archive-location "%s_archive::* Archived Tasks")
3567 #+BEGIN_SRC emacs-lisp
3568 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
3569 (setq org-plantuml-jar-path "~/java/plantuml.jar")
3571 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
3573 ; Make babel results blocks lowercase
3574 (setq org-babel-results-keyword "results")
3576 (org-babel-do-load-languages
3577 (quote org-babel-load-languages)
3578 (quote ((emacs-lisp . t)
3597 ; Do not prompt to confirm evaluation
3598 ; This may be dangerous - make sure you understand the consequences
3599 ; of setting this -- see the docstring for details
3600 (setq org-confirm-babel-evaluate nil)
3602 ; Use fundamental mode when editing plantuml blocks with C-c '
3603 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
3606 #+BEGIN_SRC emacs-lisp
3607 ;; Don't have images visible on startup, breaks on console
3608 (setq org-startup-with-inline-images nil)
3611 #+BEGIN_SRC emacs-lisp
3612 (add-to-list 'org-structure-template-alist
3613 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
3614 "<comment>\n?\n</comment>"))
3616 **** ditaa, graphviz, etc
3617 Those are all nice tools. Look at
3618 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
3621 *** Publishing and exporting
3624 Org-mode can export to a variety of publishing formats including (but not limited to)
3627 (plain text - but not the original org-mode file)
3631 which enables getting to lots of other formats like ODF, XML, etc
3633 via LaTeX or Docbook
3636 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
3638 #+BEGIN_SRC emacs-lisp
3639 ;; Explicitly load required exporters
3643 (require 'ox-reveal)
3644 ;; FIXME, check the following two
3645 ;(require 'ox-icalendar)
3648 ; experimenting with docbook exports - not finished
3649 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
3650 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
3652 (setq org-reveal-root "file:///home/joerg/devel/ganeticon2015/reveal.js/reveal.js")
3654 ;; define categories that should be excluded
3655 (setq org-export-exclude-category (list "google" "google"))
3656 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
3658 ; define how the date strings look
3659 (setq org-export-date-timestamp-format "%Y-%m-%d")
3660 ; Inline images in HTML instead of producting links to the image
3661 (setq org-html-inline-images t)
3662 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
3663 (setq org-export-with-sub-superscripts nil)
3665 (setq org-html-head-extra (concat
3666 "<link rel=\"stylesheet\" href=\"https://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
3668 (setq org-html-head-include-default-style nil)
3669 ; Do not generate internal css formatting for HTML exports
3670 (setq org-export-htmlize-output-type (quote css))
3671 ; Export with LaTeX fragments
3672 (setq org-export-with-LaTeX-fragments t)
3673 ; Increase default number of headings to export
3674 (setq org-export-headline-levels 6)
3677 (setq org-publish-project-alist
3680 :base-directory "~/.emacs.d/"
3681 :base-extension "org"
3683 :publishing-directory "/develop/www/emacs"
3685 :publishing-function org-html-publish-to-html
3686 :headline-levels 4 ; Just the default for this project.
3692 :base-directory "~/.emacs.d/"
3693 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
3694 :publishing-directory "/develop/www/emacs"
3695 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
3697 :publishing-function org-publish-attachment
3699 ("inherit-org-info-js"
3700 :base-directory "/develop/vcs/org-info-js/"
3702 :base-extension "js"
3703 :publishing-directory "/develop/www/"
3704 :publishing-function org-publish-attachment
3706 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
3711 (setq org-export-with-timestamps nil)
3716 #+BEGIN_SRC emacs-lisp
3717 (setq org-latex-to-pdf-process
3718 '("xelatex -interaction nonstopmode %f"
3719 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
3720 (setq org-export-latex-listings 'minted)
3721 (setq org-latex-listings t)
3723 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
3724 ;; but adapted to use latexmk 4.20 or higher.
3725 (defun my-auto-tex-cmd ()
3726 "When exporting from .org with latex, automatically run latex,
3727 pdflatex, or xelatex as appropriate, using latexmk."
3729 ;; default command: oldstyle latex via dvi
3730 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
3732 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
3733 (setq texcmd "latexmk -pdf -quiet %f"))
3735 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3736 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
3737 ;; LaTeX compilation command
3738 (setq org-latex-to-pdf-process (list texcmd)))
3740 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
3742 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
3743 (setq org-export-latex-packages-alist
3745 ("" "longtable" nil)
3750 (defun my-auto-tex-parameters ()
3751 "Automatically select the tex packages to include."
3752 ;; default packages for ordinary latex or pdflatex export
3753 (setq org-export-latex-default-packages-alist
3754 '(("AUTO" "inputenc" t)
3764 ("" "hyperref" nil)))
3766 ;; Packages to include when xelatex is used
3767 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3768 (setq org-export-latex-default-packages-alist
3773 ("german" "babel" t)
3774 ("babel" "csquotes" t)
3776 ("xetex" "hyperref" nil)
3779 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
3780 (setq org-export-latex-classes
3782 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
3783 ("\\section{%s}" . "\\section*{%s}")
3784 ("\\subsection{%s}" . "\\subsection*{%s}")
3785 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
3786 ("\\paragraph{%s}" . "\\paragraph*{%s}")
3787 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
3788 org-export-latex-classes))))
3790 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
3793 *** Prevent editing invisible text
3794 The following setting prevents accidentally editing hidden text when
3795 the point is inside a folded region. This can happen if you are in
3796 the body of a heading and globally fold the org-file with =S-TAB=
3798 I find invisible edits (and undo's) hard to deal with so now I can't
3799 edit invisible text. =C-c C-r= (org-reveal) will display where the
3800 point is if it is buried in invisible text to allow editing again.
3802 #+BEGIN_SRC emacs-lisp
3803 (setq org-catch-invisible-edits 'error)
3807 #+BEGIN_SRC emacs-lisp
3808 ;; disable the default org-mode stuck projects agenda view
3809 (setq org-stuck-projects (quote ("" nil nil "")))
3811 ; force showing the next headline.
3812 (setq org-show-entry-below (quote ((default))))
3814 (setq org-show-following-heading t)
3815 (setq org-show-hierarchy-above t)
3816 (setq org-show-siblings (quote ((default))))
3818 (setq org-special-ctrl-a/e t)
3819 (setq org-special-ctrl-k t)
3820 (setq org-yank-adjusted-subtrees t)
3822 (setq org-table-export-default-format "orgtbl-to-csv")
3826 The following setting adds alphabetical lists like
3830 #+BEGIN_SRC emacs-lisp
3831 (if (> emacs-major-version 23)
3832 (setq org-list-allow-alphabetical t)
3833 (setq org-alphabetical-lists t))
3836 #+BEGIN_SRC emacs-lisp
3837 (setq org-remove-highlights-with-change nil)
3839 (setq org-list-demote-modify-bullet (quote (("+" . "-")
3846 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
3849 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
3850 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
3855 #+BEGIN_SRC emacs-lisp
3856 ;; Enable abbrev-mode
3857 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
3858 (setq org-startup-indented t)
3859 (setq org-startup-folded t)
3860 (setq org-cycle-separator-lines 0)
3863 I find extra blank lines in lists and headings a bit of a nuisance.
3864 To get a body after a list you need to include a blank line between
3865 the list entry and the body -- and indent the body appropriately.
3866 Most of my lists have no body detail so I like the look of collapsed
3867 lists with no blank lines better.
3869 The following setting prevents creating blank lines before headings
3870 but allows list items to adapt to existing blank lines around the items:
3871 #+BEGIN_SRC emacs-lisp
3872 (setq org-blank-before-new-entry (quote ((heading)
3873 (plain-list-item . auto))))
3876 #+BEGIN_SRC emacs-lisp
3877 (setq org-reverse-note-order nil)
3878 (setq org-default-notes-file "~/notes.org")
3881 Enforce task blocking. Tasks can't go done when there is any subtask
3882 still open. Unless they have a property of =NOBLOCKING: t=
3883 #+BEGIN_SRC emacs-lisp
3884 (setq org-enforce-todo-checkbox-dependencies t)
3885 (setq org-enforce-todo-dependencies t)
3888 #+BEGIN_SRC emacs-lisp
3889 (setq org-fast-tag-selection-single-key (quote expert))
3890 (setq org-footnote-auto-adjust t)
3891 (setq org-hide-block-startup t)
3892 (setq org-icalendar-alarm-time 15)
3893 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
3894 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
3895 (setq org-icalendar-honor-noexport-tag t)
3896 (setq org-icalendar-include-bbdb-anniversaries nil)
3897 (setq org-icalendar-include-body 200)
3898 (setq org-icalendar-include-todo nil)
3899 (setq org-icalendar-store-UID t)
3900 (setq org-icalendar-timezone "Europe/Berlin")
3901 (setq org-insert-mode-line-in-empty-file t)
3902 (setq org-log-done (quote note))
3903 (setq org-log-into-drawer t)
3904 (setq org-log-state-notes-insert-after-drawers nil)
3905 (setq org-log-reschedule (quote time))
3906 (setq org-log-states-order-reversed t)
3907 (setq org-mobile-agendas (quote all))
3908 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
3909 (setq org-mobile-inbox-for-pull "~/org/refile.org")
3910 (setq org-remember-store-without-prompt t)
3911 (setq org-return-follows-link t)
3912 (setq org-reverse-note-order t)
3914 ; regularly save our org-mode buffers
3915 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
3917 (setq org-log-done t)
3919 (setq org-enable-priority-commands t)
3920 (setq org-default-priority ?E)
3921 (setq org-lowest-priority ?E)
3926 Speed commands enable single-letter commands in Org-mode files when
3927 the point is at the beginning of a headline, or at the beginning of a
3930 See the `=org-speed-commands-default=' variable for a list of the keys
3931 and commands enabled at the beginning of headlines. All code blocks
3932 are available at the beginning of a code block, the following key
3933 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
3934 display a list of the code blocks commands and their related keys.
3936 #+BEGIN_SRC emacs-lisp
3937 (setq org-use-speed-commands nil)
3938 (setq org-speed-commands-user (quote (("0" . ignore)
3951 ("h" . bh/hide-other)
3954 (call-interactively 'org-insert-heading-respect-content))
3955 ("k" . org-kill-note-or-show-branches)
3958 ("q" . bh/show-org-agenda)
3960 ("s" . org-save-all-org-buffers)
3964 ("z" . org-add-note)
3969 ("F" . bh/restrict-to-file-or-follow)
3972 ("J" . org-clock-goto)
3976 ("N" . bh/narrow-to-org-subtree)
3977 ("P" . bh/narrow-to-org-project)
3982 ("U" . bh/narrow-up-one-org-level)
3989 (add-hook 'org-agenda-mode-hook
3991 (define-key org-agenda-mode-map "q" 'bury-buffer))
3994 (defvar bh/current-view-project nil)
3995 (add-hook 'org-agenda-mode-hook
3996 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
4001 The following displays the contents of code blocks in Org-mode files
4002 using the major-mode of the code. It also changes the behavior of
4003 =TAB= to as if it were used in the appropriate major mode. This means
4004 that reading and editing code form inside of your Org-mode files is
4005 much more like reading and editing of code using its major mode.
4007 #+BEGIN_SRC emacs-lisp
4008 (setq org-src-fontify-natively t)
4009 (setq org-src-tab-acts-natively t)
4012 #+BEGIN_SRC emacs-lisp
4013 (setq org-src-preserve-indentation nil)
4014 (setq org-edit-src-content-indentation 0)
4018 #+BEGIN_SRC emacs-lisp
4019 (setq org-attach-directory "~/org/data/")
4021 #+BEGIN_SRC emacs-lisp
4022 (setq org-agenda-sticky t)
4025 **** Checklist handling
4026 [2013-05-11 Sat 22:15]
4028 #+BEGIN_SRC emacs-lisp
4029 ;(require 'org-checklist)
4032 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
4034 #+BEGIN_SRC emacs-lisp
4035 (use-package cperl-mode
4036 :commands cperl-mode
4039 (defalias 'perl-mode 'cperl-mode)
4040 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
4041 (add-auto-mode 'pod-mode "\\.pod$")
4042 (add-auto-mode 'tt-mode "\\.tt$")
4043 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
4044 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
4045 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
4049 (setq cperl-invalid-face nil
4050 cperl-close-paren-offset -4
4051 cperl-continued-statement-offset 0
4052 cperl-indent-level 4
4053 cperl-indent-parens-as-block t
4055 cperl-electric-keywords t
4056 cperl-electric-lbrace-space t
4057 cperl-electric-parens nil
4058 cperl-highlight-variables-indiscriminately t
4059 cperl-imenu-addback t
4060 cperl-invalid-face (quote underline)
4061 cperl-lazy-help-time 5
4062 cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$"
4063 cperl-syntaxify-by-font-lock t
4064 cperl-use-syntax-table-text-property-for-tags t)
4066 ;; And have cperl mode give ElDoc a useful string
4067 (defun my-cperl-eldoc-documentation-function ()
4068 "Return meaningful doc string for `eldoc-mode'."
4070 (let ((cperl-message-on-help-error nil))
4072 (add-hook 'cperl-mode-hook
4074 (set (make-local-variable 'eldoc-documentation-function)
4075 'my-cperl-eldoc-documentation-function)
4080 [2014-05-22 Thu 00:05]
4081 #+BEGIN_SRC emacs-lisp
4082 (use-package puppet-mode
4083 :mode ("\\.pp\\'" . puppet-mode)
4084 :commands puppet-mode
4087 (defun my-puppet-mode-hook ()
4088 (setq require-final-newline nil))
4089 (add-hook 'puppet-mode-hook 'my-puppet-mode-hook))
4092 (use-package puppet-ext
4095 (bind-key "C-x ?" 'puppet-set-anchor puppet-mode-map)
4096 (bind-key "C-c C-r" 'puppet-create-require puppet-mode-map)))))
4100 Use elpy for the emacs python fun, but dont let it initialize all the
4101 various variables. Elpy author may like them, but I'm not him...
4102 #+BEGIN_SRC emacs-lisp
4105 :mode ("\.py" . python-mode)
4108 (safe-load (concat jj-elisp-dir "/elpy/elpy-autoloads.el"))
4115 :commands (nosetests-all nosetests-module nosetests-one
4116 nosetests-failed nosetests-pdb-all
4117 nosetests-pdb-module nosetests-pdb-one)
4122 :commands (pyvenv-activate pyvenv-deactivate pyvenv-mode pyvenv-restart-python)
4125 (use-package idomenu
4130 (use-package highlight-indentation
4132 :commands (highlight-indentation-mode))
4134 (use-package find-file-in-project
4136 :commands (find-file-in-project ffip-project-files ffip ))
4141 ;; Local variables in `python-mode'. This is not removed when Elpy
4142 ;; is disabled, which can cause some confusion.
4143 (add-hook 'python-mode-hook 'elpy-initialize-local-variables)
4145 (defun my-python-mode-hook ()
4146 (setq require-final-newline nil)
4147 (setq mode-require-final-newline))
4148 (add-hook 'python-mode-hook 'my-python-mode-hook)
4150 ;; Flymake support using flake8, including warning faces.
4151 (when (and (executable-find "flake8")
4152 (not (executable-find python-check-command)))
4153 (setq python-check-command "flake8"))
4155 ;; `flymake-no-changes-timeout': The original value of 0.5 is too
4156 ;; short for Python code, as that will result in the current line to
4157 ;; be highlighted most of the time, and that's annoying. This value
4158 ;; might be on the long side, but at least it does not, in general,
4159 ;; interfere with normal interaction.
4160 (setq flymake-no-changes-timeout 60)
4162 ;; `flymake-start-syntax-check-on-newline': This should be nil for
4163 ;; Python, as;; most lines with a colon at the end will mean the next
4164 ;; line is always highlighted as error, which is not helpful and
4166 (setq flymake-start-syntax-check-on-newline nil)
4168 ;; `ac-auto-show-menu': Short timeout because the menu is great.
4169 (setq ac-auto-show-menu 0.4)
4171 ;; `ac-quick-help-delay': I'd like to show the menu right with the
4172 ;; completions, but this value should be greater than
4173 ;; `ac-auto-show-menu' to show help for the first entry as well.
4174 (setq ac-quick-help-delay 0.5)
4176 ;; `yas-trigger-key': TAB, as is the default, conflicts with the
4177 ;; autocompletion. We also need to tell yasnippet about the new
4178 ;; binding. This is a bad interface to set the trigger key. Stop
4180 (let ((old (when (boundp 'yas-trigger-key)
4182 (setq yas-trigger-key "C-c C-i")
4183 (when (fboundp 'yas--trigger-key-reload)
4184 (yas--trigger-key-reload old)))
4186 ;; yas-snippet-dirs can be a string for a single directory. Make
4187 ;; sure it's a list in that case so we can add our own entry.
4188 (when (not (listp yas-snippet-dirs))
4189 (setq yas-snippet-dirs (list yas-snippet-dirs)))
4190 (add-to-list 'yas-snippet-dirs
4191 (concat (file-name-directory (locate-library "elpy"))
4195 ;; Now load yasnippets.
4198 (elpy-use-ipython)))