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))))
57 [2014-05-20 Tue 22:36]
58 #+BEGIN_SRC emacs-lisp
59 (defmacro hook-into-modes (func modes)
60 `(dolist (mode-hook ,modes)
61 (add-hook mode-hook ,func)))
65 The Emacs Lisp Package Archive contains things I want.
66 #+BEGIN_SRC emacs-lisp
67 (when (> emacs-major-version 23)
69 (setq package-user-dir (expand-file-name "elpa" jj-elisp-dir))
70 (dolist (source '(("melpa" . "http://melpa.org/packages/")
71 ("melpa-stable" . "http://stable.melpa.org/packages/")
72 ("marmalade" . "http://marmalade-repo.org/packages/")
73 ("elpy" . "http://jorgenschaefer.github.io/packages/")
74 ("elpa" . "http://elpa.gnu.org/packages/")
76 (add-to-list 'package-archives source t))
80 And Paradox is a nicer interface for it
81 #+BEGIN_SRC emacs-lisp
84 :commands (paradox-list-packages paradox-install paradox-upgrade-packages)
88 (setq paradox-github-token t)
91 *** config helpers use-package/bind-key
92 Helpers for the config
93 https://github.com/jwiegley/use-package
94 #+BEGIN_SRC emacs-lisp
95 (unless (package-installed-p 'use-package)
96 (package-refresh-contents)
97 (package-install 'use-package)))
98 (require 'use-package)
104 We need to define the load-path. As I have lots of things I add
105 locally, its getting a few entries. I disliked the repeated
106 /add-to-list/ lines, so I now just take all subdirectories of
107 jj-elisp-dir and add them.
109 #+BEGIN_SRC emacs-lisp
111 (project (directory-files jj-elisp-dir t "\\w+"))
112 (when (file-directory-p project)
113 (if (string= project "emacs23")
114 (when (version< emacs-version "24")
115 (add-to-list 'load-path project))
116 (add-to-list 'load-path project))
117 ;(byte-recompile-directory project 0)
122 Help emacs to find the info files
123 #+BEGIN_SRC emacs-lisp :tangle yes
124 (setq Info-directory-list (cons jj-info-dir
125 '("/usr/local/share/info/"
127 "/usr/local/gnu/info/"
128 "/usr/local/gnu/lib/info/"
129 "/usr/local/gnu/lib/emacs/info/"
130 "/usr/local/emacs/info/"
131 "/usr/local/lib/info/"
132 "/usr/local/lib/emacs/info/"
133 "/usr/share/info/emacs-23"
135 "/usr/share/info/")))
136 (setq Info-default-directory-list
137 (cons jj-info-dir Info-default-directory-list))
143 :ID: 0a1560d9-7e55-47ab-be52-b3a8b8eea4aa
145 I dislike the startup message
146 #+BEGIN_SRC emacs-lisp
147 (setq inhibit-splash-screen t)
148 (setq inhibit-startup-message t)
151 Usually I want the lines to break at 72 characters.
152 #+BEGIN_SRC emacs-lisp
153 (setq fill-column 72)
156 And it is nice to have a final newline in files.
157 (Now off, ethan-wspace is doing it better).
158 #+BEGIN_SRC emacs-lisp
159 (setq require-final-newline nil)
160 (setq mode-require-final-newline nil)
163 After I typed 300 characters or took a break for more than a minute it
164 would be nice of emacs to save whatever I am on in one of its auto-save
165 backups. See [[info:emacs#Auto%20Save%20Control][info:emacs#Auto Save Control]] for more details.
166 #+BEGIN_SRC emacs-lisp
167 (setq auto-save-interval 300)
168 (setq auto-save-timeout 60)
171 Set my full name and my default mail address - for whatever wants to use
172 it later. Also, I am using gnus.
173 #+BEGIN_SRC emacs-lisp
174 (setq user-full-name "Joerg Jaspert")
175 (setq user-mail-address "joerg@ganneff.de")
176 (setq mail-user-agent (quote gnus-user-agent))
179 My default mail server. Well, simply a localhost, I have a forwarder that
180 puts mail off the right way, no need for emacs to have any further
182 #+BEGIN_SRC emacs-lisp
183 (setq smtpmail-default-smtp-server "localhost")
184 (setq smtpmail-smtp-server "localhost")
187 Enable automatic handling of compressed files.
188 #+BEGIN_SRC emacs-lisp
189 (auto-compression-mode 1)
192 Emacs forbids a certain set of commands, as they can be very confusing
193 for new users. Enable them.
194 #+BEGIN_SRC emacs-lisp
195 (put 'narrow-to-region 'disabled nil)
196 (put 'narrow-to-page 'disabled nil)
197 (put 'narrow-to-defun 'disabled nil)
198 (put 'upcase-region 'disabled nil)
199 (put 'downcase-region 'disabled nil)
202 Recenter in a different order - first go to top, then middle, then
204 #+BEGIN_SRC emacs-lisp
205 (setq recenter-positions '(top middle bottom))
208 I've tried various different fonts and while I like the Terminus font
209 most for my shells, in Emacs Inconsolata clearly wins.
210 #+BEGIN_SRC emacs-lisp
211 (set-frame-font "Inconsolata-14")
214 I always use dark backgrounds, so tell Emacs about it. No need to
216 #+BEGIN_SRC emacs-lisp
217 (setq-default frame-background-mode jj-color-style)
220 And I always liked dark backgrounds with colors setup for them. So I
221 switched through multiple themes doing it in emacs too, but never
222 entirely liked it. Until I found solarized, which is now not only my
223 emacs theme, but also for most of my other software too, especially my
224 shell. Consistent look is great.
225 #+BEGIN_SRC emacs-lisp :tangle no
226 (if (or (> emacs-major-version 23) (boundp 'custom-theme-load-path))
228 (defun jj-init-theme ()
230 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
231 (load-theme 'solarized-light t))
232 (set-face-attribute 'org-date nil :underline nil)
233 (message "Initializing theme solarized-dark")
235 (add-to-list 'custom-theme-load-path jj-theme-dir)
236 (add-hook 'after-init-hook 'jj-init-theme)
238 (add-to-list 'load-path (expand-file-name "emacs-color-theme-solarized" jj-elisp-dir))
239 (require 'color-theme-solarized)
240 (color-theme-solarized-dark)
243 #+BEGIN_SRC emacs-lisp
244 (use-package color-theme-solarized
245 :ensure solarized-theme
248 (defun jj-init-theme ()
250 ;; ;; make the fringe stand out from the background
251 (setq solarized-distinct-fringe-background t)
253 ;; ;; Don't change the font for some headings and titles
254 ;; (setq solarized-use-variable-pitch nil)
256 ;; ;; make the modeline high contrast
257 ;; (setq solarized-high-contrast-mode-line t)
259 ;; ;; Use less bolding
260 ;; (setq solarized-use-less-bold t)
262 ;; ;; Use more italics
263 ;; (setq solarized-use-more-italic t)
265 ;; ;; Use less colors for indicators such as git:gutter, flycheck and similar
266 ;; (setq solarized-emphasize-indicators nil)
268 ;; ;; Don't change size of org-mode headlines (but keep other size-changes)
269 ;; (setq solarized-scale-org-headlines nil)
271 ;; ;; Avoid all font-size changes
272 ;; (setq solarized-height-minus-1 1)
273 ;; (setq solarized-height-plus-1 1)
274 ;; (setq solarized-height-plus-2 1)
275 ;; (setq solarized-height-plus-3 1)
276 ;; (setq solarized-height-plus-4 1)
277 (setq x-underline-at-descent-line t)
279 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
280 (load-theme 'solarized-light t))
281 (set-face-attribute 'org-date nil :underline nil)
282 (message "Initializing theme solarized-dark")
284 (add-to-list 'custom-theme-load-path jj-theme-dir)
285 (add-hook 'after-init-hook 'jj-init-theme)
289 Make the fringe (gutter) smaller, the argument is a width in pixels (the default is 8)
290 #+BEGIN_SRC emacs-lisp
291 (if (fboundp 'fringe-mode)
295 A bit more spacing between buffer lines
296 #+BEGIN_SRC emacs-lisp
297 (setq-default line-spacing 0.1)
300 [2013-04-21 So 20:54]
301 I do not want my cursor to blink.
302 #+BEGIN_SRC emacs-lisp
303 (blink-cursor-mode -1)
305 *** Menu, Tool and Scrollbar
306 I don't want to see the menu-bar, tool-bar or scrollbar.
307 #+BEGIN_SRC emacs-lisp
309 (dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode))
310 (when (fboundp mode) (funcall mode -1))))
312 **** When using emacs in daemon mode
313 Emacs has a very nice mode where it detaches itself and runs as daemon -
314 and you can just open /frames/ (windows) from it by using [[http://www.emacswiki.org/emacs/EmacsClient][Emacs
315 Client]]. It's fast, it's nice, it's convinient.
317 Except that Emacs behaves stupid when you do that and ignores your
318 menu/tool/scrollbar settings. Sucks.
320 For them to work even then, we have to do two things.
321 1. We have to set the frame alist. We simple set both,
322 =initial-frame-alist= and =default-frame-alist= to the same value here.
323 #+BEGIN_SRC emacs-lisp
324 (setq initial-frame-alist '(
325 (horizontal-scroll-bars . nil)
326 (vertical-scroll-bars . nil)
329 (setq default-frame-alist (copy-alist initial-frame-alist))
331 2. We have to disable the toolbar using the customize interface, so you
332 can find that in the [[id:0102208d-fdf6-4928-9e40-7e341bd3aa3a][Customized variables]] section.
334 *** Hilight current line in buffer
335 As it says, it does a hilight of the current line.
336 #+BEGIN_SRC emacs-lisp
337 (global-hl-line-mode +1)
339 *** Allow recursive minibuffers
340 This allows (additional) minibuffer commands while in the minibuffer.
341 #+BEGIN_SRC emacs-lisp
342 (setq enable-recursive-minibuffers 't)
344 *** No GC during minibuffer action
345 [2016-02-15 Mon 22:09]
346 See [[https://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/][Why are you changing gc cons threshold?]] for more details.
347 #+BEGIN_SRC emacs-lisp
348 (defun my-minibuffer-setup-hook ()
349 (setq gc-cons-threshold most-positive-fixnum))
351 (defun my-minibuffer-exit-hook ()
352 (setq gc-cons-threshold 800000))
354 (add-hook 'minibuffer-setup-hook #'my-minibuffer-setup-hook)
355 (add-hook 'minibuffer-exit-hook #'my-minibuffer-exit-hook)
357 *** Modeline related changes
358 I want to see line and column numbers, so turn them on.
359 Size indication lets me know how far I am in a buffer.
361 And modeline-posn is great. It will hilight the column number in the
362 modeline in red as soon as you are over the defined limit.
363 #+BEGIN_SRC emacs-lisp
365 (column-number-mode 1)
366 (size-indication-mode 1)
367 (display-time-mode 1)
368 (setq display-time-day-and-date nil)
369 (setq display-time-default-load-average nil)
370 (setq display-time-24hr-format t)
371 (setq display-time-mail-string "")
372 (setq display-time-default-load-average nil)
373 (setq modelinepos-column-limit 72)
375 (use-package modeline-posn
379 (set-face-foreground 'modelinepos-column-warning "grey20")
380 (set-face-background 'modelinepos-column-warning "red")
381 (setq modelinepos-column-limit 72))
386 [2013-04-22 Mon 11:27]
387 The modeline is easily cluttered up with stuff I don't really need to
388 see. So lets hide those. There are two ways, one of them uses diminish
389 to get entirely rid of some modes, the other is a function taken from
390 "Mastering Emacs" which replaces the modes text with an own (set of)
392 #+BEGIN_SRC emacs-lisp
394 (diminish 'auto-fill-function)
395 (defvar mode-line-cleaner-alist
396 `((auto-complete-mode . " α")
397 (yas-minor-mode . " y")
398 (paredit-mode . " π")
402 (lisp-interaction-mode . "λ")
405 (emacs-lisp-mode . "EL")
407 (org-indent-mode . "")
412 "Alist for `clean-mode-line'.
414 When you add a new element to the alist, keep in mind that you
415 must pass the correct minor/major mode symbol and a string you
416 want to use in the modeline *in lieu of* the original.
418 Want some symbols? Go:
420 ;ςερτζθιοπασδφγηξκλυχψωβνμ
421 :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
422 @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
426 ; (add-hook 'after-change-major-mode-hook 'clean-mode-line)
429 Unfortunately icicles breaks this with the way it adds/removes itself,
430 so take it our for now...
433 Back when I started with text-mode. But nowadays I want default mode to
434 be org-mode - it is just so much better to use. And does sensible things
435 with many README files out there, and various other "crap" you get to
437 #+BEGIN_SRC emacs-lisp :tangle yes
438 (setq-default major-mode 'org-mode)
440 #+BEGIN_SRC emacs-lisp :tangle no
441 (setq initial-major-mode 'org-mode)
445 [2013-04-23 Tue 16:43]
446 Shell. zsh in my case.
447 #+BEGIN_SRC emacs-lisp
448 (setq shell-file-name "zsh")
449 (setq shell-command-switch "-c")
450 (setq explicit-shell-file-name shell-file-name)
451 (setenv "SHELL" shell-file-name)
452 (setq explicit-sh-args '("-login" "-i"))
453 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
454 (setq comint-scroll-to-bottom-on-input t) ; always insert at the bottom
455 (setq comint-scroll-to-bottom-on-output t) ; always add output at the bottom
456 (setq comint-scroll-show-maximum-output t) ; scroll to show max possible output
457 (setq comint-completion-autolist t) ; show completion list when ambiguous
458 (setq comint-input-ignoredups t) ; no duplicates in command history
459 (setq comint-completion-addsuffix t) ; insert space/slash after file completion
460 (setq comint-buffer-maximum-size 20000) ; max lenght of the buffer in lines
461 (setq comint-prompt-read-only nil) ; if this is t, it breaks shell-command
463 *** Keyboard related changes
465 This lets M-SPC cycle through spacing, that is
466 1. replace all spaces with a single space
468 3. restore the original spacing
469 #+BEGIN_SRC emacs-lisp :tangle yes
470 (bind-key "M-SPC" 'cycle-spacing)
472 **** Toggle/Cycle letter case
473 [2015-05-22 Fri 22:42]
475 This is from [[http://ergoemacs.org/emacs/modernization_upcase-word.html][Emacs: Toggle/Cycle Letter Case]]
477 Emacs has several user level commands for changing letter case. They
478 are: upcase-word 【Alt+u】, downcase-word 【Alt+l】, capitalize-word
481 There are also “region” versions for each: upcase-region 【Ctrl+x
482 Ctrl+u】, downcase-region 【Ctrl+x Ctrl+l】, capitalize-region, and
483 also upcase-initials-region. (Note: for elisp programing, there are
484 also these functions: upcase, capitalize, downcase, upcase-initials.)
486 One problem with these commands is that you need to move your cursor
487 to the beginning of the word first. For example, if you have the text
488 “THat”, and your cursor is on the “a”, and you call downcase-word, but
489 it doesn't do anything because it only start at the cursor point to
490 end of word. It would be nice if it'll just automatically perform the
491 operation on the whole word.
493 Another problem is that it does not consider the final result. For
494 example, if you have “oncE upon a time …”, and you select the whole
495 sentence and call upcase-initials-region, it becomes “OncE Upon A Time
496 …”. Note the capital E is not automatically lowered. For elisp
497 programing, the orthogonal precision is nice, but as user commands, it
498 is better to change the whole sentence.
500 Also, these commands have a “-word” and “-region” variants, great for
501 precision in elisp programing but not smart as user commands. It would
502 be nice if emacs automatically choose the right command depending
503 whether there is text selection.
504 #+BEGIN_SRC emacs-lisp :tangle yes
505 (bind-key "M-c" 'toggle-letter-case)
507 **** Faster pop-to-mark command
508 [2015-12-22 Di 14:56]
509 From [[http://endlessparentheses.com/faster-pop-to-mark-command.html?source=rss][Endless Parentheses]], a nice way to pop back in the marks.
510 #+BEGIN_SRC emacs-lisp :tangle yes
511 ;; When popping the mark, continue popping until the cursor
513 (defadvice pop-to-mark-command (around ensure-new-position activate)
516 (when (= p (point)) ad-do-it))))
517 (setq set-mark-command-repeat-pop t)
519 **** Don't kill-buffer, kill-this-buffer instead
520 From [[http://pragmaticemacs.com/emacs/dont-kill-buffer-kill-this-buffer-instead/][Pragmatic Emacs]]: By default C-x k runs the command kill-buffer
521 which prompts you for which buffer you want to kill, defaulting to the
522 current active buffer. I don’t know about you, but I rarely want to
523 kill a different buffer than the one I am looking at, so I rebind C-x
524 k to kill-this-buffer which just kills the current buffer without
525 prompting (unless there are unsaved changes).
526 #+BEGIN_SRC emacs-lisp :tangle yes
527 (global-set-key (kbd "C-x k") 'kill-this-buffer)
529 *** Don't query to kill processes at exit
530 [2016-10-03 Mo 14:05]
531 The variable at t (its default) lets emacs query before killing
532 processes when exiting.
533 #+BEGIN_SRC emacs-lisp :tangle yes
534 (setq confirm-kill-processes nil)
536 ** Miscellaneous stuff
537 Searches and matches should ignore case.
538 #+BEGIN_SRC emacs-lisp
539 (setq-default case-fold-search t)
542 Which buffers to get rid off at midnight.
543 #+BEGIN_SRC emacs-lisp
544 (setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
545 "*Man " "*Buffer List*"
551 "*magit" "*Calendar")))
554 Don't display a cursor in non-selected windows.
555 #+BEGIN_SRC emacs-lisp
556 (setq-default cursor-in-non-selected-windows nil)
559 What should be displayed in the mode-line for files with those types
561 #+BEGIN_SRC emacs-lisp
562 (setq eol-mnemonic-dos "(DOS)")
563 (setq eol-mnemonic-mac "(Mac)")
566 #+BEGIN_SRC emacs-lisp
567 (setq max-lisp-eval-depth 1000)
568 (setq max-specpdl-size 3000)
572 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
573 #+BEGIN_SRC emacs-lisp
574 (defun unfill-paragraph ()
575 "Takes a multi-line paragraph and makes it into a single line of text."
577 (let ((fill-column (point-max)))
578 (fill-paragraph nil)))
579 (bind-key "H-u" 'unfill-paragraph)
582 #+BEGIN_SRC emacs-lisp
583 (setq-default indicate-empty-lines t)
584 (setq sentence-end-double-space nil)
587 Hilight annotations in comments, like FIXME/TODO/...
588 #+BEGIN_SRC emacs-lisp :tangle no
589 (add-hook 'prog-mode-hook 'font-lock-comment-annotations)
593 #+BEGIN_SRC emacs-lisp
594 (setq browse-url-browser-function (quote browse-url-generic))
595 (setq browse-url-generic-program "/usr/bin/x-www-browser")
598 *** When saving a script - make it executable
599 #+BEGIN_SRC emacs-lisp
600 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
604 #+BEGIN_SRC emacs-lisp
608 (add-hook 'after-init-hook 'server-start)))
610 **** Edit-server for chromium extension "Edit with emacs"
611 [2015-10-15 Thu 22:32]
612 #+BEGIN_SRC emacs-lisp
613 (use-package edit-server
616 (setq edit-server-new-frame nil)
617 (edit-server-start)))
619 ** Customized variables
620 [2013-05-02 Thu 22:14]
621 The following contains a set of variables i may reasonably want to
622 change on other systems - which don't affect the init file loading
623 process. So I *can* use the customization interface for it...
624 #+BEGIN_SRC emacs-lisp
625 (defgroup ganneff nil
626 "Modify ganneffs settings"
629 (defgroup ganneff-org-mode nil
630 "Ganneffs org-mode settings"
631 :tag "Ganneffs org-mode settings"
633 :link '(custom-group-link "ganneff"))
635 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
636 "ID of the organization task."
637 :tag "Organization Task ID"
639 :group 'ganneff-org-mode)
641 (defcustom org-my-archive-expiry-days 2
642 "The number of days after which a completed task should be auto-archived.
643 This can be 0 for immediate, or a floating point value."
644 :tag "Archive expiry days"
646 :group 'ganneff-org-mode)
651 [2013-05-21 Tue 23:22]
652 Restore removed var alias, used by ruby-electric-brace and others
653 #+BEGIN_SRC emacs-lisp
654 (unless (boundp 'last-command-char)
655 (defvaralias 'last-command-char 'last-command-event))
657 * Customized variables
659 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
661 Of course I want to be able to use the customize interface, and some
662 things can only be set via it (or so they say). I usually prefer to put
663 things I keep for a long while into statements somewhere else, not just
664 custom-set here, but we need it anyways.
666 #+BEGIN_SRC emacs-lisp
667 (setq custom-file jj-custom-file)
668 (safe-load custom-file)
671 The source of this is:
672 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
673 * Extra modes and their configuration
675 A defined abbrev is a word which expands, if you insert it, into some
676 different text. Abbrevs are defined by the user to expand in specific
678 #+BEGIN_SRC emacs-lisp
680 :commands abbrev-mode
681 :diminish abbrev-mode
684 (setq save-abbrevs 'silently)
685 (setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
686 (if (file-exists-p abbrev-file-name)
687 (quietly-read-abbrev-file))
689 (hook-into-modes #'abbrev-mode '(text-mode-hook))
690 (add-hook 'expand-load-hook
692 (add-hook 'expand-expand-hook 'indent-according-to-mode)
693 (add-hook 'expand-jump-hook 'indent-according-to-mode)))))
696 [2016-02-15 Mon 22:19]
697 See [[http://endlessparentheses.com/ispell-and-abbrev-the-perfect-auto-correct.html][Ispell and Abbrev, the Perfect Auto-Correct]].
698 #+BEGIN_SRC emacs-lisp
699 (define-key ctl-x-map "\C-i"
700 #'endless/ispell-word-then-abbrev)
702 (defun endless/ispell-word-then-abbrev (p)
703 "Call `ispell-word', then create an abbrev for it.
704 With prefix P, create local abbrev. Otherwise it will
706 If there's nothing wrong with the word at point, keep
707 looking for a typo until the beginning of buffer. You can
708 skip typos you don't want to fix with `SPC', and you can
709 abort completely with `C-g'."
713 (while (if (setq bef (thing-at-point 'word))
714 ;; Word was corrected or used quit.
715 (if (ispell-word nil 'quiet)
717 ;; Also end if we reach `bob'.
719 ;; If there's no word at point, keep looking
723 (setq aft (thing-at-point 'word)))
724 (if (and aft bef (not (equal aft bef)))
725 (let ((aft (downcase aft))
726 (bef (downcase bef)))
728 (if p local-abbrev-table global-abbrev-table)
730 (message "\"%s\" now expands to \"%s\" %sally"
731 bef aft (if p "loc" "glob")))
732 (user-error "No typo at or before point"))))
734 (setq save-abbrevs 'silently)
735 (setq-default abbrev-mode t)
738 [2013-04-28 So 11:26]
739 avy is a GNU Emacs package for jumping to visible text using a char-based decision tree.
740 #+BEGIN_SRC emacs-lisp
743 :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)
744 :bind (("H-SPC" . avy-goto-char-2)
745 ("M-g g" . avy-goto-line)
749 (setq avy-all-windows 'all-frames)
750 (setq avi-keys '(?a ?s ?d ?e ?f ?h ?j ?k ?l ?n ?m ?v ?r ?u) )
754 (bind-key "C-y" 'avy-isearch isearch-mode-map)
759 [2013-04-21 So 20:27]
760 Use H-w to switch windows
761 #+BEGIN_SRC emacs-lisp
762 (use-package ace-window
765 :bind ("H-w" . ace-window)
768 (setq aw-keys '(?a ?s ?d ?f ?j ?k ?l))
772 [2014-10-27 Mon 13:08]
773 electric-indent-mode is enough to keep your code nicely aligned when
774 all you do is type. However, once you start shifting blocks around,
775 transposing lines, or slurping and barfing sexps, indentation is bound
778 aggressive-indent-mode is a minor mode that keeps your code always
779 indented. It reindents after every command, making it more reliable
780 than electric-indent-mode.
781 #+BEGIN_SRC emacs-lisp
782 (use-package aggressive-indent
783 :ensure aggressive-indent
784 :commands (aggressive-indent-mode global-aggressive-indent-mode)
787 (global-aggressive-indent-mode 0)
788 (setq aggressive-indent-comments-too 0)
789 (add-to-list 'aggressive-indent-excluded-modes 'html-mode)
793 [2014-06-01 Sun 23:02]
794 Provides a minor mode which displays current match and total matches
795 information in the mode-line in various search modes.
796 #+BEGIN_SRC emacs-lisp
803 (setq anzu-search-threshold 1000)
805 (set-face-attribute 'anzu-mode-line nil :foreground "yellow" :weight 'bold)))
808 [2014-05-21 Wed 00:33]
809 #+BEGIN_SRC emacs-lisp
811 :commands (ascii-on ascii-toggle ascii-display)
812 :bind (("C-c e A" . ascii-toggle))
815 (defun ascii-toggle ()
817 (defvar ascii-display nil)
822 (bind-key "C-c e A" 'ascii-toggle)))
825 #+BEGIN_SRC emacs-lisp
826 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
827 (setq TeX-auto-save t)
828 (setq TeX-parse-self t)
829 (setq TeX-PDF-mode t)
831 ** auto-complete mode
832 [2013-04-27 Sa 16:33]
833 And aren't we all lazy? I definitely am, and I like my emacs doing as
834 much possible work for me as it can.
835 So here, auto-complete-mode, which lets emacs do this, based on what I
837 #+BEGIN_SRC emacs-lisp
838 (use-package auto-complete-config
839 :ensure auto-complete
843 ;; hook AC into completion-at-point
844 (defun sanityinc/auto-complete-at-point ()
845 (when (and (not (minibufferp))
846 (fboundp 'auto-complete-mode)
849 (defun set-auto-complete-as-completion-at-point-function ()
850 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
851 ;; Exclude very large buffers from dabbrev
852 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
853 (< (buffer-size other-buffer) (* 1 1024 1024)))
858 ;; custom keybindings to use tab, enter and up and down arrows
859 (bind-key "\t" 'ac-expand ac-complete-mode-map)
860 (bind-key "\r" 'ac-complete ac-complete-mode-map)
861 (bind-key "M-n" 'ac-next ac-complete-mode-map)
862 (bind-key "M-p" 'ac-previous ac-complete-mode-map)
863 (bind-key "C-s" 'ac-isearch ac-completing-map)
864 (bind-key "M-TAB" 'auto-complete ac-mode-map)
866 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
867 (setq ac-use-comphist t)
868 (setq ac-expand-on-auto-complete nil)
870 (setq ac-auto-start 3)
872 (setq ac-menu-height 15)
873 (setq ac-quick-help-delay 0.5)
874 (setq ac-use-fuzzy t)
876 (ac-flyspell-workaround)
878 ;; use 't when auto-complete is disabled
879 (setq tab-always-indent 'complete)
880 (add-to-list 'completion-styles 'initials t)
882 ;; Use space and punctuation to accept the current the most likely completion.
883 (setq auto-completion-syntax-alist (quote (global accept . word)))
884 ;; Avoid completion for short trivial words.
885 (setq auto-completion-min-chars (quote (global . 3)))
886 (setq completion-use-dynamic t)
888 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
890 ;; Exclude very large buffers from dabbrev
891 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
893 (use-package ac-dabbrev
896 (set-default 'ac-sources
899 ac-source-words-in-buffer
900 ac-source-words-in-same-mode-buffers
901 ; ac-source-words-in-all-buffer
904 (dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
905 sass-mode yaml-mode csv-mode espresso-mode haskell-mode
906 html-mode nxml-mode sh-mode smarty-mode clojure-mode
907 lisp-mode textile-mode markdown-mode tuareg-mode python-mode
908 js3-mode css-mode less-css-mode sql-mode ielm-mode))
909 (add-to-list 'ac-modes mode))
911 (add-hook 'latex-mode-hook 'auto-complete-mode)
912 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
913 (add-hook 'prog-mode-hook 'auto-complete-mode)
914 (add-hook 'org-mode-hook 'auto-complete-mode)))
919 When files change outside emacs for whatever reason I want emacs to deal
920 with it. Not to have to revert buffers myself
921 #+BEGIN_SRC emacs-lisp
922 (use-package autorevert
923 :commands auto-revert-mode
924 :diminish auto-revert-mode
927 (setq global-auto-revert-mode t)
928 (setq global-auto-revert-non-file-buffers t)
929 (global-auto-revert-mode)))
933 Emacs should keep backup copies of files I edit, but I do not want them
934 to clutter up the filesystem everywhere. So I put them into one defined
935 place, backup-directory, which even contains my username (for systems
936 where =temporary-file-directory= is not inside my home).
937 #+BEGIN_SRC emacs-lisp
938 (use-package backups-mode
939 :load-path "elisp/backups-mode"
941 :bind (("\C-cv" . save-version)
942 ("\C-cb" . list-backups)
943 ("\C-ck" . kill-buffer-prompt)
944 ("\C-cw" . backup-walker-start))
947 (setq backup-directory jj-backup-directory)
948 ; (setq tramp-backup-directory (concat jj-backup-directory "/tramp"))
949 ; (if (not (file-exists-p tramp-backup-directory))
950 ; (make-directory tramp-backup-directory))
951 ; (setq tramp-backup-directory-alist `((".*" . ,tramp-backup-directory)))
952 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
953 (setq auto-save-list-file-prefix (concat jj-backup-directory ".auto-saves-"))
954 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
956 (setq version-control t) ;; Use version numbers for backups
957 (setq kept-new-versions 10) ;; Number of newest versions to keep
958 (setq kept-old-versions 2) ;; Number of oldest versions to keep
959 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
960 (setq backup-by-copying t)
961 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
962 (setq make-backup-files t)
964 (defadvice kill-buffer (around kill-buffer)
965 "Always save before killing a file buffer"
966 (when (and (buffer-modified-p)
968 (file-exists-p (buffer-file-name)))
971 (ad-activate 'kill-buffer)
973 (defadvice save-buffers-kill-emacs (around save-buffers-kill-emacs)
974 "Always save before killing emacs"
975 (save-some-buffers t)
977 (ad-activate 'save-buffers-kill-emacs)
979 (defun kill-buffer-prompt ()
980 "Allows one to kill a buffer without saving it.
981 This is necessary since once you start backups-mode all file based buffers
982 are saved automatically when they are killed"
984 (if (and (buffer-modified-p) (buffer-file-name) (file-exists-p (buffer-file-name)) (y-or-n-p "Save buffer?"))
986 (set-buffer-modified-p nil))
989 (setq backup-enable-predicate
991 (and (normal-backup-enable-predicate name)
993 (let ((method (file-remote-p name 'method)))
994 (when (stringp method)
995 (member method '("su" "sudo"))))))))))
999 [2014-12-11 Thu 11:31]
1000 #+BEGIN_SRC emacs-lisp
1001 (use-package browse-kill-ring
1002 :commands (browse-kill-ring browse-kill-ring-mode)
1003 :bind ("M-y" . browse-kill-ring)
1007 [2014-06-10 Tue 22:20]
1008 #+BEGIN_SRC emacs-lisp
1010 :commands (cal/insert)
1011 :bind ("C-c c" . cal/insert)
1014 ; Weeks start on Monday, not sunday.
1015 (setq calendar-week-start-day 1)
1017 ; Display ISO week numbers in Calendar Mode
1018 (copy-face font-lock-constant-face 'calendar-iso-week-face)
1019 (set-face-attribute 'calendar-iso-week-face nil :height 0.7)
1020 (setq calendar-intermonth-text
1024 (calendar-iso-from-absolute
1025 (calendar-absolute-from-gregorian (list month day year)))))
1026 'font-lock-face 'calendar-iso-week-face))
1027 (copy-face 'default 'calendar-iso-week-header-face)
1028 (set-face-attribute 'calendar-iso-week-header-face nil :height 0.7)
1029 (setq calendar-intermonth-header
1030 (propertize "Wk" ; or e.g. "KW" in Germany
1031 'font-lock-face 'calendar-iso-week-header-face))))
1035 [2015-10-15 Thu 11:34]
1036 Corral is a lightweight package that lets you quickly wrap parentheses
1037 and other delimiters around text, intuitively surrounding what you
1038 want it to using just two commands.
1039 #+BEGIN_SRC emacs-lisp
1044 ; Interpret # and * as part of the word
1045 (setq corral-syntax-entries '((?# "_")
1049 (defhydra hydra-corral (:columns 4)
1051 ("(" corral-parentheses-backward "Back")
1052 (")" corral-parentheses-forward "Forward")
1053 ("[" corral-brackets-backward "Back")
1054 ("]" corral-brackets-forward "Forward")
1055 ("{" corral-braces-backward "Back")
1056 ("}" corral-braces-forward "Forward")
1057 ("\"" corral-double-quotes-backward "Back")
1058 ("2" corral-double-quotes-forward "Forward")
1059 ("'" corral-single-quotes-backward "Back")
1060 ("#" corral-single-quotes-forward "Forward")
1061 ("." hydra-repeat "Repeat"))
1062 (bind-key "C-c c" 'hydra-corral/body)
1066 [2013-05-21 Tue 23:18]
1067 #+BEGIN_SRC emacs-lisp
1068 (use-package crontab-mode
1069 :ensure crontab-mode
1070 :commands crontab-mode
1071 :mode ("\\.?cron\\(tab\\)?\\'" . crontab-mode))
1075 web-mode takes over, see [[*web-mode][web-mode]]
1076 #+BEGIN_SRC emacs-lisp :tangle no
1077 (use-package css-mode
1078 :mode ("\\.css\\'" . css-mode)
1083 (use-package flymake-css
1087 (defun maybe-flymake-css-load ()
1088 "Activate flymake-css as necessary, but not in derived modes."
1089 (when (eq major-mode 'css-mode)
1090 (flymake-css-load)))
1091 (add-hook 'css-mode-hook 'maybe-flymake-css-load)))
1092 ;;; Auto-complete CSS keywords
1093 (eval-after-load 'auto-complete
1095 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
1096 (add-hook hook 'ac-css-mode-setup))))))
1100 I know that this lets it look "more like windows", but I don't much care
1101 about its paste/copy/cut keybindings, the really nice part is the great
1102 support for rectangular regions, which I started to use a lot since I
1103 know this mode. The normal keybindings for those are just to useless.
1104 #+BEGIN_SRC emacs-lisp
1106 (setq cua-enable-cua-keys (quote shift))
1109 Luckily cua-mode easily supports this, with the following line I just
1110 get the CUA selection and rectangle stuff, not the keybindings. Yes,
1111 even though the above =cua-enable-cua-keys= setting would only enable
1112 them if the selection is done when the region was marked with a shifted
1114 #+BEGIN_SRC emacs-lisp
1115 (cua-selection-mode t)
1119 #+BEGIN_SRC emacs-lisp
1120 (require 'dpkg-dev-el-loaddefs nil 'noerror)
1121 (require 'debian-el-loaddefs nil 'noerror)
1123 (setq debian-changelog-full-name "Joerg Jaspert")
1124 (setq debian-changelog-mailing-address "joerg@debian.org")
1128 #+BEGIN_SRC emacs-lisp
1129 (use-package diff-mode
1131 :mode (("\\.diff" . diff-mode)))
1135 #+BEGIN_SRC emacs-lisp
1137 :commands (dired dired-other-window dired-other-frame dired-noselect
1138 dired-mode dired-jump)
1139 :defines (dired-omit-regexp-orig)
1140 :bind (:map dired-mode-map
1141 ("F" . find-name-dired))
1144 (setq diredp-hide-details-initially-flag nil))
1147 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
1148 (setq dired-dwim-target t)
1149 (setq dired-listing-switches "-alh")
1150 (setq dired-listing-switches "-alXh --group-directories-first")
1151 (setq dired-recursive-copies (quote top))
1152 (setq dired-recursive-deletes (quote top))
1153 (setq dired-guess-shell-alist-user
1154 '(("\\.pdf\\'" "mupdf")
1155 ("\\.\\(?:djvu\\|eps\\)\\'" "evince")
1156 ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "eog")
1157 ("\\.\\(?:xcf\\)\\'" "gimp")
1158 ("\\.csv\\'" "libreoffice")
1159 ("\\.tex\\'" "pdflatex" "latex")
1160 ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\)\\(?:\\.part\\)?\\'" "vlc")
1161 ("\\.html?\\'" "conkeror")))
1166 (use-package dired-x)
1168 (use-package dired-single
1169 :ensure dired-single
1172 (bind-key "<return>" 'dired-single-buffer dired-mode-map)
1173 (bind-key "<mouse-1>" 'dired-single-buffer-mouse dired-mode-map)
1176 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
1182 (setq wdired-allow-to-change-permissions t)
1183 (bind-key "r" 'wdired-change-to-wdired-mode dired-mode-map)))
1185 (use-package gnus-dired
1186 :commands (gnus-dired-attach gnus-dired-mode)
1189 ;;(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
1190 (bind-key "a" 'gnus-dired-attach dired-mode-map)))
1195 (defvar mark-files-cache (make-hash-table :test #'equal))
1197 (defun mark-similar-versions (name)
1199 (if (string-match "^\\(.+?\\)-[0-9._-]+$" pat)
1200 (setq pat (match-string 1 pat)))
1201 (or (gethash pat mark-files-cache)
1202 (ignore (puthash pat t mark-files-cache)))))
1204 (defun dired-mark-similar-version ()
1206 (setq mark-files-cache (make-hash-table :test #'equal))
1207 (dired-mark-sexp '(mark-similar-versions name)))
1209 (defun dired-package-initialize ()
1210 (unless (featurep 'runner)
1211 (bind-key "M-!" 'async-shell-command dired-mode-map)
1212 (unbind-key "M-s f" dired-mode-map)
1214 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1215 "Make sure to remove \"Omit\" from the modeline."
1216 (diminish 'dired-omit-mode) dired-mode-map)
1218 ;; Omit files that Git would ignore
1219 (defun dired-omit-regexp ()
1220 (let ((file (expand-file-name ".git"))
1222 (while (and (not (file-exists-p file))
1225 (file-name-directory
1226 (directory-file-name
1227 (file-name-directory file))))
1228 ;; Give up if we are already at the root dir.
1229 (not (string= (file-name-directory file)
1231 ;; Move up to the parent dir and try again.
1232 (setq file (expand-file-name ".git" parent-dir)))
1233 ;; If we found a change log in a parent, use that.
1234 (if (file-exists-p file)
1235 (let ((regexp (funcall dired-omit-regexp-orig))
1237 (shell-command-to-string "git clean -d -x -n")))
1238 (if (= 0 (length omitted-files))
1242 (if (> (length regexp) 0)
1251 (if (= ?/ (aref str (1- (length str))))
1255 (split-string omitted-files "\n" t)
1258 (funcall dired-omit-regexp-orig))))))
1260 (add-hook 'dired-mode-hook 'dired-package-initialize)
1262 (defun dired-double-jump (first-dir second-dir)
1264 (list (read-directory-name "First directory: "
1265 (expand-file-name "~")
1266 nil nil "/Downloads/")
1267 (read-directory-name "Second directory: "
1268 (expand-file-name "~")
1271 (dired-other-window second-dir))
1272 (bind-key "C-c J" 'dired-double-jump)
1274 (defun dired-back-to-top ()
1276 (goto-char (point-min))
1277 (dired-next-line 4))
1279 (define-key dired-mode-map
1280 (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
1282 (defun dired-jump-to-bottom ()
1284 (goto-char (point-max))
1285 (dired-next-line -1))
1287 (define-key dired-mode-map
1288 (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)))
1291 ** discover-my-major
1292 [2014-06-01 Sun 23:32]
1293 Discover key bindings and their meaning for the current Emacs major mode.
1294 #+BEGIN_SRC emacs-lisp
1295 (use-package discover-my-major
1296 :ensure discover-my-major
1297 :commands discover-my-major
1298 :bind ("C-h C-m" . discover-my-major))
1301 EasyPG is a GnuPG interface for Emacs.
1302 Bookmark: [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1303 #+BEGIN_SRC emacs-lisp
1304 (use-package epa-file
1308 ;; I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1309 (defadvice epg--start (around advice-epg-disable-agent disable)
1310 "Don't allow epg--start to use gpg-agent in plain text
1312 (if (display-graphic-p)
1314 (let ((agent (getenv "GPG_AGENT_INFO")))
1315 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
1317 (setenv "GPG_AGENT_INFO" agent))))
1318 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
1319 (ad-activate 'epg--start)
1323 [2013-04-21 So 20:36]
1324 ediff - don't start another frame
1325 #+BEGIN_SRC emacs-lisp
1329 (defvar ctl-period-equals-map)
1330 (define-prefix-command 'ctl-period-equals-map)
1331 (bind-key "C-. =" 'ctl-period-equals-map)
1332 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
1334 :bind (("C-. = b" . ediff-buffers)
1335 ("C-. = B" . ediff-buffers3)
1336 ("C-. = =" . ediff-files)
1337 ("C-. = f" . ediff-files)
1338 ("C-. = F" . ediff-files3)
1339 ("C-. = r" . ediff-revision)
1340 ("C-. = p" . ediff-patch-file)
1341 ("C-. = P" . ediff-patch-buffer)
1342 ("C-. = l" . ediff-regions-linewise)
1343 ("C-. = w" . ediff-regions-wordwise))
1345 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1346 (setq ediff-split-window-function 'split-window-horizontally)
1351 [2015-12-16 Wed 22:13]
1352 Allows chromium to "send" files (textbox inputs) to emacs to edit.
1353 #+BEGIN_SRC emacs-lisp
1354 (use-package edit-server
1359 (setq edit-server-new-frame t)
1360 (edit-server-start)))
1364 EMMS is the Emacs Multimedia System.
1365 #+BEGIN_SRC emacs-lisp :tangle no
1366 (require 'emms-source-file)
1367 (require 'emms-source-playlist)
1368 (require 'emms-info)
1369 (require 'emms-cache)
1370 (require 'emms-playlist-mode)
1371 (require 'emms-playing-time)
1372 (require 'emms-player-mpd)
1373 (require 'emms-playlist-sort)
1374 (require 'emms-mark)
1375 (require 'emms-browser)
1376 (require 'emms-lyrics)
1377 (require 'emms-last-played)
1378 (require 'emms-score)
1379 (require 'emms-tag-editor)
1380 (require 'emms-history)
1381 (require 'emms-i18n)
1383 (setq emms-playlist-default-major-mode 'emms-playlist-mode)
1384 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
1385 (emms-playing-time 1)
1387 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
1388 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
1390 (when (fboundp 'emms-cache) ; work around compiler warning
1392 (setq emms-score-default-score 3)
1394 (defun emms-mpd-init ()
1395 "Connect Emms to mpd."
1397 (emms-player-mpd-connect))
1400 (require 'emms-player-mpd)
1401 (setq emms-player-mpd-server-name "localhost")
1402 (setq emms-player-mpd-server-port "6600")
1403 (add-to-list 'emms-info-functions 'emms-info-mpd)
1404 (add-to-list 'emms-player-list 'emms-player-mpd)
1405 (setq emms-volume-change-function 'emms-volume-mpd-change)
1406 (setq emms-player-mpd-sync-playlist t)
1408 (setq emms-source-file-default-directory "/var/lib/mpd/music")
1409 (setq emms-player-mpd-music-directory "/var/lib/mpd/music")
1410 (setq emms-info-auto-update t)
1411 (setq emms-lyrics-scroll-p t)
1412 (setq emms-lyrics-display-on-minibuffer t)
1413 (setq emms-lyrics-display-on-modeline nil)
1414 (setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
1416 (setq emms-last-played-format-alist
1417 '(((emms-last-played-seconds-today) . "%H:%M")
1418 (604800 . "%a %H:%M") ; this week
1419 ((emms-last-played-seconds-month) . "%d.%m.%Y")
1420 ((emms-last-played-seconds-year) . "%d.%m.%Y")
1421 (t . "Never played")))
1424 (defun my-describe (track)
1425 (let* ((empty "...")
1426 (name (emms-track-name track))
1427 (type (emms-track-type track))
1428 (short-name (file-name-nondirectory name))
1429 (play-count (or (emms-track-get track 'play-count) 0))
1430 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
1431 (artist (or (emms-track-get track 'info-artist) empty))
1432 (year (emms-track-get track 'info-year))
1433 (playing-time (or (emms-track-get track 'info-playing-time) 0))
1434 (min (/ playing-time 60))
1435 (sec (% playing-time 60))
1436 (album (or (emms-track-get track 'info-album) empty))
1437 (tracknumber (emms-track-get track 'info-tracknumber))
1438 (short-name (file-name-sans-extension
1439 (file-name-nondirectory name)))
1440 (title (or (emms-track-get track 'info-title) short-name))
1441 (rating (emms-score-get-score name))
1444 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
1445 (emms-last-played-format-date last-played)
1449 (if (and tracknumber ; tracknumber
1450 (not (zerop (string-to-number tracknumber))))
1451 (format "%02d" (string-to-number tracknumber))
1455 (make-string rating rate-char)))
1458 (setq emms-track-description-function 'my-describe)
1460 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
1461 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
1462 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
1463 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
1464 (global-set-key (kbd "H-<f9> x") 'emms-start)
1465 (global-set-key (kbd "H-<f9> v") 'emms-stop)
1466 (global-set-key (kbd "H-<f9> n") 'emms-next)
1467 (global-set-key (kbd "H-<f9> p") 'emms-previous)
1468 (global-set-key (kbd "H-<f9> o") 'emms-show)
1469 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
1470 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
1471 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
1472 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
1473 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
1475 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
1476 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
1477 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
1478 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
1480 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
1481 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
1482 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
1483 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
1485 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
1486 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
1487 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
1488 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
1490 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
1491 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
1492 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
1493 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
1494 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
1495 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
1497 (define-key emms-playlist-mode-map "x" 'emms-start)
1498 (define-key emms-playlist-mode-map "v" 'emms-stop)
1499 (define-key emms-playlist-mode-map "n" 'emms-next)
1500 (define-key emms-playlist-mode-map "p" 'emms-previous)
1502 (setq emms-playlist-buffer-name "*EMMS Playlist*"
1503 emms-playlist-mode-open-playlists t)
1509 'emms-browser-artist-face nil
1514 (setq emms-player-mpd-supported-regexp
1515 (or (emms-player-mpd-get-supported-regexp)
1516 (concat "\\`http://\\|"
1517 (emms-player-simple-regexp
1518 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
1519 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
1523 Basic settings for emacs integrated shell
1524 #+BEGIN_SRC emacs-lisp :tangle no
1530 (defun eshell-initialize ()
1531 (defun eshell-spawn-external-command (beg end)
1532 "Parse and expand any history references in current input."
1535 (when (looking-back "&!" beg)
1536 (delete-region (match-beginning 0) (match-end 0))
1538 (insert "spawn "))))
1539 (add-hook 'eshell-expand-input-functions 'eshell-spawn-external-command)
1540 (eval-after-load "em-unix"
1542 (unintern 'eshell/su)
1543 (unintern 'eshell/sudo))))
1544 (add-hook 'eshell-first-time-mode-hook 'eshell-initialize)
1548 (defalias 'emacs 'find-file)
1549 (defalias 'ec 'find-file)
1550 (defalias 'e 'find-file)
1554 (use-package 'em-cmpl)
1555 (use-package 'em-prompt)
1556 (use-package 'em-term)
1558 (setq eshell-cmpl-cycle-completions nil
1559 eshell-save-history-on-exit t
1560 eshell-buffer-maximum-lines 20000
1561 eshell-history-size 350
1562 eshell-buffer-shorthand t
1563 eshell-highlight-prompt t
1564 eshell-plain-echo-behavior t
1565 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
1567 (setenv "PAGER" "cat")
1568 (setq eshell-visual-commands
1569 '("less" "tmux" "htop" "top" "bash" "zsh" "tail"))
1570 (setq eshell-visual-subcommands
1571 '(("git" "log" "l" "diff" "show")))
1573 (add-to-list 'eshell-command-completions-alist
1574 '("gunzip" "gz\\'"))
1575 (add-to-list 'eshell-command-completions-alist
1576 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
1578 (when (not (functionp 'eshell/rgrep))
1579 (defun eshell/rgrep (&rest args)
1580 "Use Emacs grep facility instead of calling external grep."
1581 (eshell-grep "rgrep" args t)))
1583 ;(set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
1584 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
1585 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
1586 (add-hook 'eshell-preoutput-filter-functions
1587 'ansi-color-filter-apply)
1588 ;; Prompt with a bit of help from http://www.emacswiki.org/emacs/EshellPrompt
1590 (defmacro with-face (str &rest properties)
1591 `(propertize ,str 'face (list ,@properties)))
1593 (defun eshell/abbr-pwd ()
1594 (let ((home (getenv "HOME"))
1595 (path (eshell/pwd)))
1597 ((string-equal home path) "~")
1598 ((f-ancestor-of? home path) (concat "~/" (f-relative path home)))
1601 (defun eshell/my-prompt ()
1602 (let ((header-bg "#161616"))
1604 (with-face user-login-name :foreground "cyan")
1605 (with-face (concat "@" hostname) :foreground "white")
1607 (with-face (eshell/abbr-pwd) :foreground "#009900")
1608 (if (= (user-uid) 0)
1609 (with-face "#" :foreground "red")
1610 (with-face "$" :foreground "#69b7f0"))
1613 (use-package eshell-prompt-extras
1617 (setq eshell-highlight-prompt nil
1618 ;; epe-git-dirty-char "Ϟ"
1619 epe-git-dirty-char "*"
1620 eshell-prompt-function 'epe-theme-dakrone)))
1622 (defun eshell/magit ()
1623 "Function to open magit-status for the current directory"
1625 (magit-status default-directory)
1628 (setq eshell-prompt-function 'eshell/my-prompt)
1629 (setq eshell-highlight-prompt nil)
1630 (setq eshell-prompt-regexp "^[^#$\n]+[#$] ")))
1635 Incremental search is great, but annoyingly you need to type whatever
1636 you want. If you want to search for just the next (or previous)
1637 occurence of what is at your cursor position use the following.
1638 *C-x* will insert the current word while *M-up* and *M-down* will just
1639 jump to the next/previous occurence of it.
1640 #+BEGIN_SRC emacs-lisp
1641 (bind-key "C-x" 'sacha/isearch-yank-current-word isearch-mode-map)
1642 (bind-key* "<M-up>" 'sacha/search-word-backward)
1643 (bind-key* "<M-down>" 'sacha/search-word-forward)
1646 *** Frame configuration
1647 I want to see the buffername and its size, not the host I am on in my
1649 #+BEGIN_SRC emacs-lisp
1650 (setq frame-title-format "%b (%i)")
1653 *** Protect some buffers
1654 I don't want some buffers to be killed, **scratch** for example.
1655 In the past I had a long function that just recreated them, but the
1656 =keep-buffers= package is easier.
1657 #+BEGIN_SRC emacs-lisp
1658 (use-package keep-buffers
1661 (keep-buffers-mode 1)
1662 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
1663 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
1668 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
1670 #+BEGIN_SRC emacs-lisp
1671 (defalias 'yes-or-no-p 'y-or-n-p)
1674 *** Language/i18n stuff
1675 In this day and age, UTF-8 is the way to go.
1676 #+BEGIN_SRC emacs-lisp
1677 (set-language-environment 'utf-8)
1678 (set-default-coding-systems 'utf-8)
1679 (set-terminal-coding-system 'utf-8)
1680 (set-keyboard-coding-system 'utf-8)
1681 (set-clipboard-coding-system 'utf-8)
1682 (prefer-coding-system 'utf-8)
1683 (set-charset-priority 'unicode)
1684 (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
1685 (when (display-graphic-p)
1686 (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
1689 *** Hilight matching parentheses
1690 While I do have the nifty shortcut to jump to the other parentheses,
1691 hilighting them makes it obvious where they are.
1692 #+BEGIN_SRC emacs-lisp
1693 (use-package mic-paren
1697 *** Kill other buffers
1698 While many editors allow you to close "all the other files, not the one
1699 you are in", emacs doesn't have this... Except, now it will.
1700 (Update 30.05.2014: Not used ever, deactivated)
1701 #+BEGIN_SRC emacs-lisp :tangle no
1702 (bind-key "C-c k" 'prelude-kill-other-buffers)
1705 Default scrolling behaviour in emacs is a bit annoying, who wants to
1707 #+BEGIN_SRC emacs-lisp
1708 (setq scroll-margin 3)
1709 (setq scroll-conservatively 100000)
1710 (setq scroll-up-aggressively 0.0)
1711 (setq scroll-down-aggressively 0.0)
1712 (setq scroll-preserve-screen-position 'always)
1715 *** Copy/Paste with X
1716 [2013-04-09 Di 23:31]
1717 The default how emacs handles cutting/pasting with the primary selection
1718 changed in emacs24. I am used to the old way, so get it back.
1719 #+BEGIN_SRC emacs-lisp
1720 (setq select-enable-primary t)
1721 (setq select-enable-clipboard nil)
1722 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
1723 (setq mouse-drag-copy-region t)
1725 *** Global keyboard changes not directly related to a mode
1726 Disable /suspend_frame/ function, I dislike it.
1727 #+BEGIN_SRC emacs-lisp
1729 (unbind-key "C-x C-z")
1732 http://endlessparentheses.com/kill-entire-line-with-prefix-argument.html?source=rss
1733 #+BEGIN_SRC emacs-lisp
1734 (defmacro bol-with-prefix (function)
1735 "Define a new function which calls FUNCTION.
1736 Except it moves to beginning of line before calling FUNCTION when
1737 called with a prefix argument. The FUNCTION still receives the
1739 (let ((name (intern (format "endless/%s-BOL" function))))
1743 "Call `%s', but move to BOL when called with a prefix argument."
1748 (call-interactively ',function))
1751 (global-set-key [remap paredit-kill] (bol-with-prefix paredit-kill))
1752 (global-set-key [remap org-kill-line] (bol-with-prefix org-kill-line))
1753 (global-set-key [remap kill-line] (bol-with-prefix kill-line))
1756 Default of *C-k* is to kill from the point to the end of line. If
1757 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
1758 set, including newline. But to kill the entire line, one still needs a
1759 *C-a* in front of it. So I change it, by defining a function to do just this for
1761 #+BEGIN_SRC emacs-lisp :tangle no
1762 (defun kill-entire-line ()
1763 "Kill this entire line (including newline), regardless of where point is within the line."
1767 (back-to-indentation))
1769 (bind-key* "C-k" 'kill-entire-line)
1770 (global-set-key [remap kill-whole-line] 'kill-entire-line)
1773 And the same is true when I'm in org-mode, which has an own kill function...
1774 (the keybinding happens later, after org-mode is loaded fully)
1775 #+BEGIN_SRC emacs-lisp :tangle no
1776 (defun jj-org-kill-line (&optional arg)
1777 "Kill the entire line, regardless of where point is within the line, org-mode-version"
1781 (back-to-indentation)
1785 I really hate tabs, so I don't want any indentation to try using them.
1786 And in case a project really needs them, I can change it just for that
1787 file/project, but luckily none of those I work in is as broken.
1788 #+BEGIN_SRC emacs-lisp
1789 (setq-default indent-tabs-mode nil)
1792 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
1793 #+BEGIN_SRC emacs-lisp
1794 (bind-key* "M-5" 'match-paren)
1797 Instead of the default "mark-defun" I want a more readline-like setting.
1798 #+BEGIN_SRC emacs-lisp
1799 (bind-key "C-M-h" 'backward-kill-word)
1802 Align whatever with a regexp.
1803 #+BEGIN_SRC emacs-lisp
1804 (bind-key "C-x \\" 'align-regexp)
1808 #+BEGIN_SRC emacs-lisp
1809 (bind-key "C-+" 'text-scale-increase)
1810 (bind-key "C--" 'text-scale-decrease)
1813 Regexes are too useful, so use the regex search by default.
1814 Disabled, see ivy-mode.
1815 #+begin_src emacs-lisp :tangle no
1816 (bind-key "C-s" 'isearch-forward-regexp)
1817 (bind-key "C-r" 'isearch-backward-regexp)
1818 (bind-key "C-M-s" 'isearch-forward)
1819 (bind-key "C-M-r" 'isearch-backward)
1822 Rgrep is infinitely useful in multi-file projects.
1823 #+begin_src emacs-lisp
1824 (bind-key "C-x C-g" 'rgrep)
1827 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
1828 AKA transpose lines.
1829 #+BEGIN_SRC emacs-lisp
1830 (bind-key "<M-S-up>" 'move-line-up)
1831 (bind-key "<M-S-down>" 'move-line-down)
1834 "Pull" lines up, join them
1835 #+BEGIN_SRC emacs-lisp
1836 (defun join-line-or-lines-in-region ()
1837 "Join this line or the lines in the selected region.
1838 Joins single lines in reverse order to the default, ie. pulls the next one up."
1840 (cond ((region-active-p)
1841 (let ((min (line-number-at-pos (region-beginning))))
1842 (goto-char (region-end))
1843 (while (> (line-number-at-pos) min)
1845 (t (let ((current-prefix-arg '(4)))
1846 (call-interactively 'join-line)))))
1847 (bind-key "M-j" 'join-line-or-lines-in-region)
1850 When I press Enter I almost always want to go to the right indentation on the next line.
1851 #+BEGIN_SRC emacs-lisp
1852 (bind-key "RET" 'newline-and-indent)
1855 Easier undo, and i don't need suspend-frame
1856 #+BEGIN_SRC emacs-lisp
1857 (bind-key "C-z" 'undo)
1860 Window switching, go backwards. (C-x o goes to the next window)
1861 #+BEGIN_SRC emacs-lisp
1862 (bind-key "C-x O" (lambda ()
1868 #+BEGIN_SRC emacs-lisp
1869 (bind-key "C-x C-r" 'prelude-sudo-edit)
1872 M-space is bound to just-one-space, which is great for programming. What
1873 it does is remove all spaces around the cursor, except for one. But to
1874 be really useful, it also should include newlines. It doesn’t do this by
1875 default. Rather, you have to call it with a negative argument. Sure
1877 #+BEGIN_SRC emacs-lisp
1878 (bind-key "M-SPC" 'just-one-space-with-newline)
1881 Count which commands I use how often.
1882 #+BEGIN_SRC emacs-lisp
1883 (use-package keyfreq
1887 (setq keyfreq-file (expand-file-name "keyfreq" jj-cache-dir))
1888 (setq keyfreq-file-lock (expand-file-name "keyfreq.lock" jj-cache-dir))
1890 (keyfreq-autosave-mode 1)))
1893 Duplicate current line
1894 #+BEGIN_SRC emacs-lisp
1895 (defun duplicate-line ()
1896 "Insert a copy of the current line after the current line."
1899 (let ((line-text (buffer-substring-no-properties
1900 (line-beginning-position)
1901 (line-end-position))))
1902 (move-end-of-line 1)
1904 (insert line-text))))
1906 (bind-key "C-c p" 'duplicate-line)
1909 Smarter move to the beginning of the line. That is, it first moves to
1910 the beginning of the line - and on second keypress it goes to the
1911 first character on line.
1912 #+BEGIN_SRC emacs-lisp
1913 (defun smarter-move-beginning-of-line (arg)
1914 "Move point back to indentation of beginning of line.
1916 Move point to the first non-whitespace character on this line.
1917 If point is already there, move to the beginning of the line.
1918 Effectively toggle between the first non-whitespace character and
1919 the beginning of the line.
1921 If ARG is not nil or 1, move forward ARG - 1 lines first. If
1922 point reaches the beginning or end of the buffer, stop there."
1924 (setq arg (or arg 1))
1928 (let ((line-move-visual nil))
1929 (forward-line (1- arg))))
1931 (let ((orig-point (point)))
1932 (back-to-indentation)
1933 (when (= orig-point (point))
1934 (move-beginning-of-line 1))))
1936 ;; remap C-a to `smarter-move-beginning-of-line'
1937 (global-set-key [remap move-beginning-of-line]
1938 'smarter-move-beginning-of-line)
1942 Easily copy characters from the previous nonblank line, starting just
1943 above point. With a prefix argument, only copy ARG characters (never
1944 past EOL), no argument copies rest of line.
1945 #+BEGIN_SRC emacs-lisp
1947 (bind-key "H-y" 'copy-from-above-command)
1950 Open a new X Terminal pointing to the directory of the current
1952 #+BEGIN_SRC emacs-lisp
1953 (bind-key "H-t" 'jj-open-shell)
1957 #+BEGIN_SRC emacs-lisp
1958 (bind-key "H-a" 'align-code)
1962 #+BEGIN_SRC emacs-lisp
1963 (bind-key "C-c d" 'insert-date)
1966 Another key for indenting
1967 #+BEGIN_SRC emacs-lisp
1968 (bind-key "H-i" 'indent-region)
1971 Clean all whitespace stuff
1972 #+BEGIN_SRC emacs-lisp
1973 (bind-key "H-w" 'whitespace-cleanup)
1977 #+BEGIN_SRC emacs-lisp
1978 (bind-key "H-c" 'comment-dwim)
1981 Show keystrokes in progress
1982 #+BEGIN_SRC emacs-lisp
1983 (setq echo-keystrokes 0.1)
1986 Usually you can press the *Ins*ert key, to get into overwrite mode. I
1987 don't like that, have broken much with it and so just forbid it by
1989 #+BEGIN_SRC emacs-lisp
1990 (unbind-key "<insert>")
1991 (unbind-key "<kp-insert>")
1994 *** Easily navigate sillyCased words
1995 #+BEGIN_SRC emacs-lisp
1996 (global-subword-mode 1)
1998 *** Delete file of current buffer, then kill buffer
1999 [2014-06-14 Sat 23:03]
2000 #+BEGIN_SRC emacs-lisp
2001 (defun delete-current-buffer-file ()
2002 "Removes file connected to current buffer and kills buffer."
2004 (let ((filename (buffer-file-name))
2005 (buffer (current-buffer))
2006 (name (buffer-name)))
2007 (if (not (and filename (file-exists-p filename)))
2009 (when (yes-or-no-p "Are you sure you want to remove this file? ")
2010 (delete-file filename)
2011 (kill-buffer buffer)
2012 (message "File '%s' successfully removed" filename)))))
2014 (global-set-key (kbd "C-x C-k") 'delete-current-buffer-file)
2016 *** Rename file of current buffer
2017 [2014-06-14 Sat 23:04]
2018 #+BEGIN_SRC emacs-lisp
2019 (defun rename-current-buffer-file ()
2020 "Renames current buffer and file it is visiting."
2022 (let ((name (buffer-name))
2023 (filename (buffer-file-name)))
2024 (if (not (and filename (file-exists-p filename)))
2025 (error "Buffer '%s' is not visiting a file!" name)
2026 (let ((new-name (read-file-name "New name: " filename)))
2027 (if (get-buffer new-name)
2028 (error "A buffer named '%s' already exists!" new-name)
2029 (rename-file filename new-name 1)
2030 (rename-buffer new-name)
2031 (set-visited-file-name new-name)
2032 (set-buffer-modified-p nil)
2033 (message "File '%s' successfully renamed to '%s'"
2034 name (file-name-nondirectory new-name)))))))
2036 (global-set-key (kbd "C-x C-S-r") 'rename-current-buffer-file)
2038 *** Quickly find emacs lisp sources
2039 [2014-06-22 Sun 23:05]
2040 #+BEGIN_SRC emacs-lisp
2041 (bind-key "C-l" 'find-library 'help-command)
2042 (bind-key "C-f" 'find-function 'help-command)
2043 (bind-key "C-k" 'find-function-on-key 'help-command)
2044 (bind-key "C-v" 'find-variable 'help-command)
2047 [2015-01-26 Mon 16:01]
2048 #+BEGIN_SRC emacs-lisp
2049 (bind-key "M-s o" 'occur-dwim)
2053 [2014-06-01 Sun 15:00]
2054 Proper whitespace handling
2055 #+BEGIN_SRC emacs-lisp :tangle no
2056 (use-package ethan-wspace
2057 :ensure ethan-wspace
2058 :diminish (ethan-wspace-mode . "ew")
2060 (global-ethan-wspace-mode 1))
2062 ** Eww - Emacs browser
2063 [2016-10-03 Mo 21:30]
2064 #+BEGIN_SRC emacs-lisp :tangle yes
2065 ;; Time-stamp: <2016-07-08 18:22:46 kmodi>
2067 ;; Eww - Emacs browser (needs emacs 24.4 or higher)
2070 :bind ( ("M-s M-w" . eww-search-words))
2073 ;; (setq eww-search-prefix "https://duckduckgo.com/html/?q=")
2074 (setq eww-search-prefix "https://www.google.com/search?q=")
2075 (setq eww-download-directory "~/Downloads")
2076 ;; (setq eww-form-checkbox-symbol "[ ]")
2077 (setq eww-form-checkbox-symbol "☐") ; Unicode hex 2610
2078 ;; (setq eww-form-checkbox-selected-symbol "[X]")
2079 (setq eww-form-checkbox-selected-symbol "☑") ; Unicode hex 2611
2080 ;; Improve the contract of pages like Google results
2081 ;; http://emacs.stackexchange.com/q/2955/115
2082 (setq shr-color-visible-luminance-min 80) ; default = 40
2084 ;; Auto-rename new eww buffers
2085 ;; http://ergoemacs.org/emacs/emacs_eww_web_browser.html
2086 (defun xah-rename-eww-hook ()
2087 "Rename eww browser's buffer so sites open in new page."
2088 (rename-buffer "eww" t))
2089 (add-hook 'eww-mode-hook #'xah-rename-eww-hook)
2091 ;; If the current buffer is an eww buffer, "M-x eww" will always reuse the
2092 ;; current buffer to load the new page. Below advice will make "C-u M-x eww"
2093 ;; force a new eww buffer even when the current buffer is an eww buffer.
2094 ;; The above `xah-rename-eww-hook' fix is still needed in order to create
2095 ;; uniquely named eww buffers.
2096 ;; http://emacs.stackexchange.com/a/24477/115
2097 (defun modi/force-new-eww-buffer (orig-fun &rest args)
2098 "When prefix argument is used, a new eww buffer will be created.
2099 This is regardless of whether the current buffer is an eww buffer. "
2100 (if current-prefix-arg
2102 (apply orig-fun args))
2103 (apply orig-fun args)))
2104 (advice-add 'eww :around #'modi/force-new-eww-buffer)
2106 ;; Override the default definition of `eww-search-words'
2107 (defun eww-search-words (&optional beg end)
2108 "Search the web for the text between the point and marker.
2109 See the `eww-search-prefix' variable for the search engine used."
2112 (eww (buffer-substring beg end))
2113 (eww (modi/get-symbol-at-point))))
2116 ;; https://github.com/m00natic/eww-lnum
2117 (use-package eww-lnum
2119 :bind (:map eww-mode-map
2120 ("f" . eww-lnum-follow)
2121 ("U" . eww-lnum-universal)))
2124 ;; Copy text from html page for pasting in org mode file/buffer
2125 ;; e.g. Copied HTML hyperlinks get converted to [[link][desc]] for org mode.
2126 ;; http://emacs.stackexchange.com/a/8191/115
2127 (use-package org-eww
2128 :bind (:map eww-mode-map
2129 ("o" . org-eww-copy-for-org-mode)))
2131 ;; Auto-refreshing eww buffer whenever the html file it's showing changes
2132 ;; http://emacs.stackexchange.com/a/2566/115
2133 (defvar modi/eww--file-notify-descriptors-list ()
2134 "List to store file-notify descriptor for all files that have an
2135 associated auto-reloading eww buffer.")
2137 (defun modi/advice-eww-open-file-to-auto-reload (orig-fun &rest args)
2138 "When `eww-open-file' is called with \\[universal-argument], open
2139 the file in eww and also add `file-notify' watch for it so that the eww
2140 buffer auto-reloads when the HTML file changes."
2142 (apply orig-fun args)
2143 (when current-prefix-arg ; C-u M-x eww-open-file
2144 (require 'filenotify)
2145 (let ((file-name (car args)))
2146 (file-notify-add-watch file-name
2147 '(change attribute-change)
2148 #'modi/file-notify-callback-eww-reload)
2149 ;; Show the HTML file and its rendered form in eww side-by-side
2150 (find-file-other-window file-name))
2151 ;; Redefine the `q' binding in `eww-mode-map'
2152 (bind-key "q" #'modi/eww-quit-and-update-fn-descriptors eww-mode-map))))
2153 (advice-add 'eww-open-file :around #'modi/advice-eww-open-file-to-auto-reload)
2155 (defun modi/file-notify-callback-eww-reload (event)
2156 "On getting triggered, switch to the eww buffer, reload and switch
2157 back to the working buffer. Also save the `file-notify-descriptor' of the
2159 (let* ((working-buffer (buffer-name)))
2160 (switch-to-buffer-other-window "eww")
2162 (switch-to-buffer-other-window working-buffer))
2163 ;; `(car event)' will return the event descriptor
2164 (add-to-list 'modi/eww--file-notify-descriptors-list (car event)))
2166 (defun modi/eww-quit-and-update-fn-descriptors ()
2167 "When quitting `eww', first remove any saved file-notify descriptors
2168 specific to eww, while also updating `modi/eww--file-notify-descriptors-list'."
2170 (dotimes (index (safe-length modi/eww--file-notify-descriptors-list))
2171 (file-notify-rm-watch (pop modi/eww--file-notify-descriptors-list)))
2172 (quit-window :kill))
2176 (":" . eww) ; Go to URL
2177 ("h" . eww-list-histories)) ; View history
2179 ;; Make the binding for `revert-buffer' do `eww-reload' in eww-mode
2180 (define-key eww-mode-map [remap revert-buffer] #'eww-reload)
2182 :map eww-text-map ; For single line text fields
2183 ("<backtab>" . shr-previous-link) ; S-TAB Jump to previous link on the page
2184 ("<C-return>" . eww-submit)) ; S-TAB Jump to previous link on the page
2186 :map eww-textarea-map ; For multi-line text boxes
2187 ("<backtab>" . shr-previous-link) ; S-TAB Jump to previous link on the page
2188 ("<C-return>" . eww-submit)) ; S-TAB Jump to previous link on the page
2190 :map eww-checkbox-map
2191 ("<down-mouse-1>" . eww-toggle-checkbox))
2194 ("w" . modi/eww-copy-url-dwim))
2196 :map eww-link-keymap
2197 ("w" . modi/eww-copy-url-dwim))))
2199 ;; Default eww key bindings
2200 ;; |-----------+---------------------------------------------------------------------|
2201 ;; | Key | Function |
2202 ;; |-----------+---------------------------------------------------------------------|
2203 ;; | & | Browse the current URL with an external browser. |
2204 ;; | - | Begin a negative numeric argument for the next command. |
2205 ;; | 0 .. 9 | Part of the numeric argument for the next command. |
2206 ;; | C | Display a buffer listing the current URL cookies, if there are any. |
2207 ;; | H | List the eww-histories. |
2208 ;; | F | Toggle font between variable-width and fixed-width. |
2209 ;; | G | Go to a URL |
2210 ;; | R | Readable mode |
2211 ;; | S | List eww buffers |
2212 ;; | d | Download URL under point to `eww-download-directory'. |
2213 ;; | g | Reload the current page. |
2214 ;; | q | Quit WINDOW and bury its buffer. |
2215 ;; | v | `eww-view-source' |
2216 ;; | w | `eww-copy-page-url' |
2217 ;; |-----------+---------------------------------------------------------------------|
2218 ;; | b | Add the current page to the bookmarks. |
2219 ;; | B | Display the bookmark list. |
2220 ;; | M-n | Visit the next bookmark |
2221 ;; | M-p | Visit the previous bookmark |
2222 ;; |-----------+---------------------------------------------------------------------|
2223 ;; | t | Go to the page marked `top'. |
2224 ;; | u | Go to the page marked `up'. |
2225 ;; |-----------+---------------------------------------------------------------------|
2226 ;; | n | Go to the page marked `next'. |
2227 ;; | p | Go to the page marked `previous'. |
2228 ;; |-----------+---------------------------------------------------------------------|
2229 ;; | l | Go to the previously displayed page. |
2230 ;; | r | Go to the next displayed page. |
2231 ;; |-----------+---------------------------------------------------------------------|
2232 ;; | TAB | Move point to next link on the page. |
2233 ;; | S-TAB | Move point to previous link on the page. |
2234 ;; |-----------+---------------------------------------------------------------------|
2235 ;; | SPC | Scroll up |
2236 ;; | DEL/Bkspc | Scroll down |
2237 ;; | S-SPC | Scroll down |
2238 ;; |-----------+---------------------------------------------------------------------|
2241 [2014-06-01 Sun 15:16]
2242 #+BEGIN_SRC emacs-lisp
2243 (use-package expand-region
2244 :ensure expand-region
2245 :bind ("C-M-+" . er/expand-region)
2246 :commands er/expand-region)
2249 [2013-05-02 Thu 00:04]
2250 Filladapt by KyleJones enhances Emacs’ fill functions by guessing a
2251 fill prefix, such as a comment sequence in program code, and handling
2252 bullet points like “1.” or “*”.
2253 #+BEGIN_SRC emacs-lisp
2254 (use-package filladapt
2255 :diminish filladapt-mode
2257 (setq-default filladapt-mode t))
2260 [2013-04-28 So 22:21]
2261 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
2262 As the one time I tried Flymake i wasn't happy, thats easy to
2264 #+BEGIN_SRC emacs-lisp
2265 (use-package flycheck
2267 :diminish flycheck-mode
2268 :bind (("M-n" . next-error)
2269 ("M-p" . previous-error))
2272 (use-package flycheck-color-mode-line
2273 :ensure flycheck-color-mode-line)
2274 (setq flycheck-highlighting-mode 'nil)
2275 (setq flycheck-flake8-maximum-line-length '150)
2276 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
2277 (setq flycheck-sh-shellcheck-executable "/usr/bin/shellcheck -e 2086")
2278 (add-hook 'find-file-hook
2280 (when (not (equal 'emacs-lisp-mode major-mode))
2285 Obviously emacs can do syntax hilighting. For more things than you ever
2287 And I want to have it everywhere.
2288 #+BEGIN_SRC emacs-lisp
2289 (use-package font-lock
2292 (global-font-lock-mode 1)
2293 (setq font-lock-maximum-decoration t)))
2296 [2015-08-31 Mon 11:27]
2297 Display nice lines instead of page breaks
2298 #+BEGIN_SRC emacs-lisp
2299 (use-package form-feed
2304 #+BEGIN_SRC emacs-lisp :tangle no
2305 (use-package git-commit
2306 :commands git-commit
2307 :mode ("COMMIT_EDITMSG" . git-commit-mode))
2311 #+BEGIN_SRC emacs-lisp :tangle no
2312 (use-package git-rebase
2313 :commands git-rebase
2314 :mode ("git-rebase-todo" . git-rebase-mode))
2317 [2014-05-21 Wed 22:56]
2318 #+BEGIN_SRC emacs-lisp
2319 (use-package git-gutter+
2321 :diminish git-gutter+-mode
2322 :bind (("C-x n" . git-gutter+-next-hunk)
2323 ("C-x p" . git-gutter+-previous-hunk)
2324 ("C-x v =" . git-gutter+-show-hunk)
2325 ("C-x r" . git-gutter+-revert-hunks)
2326 ("C-x s" . git-gutter+-stage-hunks)
2327 ("C-x c" . git-gutter+-commit)
2331 (setq git-gutter+-disabled-modes '(org-mode))
2332 (global-git-gutter+-mode 1)
2333 (use-package git-gutter-fringe+
2334 :ensure git-gutter-fringe+
2337 (setq git-gutter-fr+-side 'right-fringe)
2338 ;(git-gutter-fr+-minimal)
2343 [2015-02-22 Sun 14:00]
2344 Provides function that popup commit message at current line. This is
2345 useful when you want to know why this line was changed.
2346 #+BEGIN_SRC emacs-lisp
2347 (use-package git-messenger
2348 :ensure git-messenger
2349 :commands (git-messenger:popup-message)
2350 :bind (("C-x v p" . git-messenger:popup-message))
2353 (bind-key "m" 'git-messenger:copy-message git-messenger-map)
2354 (add-hook 'git-messenger:popup-buffer-hook 'magit-revision-mode)
2355 (setq git-messenger:show-detail t)))
2358 [2014-07-23 Mi 12:57]
2359 Browse historic versions of a file with p (previous) and n (next).
2360 #+BEGIN_SRC emacs-lisp
2361 (use-package git-timemachine
2362 :ensure git-timemachine
2363 :commands git-timemachine)
2366 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
2367 what I want every emacs to know.
2368 #+BEGIN_SRC emacs-lisp
2369 (bind-key "C-c g" 'gnus) ; Start gnus with M-n
2375 [2015-02-20 Fri 16:27]
2376 When working with many windows at the same time, each window has a
2377 size that is not convenient for editing.
2379 golden-ratio helps on this issue by resizing automatically the windows
2380 you are working on to the size specified in the "Golden Ratio". The
2381 window that has the main focus will have the perfect size for editing,
2382 while the ones that are not being actively edited will be re-sized to
2383 a smaller size that doesn't get in the way, but at the same time will
2384 be readable enough to know it's content.
2385 #+BEGIN_SRC emacs-lisp
2386 (use-package golden-ratio
2387 :ensure golden-ratio
2388 :diminish golden-ratio-mode
2391 (golden-ratio-mode 1)
2392 (setq golden-ratio-exclude-buffer-names '("*LV*" "*guide-key*" "*Ediff Control Panel*"))
2393 (setq golden-ratio-exclude-modes '("calendar-mode" "gnus-summary-mode"
2394 "gnus-article-mode" "calc-mode" "calc-trail-mode"
2399 [2015-02-22 Sun 13:28]
2400 Move point through buffer-undo-list positions.
2401 #+BEGIN_SRC emacs-lisp
2402 (use-package goto-last-change
2403 :commands (goto-last-change)
2404 :bind (("M-g l" . goto-last-change))
2408 [2014-06-11 Wed 22:27]
2409 guide-key.el displays the available key bindings automatically and
2412 For whatever reason I like this more than icicles <backtab> completion
2414 #+BEGIN_SRC emacs-lisp
2415 (use-package guide-key
2417 :diminish guide-key-mode
2420 (setq guide-key/guide-key-sequence '("C-x" "C-c" "M-g" "M-s"))
2422 (setq guide-key/recursive-key-sequence-flag t)
2423 (setq guide-key/popup-window-position 'bottom)
2424 (setq guide-key/idle-delay 0.5)))
2429 [2014-05-21 Wed 23:51]
2430 #+BEGIN_SRC emacs-lisp
2431 (use-package hi-lock
2432 :bind (("M-o l" . highlight-lines-matching-regexp)
2433 ("M-o r" . highlight-regexp)
2434 ("M-o w" . highlight-phrase)
2435 ("M-o u" . unhighlight-regexp)))
2437 (use-package hilit-chg
2438 :bind ("M-o C" . highlight-changes-mode))
2442 Crazy way of completion. It looks at the word before point and then
2443 tries to expand it in various ways.
2444 #+BEGIN_SRC emacs-lisp
2445 (use-package hippie-exp
2446 :bind ("M-/" . hippie-expand)
2447 :commands hippie-expand
2450 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
2451 try-expand-dabbrev-all-buffers
2452 try-expand-dabbrev-from-kill
2453 try-complete-file-name-partially
2454 try-complete-file-name
2455 try-expand-all-abbrevs try-expand-list
2457 try-complete-lisp-symbol-partially
2458 try-complete-lisp-symbol))))
2461 Replaced by web-mode [[*web-mode][web-mode]]
2462 #+BEGIN_SRC emacs-lisp :tangle no
2463 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
2464 (add-auto-mode 'html-helper-mode "\\.html$")
2465 (add-auto-mode 'html-helper-mode "\\.asp$")
2466 (add-auto-mode 'html-helper-mode "\\.phtml$")
2467 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
2468 (defalias 'html-mode 'html-helper-mode)
2471 [2015-01-26 Mon 15:50]
2472 This is a package for GNU Emacs that can be used to tie related
2473 commands into a family of short bindings with a common prefix - a
2476 Once you summon the Hydra through the prefixed binding (the body + any
2477 one head), all heads can be called in succession with only a short
2480 The Hydra is vanquished once Hercules, any binding that isn't the
2481 Hydra's head, arrives. Note that Hercules, besides vanquishing the
2482 Hydra, will still serve his orignal purpose, calling his proper
2483 command. This makes the Hydra very seamless, it's like a minor mode
2484 that disables itself auto-magically.
2485 #+BEGIN_SRC emacs-lisp
2490 (setq hydra-is-helpful t)
2493 (defhydra hydra-zoom (:color red)
2495 ("g" text-scale-increase "in")
2496 ("l" text-scale-decrease "out")
2498 (bind-key "<F2>" 'hydra-zoom/toggle)
2500 (defhydra hydra-error (:color red)
2502 ("h" first-error "first")
2503 ("j" next-error "next")
2504 ("k" previous-error "prev")
2505 ("v" recenter-top-bottom "recenter")
2507 (bind-key "M-g e" 'hydra-error/body)
2509 (defhydra hydra-gnus (:color red)
2511 ("m" gnus-uu-mark-thread "mark thread")
2512 ("d" gnus-summary-delete-article "delete article(s)")
2513 ("r" gnus-summary-mark-as-read-forward "mark read")
2514 ("n" gnus-summary-next-thread "next thread")
2515 ("p" gnus-summary-prev-thread "previous thread")
2516 ("g" gnus-summary-next-group "next group")
2517 ("l" gnus-recenter "recenter")
2518 ("x" gnus-summary-limit-to-unread "unread")
2520 (bind-key "C-c h" 'hydra-gnus/body)
2522 (defhydra hydra-launcher (:color blue)
2525 ("r" (browse-url "http://www.reddit.com/r/emacs/") "reddit")
2526 ("w" (browse-url "http://www.emacswiki.org/") "emacswiki")
2529 (bind-key "C-c r" 'hydra-launcher/body)
2531 ; whitespace mode gets loaded late, so variable may not be there yet. Workaround...
2532 (defvar whitespace-mode nil)
2533 (defhydra hydra-toggle (:color pink)
2535 _a_ abbrev-mode: % 4`abbrev-mode^^^^ _f_ auto-fill-mode: %`auto-fill-function
2536 _c_ auto-complete-mode: % 4`auto-complete-mode _r_ auto-revert-mode: %`auto-revert-mode
2537 _d_ debug-on-error: % 4`debug-on-error^ _t_ truncate-lines: %`truncate-lines
2538 _w_ whitespace-mode: % 4`whitespace-mode _g_ golden-ratio-mode: %`golden-ratio-mode
2539 _l_ linum-mode: % 4`linum-mode _k_ linum relative: %`linum-format
2542 ("a" abbrev-mode nil)
2543 ("c" auto-complete-mode nil)
2544 ("i" aggressive-indent-mode nil)
2545 ("d" toggle-debug-on-error nil)
2546 ("f" auto-fill-mode nil)
2547 ("g" golden-ratio-mode nil)
2548 ("t" toggle-truncate-lines nil)
2549 ("w" whitespace-mode nil)
2550 ("r" auto-revert-mode nil)
2551 ("l" linum-mode nil)
2552 ("k" linum-relative-toggle nil)
2554 (bind-key "C-c C-v" 'hydra-toggle/body)
2560 [2014-05-21 Wed 23:54]
2561 #+BEGIN_SRC emacs-lisp
2562 (use-package ibuffer
2564 :bind (("C-h h" . ibuffer)
2565 ("C-x C-b" . ibuffer)
2566 ("<XF86WebCam>" . ibuffer)
2569 :defines (ibuffer-filtering-alist
2570 ibuffer-filter-groups ibuffer-compile-formats ibuffer-git-column-length
2571 ibuffer-show-empty-filter-groups ibuffer-saved-filter-groups)
2574 (defvar my-ibufffer-separator " • ")
2575 (setq ibuffer-filter-group-name-face 'variable-pitch
2576 ibuffer-use-header-line t
2577 ibuffer-old-time 12)
2578 (unbind-key "M-o" ibuffer-mode-map)
2579 (bind-key "s" 'isearch-forward-regexp ibuffer-mode-map)
2580 (bind-key "." 'ibuffer-invert-sorting ibuffer-mode-map)
2585 (use-package ibuffer-vc
2588 (ibuffer-vc-set-filter-groups-by-vc-root
2589 ibuffer-vc-generate-filter-groups-by-vc-root))
2591 (use-package ibuffer-tramp
2593 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
2594 ibuffer-tramp-set-filter-groups-by-tramp-connection))
2595 ;; Switching to ibuffer puts the cursor on the most recent buffer
2596 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
2597 "Open ibuffer with cursor pointed to most recent buffer name"
2598 (let ((recent-buffer-name (buffer-name)))
2600 (ibuffer-update nil t)
2601 (unless (string= recent-buffer-name "*Ibuffer*")
2602 (ibuffer-jump-to-buffer recent-buffer-name))))
2604 (defun ibuffer-magit-status ()
2606 (--when-let (get-buffer "*Ibuffer*")
2607 (with-current-buffer it
2608 (let* ((selected-buffer (ibuffer-current-buffer))
2609 (buffer-path (with-current-buffer
2611 (or (buffer-file-name)
2612 list-buffers-directory
2613 default-directory)))
2615 (if (file-regular-p buffer-path)
2616 (file-name-directory buffer-path)
2618 (magit-status default-directory)))))
2619 (bind-key "i" 'ibuffer-magit-status ibuffer-mode-map)
2620 (bind-key "G" 'ibuffer-magit-status ibuffer-mode-map)
2622 (setq ibuffer-directory-abbrev-alist
2627 (cons (f-slash (f-expand (cdr it))) my-ibufffer-separator)
2628 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
2630 ("dak" . "/develop/dak/")
2632 ("config" . "~/.emacs.d/config/")
2634 ("systmp" . "/tmp/")
2635 ("puppet" . "~/git/puppet")
2639 (use-package ibuffer-git
2641 (use-package ibuffer-vc
2644 (define-ibuffer-column size-h
2645 (:name "Size" :inline t)
2647 ((> (buffer-size) 1000)
2648 (format "%7.1fk" (/ (buffer-size) 1000.0)))
2649 ((> (buffer-size) 1000000)
2650 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
2652 (format "%8d" (buffer-size)))))
2654 (use-package ibuf-ext)
2655 (define-ibuffer-filter filename2
2656 "Toggle current view to buffers with filename matching QUALIFIER."
2657 (:description "filename2"
2658 :reader (read-from-minibuffer "Filter by filename (regexp): "))
2659 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
2660 (ibuffer-awhen (with-current-buffer buf
2661 (or buffer-file-name
2663 (string-match qualifier it)))
2665 (defvar ibuffer-magit-filter-groups nil)
2666 (defun ibuffer-magit-define-filter-groups ()
2667 (when (and (not ibuffer-magit-filter-groups)
2668 (boundp 'magit-repo-dirs))
2669 (setq ibuffer-magit-filter-groups
2672 (file-name-nondirectory (directory-file-name it)))
2674 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
2676 (defun ibuffer-set-filter-groups-by-root ()
2678 ;; (ibuffer-projectile-define-filter-groups)
2679 ;; (ibuffer-magit-define-filter-groups)
2680 (setq ibuffer-filter-groups
2682 ;; ibuffer-projectile-filter-groups
2683 ibuffer-magit-filter-groups
2686 (or (mode . magit-log-edit-mode)
2687 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2688 (name . "^\\*Pymacs\\*$")
2689 (name . "^\\*helm.*\\*")
2690 (name . "^\\*Compile-log\\*$")
2691 (name . "^\\*Ido Completions\\*$")
2692 (name . "^\\*magit-\\(process\\)\\*$")
2696 (name . "^\\*\\(tramp/.*\\)\\*$"))))
2699 (name . "^\\*scratch")
2700 (name . "^\\*Messages")
2703 (ibuffer-vc-generate-filter-groups-by-vc-root)
2704 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
2706 (defun toggle-ibuffer-filter-groups ()
2709 (let ((ibuf (get-buffer "*Ibuffer*")))
2711 (with-current-buffer ibuf
2712 (let ((selected-buffer (ibuffer-current-buffer)))
2713 (if (not ibuffer-filter-groups)
2714 (ibuffer-set-filter-groups-by-root)
2715 (setq ibuffer-filter-groups nil))
2716 (pop-to-buffer ibuf)
2717 (ibuffer-update nil t)
2718 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
2720 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
2722 (defun ibuffer-back-to-top ()
2724 (beginning-of-buffer)
2727 (defun ibuffer-jump-to-bottom ()
2733 (define-key ibuffer-mode-map
2734 (vector 'remap 'end-of-buffer) 'ibuffer-jump-to-bottom)
2735 (define-key ibuffer-mode-map
2736 (vector 'remap 'beginning-of-buffer) 'ibuffer-back-to-top)
2738 (setq ibuffer-default-sorting-mode 'recency
2739 ibuffer-eliding-string "…"
2740 ibuffer-compile-formats t
2741 ibuffer-git-column-length 6
2742 ibuffer-show-empty-filter-groups nil
2743 ibuffer-default-directory "~/"
2746 (setq ibuffer-formats '((mark vc-status-mini
2748 (git-status 8 8 :left)
2752 (name 18 18 :left :elide)
2754 (size-h 9 -1 :right)
2756 (mode 16 16 :left :elide)
2757 " " filename-and-process)
2759 (git-status 8 8 :left)
2765 (setq ibuffer-saved-filter-groups
2768 ("dired" (mode . dired-mode))
2769 ("perl" (mode . cperl-mode))
2771 (mode . puppet-mode)
2772 (mode . yaml-mode)))
2773 ("ruby" (mode . ruby-mode))
2775 (name . "^\\*scratch\\*$")
2776 (name . "^\\*Compile-log\\*$")
2777 (name . "^\\*Completions\\*$")
2778 (name . "^\\*Messages\\*$")
2779 (name . "^\\*Backtrace\\*$")
2780 (name . "^\\*Packages*\\*$")
2781 (name . "^\\*Help*\\*$")
2785 (mode . message-mode)
2788 (mode . gnus-group-mode)
2789 (mode . gnus-summary-mode)
2790 (mode . gnus-article-mode)
2791 (name . "^\\.bbdb$")
2792 (name . "^\\.newsrc-dribble")))
2794 (mode . org-agenda-mode)
2795 (name . "^*Org Agenda")))
2797 (filename . ".*/org/.*")
2798 ;(mode . org-agenda-mode)
2799 (name . "^diary$")))
2801 (mode . magit-status-mode)
2802 (mode . magit-log-mode)
2803 (mode . magit-diff-mode)
2804 (mode . magit-refs-mode)
2805 (mode . magit-revision-mode)
2806 (mode . vc-annotate-mode)))
2808 (name . "^\\*\\(tramp/.*\\)\\*$")))
2810 (mode . emacs-lisp-mode)
2811 (mode . python-mode)
2813 (mode . coffee-mode)
2816 (mode . actionscript-mode)
2819 (mode . haskell-mode)
2826 (mode . magit-log-edit-mode)
2827 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
2829 ;; -------------------------------------------------
2830 ;; programming languages #1
2832 (mode . emacs-lisp-mode)
2833 (mode . python-mode)
2835 (mode . coffee-mode)
2838 (mode . actionscript-mode)
2841 (mode . haskell-mode)
2847 ;; -------------------------------------------------
2848 ;; configuration/data files
2852 (mode . conf-mode)))
2853 ;; -------------------------------------------------
2854 ;; text/notetaking/org
2855 ("org agenda" (mode . org-agenda-mode))
2858 (name . "^\\*Calendar\\*$")
2859 (name . "^diary$")))
2863 (mode . markdown-mode)))
2864 ;; -------------------------------------------------
2867 (mode . image-mode)))
2868 ;; -------------------------------------------------
2870 ("w3m" (mode . w3m-mode))
2872 (mode . magit-status-mode)
2873 (mode . magit-log-mode)
2874 (mode . vc-annotate-mode)))
2875 ("dired" (mode . dired-mode))
2880 (name . "^\\*Personal Keybindings\\*$")))
2882 (name . "^\\*\\(tramp/.*\\)\\*$")))
2883 ;; -------------------------------------------------
2885 ("MORE" (or (mode . magit-log-edit-mode)
2886 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2887 (name . "^\\*Pymacs\\*$")
2888 (name . "^\\*Compile-log\\*$")
2889 (name . "^\\*Completions\\*$")
2890 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
2892 ("*buffer*" (name . "\\*.*\\*"))))))
2894 (add-hook 'ibuffer-mode-hook
2896 (ibuffer-auto-mode 1)
2897 (ibuffer-switch-to-saved-filter-groups "default")))
2899 ;; Unless you turn this variable on you will be prompted every time
2900 ;; you want to delete a buffer, even unmodified ones, which is way
2901 ;; too cautious for most people. You’ll still be prompted for
2902 ;; confirmation when deleting modified buffers after the option has
2904 (setq ibuffer-expert t)
2909 [2015-10-16 Fri 16:28]
2910 #+BEGIN_SRC emacs-lisp
2913 :bind (("C-s" . swiper)
2915 ("C-c C-r" . ivy-resume)
2916 ("<f7>" . ivy-resume))
2920 (setq ivy-use-virtual-buffers t)
2921 ;;advise swiper to recenter on exit
2922 (defun bjm-swiper-recenter (&rest args)
2923 "recenter display after swiper"
2926 (advice-add 'swiper :after #'bjm-swiper-recenter)
2930 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
2931 ‘TAB’ completion is to typing things manually every time.”]]
2932 #+BEGIN_SRC emacs-lisp
2933 (use-package icicles
2939 Incremental mini-buffer completion preview: Type in the minibuffer,
2940 list of matching commands is echoed
2941 #+BEGIN_SRC emacs-lisp
2945 [2014-05-26 Mon 22:49]
2946 #+BEGIN_SRC emacs-lisp
2949 :commands (iedit-mode)
2951 :bind (("C-;" . iedit-mode)
2952 ("C-," . iedit-mode-toggle-on-function))
2957 [2014-05-20 Tue 23:35]
2958 #+BEGIN_SRC emacs-lisp
2960 :bind ("C-h C-i" . info-lookup-symbol)
2961 :commands info-lookup-symbol
2964 ;; (defadvice info-setup (after load-info+ activate)
2965 ;; (use-package info+))
2967 (defadvice Info-exit (after remove-info-window activate)
2968 "When info mode is quit, remove the window."
2969 (if (> (length (window-list)) 1)
2972 (use-package info-look
2973 :commands info-lookup-add-help)
2975 ** linum (line number)
2976 Various modes should have line numbers in front of each line.
2978 But then there are some where it would just be deadly - like org-mode,
2979 gnus, so we have a list of modes where we don't want to see it.
2980 #+BEGIN_SRC emacs-lisp
2982 :diminish linum-mode
2985 (setq linum-format "%3d ")
2986 (setq linum-mode-inhibit-modes-list '(org-mode
2993 (defadvice linum-on (around linum-on-inhibit-for-modes)
2994 "Stop the load of linum-mode for some major modes."
2995 (unless (member major-mode linum-mode-inhibit-modes-list)
2998 (ad-activate 'linum-on)
3000 (use-package linum-relative
3001 :ensure linum-relative
3004 (setq linum-format 'dynamic)
3007 (global-linum-mode 1))
3015 ** lisp editing stuff
3017 [2013-04-21 So 21:00]
3018 I'm not doing much of it, except for my emacs and gnus configs, but
3019 then I like it nice too...
3020 #+BEGIN_SRC emacs-lisp
3021 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
3023 (defun remove-elc-on-save ()
3024 "If you're saving an elisp file, likely the .elc is no longer valid."
3025 (make-local-variable 'after-save-hook)
3026 (add-hook 'after-save-hook
3028 (if (file-exists-p (concat buffer-file-name "c"))
3029 (delete-file (concat buffer-file-name "c"))))))
3031 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
3032 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
3034 (use-package paredit
3036 :diminish paredit-mode " π")
3038 (setq lisp-coding-hook 'lisp-coding-defaults)
3039 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
3041 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
3042 (add-hook 'emacs-lisp-mode-hook (lambda ()
3043 (run-hooks 'prelude-emacs-lisp-mode-hook)))
3045 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
3047 (after "elisp-slime-nav"
3048 '(diminish 'elisp-slime-nav-mode))
3049 (after "rainbow-mode"
3050 '(diminish 'rainbow-mode))
3052 '(diminish 'eldoc-mode))
3055 [2013-04-21 So 20:48]
3056 magit is a mode for interacting with git.
3057 #+BEGIN_SRC emacs-lisp
3060 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
3061 magit-git-repo-p magit-list-repos)
3063 :bind (("C-x g" . magit-status)
3064 ("C-x G" . magit-status-with-prefix))
3067 (setq magit-commit-signoff t
3068 magit-repository-directories '("~/git"
3073 magit-repository-directories-depth 4
3074 magit-log-auto-more t)
3076 (use-package magit-blame
3077 :commands magit-blame-mode
3080 ; (use-package magit-svn
3082 ; :commands (magit-svn-mode
3083 ; turn-on-magit-svn)
3086 (add-hook 'magit-mode-hook 'hl-line-mode)
3087 (defun magit-status-with-prefix ()
3089 (let ((current-prefix-arg '(4)))
3090 (call-interactively 'magit-status)))
3094 (setenv "GIT_PAGER" "")
3096 (unbind-key "M-h" magit-mode-map)
3097 (unbind-key "M-s" magit-mode-map)
3098 (add-to-list 'magit-no-confirm 'stage-all-changes)
3099 (setq magit-push-always-verify nil)
3100 (setq magit-last-seen-setup-instructions "2.1.0")
3101 ; (use-package magit-find-file
3102 ; :ensure magit-find-file
3103 ; :commands (magit-find-file-completing-read)
3107 ; (bind-key "C-x C-f" 'magit-find-file-completing-read magit-mode-map)))
3109 (add-hook 'magit-log-edit-mode-hook
3111 (set-fill-column 72)
3114 (add-hook 'git-rebase-mode-hook
3118 (defadvice magit-status (around magit-fullscreen activate)
3119 (window-configuration-to-register :magit-fullscreen)
3121 (delete-other-windows))
3123 (defun magit-quit-session ()
3124 "Restores the previous window configuration and kills the magit buffer"
3127 (jump-to-register :magit-fullscreen))
3129 (bind-key "q" 'magit-quit-session magit-status-mode-map)
3131 (defun magit-rebase-unpushed (commit &optional args)
3132 "Start an interactive rebase sequence over all unpushed commits."
3133 (interactive (list (magit-get-tracked-branch)
3134 (magit-rebase-arguments)))
3135 (if (setq commit (magit-rebase-interactive-assert commit))
3136 (magit-run-git-sequencer "rebase" "-i" commit args)
3139 (magit-rebase-interactive (concat commit "^") (list ,@args))))))
3141 (magit-define-popup-action 'magit-rebase-popup ?l "Rebase unpushed" 'magit-rebase-unpushed)
3145 [2014-05-20 Tue 23:04]
3146 #+BEGIN_SRC emacs-lisp
3147 (use-package markdown-mode
3148 :mode (("\\.md\\'" . markdown-mode)
3149 ("\\.mdwn\\'" . markdown-mode))
3153 #+BEGIN_SRC emacs-lisp
3154 (use-package message
3157 (setq message-kill-buffer-on-exit t)))
3160 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
3162 I want to access it from anywhere using =F6=.
3163 #+BEGIN_SRC emacs-lisp
3164 (use-package mingus-stays-home
3165 :bind ( "<f6>" . mingus)
3169 (setq mingus-dired-add-keys t)
3170 (setq mingus-mode-always-modeline nil)
3171 (setq mingus-mode-line-show-elapsed-percentage nil)
3172 (setq mingus-mode-line-show-volume nil)
3173 (setq mingus-mpd-config-file "/etc/mpd.conf")
3174 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
3175 (setq mingus-mpd-root "/share/music/")))
3179 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
3180 #+BEGIN_SRC emacs-lisp
3181 (use-package miniedit
3186 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
3187 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
3188 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
3189 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
3194 [2013-05-21 Tue 23:39]
3195 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
3196 coexist in one buffer.
3197 #+BEGIN_SRC emacs-lisp :tangle no
3198 (use-package mmm-auto
3202 (setq mmm-global-mode 'buffers-with-submode-classes)
3203 (setq mmm-submode-decoration-level 2)
3204 (eval-after-load 'mmm-vars
3210 :face mmm-code-submode-face
3211 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
3212 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
3213 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
3214 @ "\n" _ "\n" @ "</script>" @)))
3217 :face mmm-code-submode-face
3218 :front "<style[^>]*>[ \t]*\n?"
3219 :back "[ \t]*</style>"
3220 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
3221 @ "\n" _ "\n" @ "</style>" @)))
3224 :face mmm-code-submode-face
3227 (dolist (mode (list 'html-mode 'nxml-mode))
3228 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
3229 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
3234 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
3236 #+BEGIN_SRC emacs-lisp
3237 (use-package mo-git-blame
3238 :ensure mo-git-blame
3239 :commands (mo-git-blame-current
3243 (setq mo-git-blame-blame-window-width 25)))
3247 [2013-04-08 Mon 23:57]
3248 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
3249 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
3250 #+BEGIN_SRC emacs-lisp tangle no
3251 (use-package multiple-cursors
3252 :ensure multiple-cursors
3254 :commands (mc/remove-fake-cursors
3255 mc/create-fake-cursor-at-point
3256 mc/pop-state-from-overlay
3257 mc/maybe-multiple-cursors-mode)
3258 :defines (multiple-cursors-mode
3260 mc--read-quoted-char
3261 rectangular-region-mode)
3262 :bind (("C-S-c C-S-c" . mc/edit-lines)
3263 ("C->" . mc/mark-next-like-this)
3264 ("C-<" . mc/mark-previous-like-this)
3265 ("C-c C-<" . mc/mark-all-like-this)
3266 ("C-c i" . mc/insert-numbers))
3269 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
3270 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
3271 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
3272 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
3273 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
3274 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
3277 [2014-08-27 Wed 17:15]
3279 #+BEGIN_SRC emacs-lisp
3280 (use-package neotree
3283 :bind (("<f8>" . neotree-toggle))
3284 :commands (neotree-find
3289 (bind-key "^" 'neotree-select-up-node neotree-mode-map)
3290 (setq neo-smart-open t)))
3294 [2013-05-22 Wed 22:02]
3295 nxml-mode is a major mode for editing XML.
3296 #+BEGIN_SRC emacs-lisp
3301 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
3304 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
3305 (fset 'xml-mode 'nxml-mode)
3306 (setq nxml-slash-auto-complete-flag t)
3308 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
3309 (defun pp-xml-region (begin end)
3310 "Pretty format XML markup in region. The function inserts
3311 linebreaks to separate tags that have nothing but whitespace
3312 between them. It then indents the markup by using nxml's
3318 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
3319 (backward-char) (insert "\n"))
3320 (indent-region begin end)))
3322 ;;----------------------------------------------------------------------------
3323 ;; Integration with tidy for html + xml
3324 ;;----------------------------------------------------------------------------
3325 ;; tidy is autoloaded
3326 (eval-after-load 'tidy
3328 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
3329 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
3334 *** General settings
3335 [2013-04-28 So 17:06]
3337 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
3338 it is quite extensive. Nevertheless, it starts out small, loading it.
3339 #+BEGIN_SRC emacs-lisp
3343 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
3344 that we need org-protocol.
3345 #+BEGIN_SRC emacs-lisp
3346 (require 'org-protocol)
3351 My current =org-agenda-files= variable only includes a set of
3353 #+BEGIN_SRC emacs-lisp
3354 (setq org-agenda-files (quote ("~/org/"
3357 (setq org-default-notes-file "~/org/notes.org")
3359 =org-mode= manages the =org-agenda-files= variable automatically using
3360 =C-c [= and =C-c ]= to add and remove files respectively. However,
3361 this replaces my directory list with a list of explicit filenames
3362 instead and is not what I want. If this occurs then adding a new org
3363 file to any of the above directories will not contribute to my agenda
3364 and I will probably miss something important.
3366 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
3367 prevent messing up my list of directories in the =org-agenda-files=
3368 variable. I just add and remove directories manually here. Changing
3369 the list of directories in =org-agenda-files= happens very rarely
3370 since new files in existing directories are automatically picked up.
3372 #+BEGIN_SRC emacs-lisp
3373 ;; Keep tasks with dates on the global todo lists
3374 (setq org-agenda-todo-ignore-with-date nil)
3376 ;; Keep tasks with deadlines on the global todo lists
3377 (setq org-agenda-todo-ignore-deadlines nil)
3379 ;; Keep tasks with scheduled dates on the global todo lists
3380 (setq org-agenda-todo-ignore-scheduled nil)
3382 ;; Keep tasks with timestamps on the global todo lists
3383 (setq org-agenda-todo-ignore-timestamp nil)
3385 ;; Remove completed deadline tasks from the agenda view
3386 (setq org-agenda-skip-deadline-if-done t)
3388 ;; Remove completed scheduled tasks from the agenda view
3389 (setq org-agenda-skip-scheduled-if-done t)
3391 ;; Remove completed items from search results
3392 (setq org-agenda-skip-timestamp-if-done t)
3394 ;; Include agenda archive files when searching for things
3395 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
3397 ;; Show all future entries for repeating tasks
3398 (setq org-agenda-repeating-timestamp-show-all t)
3400 ;; Show all agenda dates - even if they are empty
3401 (setq org-agenda-show-all-dates t)
3403 ;; Sorting order for tasks on the agenda
3404 (setq org-agenda-sorting-strategy
3405 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
3406 (todo category-up priority-down effort-up)
3407 (tags category-up priority-down effort-up)
3408 (search category-up))))
3410 ;; Start the weekly agenda on Monday
3411 (setq org-agenda-start-on-weekday 1)
3413 ;; Enable display of the time grid so we can see the marker for the current time
3414 (setq org-agenda-time-grid (quote ((daily today remove-match)
3415 #("----------------" 0 16 (org-heading t))
3416 (0800 1000 1200 1400 1500 1700 1900 2100))))
3418 ;; Display tags farther right
3419 (setq org-agenda-tags-column -102)
3421 ; position the habit graph on the agenda to the right of the default
3422 (setq org-habit-graph-column 50)
3424 ; turn habits back on
3425 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
3428 ;; Agenda sorting functions
3430 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
3433 (setq org-deadline-warning-days 30)
3435 ;; Always hilight the current agenda line
3436 (add-hook 'org-agenda-mode-hook
3437 '(lambda () (hl-line-mode 1))
3441 #+BEGIN_SRC emacs-lisp
3442 (setq org-agenda-persistent-filter t)
3443 (add-hook 'org-agenda-mode-hook
3444 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
3447 (add-hook 'org-agenda-mode-hook
3448 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
3451 (add-hook 'org-agenda-mode-hook
3452 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
3455 (add-hook 'org-agenda-mode-hook
3456 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
3459 (add-hook 'org-agenda-mode-hook
3460 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
3463 ; Rebuild the reminders everytime the agenda is displayed
3464 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
3466 ;(if (file-exists-p "~/org/refile.org")
3467 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
3469 ; Activate appointments so we get notifications
3472 (setq org-agenda-log-mode-items (quote (closed clock state)))
3473 (if (> emacs-major-version 23)
3474 (setq org-agenda-span 3)
3475 (setq org-agenda-ndays 3))
3477 (setq org-agenda-show-all-dates t)
3478 (setq org-agenda-start-on-weekday nil)
3479 (setq org-deadline-warning-days 14)
3482 *** Global keybindings.
3483 Start off by defining a series of keybindings.
3485 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
3486 setup manually, not by org-mode. Also turn off =C-c ;=, which
3487 comments headlines - a function never used.
3488 #+BEGIN_SRC emacs-lisp
3489 (add-hook 'org-mode-hook
3491 (org-defkey org-mode-map "\C-c[" 'undefined)
3492 (org-defkey org-mode-map "\C-c]" 'undefined)
3493 (org-defkey org-mode-map "\C-c;" 'undefined))
3497 And now a largish set of keybindings...
3498 #+BEGIN_SRC emacs-lisp
3499 (bind-key "C-c l" 'org-store-link)
3500 (bind-key "C-c a" 'org-agenda)
3501 ;(bind-key "C-c b" 'org-iswitchb)
3502 (define-key mode-specific-map [?a] 'org-agenda)
3504 (bind-key "<f12>" 'org-agenda)
3505 (bind-key "<f5>" 'bh/org-todo)
3506 (bind-key "<S-f5>" 'bh/widen)
3507 ;(bind-key "<f7>" 'bh/set-truncate-lines)
3508 ;(bind-key "<f8>" 'org-cycle-agenda-files)
3510 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
3511 (bind-key "<f9> b" 'bbdb)
3512 (bind-key "<f9> c" 'calendar)
3513 (bind-key "<f9> f" 'boxquote-insert-file)
3514 (bind-key "<f9> h" 'bh/hide-other)
3515 (bind-key "<f9> n" 'org-narrow-to-subtree)
3516 (bind-key "<f9> w" 'widen)
3517 (bind-key "<f9> u" 'bh/narrow-up-one-level)
3518 (bind-key "<f9> I" 'bh/punch-in)
3519 (bind-key "<f9> O" 'bh/punch-out)
3520 (bind-key "<f9> H" 'jj/punch-in-hw)
3521 (bind-key "<f9> W" 'jj/punch-out-hw)
3522 (bind-key "<f9> o" 'bh/make-org-scratch)
3523 (bind-key "<f9> p" 'bh/phone-call)
3524 (bind-key "<f9> r" 'boxquote-region)
3525 (bind-key "<f9> s" 'bh/switch-to-scratch)
3526 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
3527 (bind-key "<f9> T" 'tabify)
3528 (bind-key "<f9> U" 'untabify)
3529 (bind-key "<f9> v" 'visible-mode)
3530 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
3531 (bind-key "C-<f9>" 'previous-buffer)
3532 (bind-key "C-<f10>" 'next-buffer)
3533 (bind-key "M-<f9>" 'org-toggle-inline-images)
3534 ;(bind-key "C-x n r" 'narrow-to-region)
3535 (bind-key "<f11>" 'org-clock-goto)
3536 (bind-key "C-<f11>" 'org-clock-in)
3537 (bind-key "C-M-r" 'org-capture)
3538 (bind-key "C-c r" 'org-capture)
3539 (bind-key "C-S-<f12>" 'bh/save-then-publish)
3540 ;(bind-key "C-k" 'jj-org-kill-line org-mode-map)
3544 *** Tasks, States, Todo fun
3546 First we define the global todo keywords.
3547 #+BEGIN_SRC emacs-lisp
3548 (setq org-todo-keywords
3549 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
3550 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
3552 (setq org-todo-keyword-faces
3553 (quote (("TODO" :foreground "red" :weight bold)
3554 ("NEXT" :foreground "light blue" :weight bold)
3555 ("DONE" :foreground "forest green" :weight bold)
3556 ("WAITING" :foreground "orange" :weight bold)
3557 ("HOLD" :foreground "orange" :weight bold)
3558 ("DELEGATED" :foreground "yellow" :weight bold)
3559 ("CANCELLED" :foreground "dark green" :weight bold)
3560 ("PHONE" :foreground "dark green" :weight bold))))
3563 **** Fast Todo Selection
3564 Fast todo selection allows changing from any task todo state to any
3565 other state directly by selecting the appropriate key from the fast
3566 todo selection key menu.
3567 #+BEGIN_SRC emacs-lisp
3568 (setq org-use-fast-todo-selection t)
3570 Changing a task state is done with =C-c C-t KEY=
3572 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
3575 #+BEGIN_SRC emacs-lisp
3576 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
3578 allows changing todo states with S-left and S-right skipping all of
3579 the normal processing when entering or leaving a todo state. This
3580 cycles through the todo states but skips setting timestamps and
3581 entering notes which is very convenient when all you want to do is fix
3582 up the status of an entry.
3584 **** Todo State Triggers
3585 I have a few triggers that automatically assign tags to tasks based on
3586 state changes. If a task moves to =CANCELLED= state then it gets a
3587 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
3588 =CANCELLED= tag. These are used for filtering tasks in agenda views
3589 which I'll talk about later.
3591 The triggers break down to the following rules:
3593 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
3594 - Moving a task to =WAITING= adds a =WAITING= tag
3595 - Moving a task to =HOLD= adds a =WAITING= tag
3596 - Moving a task to a done state removes a =WAITING= tag
3597 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
3598 - Moving a task to =NEXT= removes a =WAITING= tag
3599 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
3601 The tags are used to filter tasks in the agenda views conveniently.
3602 #+BEGIN_SRC emacs-lisp
3603 (setq org-todo-state-tags-triggers
3604 (quote (("CANCELLED" ("CANCELLED" . t))
3605 ("WAITING" ("WAITING" . t))
3606 ("HOLD" ("WAITING" . t) ("HOLD" . t))
3607 (done ("WAITING") ("HOLD"))
3608 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
3609 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
3610 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
3613 *** Capturing new tasks
3614 Org capture replaces the old remember mode.
3615 #+BEGIN_SRC emacs-lisp
3616 (setq org-directory "~/org")
3617 (setq org-default-notes-file "~/org/refile.org")
3619 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
3620 ;; see http://orgmode.org/manual/Template-elements.html
3621 (setq org-capture-templates
3622 (quote (("t" "todo" entry (file "~/org/refile.org")
3623 "* TODO %?\nAdded: %U\n"
3624 :clock-in t :clock-resume t)
3625 ("l" "linktodo" entry (file "~/org/refile.org")
3626 "* TODO %?\nAdded: %U\n%a\n"
3627 :clock-in t :clock-resume t)
3628 ("r" "respond" entry (file "~/org/refile.org")
3629 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
3630 :clock-in t :clock-resume t :immediate-finish t)
3631 ("n" "note" entry (file "~/org/refile.org")
3632 "* %? :NOTE:\nAdded: %U\n%a\n"
3633 :clock-in t :clock-resume t)
3634 ("d" "Delegated" entry (file "~/org/refile.org")
3635 "* DELEGATED %?\nAdded: %U\n%a\n"
3636 :clock-in t :clock-resume t)
3637 ("j" "Journal" entry (file+datetree "~/org/diary.org")
3639 :clock-in t :clock-resume t)
3640 ("w" "org-protocol" entry (file "~/org/refile.org")
3641 "* TODO Review %c\nAdded: %U\n"
3642 :immediate-finish t)
3643 ("p" "Phone call" entry (file "~/org/refile.org")
3644 "* PHONE %? :PHONE:\nAdded: %U"
3645 :clock-in t :clock-resume t)
3646 ("x" "Bookmark link" entry (file "~/org/refile.org")
3647 "* Bookmark: %c\n%i\nAdded: %U\n"
3648 :immediate-finish t)
3649 ("h" "Habit" entry (file "~/org/refile.org")
3650 "* 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")
3654 Capture mode now handles automatically clocking in and out of a
3655 capture task. This all works out of the box now without special hooks.
3656 When I start a capture mode task the task is clocked in as specified
3657 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
3658 resumes on the original clocking task.
3660 The quick clocking in and out of capture mode tasks (often it takes
3661 less than a minute to capture some new task details) can leave
3662 empty clock drawers in my tasks which aren't really useful.
3663 The following prevents this.
3664 #+BEGIN_SRC emacs-lisp :tangle no
3665 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
3669 All my newly captured entries end up in =refile.org= and want to be
3670 moved over to the right place. The following is the setup for it.
3671 #+BEGIN_SRC emacs-lisp
3672 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
3673 (setq org-refile-targets (quote ((nil :maxlevel . 9)
3674 (org-agenda-files :maxlevel . 9))))
3676 ; Use full outline paths for refile targets - we file directly with IDO
3677 (setq org-refile-use-outline-path t)
3679 ; Targets complete directly with IDO
3680 (setq org-outline-path-complete-in-steps nil)
3682 ; Allow refile to create parent tasks with confirmation
3683 (setq org-refile-allow-creating-parent-nodes (quote confirm))
3685 ; Use IDO for both buffer and file completion and ido-everywhere to t
3686 (setq org-completion-use-ido t)
3687 (setq org-completion-use-iswitchb nil)
3688 :; Use IDO for both buffer and file completion and ido-everywhere to t
3689 ;(setq ido-everywhere t)
3690 ;(setq ido-max-directory-size 100000)
3691 ;(ido-mode (quote both))
3692 ; Use the current window when visiting files and buffers with ido
3693 (setq ido-default-file-method 'selected-window)
3694 (setq ido-default-buffer-method 'selected-window)
3696 ;;;; Refile settings
3697 (setq org-refile-target-verify-function 'bh/verify-refile-target)
3701 Agenda view is the central place for org-mode interaction...
3702 #+BEGIN_SRC emacs-lisp
3703 ;; Do not dim blocked tasks
3704 (setq org-agenda-dim-blocked-tasks nil)
3705 ;; Compact the block agenda view
3706 (setq org-agenda-compact-blocks t)
3708 ;; Custom agenda command definitions
3709 (setq org-agenda-custom-commands
3710 (quote (("N" "Notes" tags "NOTE"
3711 ((org-agenda-overriding-header "Notes")
3712 (org-tags-match-list-sublevels t)))
3713 ("h" "Habits" tags-todo "STYLE=\"habit\""
3714 ((org-agenda-overriding-header "Habits")
3715 (org-agenda-sorting-strategy
3716 '(todo-state-down effort-up category-keep))))
3720 ((org-agenda-overriding-header "Tasks to Refile")
3721 (org-tags-match-list-sublevels nil)))
3722 (tags-todo "-HOLD-CANCELLED/!"
3723 ((org-agenda-overriding-header "Projects")
3724 (org-agenda-skip-function 'bh/skip-non-projects)
3725 (org-agenda-sorting-strategy
3727 (tags-todo "-CANCELLED/!"
3728 ((org-agenda-overriding-header "Stuck Projects")
3729 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3730 (tags-todo "-WAITING-CANCELLED/!NEXT"
3731 ((org-agenda-overriding-header "Next Tasks")
3732 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3733 (org-agenda-todo-ignore-scheduled t)
3734 (org-agenda-todo-ignore-deadlines t)
3735 (org-agenda-todo-ignore-with-date t)
3736 (org-tags-match-list-sublevels t)
3737 (org-agenda-sorting-strategy
3738 '(todo-state-down effort-up category-keep))))
3739 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3740 ((org-agenda-overriding-header "Tasks")
3741 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3742 (org-agenda-todo-ignore-scheduled t)
3743 (org-agenda-todo-ignore-deadlines t)
3744 (org-agenda-todo-ignore-with-date t)
3745 (org-agenda-sorting-strategy
3747 (tags-todo "-CANCELLED+WAITING/!"
3748 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
3749 (org-agenda-skip-function 'bh/skip-stuck-projects)
3750 (org-tags-match-list-sublevels nil)
3751 (org-agenda-todo-ignore-scheduled 'future)
3752 (org-agenda-todo-ignore-deadlines 'future)))
3754 ((org-agenda-overriding-header "Tasks to Archive")
3755 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3756 (org-tags-match-list-sublevels nil))))
3758 ("r" "Tasks to Refile" tags "REFILE"
3759 ((org-agenda-overriding-header "Tasks to Refile")
3760 (org-tags-match-list-sublevels nil)))
3761 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
3762 ((org-agenda-overriding-header "Stuck Projects")
3763 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3764 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
3765 ((org-agenda-overriding-header "Next Tasks")
3766 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3767 (org-agenda-todo-ignore-scheduled t)
3768 (org-agenda-todo-ignore-deadlines t)
3769 (org-agenda-todo-ignore-with-date t)
3770 (org-tags-match-list-sublevels t)
3771 (org-agenda-sorting-strategy
3772 '(todo-state-down effort-up category-keep))))
3773 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3774 ((org-agenda-overriding-header "Tasks")
3775 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3776 (org-agenda-sorting-strategy
3778 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
3779 ((org-agenda-overriding-header "Projects")
3780 (org-agenda-skip-function 'bh/skip-non-projects)
3781 (org-agenda-sorting-strategy
3783 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
3784 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
3785 (org-tags-match-list-sublevels nil))
3786 ("A" "Tasks to Archive" tags "-REFILE/"
3787 ((org-agenda-overriding-header "Tasks to Archive")
3788 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3789 (org-tags-match-list-sublevels nil))))))
3791 ; Overwrite the current window with the agenda
3792 (setq org-agenda-window-setup 'current-window)
3797 #+BEGIN_SRC emacs-lisp
3799 ;; Resume clocking task when emacs is restarted
3800 (org-clock-persistence-insinuate)
3802 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
3803 (setq org-clock-history-length 36)
3804 ;; Resume clocking task on clock-in if the clock is open
3805 (setq org-clock-in-resume t)
3806 ;; Change tasks to NEXT when clocking in
3807 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
3808 ;; Separate drawers for clocking and logs
3809 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
3810 ;; Save clock data and state changes and notes in the LOGBOOK drawer
3811 (setq org-clock-into-drawer t)
3812 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
3813 (setq org-clock-out-remove-zero-time-clocks t)
3814 ;; Clock out when moving task to a done state
3815 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
3816 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
3817 (setq org-clock-persist t)
3818 ;; Do not prompt to resume an active clock
3819 (setq org-clock-persist-query-resume nil)
3820 ;; Enable auto clock resolution for finding open clocks
3821 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
3822 ;; Include current clocking task in clock reports
3823 (setq org-clock-report-include-clocking-task t)
3825 ; use discrete minute intervals (no rounding) increments
3826 (setq org-time-stamp-rounding-minutes (quote (1 1)))
3828 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
3830 (setq bh/keep-clock-running nil)
3832 (setq org-agenda-clock-consistency-checks
3833 (quote (:max-duration "4:00"
3836 :gap-ok-around ("4:00"))))
3840 **** Setting a default clock task
3841 Per default the =** Organization= task in my tasks.org file receives
3842 misc clock time. This is the task I clock in on when I punch in at the
3843 start of my work day with =F9-I=. Punching-in anywhere clocks in this
3844 Organization task as the default task.
3846 If I want to change the default clocking task I just visit the
3847 new task in any org buffer and clock it in with =C-u C-u C-c C-x
3848 C-i=. Now this new task that collects miscellaneous clock
3849 minutes when the clock would normally stop.
3851 You can quickly clock in the default clocking task with =C-u C-c
3852 C-x C-i d=. Another option is to repeatedly clock out so the
3853 clock moves up the project tree until you clock out the
3854 top-level task and the clock moves to the default task.
3857 #+BEGIN_SRC emacs-lisp
3858 ;; Agenda clock report parameters
3859 (setq org-agenda-clockreport-parameter-plist
3860 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
3862 ;; Agenda log mode items to display (closed and state changes by default)
3863 (setq org-agenda-log-mode-items (quote (closed state)))
3865 **** Task estimates, column view
3866 Setup column view globally with the following headlines
3867 #+BEGIN_SRC emacs-lisp
3868 ; Set default column view headings: Task Effort Clock_Summary
3869 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
3871 Setup the estimate for effort values.
3872 #+BEGIN_SRC emacs-lisp
3873 ; global Effort estimate values
3874 ; global STYLE property values for completion
3875 (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")
3876 ("STYLE_ALL" . "habit"))))
3880 Tags are mostly used for filtering inside the agenda.
3881 #+BEGIN_SRC emacs-lisp
3882 ; Tags with fast selection keys
3883 (setq org-tag-alist (quote ((:startgroup)
3901 ; Allow setting single tags without the menu
3902 (setq org-fast-tag-selection-single-key (quote expert))
3904 ; For tag searches ignore tasks with scheduled and deadline dates
3905 (setq org-agenda-tags-todo-honor-ignore-options t)
3909 #+BEGIN_SRC emacs-lisp
3910 (setq org-archive-mark-done nil)
3911 (setq org-archive-location "%s_archive::* Archived Tasks")
3915 #+BEGIN_SRC emacs-lisp
3916 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
3917 (setq org-plantuml-jar-path "~/java/plantuml.jar")
3919 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
3921 ; Make babel results blocks lowercase
3922 (setq org-babel-results-keyword "results")
3924 (org-babel-do-load-languages
3925 (quote org-babel-load-languages)
3926 (quote ((emacs-lisp . t)
3945 ; Do not prompt to confirm evaluation
3946 ; This may be dangerous - make sure you understand the consequences
3947 ; of setting this -- see the docstring for details
3948 (setq org-confirm-babel-evaluate nil)
3950 ; Use fundamental mode when editing plantuml blocks with C-c '
3951 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
3954 #+BEGIN_SRC emacs-lisp
3955 ;; Don't have images visible on startup, breaks on console
3956 (setq org-startup-with-inline-images nil)
3959 #+BEGIN_SRC emacs-lisp
3960 (add-to-list 'org-structure-template-alist
3961 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
3962 "<comment>\n?\n</comment>"))
3964 **** ditaa, graphviz, etc
3965 Those are all nice tools. Look at
3966 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
3969 *** Publishing and exporting
3972 Org-mode can export to a variety of publishing formats including (but not limited to)
3975 (plain text - but not the original org-mode file)
3979 which enables getting to lots of other formats like ODF, XML, etc
3981 via LaTeX or Docbook
3984 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
3986 #+BEGIN_SRC emacs-lisp
3987 ;; Explicitly load required exporters
3991 ;(require 'ox-reveal)
3992 ;; FIXME, check the following two
3993 ;(require 'ox-icalendar)
3996 ; experimenting with docbook exports - not finished
3997 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
3998 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
4000 (setq org-reveal-root "file:///home/joerg/devel/ganeticon2015/reveal.js/reveal.js")
4002 ;; define categories that should be excluded
4003 (setq org-export-exclude-category (list "google" "google"))
4004 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
4006 ; define how the date strings look
4007 (setq org-export-date-timestamp-format "%Y-%m-%d")
4008 ; Inline images in HTML instead of producting links to the image
4009 (setq org-html-inline-images t)
4010 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
4011 (setq org-export-with-sub-superscripts nil)
4013 (setq org-html-head-extra (concat
4014 "<link rel=\"stylesheet\" href=\"https://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
4016 (setq org-html-head-include-default-style nil)
4017 ; Do not generate internal css formatting for HTML exports
4018 (setq org-export-htmlize-output-type (quote css))
4019 ; Export with LaTeX fragments
4020 (setq org-export-with-LaTeX-fragments t)
4021 ; Increase default number of headings to export
4022 (setq org-export-headline-levels 6)
4025 (setq org-publish-project-alist
4028 :base-directory "~/.emacs.d/"
4029 :base-extension "org"
4031 :publishing-directory "/develop/www/emacs"
4033 :publishing-function org-html-publish-to-html
4034 :headline-levels 4 ; Just the default for this project.
4040 :base-directory "~/.emacs.d/"
4041 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
4042 :publishing-directory "/develop/www/emacs"
4043 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
4045 :publishing-function org-publish-attachment
4047 ("inherit-org-info-js"
4048 :base-directory "/develop/vcs/org-info-js/"
4050 :base-extension "js"
4051 :publishing-directory "/develop/www/"
4052 :publishing-function org-publish-attachment
4054 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
4059 (setq org-export-with-timestamps nil)
4064 #+BEGIN_SRC emacs-lisp
4065 (setq org-latex-to-pdf-process
4066 '("xelatex -interaction nonstopmode %f"
4067 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
4068 (setq org-export-latex-listings 'minted)
4069 (setq org-latex-listings t)
4071 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
4072 ;; but adapted to use latexmk 4.20 or higher.
4073 (defun my-auto-tex-cmd ()
4074 "When exporting from .org with latex, automatically run latex,
4075 pdflatex, or xelatex as appropriate, using latexmk."
4077 ;; default command: oldstyle latex via dvi
4078 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
4080 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
4081 (setq texcmd "latexmk -pdf -quiet %f"))
4083 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
4084 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
4085 ;; LaTeX compilation command
4086 (setq org-latex-to-pdf-process (list texcmd)))
4088 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
4090 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
4091 (setq org-export-latex-packages-alist
4093 ("" "longtable" nil)
4098 (defun my-auto-tex-parameters ()
4099 "Automatically select the tex packages to include."
4100 ;; default packages for ordinary latex or pdflatex export
4101 (setq org-export-latex-default-packages-alist
4102 '(("AUTO" "inputenc" t)
4112 ("" "hyperref" nil)))
4114 ;; Packages to include when xelatex is used
4115 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
4116 (setq org-export-latex-default-packages-alist
4121 ("german" "babel" t)
4122 ("babel" "csquotes" t)
4124 ("xetex" "hyperref" nil)
4127 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
4128 (setq org-export-latex-classes
4130 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
4131 ("\\section{%s}" . "\\section*{%s}")
4132 ("\\subsection{%s}" . "\\subsection*{%s}")
4133 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
4134 ("\\paragraph{%s}" . "\\paragraph*{%s}")
4135 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
4136 org-export-latex-classes))))
4138 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
4141 *** Prevent editing invisible text
4142 The following setting prevents accidentally editing hidden text when
4143 the point is inside a folded region. This can happen if you are in
4144 the body of a heading and globally fold the org-file with =S-TAB=
4146 I find invisible edits (and undo's) hard to deal with so now I can't
4147 edit invisible text. =C-c C-r= (org-reveal) will display where the
4148 point is if it is buried in invisible text to allow editing again.
4150 #+BEGIN_SRC emacs-lisp
4151 (setq org-catch-invisible-edits 'error)
4155 #+BEGIN_SRC emacs-lisp
4156 ;; disable the default org-mode stuck projects agenda view
4157 (setq org-stuck-projects (quote ("" nil nil "")))
4159 ; force showing the next headline.
4160 (setq org-show-entry-below (quote ((default))))
4162 (setq org-show-following-heading t)
4163 (setq org-show-hierarchy-above t)
4164 (setq org-show-siblings (quote ((default))))
4166 (setq org-special-ctrl-a/e t)
4167 (setq org-special-ctrl-k t)
4168 (setq org-yank-adjusted-subtrees t)
4170 (setq org-table-export-default-format "orgtbl-to-csv")
4174 The following setting adds alphabetical lists like
4178 #+BEGIN_SRC emacs-lisp
4179 (if (> emacs-major-version 23)
4180 (setq org-list-allow-alphabetical t)
4181 (setq org-alphabetical-lists t))
4184 #+BEGIN_SRC emacs-lisp
4185 (setq org-remove-highlights-with-change nil)
4187 (setq org-list-demote-modify-bullet (quote (("+" . "-")
4194 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
4197 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
4198 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
4203 #+BEGIN_SRC emacs-lisp
4204 ;; Enable abbrev-mode
4205 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
4206 (setq org-startup-indented t)
4207 (setq org-startup-folded t)
4208 (setq org-cycle-separator-lines 0)
4211 I find extra blank lines in lists and headings a bit of a nuisance.
4212 To get a body after a list you need to include a blank line between
4213 the list entry and the body -- and indent the body appropriately.
4214 Most of my lists have no body detail so I like the look of collapsed
4215 lists with no blank lines better.
4217 The following setting prevents creating blank lines before headings
4218 but allows list items to adapt to existing blank lines around the items:
4219 #+BEGIN_SRC emacs-lisp
4220 (setq org-blank-before-new-entry (quote ((heading)
4221 (plain-list-item . auto))))
4224 #+BEGIN_SRC emacs-lisp
4225 (setq org-reverse-note-order nil)
4226 (setq org-default-notes-file "~/notes.org")
4229 Enforce task blocking. Tasks can't go done when there is any subtask
4230 still open. Unless they have a property of =NOBLOCKING: t=
4231 #+BEGIN_SRC emacs-lisp
4232 (setq org-enforce-todo-checkbox-dependencies t)
4233 (setq org-enforce-todo-dependencies t)
4236 #+BEGIN_SRC emacs-lisp
4237 (setq org-fast-tag-selection-single-key (quote expert))
4238 (setq org-footnote-auto-adjust t)
4239 (setq org-hide-block-startup t)
4240 (setq org-icalendar-alarm-time 15)
4241 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
4242 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
4243 (setq org-icalendar-honor-noexport-tag t)
4244 (setq org-icalendar-include-bbdb-anniversaries nil)
4245 (setq org-icalendar-include-body 200)
4246 (setq org-icalendar-include-todo nil)
4247 (setq org-icalendar-store-UID t)
4248 (setq org-icalendar-timezone "Europe/Berlin")
4249 (setq org-insert-mode-line-in-empty-file t)
4250 (setq org-log-done (quote note))
4251 (setq org-log-into-drawer t)
4252 (setq org-log-state-notes-insert-after-drawers nil)
4253 (setq org-log-reschedule (quote time))
4254 (setq org-log-states-order-reversed t)
4255 (setq org-mobile-agendas (quote all))
4256 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
4257 (setq org-mobile-inbox-for-pull "~/org/refile.org")
4258 (setq org-remember-store-without-prompt t)
4259 (setq org-return-follows-link t)
4260 (setq org-reverse-note-order t)
4262 ; regularly save our org-mode buffers
4263 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
4265 (setq org-log-done t)
4267 (setq org-enable-priority-commands t)
4268 (setq org-default-priority ?E)
4269 (setq org-lowest-priority ?E)
4274 Speed commands enable single-letter commands in Org-mode files when
4275 the point is at the beginning of a headline, or at the beginning of a
4278 See the `=org-speed-commands-default=' variable for a list of the keys
4279 and commands enabled at the beginning of headlines. All code blocks
4280 are available at the beginning of a code block, the following key
4281 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
4282 display a list of the code blocks commands and their related keys.
4284 #+BEGIN_SRC emacs-lisp
4285 (setq org-use-speed-commands nil)
4286 (setq org-speed-commands-user (quote (("0" . ignore)
4299 ("h" . bh/hide-other)
4302 (call-interactively 'org-insert-heading-respect-content))
4303 ("k" . org-kill-note-or-show-branches)
4306 ("q" . bh/show-org-agenda)
4308 ("s" . org-save-all-org-buffers)
4312 ("z" . org-add-note)
4317 ("F" . bh/restrict-to-file-or-follow)
4320 ("J" . org-clock-goto)
4324 ("N" . bh/narrow-to-org-subtree)
4325 ("P" . bh/narrow-to-org-project)
4330 ("U" . bh/narrow-up-one-org-level)
4337 (add-hook 'org-agenda-mode-hook
4339 (define-key org-agenda-mode-map "q" 'bury-buffer))
4342 (defvar bh/current-view-project nil)
4343 (add-hook 'org-agenda-mode-hook
4344 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
4349 The following displays the contents of code blocks in Org-mode files
4350 using the major-mode of the code. It also changes the behavior of
4351 =TAB= to as if it were used in the appropriate major mode. This means
4352 that reading and editing code form inside of your Org-mode files is
4353 much more like reading and editing of code using its major mode.
4355 #+BEGIN_SRC emacs-lisp
4356 (setq org-src-fontify-natively t)
4357 (setq org-src-tab-acts-natively t)
4360 #+BEGIN_SRC emacs-lisp
4361 (setq org-src-preserve-indentation nil)
4362 (setq org-edit-src-content-indentation 0)
4366 #+BEGIN_SRC emacs-lisp
4367 (setq org-attach-directory "~/org/data/")
4369 #+BEGIN_SRC emacs-lisp
4370 (setq org-agenda-sticky t)
4373 **** Checklist handling
4374 [2013-05-11 Sat 22:15]
4376 #+BEGIN_SRC emacs-lisp
4377 (require 'org-checklist)
4380 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
4382 #+BEGIN_SRC emacs-lisp
4383 (use-package cperl-mode
4384 :commands cperl-mode
4387 (defalias 'perl-mode 'cperl-mode)
4388 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
4389 (add-auto-mode 'pod-mode "\\.pod$")
4390 (add-auto-mode 'tt-mode "\\.tt$")
4391 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
4392 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
4393 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
4394 (setq cperl-invalid-face nil
4395 cperl-close-paren-offset -4
4396 cperl-continued-statement-offset 0
4397 cperl-indent-level 4
4398 cperl-indent-parens-as-block t
4400 cperl-electric-keywords t
4401 cperl-electric-lbrace-space t
4402 cperl-electric-parens nil
4403 cperl-highlight-variables-indiscriminately t
4404 cperl-imenu-addback t
4405 cperl-invalid-face (quote underline)
4406 cperl-lazy-help-time 5
4407 cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$"
4408 cperl-syntaxify-by-font-lock t
4409 cperl-use-syntax-table-text-property-for-tags t)
4411 ;; And have cperl mode give ElDoc a useful string
4412 (defun my-cperl-eldoc-documentation-function ()
4413 "Return meaningful doc string for `eldoc-mode'."
4415 (let ((cperl-message-on-help-error nil))
4417 (add-hook 'cperl-mode-hook
4419 (set (make-local-variable 'eldoc-documentation-function)
4420 'my-cperl-eldoc-documentation-function)
4425 [2014-05-22 Thu 00:05]
4426 #+BEGIN_SRC emacs-lisp
4427 (use-package puppet-mode
4429 :mode ("\\.pp\\'" . puppet-mode)
4430 :bind (:map puppet-mode-map
4431 ("C-c C-a" . puppet-align-block)
4432 ("C-c '" . puppet-toggle-string-quotes)
4433 ("C-c <delete>" . puppet-clear-string)
4435 ("C-c M-a" . puppet-set-anchor)
4436 ("C-c C-r" . puppet-create-require)
4438 :commands puppet-mode
4441 (defun my-puppet-mode-hook ()
4442 (setq require-final-newline nil))
4443 (add-hook 'puppet-mode-hook 'my-puppet-mode-hook)
4444 (use-package puppet-ext)))
4448 Use elpy for the emacs python fun, but dont let it initialize all the
4449 various variables. Elpy author may like them, but I'm not him...
4450 #+BEGIN_SRC emacs-lisp :tangle no
4453 :mode ("\.py" . python-mode)
4456 (safe-load (concat jj-elisp-dir "/elpy/elpy-autoloads.el"))
4463 :commands (nosetests-all nosetests-module nosetests-one
4464 nosetests-failed nosetests-pdb-all
4465 nosetests-pdb-module nosetests-pdb-one)
4470 :commands (pyvenv-activate pyvenv-deactivate pyvenv-mode pyvenv-restart-python)
4473 (use-package idomenu
4478 (use-package highlight-indentation
4480 :commands (highlight-indentation-mode))
4482 (use-package find-file-in-project
4484 :commands (find-file-in-project ffip-project-files ffip ))
4489 ;; Local variables in `python-mode'. This is not removed when Elpy
4490 ;; is disabled, which can cause some confusion.
4491 (add-hook 'python-mode-hook 'elpy-initialize-local-variables)
4493 (defun my-python-mode-hook ()
4494 (setq require-final-newline nil)
4495 (setq mode-require-final-newline))
4496 (add-hook 'python-mode-hook 'my-python-mode-hook)
4498 ;; Flymake support using flake8, including warning faces.
4499 (when (and (executable-find "flake8")
4500 (not (executable-find python-check-command)))
4501 (setq python-check-command "flake8"))
4503 ;; `flymake-no-changes-timeout': The original value of 0.5 is too
4504 ;; short for Python code, as that will result in the current line to
4505 ;; be highlighted most of the time, and that's annoying. This value
4506 ;; might be on the long side, but at least it does not, in general,
4507 ;; interfere with normal interaction.
4508 (setq flymake-no-changes-timeout 60)
4510 ;; `flymake-start-syntax-check-on-newline': This should be nil for
4511 ;; Python, as;; most lines with a colon at the end will mean the next
4512 ;; line is always highlighted as error, which is not helpful and
4514 (setq flymake-start-syntax-check-on-newline nil)
4516 ;; `ac-auto-show-menu': Short timeout because the menu is great.
4517 (setq ac-auto-show-menu 0.4)
4519 ;; `ac-quick-help-delay': I'd like to show the menu right with the
4520 ;; completions, but this value should be greater than
4521 ;; `ac-auto-show-menu' to show help for the first entry as well.
4522 (setq ac-quick-help-delay 0.5)
4524 ;; `yas-trigger-key': TAB, as is the default, conflicts with the
4525 ;; autocompletion. We also need to tell yasnippet about the new
4526 ;; binding. This is a bad interface to set the trigger key. Stop
4528 (let ((old (when (boundp 'yas-trigger-key)
4530 (setq yas-trigger-key "C-c C-i")
4531 (when (fboundp 'yas--trigger-key-reload)
4532 (yas--trigger-key-reload old)))
4534 ;; yas-snippet-dirs can be a string for a single directory. Make
4535 ;; sure it's a list in that case so we can add our own entry.
4536 (when (not (listp yas-snippet-dirs))
4537 (setq yas-snippet-dirs (list yas-snippet-dirs)))
4538 (add-to-list 'yas-snippet-dirs
4539 (concat (file-name-directory (locate-library "elpy"))
4543 ;; Now load yasnippets.
4546 (elpy-use-ipython)))
4551 #+BEGIN_SRC emacs-lisp :tangle no
4552 (autoload 'python-mode "python-mode" "Python Mode." t)
4553 (add-auto-mode 'python-mode "\\.py\\'")
4554 (add-auto-mode 'python-mode "\\.py$")
4555 (add-auto-mode 'python-mode "SConstruct\\'")
4556 (add-auto-mode 'python-mode "SConscript\\'")
4557 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
4560 (set-variable 'py-indent-offset 4)
4561 (set-variable 'py-smart-indentation nil)
4562 (set-variable 'indent-tabs-mode nil)
4563 (define-key python-mode-map "\C-m" 'newline-and-indent)
4564 (turn-on-eldoc-mode)
4565 (defun python-auto-fill-comments-only ()
4567 (set (make-local-variable 'fill-nobreak-predicate)
4569 (not (python-in-string/comment)))))
4570 (add-hook 'python-mode-hook
4572 (python-auto-fill-comments-only)))
4574 (autoload 'pymacs-apply "pymacs")
4575 (autoload 'pymacs-call "pymacs")
4576 (autoload 'pymacs-eval "pymacs" nil t)
4577 (autoload 'pymacs-exec "pymacs" nil t)
4578 (autoload 'pymacs-load "pymacs" nil t))
4581 If an =ipython= executable is on the path, then assume that IPython is
4582 the preferred method python evaluation.
4583 #+BEGIN_SRC emacs-lisp :tangle no
4584 (when (executable-find "ipython")
4586 (setq org-babel-python-mode 'python-mode))
4588 (setq python-shell-interpreter "ipython")
4589 (setq python-shell-interpreter-args "")
4590 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
4591 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
4592 (setq python-shell-completion-setup-code
4593 "from IPython.core.completerlib import module_completion")
4594 (setq python-shell-completion-module-string-code
4595 "';'.join(module_completion('''%s'''))\n")
4596 (setq python-shell-completion-string-code
4597 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
4599 ** rainbow-delimiters
4600 [2013-04-09 Di 23:38]
4601 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
4602 which highlights parens, brackets, and braces according to their
4603 depth. Each successive level is highlighted a different color. This
4604 makes it easy to spot matching delimiters, orient yourself in the code,
4605 and tell which statements are at the same depth.
4606 #+BEGIN_SRC emacs-lisp
4607 (use-package rainbow-delimiters
4608 :ensure rainbow-delimiters
4609 :commands rainbow-delimiters-mode
4611 (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
4614 #+BEGIN_SRC emacs-lisp
4615 (use-package rainbow-mode
4616 :ensure rainbow-mode
4618 :diminish rainbow-mode)
4623 #+BEGIN_SRC emacs-lisp
4624 (use-package re-builder
4625 :commands re-builder
4628 (setq reb-re-syntax 'string))
4631 [2014-05-19 Mo 22:56]
4632 Recentf is a minor mode that builds a list of recently opened
4633 files. This list is is automatically saved across Emacs sessions.
4634 #+BEGIN_SRC emacs-lisp
4635 (use-package recentf
4636 :if (not noninteractive)
4637 :bind ("C-x C-r" . recentf-open-files)
4642 (setq recentf-max-menu-items 25)
4643 (setq recentf-save-file (expand-file-name ".recentf" jj-cache-dir))
4645 (defun recentf-add-dired-directory ()
4646 (if (and dired-directory
4647 (file-directory-p dired-directory)
4648 (not (string= "/" dired-directory)))
4649 (let ((last-idx (1- (length dired-directory))))
4651 (if (= ?/ (aref dired-directory last-idx))
4652 (substring dired-directory 0 last-idx)
4653 dired-directory)))))
4655 (add-hook 'dired-mode-hook 'recentf-add-dired-directory)))
4657 ** Region bindings mode
4658 [2013-05-01 Wed 22:51]
4659 This mode allows to have keybindings that are only alive when the
4660 region is active. Helpful for things that only do any useful action
4661 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
4662 #+BEGIN_SRC emacs-lisp tangle no
4663 (use-package region-bindings-mode
4664 :ensure region-bindings-mode
4666 (region-bindings-mode-enable))
4669 [2013-05-22 Wed 22:33]
4670 Programming in ruby...
4673 #+BEGIN_SRC emacs-lisp
4674 (add-auto-mode 'ruby-mode
4675 "Rakefile\\'" "\\.rake\\'" "\.rxml\\'"
4676 "\\.rjs\\'" ".irbrc\\'" "\.builder\\'" "\\.ru\\'"
4677 "\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
4681 #+BEGIN_SRC emacs-lisp
4682 (use-package ruby-mode
4683 :mode ("\\.rb\\'" . ruby-mode)
4684 :interpreter ("ruby" . ruby-mode)
4691 (defvar yari-helm-source-ri-pages
4692 '((name . "RI documentation")
4693 (candidates . (lambda () (yari-ruby-obarray)))
4694 (action ("Show with Yari" . yari))
4695 (candidate-number-limit . 300)
4696 (requires-pattern . 2)
4697 "Source for completing RI documentation."))
4699 (defun helm-yari (&optional rehash)
4700 (interactive (list current-prefix-arg))
4701 (when current-prefix-arg (yari-ruby-obarray rehash))
4702 (helm 'yari-helm-source-ri-pages (yari-symbol-at-point)))))
4704 (defun my-ruby-smart-return ()
4706 (when (memq (char-after) '(?\| ?\" ?\'))
4708 (call-interactively 'newline-and-indent))
4710 (use-package ruby-hash-syntax
4711 :ensure ruby-hash-syntax)
4713 (use-package inf-ruby
4715 :commands inf-ruby-minor-mode
4718 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)
4719 (bind-key "<return>" 'my-ruby-smart-return ruby-mode-map)
4720 ;(bind-key "<tab>" 'indent-for-tab-command ruby-mode-map)
4723 ;; (set (make-local-variable 'yas-fallback-behavior)
4724 ;; '(apply ruby-indent-command . nil))
4725 ;; (bind-key "<tab>" 'yas-expand-from-trigger-key ruby-mode-map)
4728 ;; Stupidly the non-bundled ruby-mode isn't a derived mode of
4729 ;; prog-mode: we run the latter's hooks anyway in that case.
4730 (add-hook 'ruby-mode-hook
4732 (unless (derived-mode-p 'prog-mode)
4733 (run-hooks 'prog-mode-hook))))
4737 [2013-05-22 Wed 22:40]
4738 Save and restore the desktop
4739 #+BEGIN_SRC emacs-lisp
4740 (setq desktop-path (list jj-cache-dir))
4741 (desktop-save-mode 1)
4742 (defadvice desktop-read (around trace-desktop-errors activate)
4743 (let ((debug-on-error t))
4746 ;;----------------------------------------------------------------------------
4747 ;; Restore histories and registers after saving
4748 ;;----------------------------------------------------------------------------
4749 (use-package session
4750 :if (not noninteractive)
4751 :load-path "site-lisp/session/lisp/"
4754 (setq session-save-file (expand-file-name "session" jj-cache-dir))
4755 (setq desktop-globals-to-save
4756 (append '((extended-command-history . 30)
4757 (file-name-history . 100)
4759 (compile-history . 30)
4760 (minibuffer-history . 50)
4761 (query-replace-history . 60)
4762 (read-expression-history . 60)
4763 (regexp-history . 60)
4764 (regexp-search-ring . 20)
4766 (comint-input-ring . 50)
4767 (shell-command-history . 50)
4769 desktop-missing-file-warning
4773 (session-initialize)
4775 (defun remove-session-use-package-from-settings ()
4776 (when (string= (file-name-nondirectory (buffer-file-name)) "settings.el")
4778 (goto-char (point-min))
4779 (when (re-search-forward "^ '(session-use-package " nil t)
4780 (delete-region (line-beginning-position)
4781 (1+ (line-end-position)))))))
4783 (add-hook 'before-save-hook 'remove-session-use-package-from-settings)
4785 ;; expanded folded secitons as required
4786 (defun le::maybe-reveal ()
4787 (when (and (or (memq major-mode '(org-mode outline-mode))
4788 (and (boundp 'outline-minor-mode)
4789 outline-minor-mode))
4790 (outline-invisible-p))
4791 (if (eq major-mode 'org-mode)
4795 (add-hook 'session-after-jump-to-last-change-hook
4798 (defun save-information ()
4799 (with-temp-message "Saving Emacs information..."
4802 (loop for func in kill-emacs-hook
4803 unless (memq func '(exit-gnus-on-exit server-force-stop))
4806 (unless (or noninteractive
4807 (eq 'listen (process-status server-process)))
4810 (run-with-idle-timer 300 t 'save-information)
4813 (add-hook 'after-init-hook 'session-initialize t))))
4817 [2013-04-21 So 20:25]
4818 Save a bit of history
4819 #+BEGIN_SRC emacs-lisp tangle no
4820 (use-package savehist
4823 (setq savehist-file (expand-file-name "savehist" jj-cache-dir))
4824 (setq history-length 1000))
4827 (setq savehist-additional-variables
4828 '(search ring regexp-search-ring kill-ring compile-history))
4829 ;; save every minute
4830 (setq savehist-autosave-interval 60)
4831 (savehist-mode +1)))
4835 Store at which point I have been in files.
4836 #+BEGIN_SRC emacs-lisp
4837 (use-package saveplace
4842 (setq save-place-file (expand-file-name "saved-places" jj-cache-dir)
4843 (save-place-mode))))
4846 [2014-06-10 Tue 22:05]
4847 #+BEGIN_SRC emacs-lisp
4848 (use-package simple-httpd
4849 :ensure simple-httpd
4850 :commands (httpd-start httpd-stop)
4853 (setq httpd-root "/srv/www")
4858 Settings for shell scripts
4859 #+BEGIN_SRC emacs-lisp
4860 (use-package sh-script
4864 (defvar sh-script-initialized nil)
4865 (defun initialize-sh-script ()
4866 (unless sh-script-initialized
4867 (setq sh-script-initialized t)
4868 (setq sh-indent-comment t)
4869 (info-lookup-add-help :mode 'shell-script-mode
4872 '(("(bash)Index")))))
4874 (add-hook 'shell-mode-hook 'initialize-sh-script)))
4877 #+BEGIN_SRC emacs-lisp
4878 (use-package sh-toggle
4879 :bind ("C-. C-z" . shell-toggle))
4882 [2015-02-24 Tue 23:35]
4883 Make =M-n= and =M-p= go forward/backword to the symbol at point.
4884 #+BEGIN_SRC emacs-lisp
4885 (use-package smartscan
4888 :config (global-smartscan-mode t))
4891 By default, Emacs can update the time stamp for the following two
4892 formats if one exists in the first 8 lines of the file.
4895 #+BEGIN_SRC emacs-lisp
4896 (use-package time-stamp
4897 :commands time-stamp
4900 (add-hook 'write-file-hooks 'time-stamp)
4901 (setq time-stamp-active t)
4902 (setq time-stamp-format "%02H:%02M:%02S (%z) - %02d.%02m.%:y from %u (%U) on %s")
4903 (setq time-stamp-old-format-warn nil)
4904 (setq time-stamp-time-zone nil)))
4908 We configure only a bit of the tiny-tools to load when I should need
4909 them. I don't need much actually, but these things are nice to have.
4911 #+BEGIN_SRC emacs-lisp
4912 (autoload 'turn-on-tinyperl-mode "tinyperl" "" t)
4913 (add-hook 'perl-mode-hook 'turn-on-tinyperl-mode)
4914 (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode)
4916 (autoload 'tinycomment-indent-for-comment "tinycomment" "" t)
4917 (autoload 'tinyeat-forward-preserve "tinyeat" "" t)
4918 (autoload 'tinyeat-backward-preserve "tinyeat" "" t)
4919 (autoload 'tinyeat-kill-line-backward "tinyeat" "" t)
4921 *** Keyboard changes for tiny-tools
4922 #+BEGIN_SRC emacs-lisp
4923 (bind-key "\M-;" 'tinycomment-indent-for-comment)
4924 (bind-key "ESC C-k" 'tinyeat-kill-line-backward)
4925 (bind-key "ESC d" 'tinyeat-forward-preserve)
4926 (bind-key "<M-backspace>" 'tinyeat-backward-preserve)
4927 (bind-key "<S-backspace>" 'tinyeat-delete-whole-word)
4930 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
4931 #+BEGIN_SRC emacs-lisp
4936 ;(setq tramp-persistency-file-name (expand-file-name "tramp" jj-cache-dir))
4937 (setq shell-prompt-pattern "^[^a-zA-Z].*[#$%>] *")
4938 ;(add-to-list 'tramp-default-method-alist '("\\`localhost\\'" "\\`root\\'" "su"))
4939 (setq tramp-debug-buffer nil)
4940 (setq tramp-default-method "sshx")
4941 ;(tramp-set-completion-function "ssh"
4942 ; '((tramp-parse-sconfig "/etc/ssh_config")
4943 ; (tramp-parse-sconfig "~/.ssh/config")))
4944 ;(setq tramp-verbose 5)
4949 For some reason I prefer this mode more than the way without. I want to
4950 see the marked region.
4951 #+BEGIN_SRC emacs-lisp
4952 (transient-mark-mode 1)
4953 (make-variable-buffer-local 'transient-mark-mode)
4954 (put 'transient-mark-mode 'permanent-local t)
4955 (setq-default transient-mark-mode t)
4958 [2013-04-21 So 11:07]
4959 Emacs undo is pretty powerful - but can also be confusing. There are
4960 tons of modes available to change it, even downgrade it to the very
4961 crappy ways one usually knows from other systems which lose
4962 information. undo-tree is different - it helps keeping you sane while
4963 keeping the full power of emacs undo/redo.
4964 #+BEGIN_SRC emacs-lisp
4965 (use-package undo-tree
4967 :diminish undo-tree-mode
4970 (global-undo-tree-mode)
4971 (setq undo-tree-visualizer-timestamps t)
4972 (setq undo-tree-visualizer-diff t)
4973 ;; Keep region when undoing in region
4974 (defadvice undo-tree-undo (around keep-region activate)
4976 (let ((m (set-marker (make-marker) (mark)))
4977 (p (set-marker (make-marker) (point))))
4986 Always have unique buffernames. See [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html][Uniquify - GNU Emacs Manual]]
4987 #+BEGIN_SRC emacs-lisp
4988 (use-package uniquify
4991 (setq uniquify-buffer-name-style 'post-forward)
4992 (setq uniquify-after-kill-buffer-p t)
4993 (setq uniquify-ignore-buffers-re "^\\*")))
4997 url contains code to parse and handle URLs - who would have thought? I
4998 set it to send Accept-language header and tell it to not send email,
4999 operating system or location info.
5000 #+BEGIN_SRC emacs-lisp
5001 (setq url-mime-language-string "de,en")
5002 (setq url-privacy-level (quote (email os lastloc)))
5005 [2014-06-01 Sun 21:38]
5006 visual-regexp for Emacs is like replace-regexp, but with live visual
5007 feedback directly in the buffer
5008 #+BEGIN_SRC emacs-lisp
5009 (use-package visual-regexp
5010 :ensure visual-regexp
5011 :bind (("C-M-%" . vr/replace)
5012 ("M-%" . vr/query-replace)
5013 ("C-c m" . vr/mc-mark))
5016 ** volatile highlights
5017 [2013-04-21 So 20:31]
5018 VolatileHighlights highlights changes to the buffer caused by commands
5019 such as ‘undo’, ‘yank’/’yank-pop’, etc. The highlight disappears at the
5020 next command. The highlighting gives useful visual feedback for what
5021 your operation actually changed in the buffer.
5022 #+BEGIN_SRC emacs-lisp
5023 (use-package volatile-highlights
5024 :ensure volatile-highlights
5026 (volatile-highlights-mode t)
5027 :diminish volatile-highlights-mode)
5030 [2015-09-28 Mon 14:48]
5031 #+BEGIN_SRC emacs-lisp
5036 (setq wgrep-auto-save-buffer t)
5037 (setq wgrep-enable-key "r")
5042 [2015-02-23 Mon 14:38]
5043 Easily move between splitted windows.
5044 #+BEGIN_SRC emacs-lisp
5045 (use-package windmove
5048 (windmove-default-keybindings)
5050 ;(setq org-replace-disputed-keys t)
5053 ** winner mode - undo and redo window configuration
5054 [2015-02-24 Tue 23:11]
5055 =winner-mode= lets you use =C-c <left>= and =C-c <right>= to switch between
5056 window configurations. This is handy when something has popped up a
5057 buffer that you want to look at briefly before returning to whatever
5058 you were working on. When you're done, press =C-c <left>=.
5059 #+BEGIN_SRC emacs-lisp
5063 :config (winner-mode 1))
5066 This highlights some /weaselwords/, a mode to /aid in finding common
5067 writing problems/...
5068 [2013-04-27 Sa 23:29]
5069 #+BEGIN_SRC emacs-lisp :tangle no
5070 (use-package writegood-mode
5071 :ensure writegood-mode
5074 (bind-key "C-c g" 'writegood-mode))
5077 [2014-06-01 Sun 22:48]
5078 #+BEGIN_SRC emacs-lisp
5079 (use-package web-mode
5082 :mode (("\\.phtml\\'" . web-mode)
5083 ("\\.tpl\\.php\\'" . web-mode)
5084 ("\\.jsp\\'" . web-mode)
5085 ("\\.as[cp]x\\'" . web-mode)
5086 ("\\.erb\\'" . web-mode)
5087 ("\\.mustache\\'" . web-mode)
5088 ("\\.html\\'" . web-mode)
5089 ("\\.css\\'" . web-mode)
5090 ("\\.djhtml\\'" . web-mode))
5093 (add-hook 'web-mode-hook
5095 (setq web-mode-markup-indent-offset 2)
5096 (setq web-mode-css-indent-offset 2)
5097 (setq web-mode-code-indent-offset 2)
5098 (setq web-mode-enable-css-colorization t)