e39e3514cfa7854f8a02dce0748b7cb20d113c3b
[emacs.git] / .emacs.d / config / emacs.org
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
6 #+LATEX_CMD: xelatex
7 #+PROPERTY: header-args :tangle yes
8 # @compile: (message "FOO")
9 # @compile: (byte-compile-file "config.el")
10
11 * Base settings, Stuff without an extra package
12 ** Configure package loading
13 That is, most of my emacs packages are taken from Melpa/Elpa/Marmalade, so configure
14 emacs that it can fetch them if needed.
15 And while compiling the .emacs.el we need use-package, but we don't want it during
16 normal runtime.
17 #+BEGIN_SRC emacs-lisp
18 ;; Disable package initialize after us. We either initialize it
19 ;; anyway in case of interpreted .emacs, or we don't want slow
20 ;; initizlization in case of byte-compiled .emacs.elc.
21 (setq package-enable-at-startup nil)
22
23 ;; Ask package.el to not add (package-initialize) to .emacs.
24 (setq package--init-file-ensured t)
25
26 (require 'package)
27 (setq package-user-dir (expand-file-name "elpa" jj-elisp-dir))
28 (dolist (source '(("melpa" . "http://melpa.org/packages/")
29 ("melpa-stable" . "http://stable.melpa.org/packages/")
30 ("marmalade" . "http://marmalade-repo.org/packages/")
31 ;("elpy" . "http://jorgenschaefer.github.io/packages/")
32 ("elpa" . "http://elpa.gnu.org/packages/")
33 ))
34 (add-to-list 'package-archives source t))
35 (package-initialize)
36
37
38 ;; set use-package-verbose to t for interpreted .emacs,
39 ;; and to nil for byte-compiled .emacs.elc
40 (eval-and-compile
41 (setq use-package-verbose (not (bound-and-true-p byte-compile-current-file))))
42
43 ;; Add the macro generated list of package.el loadpaths to load-path.
44 (mapc #'(lambda (add) (add-to-list 'load-path add))
45 (eval-when-compile
46 (package-initialize)
47 ;; Install use-package if not installed yet.
48 (unless (package-installed-p 'use-package)
49 (package-refresh-contents)
50 (package-install 'use-package))
51 (let ((package-user-dir-real (file-truename package-user-dir)))
52 ;; The reverse is necessary, because outside we mapc
53 ;; add-to-list element-by-element, which reverses.
54 (nreverse (apply #'nconc
55 ;; Only keep package.el provided loadpaths
56 (mapcar #'(lambda (path)
57 (if (string-prefix-p package-user-dir-real path)
58 (list path)
59 nil))
60 load-path))))))
61
62 (eval-when-compile
63 (require 'use-package))
64 (require 'bind-key)
65 (use-package diminish
66 :ensure t)
67 #+END_SRC
68
69 ** Tangle on save
70 Tangle my config on save, so next startup shouldn't need to do it.
71
72 #+BEGIN_SRC emacs-lisp
73 ;; This is GPLv2. If you still don't know the details, read
74 ;; http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
75 ;; Taken from https://bitbucket.org/holgerschurig/emacsconf/src/588093924ef8c1d44e7c11b9612f5aad7f6558ce/config.org?at=master
76 (defun my-tangle-config-org-hook-func ()
77 (when (string-prefix-p "emacs.org" (buffer-name))
78 (let ((orgfile (expand-file-name "emacs.org" (file-name-directory (or load-file-name (buffer-file-name)))))
79 (elfile (expand-file-name "emacs.el" (file-name-directory (or load-file-name (buffer-file-name))))))
80 (my-tangle-config-org orgfile elfile))))
81 (add-hook 'after-save-hook #'my-tangle-config-org-hook-func)
82 #+END_SRC
83
84 ** Schema validation for the config
85 [2016-10-30 Sun 17:15]
86 #+BEGIN_SRC emacs-lisp
87 (use-package validate
88 :ensure t)
89 #+END_SRC
90
91 ** safe-load
92 safe-load does not break emacs initialization, should a file be
93 unreadable while emacs boots up.
94 #+BEGIN_SRC emacs-lisp
95 (defvar safe-load-error-list ""
96 "*List of files that reported errors when loaded via safe-load")
97
98 (defun safe-load (file &optional noerror nomessage nosuffix)
99 "Load a file. If error on load, report back, wait for
100 a key stroke then continue on"
101 (interactive "f")
102 (condition-case nil (load file noerror nomessage nosuffix)
103 (error
104 (progn
105 (setq safe-load-error-list (concat safe-load-error-list " " file))
106 (message "****** [Return to continue] Error loading %s" safe-load-error-list )
107 (sleep-for 1)
108 nil))))
109
110 (defun safe-load-check ()
111 "Check for any previous safe-load loading errors. (safe-load.el)"
112 (interactive)
113 (if (string-equal safe-load-error-list "") ()
114 (message (concat "****** error loading: " safe-load-error-list))))
115 #+END_SRC
116 ** Local autoloads
117 I have some stuff put away in my local dir. I don't want to load it all
118 at startup time, so it is using the autoload feature. For that to work
119 load the loaddefs, so autoload knows where to grab stuff
120 #+BEGIN_SRC emacs-lisp
121 ;(safe-load (concat jj-elisp-dir "/tiny/loaddefs.el"))
122 (safe-load (concat jj-elisp-local-dir "/loaddefs.el"))
123 #+END_SRC
124 ** hook-into-modes
125 [2014-05-20 Tue 22:36]
126 #+BEGIN_SRC emacs-lisp
127 ;; (defmacro hook-into-modes (func modes)
128 ;; `(dolist (mode-hook ,modes)
129 ;; (add-hook mode-hook ,func)))
130
131 (defmacro hook-into-modes (function mode-hooks)
132 "Add FUNCTION to hooks in MODE-HOOKS."
133 `(dolist (hook ,mode-hooks)
134 (add-hook hook ,function)))
135 #+END_SRC
136 ** add-auto-mode
137 Handier way to add modes to auto-mode-alist
138 #+BEGIN_SRC emacs-lisp
139 (defun add-auto-mode (mode &rest patterns)
140 "Add entries to `auto-mode-alist' to use `MODE' for all given file `PATTERNS'."
141 (dolist (pattern patterns)
142 (add-to-list 'auto-mode-alist (cons pattern mode))))
143 #+END_SRC
144
145 ** Load path
146 We need to define the load-path. As I have lots of things I add
147 locally, its getting a few entries. I disliked the repeated
148 /add-to-list/ lines, so I now just take all subdirectories of
149 jj-elisp-dir and add them.
150
151 #+BEGIN_SRC emacs-lisp
152 (dolist
153 (project (directory-files jj-elisp-dir t "\\w+"))
154 (when (file-directory-p project)
155 (if (string= project "emacs23")
156 (when (version< emacs-version "24")
157 (add-to-list 'load-path project))
158 (add-to-list 'load-path project))
159 ;(byte-recompile-directory project 0)
160 ))
161 #+END_SRC
162
163 ** Info path
164 Help emacs to find the info files
165 #+BEGIN_SRC emacs-lisp :tangle yes
166 (setq Info-directory-list (cons jj-info-dir
167 '("/usr/local/share/info/"
168 "/usr/local/info/"
169 "/usr/local/gnu/info/"
170 "/usr/local/gnu/lib/info/"
171 "/usr/local/gnu/lib/emacs/info/"
172 "/usr/local/emacs/info/"
173 "/usr/local/lib/info/"
174 "/usr/local/lib/emacs/info/"
175 "/usr/share/info/emacs-23"
176 "/usr/share/info/"
177 "/usr/share/info/")))
178 (setq Info-default-directory-list
179 (cons jj-info-dir Info-default-directory-list))
180 #+END_SRC
181 ** Exec path from PATH Environment
182 [2017-03-11 Sat 20:08]
183 #+BEGIN_SRC emacs-lisp
184 (defun set-exec-path-from-shell-PATH ()
185 (let ((path-from-shell (replace-regexp-in-string
186 "[ \t\n]*$"
187 ""
188 (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
189 (setenv "PATH" path-from-shell)
190 (setq exec-path (split-string path-from-shell path-separator))))
191
192 (when window-system (set-exec-path-from-shell-PATH))
193 #+END_SRC
194
195 ** General stuff
196 :PROPERTIES:
197 :ID: 0a1560d9-7e55-47ab-be52-b3a8b8eea4aa
198 :END:
199
200 *** Hide Startup message
201 I dislike the startup message
202 #+BEGIN_SRC emacs-lisp
203 (validate-setq inhibit-splash-screen t)
204 (validate-setq inhibit-startup-message t)
205 #+END_SRC
206
207 *** Linebreak at 72
208 Usually I want the lines to break at 72 characters.
209 #+BEGIN_SRC emacs-lisp
210 (validate-setq fill-column 72)
211 #+END_SRC
212
213 *** Require final newline
214 And it is nice to have a final newline in files.
215 #+BEGIN_SRC emacs-lisp
216 (validate-setq require-final-newline nil)
217 (validate-setq mode-require-final-newline nil)
218 #+END_SRC
219
220 *** Autosave
221 After I typed 300 characters or took a break for more than a minute it
222 would be nice of emacs to save whatever I am on in one of its auto-save
223 backups. See [[info:emacs#Auto%20Save%20Control][info:emacs#Auto Save Control]] for more details.
224 #+BEGIN_SRC emacs-lisp
225 (validate-setq auto-save-interval 300)
226 (validate-setq auto-save-timeout 60)
227 #+END_SRC
228
229 *** Name and mail settings
230 Set my full name and my default mail address - for whatever wants to use
231 it later. Also, I am using gnus.
232 #+BEGIN_SRC emacs-lisp
233 (validate-setq user-full-name "Joerg Jaspert")
234 (validate-setq user-mail-address "joerg@ganneff.de")
235 (validate-setq mail-user-agent (quote gnus-user-agent))
236 #+END_SRC
237
238 *** Smtpmail
239 My default mail server. Well, simply a localhost, I have a forwarder that
240 puts mail off the right way, no need for emacs to have any further
241 knowledge here.
242 #+BEGIN_SRC emacs-lisp
243 (use-package smtpmail
244 :ensure t
245 :config
246 (progn
247 (validate-setq smtpmail-default-smtp-server "localhost")
248 (validate-setq smtpmail-smtp-server "localhost")))
249 #+END_SRC
250
251 *** Compressed files
252 Enable automatic handling of compressed files.
253 #+BEGIN_SRC emacs-lisp
254 (auto-compression-mode 1)
255 #+END_SRC
256
257 *** Advanced commands
258 Emacs forbids a certain set of commands, as they can be very confusing
259 for new users. Enable them.
260 #+BEGIN_SRC emacs-lisp
261 (put 'narrow-to-region 'disabled nil)
262 (put 'narrow-to-page 'disabled nil)
263 (put 'narrow-to-defun 'disabled nil)
264 (put 'upcase-region 'disabled nil)
265 (put 'downcase-region 'disabled nil)
266 #+END_SRC
267
268 *** Adjust recenter
269 Recenter in a different order - first go to top, then middle, then
270 bottom
271 #+BEGIN_SRC emacs-lisp
272 (validate-setq recenter-positions '(top middle bottom))
273 #+END_SRC
274
275 ** Look / Theme
276 *** Font
277 I've tried various different fonts and while I like the Terminus font
278 most for my shells, in Emacs Inconsolata clearly wins.
279 #+BEGIN_SRC emacs-lisp
280 (set-frame-font "Inconsolata-14")
281 #+END_SRC
282
283 *** Background dark
284 I always use dark backgrounds, so tell Emacs about it. No need to
285 guess around.
286 #+BEGIN_SRC emacs-lisp
287 (setq-default frame-background-mode jj-color-style)
288 #+END_SRC
289
290 *** Color theme
291 And I always liked dark backgrounds with colors setup for them. So I
292 switched through multiple themes doing it in emacs too, but never
293 entirely liked it. Until I found solarized, which is now not only my
294 emacs theme, but also for most of my other software too, especially my
295 shell. Consistent look is great.
296 #+BEGIN_SRC emacs-lisp
297 (use-package solarized-theme
298 :ensure solarized-theme
299 :init
300 (progn
301 (defun jj-init-theme ()
302 (interactive)
303
304 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
305 (load-theme 'solarized-light t))
306 (set-face-attribute 'org-date nil :underline nil)
307 (message "Initializing theme solarized-dark")
308 )
309
310 ;; ;; make the fringe stand out from the background
311 (setq solarized-distinct-fringe-background t)
312
313 ;; ;; Don't change the font for some headings and titles
314 ;; (validate-setq solarized-use-variable-pitch nil)
315
316 ;; ;; make the modeline high contrast
317 ;; (validate-setq solarized-high-contrast-mode-line nil)
318
319 ;; ;; Use less bolding
320 ;; (validate-setq solarized-use-less-bold t)
321
322 ;; ;; Use more italics
323 ;; (validate-setq solarized-use-more-italic t)
324
325 ;; ;; Use less colors for indicators such as git:gutter, flycheck and similar
326 ;; (validate-setq solarized-emphasize-indicators nil)
327
328 ;; ;; Don't change size of org-mode headlines (but keep other size-changes)
329 ;; (validate-setq solarized-scale-org-headlines nil)
330
331 ;; ;; Avoid all font-size changes
332 ;; (validate-setq solarized-height-minus-1 1)
333 ;; (validate-setq solarized-height-plus-1 1)
334 ;; (validate-setq solarized-height-plus-2 1)
335 ;; (validate-setq solarized-height-plus-3 1)
336 ;; (validate-setq solarized-height-plus-4 1)
337 (setq x-underline-at-descent-line t)
338
339 (add-to-list 'custom-theme-load-path jj-theme-dir)
340 (add-hook 'after-init-hook 'jj-init-theme)
341 (jj-init-theme)))
342 #+END_SRC
343
344 *** Fringe
345 Make the fringe (gutter) smaller, the argument is a width in pixels (the default is 8)
346 #+BEGIN_SRC emacs-lisp
347 (if (fboundp 'fringe-mode)
348 (fringe-mode 8))
349 #+END_SRC
350
351 *** Line spacing
352 A bit more spacing between buffer lines
353 #+BEGIN_SRC emacs-lisp
354 (setq-default line-spacing 0.1)
355 #+END_SRC
356 *** Cursor changes
357 [2013-04-21 So 20:54]
358 I do not want my cursor to blink.
359 #+BEGIN_SRC emacs-lisp
360 (blink-cursor-mode -1)
361 #+END_SRC
362 *** Menu, Tool and Scrollbar
363 I don't want to see the menu-bar, tool-bar or scrollbar.
364 #+BEGIN_SRC emacs-lisp
365 (when window-system
366 (dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode))
367 (when (fboundp mode) (funcall mode -1))))
368 #+END_SRC
369 **** When using emacs in daemon mode
370 Emacs has a very nice mode where it detaches itself and runs as daemon -
371 and you can just open /frames/ (windows) from it by using [[http://www.emacswiki.org/emacs/EmacsClient][Emacs
372 Client]]. It's fast, it's nice, it's convinient.
373
374 Except that Emacs behaves stupid when you do that and ignores your
375 menu/tool/scrollbar settings. Sucks.
376
377 For them to work even then, we have to do two things.
378 1. We have to set the frame alist. We simple set both,
379 =initial-frame-alist= and =default-frame-alist= to the same value here.
380 #+BEGIN_SRC emacs-lisp
381 (setq initial-frame-alist '(
382 (horizontal-scroll-bars . nil)
383 (vertical-scroll-bars . nil)
384 (menu-bar-lines . 0)
385 (tool-bar-lines . 0)
386 ))
387 (setq default-frame-alist (copy-alist initial-frame-alist))
388 #+END_SRC
389
390 *** Hilight current line in buffer
391 As it says, it does a hilight of the current line.
392 #+BEGIN_SRC emacs-lisp
393 (global-hl-line-mode +1)
394 #+END_SRC
395 *** Allow recursive minibuffers
396 This allows (additional) minibuffer commands while in the minibuffer.
397 #+BEGIN_SRC emacs-lisp
398 (validate-setq enable-recursive-minibuffers 't)
399 #+END_SRC
400 *** No GC during minibuffer action
401 [2016-02-15 Mon 22:09]
402 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.
403 #+BEGIN_SRC emacs-lisp
404 (defun my-minibuffer-setup-hook ()
405 (validate-setq gc-cons-threshold most-positive-fixnum))
406
407 (defun my-minibuffer-exit-hook ()
408 (validate-setq gc-cons-threshold 16777216))
409
410 (add-hook 'minibuffer-setup-hook #'my-minibuffer-setup-hook)
411 (add-hook 'minibuffer-exit-hook #'my-minibuffer-exit-hook)
412 #+END_SRC
413 *** Modeline related changes
414 I want to see line and column numbers, so turn them on.
415 Size indication lets me know how far I am in a buffer.
416
417 And modeline-posn is great. It will hilight the column number in the
418 modeline in red as soon as you are over the defined limit.
419 #+BEGIN_SRC emacs-lisp
420 (line-number-mode 1)
421 (column-number-mode 1)
422 (size-indication-mode 1)
423 (display-time-mode 1)
424 (validate-setq display-time-day-and-date nil)
425 (validate-setq display-time-default-load-average nil)
426 (validate-setq display-time-24hr-format t)
427 (validate-setq display-time-mail-string "")
428 (validate-setq display-time-default-load-average nil)
429 (validate-setq display-time-interval 15)
430 (setq modelinepos-column-limit 72)
431
432 (use-package modeline-posn
433 :ensure t
434 :config
435 (progn
436 (set-face-foreground 'modelinepos-column-warning "grey20")
437 (set-face-background 'modelinepos-column-warning "red")
438 (setq modelinepos-column-limit 72))
439 )
440 #+END_SRC
441
442 **** diminish
443 [2013-04-22 Mon 11:27]
444 The modeline is easily cluttered up with stuff I don't really need to
445 see. So lets hide those. There are two ways, one of them uses diminish
446 to get entirely rid of some modes, the other is a function taken from
447 "Mastering Emacs" which replaces the modes text with an own (set of)
448 character(s).
449 #+BEGIN_SRC emacs-lisp
450 (require 'diminish)
451 (diminish 'auto-fill-function)
452 (defvar mode-line-cleaner-alist
453 `((auto-complete-mode . " α")
454 (yas-minor-mode . " y")
455 (paredit-mode . " π")
456 (eldoc-mode . "")
457 (abbrev-mode . "")
458 (golden-ratio-mode . "")
459 ;; Major modes
460 (lisp-interaction-mode . "λ")
461 (hi-lock-mode . "")
462 (python-mode . "Py")
463 (emacs-lisp-mode . "EL")
464 (org-mode . "Ω")
465 (org-indent-mode . "")
466 (sh-mode . " Σ")
467 (nxhtml-mode . "nx")
468 (subword-mode . ""))
469
470 "Alist for `clean-mode-line'.
471
472 When you add a new element to the alist, keep in mind that you
473 must pass the correct minor/major mode symbol and a string you
474 want to use in the modeline *in lieu of* the original.
475
476 Want some symbols? Go:
477
478 ;ςερτζθιοπασδφγηξκλυχψωβνμ
479 :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
480 @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
481 ☃⌕☥
482 ")
483
484 ; (add-hook 'after-change-major-mode-hook 'clean-mode-line)
485 #+END_SRC
486 Unfortunately icicles breaks this with the way it adds/removes itself,
487 so take it our for now...
488
489 **** Default mode
490 Back when I started with text-mode. But nowadays I want default mode to
491 be org-mode - it is just so much better to use. And does sensible things
492 with many README files out there, and various other "crap" you get to
493 read in emacs.
494 #+BEGIN_SRC emacs-lisp :tangle yes
495 (setq-default major-mode 'org-mode)
496 #+END_SRC
497
498 *** Don't query to kill processes at exit
499 [2016-10-03 Mo 14:05]
500 The variable at t (its default) lets emacs query before killing
501 processes when exiting.
502 #+BEGIN_SRC emacs-lisp :tangle yes
503 ;;(validate-setq confirm-kill-processes nil)
504 (validate-setq kill-buffer-query-functions
505 (delq 'process-kill-buffer-query-function kill-buffer-query-functions))
506 #+END_SRC
507 ** Keyboard related changes
508 *** Cycle Spacing
509 This lets M-SPC cycle through spacing, that is
510 1. replace all spaces with a single space
511 2. remove all spaces
512 3. restore the original spacing
513 #+BEGIN_SRC emacs-lisp :tangle yes
514 (bind-key "M-SPC" 'cycle-spacing)
515 #+END_SRC
516 *** Toggle/Cycle letter case
517 [2015-05-22 Fri 22:42]
518
519 This is from [[http://ergoemacs.org/emacs/modernization_upcase-word.html][Emacs: Toggle/Cycle Letter Case]]
520
521 Emacs has several user level commands for changing letter case. They
522 are: upcase-word 【Alt+u】, downcase-word 【Alt+l】, capitalize-word
523 【Alt+c】.
524
525 There are also “region” versions for each: upcase-region 【Ctrl+x
526 Ctrl+u】, downcase-region 【Ctrl+x Ctrl+l】, capitalize-region, and
527 also upcase-initials-region. (Note: for elisp programing, there are
528 also these functions: upcase, capitalize, downcase, upcase-initials.)
529
530 One problem with these commands is that you need to move your cursor
531 to the beginning of the word first. For example, if you have the text
532 “THat”, and your cursor is on the “a”, and you call downcase-word, but
533 it doesn't do anything because it only start at the cursor point to
534 end of word. It would be nice if it'll just automatically perform the
535 operation on the whole word.
536
537 Another problem is that it does not consider the final result. For
538 example, if you have “oncE upon a time …”, and you select the whole
539 sentence and call upcase-initials-region, it becomes “OncE Upon A Time
540 …”. Note the capital E is not automatically lowered. For elisp
541 programing, the orthogonal precision is nice, but as user commands, it
542 is better to change the whole sentence.
543
544 Also, these commands have a “-word” and “-region” variants, great for
545 precision in elisp programing but not smart as user commands. It would
546 be nice if emacs automatically choose the right command depending
547 whether there is text selection.
548 #+BEGIN_SRC emacs-lisp :tangle yes
549 (bind-key "M-c" 'toggle-letter-case)
550 #+END_SRC
551 *** Faster pop-to-mark command
552 [2015-12-22 Di 14:56]
553 From [[http://endlessparentheses.com/faster-pop-to-mark-command.html?source=rss][Endless Parentheses]], a nice way to pop back in the marks.
554 #+BEGIN_SRC emacs-lisp :tangle yes
555 ;; When popping the mark, continue popping until the cursor
556 ;; actually moves
557 (defadvice pop-to-mark-command (around ensure-new-position activate)
558 (let ((p (point)))
559 (dotimes (i 10)
560 (when (= p (point)) ad-do-it))))
561 (validate-setq set-mark-command-repeat-pop t)
562 #+END_SRC
563 *** Don't kill-buffer, kill-this-buffer instead
564 From [[http://pragmaticemacs.com/emacs/dont-kill-buffer-kill-this-buffer-instead/][Pragmatic Emacs]]: By default C-x k runs the command kill-buffer
565 which prompts you for which buffer you want to kill, defaulting to the
566 current active buffer. I don’t know about you, but I rarely want to
567 kill a different buffer than the one I am looking at, so I rebind C-x
568 k to kill-this-buffer which just kills the current buffer without
569 prompting (unless there are unsaved changes).
570 #+BEGIN_SRC emacs-lisp :tangle yes
571 (global-set-key (kbd "C-x k") 'kill-this-buffer)
572 #+END_SRC
573 *** Bind sort-lines
574 [2016-10-25 Di 13:38]
575 Its really helpful, but doesn't seem to have a default keybinding, so
576 make up our own.
577 #+BEGIN_SRC emacs-lisp
578 (bind-key "C-c C-s" 'sort-lines)
579 #+END_SRC
580 *** Bind mark-sexp to an easier to reach combo
581 [2017-09-01 Fri 09:14]
582 #+BEGIN_SRC emacs-lisp
583 (bind-key "C-c C-q" 'mark-sexp)
584 #+END_SRC
585
586 ** Miscellaneous stuff
587 *** Isearch related
588 Incremental search is great, but annoyingly you need to type whatever
589 you want. If you want to search for just the next (or previous)
590 occurence of what is at your cursor position use the following.
591 *C-x* will insert the current word while *M-up* and *M-down* will just
592 jump to the next/previous occurence of it.
593 #+BEGIN_SRC emacs-lisp
594 (bind-key "C-x" 'sacha/isearch-yank-current-word isearch-mode-map)
595 (bind-key* "<M-up>" 'sacha/search-word-backward)
596 (bind-key* "<M-down>" 'sacha/search-word-forward)
597 #+END_SRC
598
599 *** Frame configuration
600 I want to see the buffername and its size, not the host I am on in my
601 frame title.
602 #+BEGIN_SRC emacs-lisp
603 (validate-setq frame-title-format "%b (%i)")
604 #+END_SRC
605
606 *** yes-or-no-p
607 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
608 lazy.
609 #+BEGIN_SRC emacs-lisp
610 (defalias 'yes-or-no-p 'y-or-n-p)
611 #+END_SRC
612
613 *** Language/i18n stuff
614 In this day and age, UTF-8 is the way to go.
615 #+BEGIN_SRC emacs-lisp
616 (set-language-environment 'utf-8)
617 (set-default-coding-systems 'utf-8)
618 (set-terminal-coding-system 'utf-8)
619 (set-keyboard-coding-system 'utf-8)
620 (set-clipboard-coding-system 'utf-8)
621 (prefer-coding-system 'utf-8)
622 (set-charset-priority 'unicode)
623 (validate-setq default-process-coding-system '(utf-8-unix . utf-8-unix))
624 (when (display-graphic-p)
625 (validate-setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
626 #+END_SRC
627
628 *** Kill other buffers
629 While many editors allow you to close "all the other files, not the one
630 you are in", emacs doesn't have this... Except, now it will.
631 (Update 30.05.2014: Not used ever, deactivated)
632 #+BEGIN_SRC emacs-lisp :tangle no
633 (bind-key "C-c k" 'prelude-kill-other-buffers)
634 #+END_SRC
635 *** Scrolling
636 Default scrolling behaviour in emacs is a bit annoying, who wants to
637 jump half-windows?
638 #+BEGIN_SRC emacs-lisp
639 (validate-setq scroll-margin 3)
640 (validate-setq scroll-conservatively 100000)
641 (validate-setq scroll-up-aggressively 0.0)
642 (validate-setq scroll-down-aggressively 0.0)
643 (validate-setq scroll-preserve-screen-position 'always)
644 #+END_SRC
645
646 *** Copy/Paste with X
647 [2013-04-09 Di 23:31]
648 The default how emacs handles cutting/pasting with the primary selection
649 changed in emacs24. I am used to the old way, so get it back.
650 #+BEGIN_SRC emacs-lisp
651 (validate-setq select-enable-primary t)
652 (validate-setq select-enable-clipboard nil)
653 (validate-setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
654 (validate-setq mouse-drag-copy-region t)
655 #+END_SRC
656 *** Global keyboard changes not directly related to a mode
657 **** disable suspend frame
658 Disable /suspend_frame/ function, I dislike it.
659 #+BEGIN_SRC emacs-lisp
660 (unbind-key "C-z")
661 (unbind-key "C-x C-z")
662 #+END_SRC
663 **** kill line but move to beginning of it first
664 http://endlessparentheses.com/kill-entire-line-with-prefix-argument.html?source=rss
665 #+BEGIN_SRC emacs-lisp :tangle no
666 (defmacro bol-with-prefix (function)
667 "Define a new function which calls FUNCTION.
668 Except it moves to beginning of line before calling FUNCTION when
669 called with a prefix argument. The FUNCTION still receives the
670 prefix argument."
671 (let ((name (intern (format "endless/%s-BOL" function))))
672 `(progn
673 (defun ,name (p)
674 ,(format
675 "Call `%s', but move to BOL when called with a prefix argument."
676 function)
677 (interactive "P")
678 (when p
679 (forward-line 0))
680 (call-interactively ',function))
681 ',name)))
682
683 (global-set-key [remap paredit-kill] (bol-with-prefix paredit-kill))
684 (global-set-key [remap org-kill-line] (bol-with-prefix org-kill-line))
685 (global-set-key [remap kill-line] (bol-with-prefix kill-line))
686 #+END_SRC
687 **** kill entire line
688 Default of *C-k* is to kill from the point to the end of line. If
689 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
690 set, including newline. But to kill the entire line, one still needs a
691 *C-a* in front of it. So I change it, by defining a function to do just this for
692 me. Lazyness++.
693 #+BEGIN_SRC emacs-lisp :tangle no
694 (defun kill-entire-line ()
695 "Kill this entire line (including newline), regardless of where point is within the line."
696 (interactive)
697 (beginning-of-line)
698 (kill-line)
699 (back-to-indentation))
700
701 (bind-key* "C-k" 'kill-entire-line)
702 (global-set-key [remap kill-whole-line] 'kill-entire-line)
703 #+END_SRC
704
705 And the same is true when I'm in org-mode, which has an own kill function...
706 (the keybinding happens later, after org-mode is loaded fully)
707 #+BEGIN_SRC emacs-lisp :tangle no
708 (defun jj-org-kill-line (&optional arg)
709 "Kill the entire line, regardless of where point is within the line, org-mode-version"
710 (interactive "P")
711 (beginning-of-line)
712 (org-kill-line arg)
713 (back-to-indentation)
714 )
715 #+END_SRC
716 **** No tabs
717 I really hate tabs, so I don't want any indentation to try using them.
718 And in case a project really needs them, I can change it just for that
719 file/project, but luckily none of those I work in is as broken.
720 #+BEGIN_SRC emacs-lisp
721 (setq-default indent-tabs-mode nil)
722 #+END_SRC
723 **** match paren
724 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
725 #+BEGIN_SRC emacs-lisp
726 (bind-key* "M-5" 'match-paren)
727 #+END_SRC
728 **** backward-kill-word
729 Instead of the default "mark-defun" I want a more readline-like setting.
730 #+BEGIN_SRC emacs-lisp
731 (bind-key "C-M-h" 'backward-kill-word)
732 #+END_SRC
733 **** Align with regexp
734 Align whatever with a regexp.
735 #+BEGIN_SRC emacs-lisp
736 (bind-key "C-x \\" 'align-regexp)
737 #+END_SRC
738 **** Font size changes
739 #+BEGIN_SRC emacs-lisp
740 (bind-key "C-+" 'text-scale-increase)
741 (bind-key "C--" 'text-scale-decrease)
742 #+END_SRC
743 **** rgrep
744 Rgrep is infinitely useful in multi-file projects.
745 #+begin_src emacs-lisp
746 ; (bind-key "C-x C-g" 'rgrep)
747 (bind-key "C-x C-g" 'counsel-ag)
748 #+end_src
749 **** Transpose lines
750 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
751 AKA transpose lines.
752 #+BEGIN_SRC emacs-lisp
753 (bind-key "<M-S-up>" 'move-line-up)
754 (bind-key "<M-S-down>" 'move-line-down)
755 #+END_SRC
756 **** "Pull" lines up, join them
757 #+BEGIN_SRC emacs-lisp
758 (defun join-line-or-lines-in-region ()
759 "Join this line or the lines in the selected region.
760 Joins single lines in reverse order to the default, ie. pulls the next one up."
761 (interactive)
762 (cond ((region-active-p)
763 (let ((min (line-number-at-pos (region-beginning))))
764 (goto-char (region-end))
765 (while (> (line-number-at-pos) min)
766 (join-line ))))
767 (t (let ((current-prefix-arg '(4)))
768 (call-interactively 'join-line)))))
769 (bind-key "M-j" 'join-line-or-lines-in-region)
770 #+END_SRC
771 **** Let enter indent next line
772 When I press Enter I almost always want to go to the right indentation on the next line.
773 #+BEGIN_SRC emacs-lisp
774 (bind-key "RET" 'newline-and-indent)
775 #+END_SRC
776 **** Easier undo
777 and i don't need suspend-frame
778 #+BEGIN_SRC emacs-lisp
779 (bind-key "C-z" 'undo)
780 #+END_SRC
781 **** Window switching, go backwards. (C-x o goes to the next window)
782 #+BEGIN_SRC emacs-lisp
783 (bind-key "C-x O" (lambda ()
784 (interactive)
785 (other-window -1)))
786 #+END_SRC
787 **** Edit file as root
788 #+BEGIN_SRC emacs-lisp
789 (bind-key "C-x C-r" 'prelude-sudo-edit)
790 #+END_SRC
791 **** Just one space with newline
792 M-space is bound to just-one-space, which is great for programming. What
793 it does is remove all spaces around the cursor, except for one. But to
794 be really useful, it also should include newlines. It doesn’t do this by
795 default. Rather, you have to call it with a negative argument. Sure
796 not, bad Emacs.
797 #+BEGIN_SRC emacs-lisp
798 (bind-key "M-SPC" 'just-one-space-with-newline)
799 #+END_SRC
800 **** Count which commands I use how often.
801 #+BEGIN_SRC emacs-lisp :tangle no
802 (use-package keyfreq
803 :ensure keyfreq
804 :config
805 (progn
806 (validate-setq keyfreq-file (expand-file-name "keyfreq" jj-cache-dir))
807 (validate-setq keyfreq-file-lock (expand-file-name "keyfreq.lock" jj-cache-dir))
808 (keyfreq-mode 1)
809 (keyfreq-autosave-mode 1)))
810 #+END_SRC
811 **** Duplicate current line
812 #+BEGIN_SRC emacs-lisp
813 (defun duplicate-line ()
814 "Insert a copy of the current line after the current line."
815 (interactive)
816 (save-excursion
817 (let ((line-text (buffer-substring-no-properties
818 (line-beginning-position)
819 (line-end-position))))
820 (move-end-of-line 1)
821 (newline)
822 (insert line-text))))
823
824 (bind-key "C-c p" 'duplicate-line)
825 #+END_SRC
826 **** Smarter move to the beginning of the line.
827 That is, it first moves to the beginning of the line - and on second
828 keypress it goes to the first character on line.
829 #+BEGIN_SRC emacs-lisp
830 (defun smarter-move-beginning-of-line (arg)
831 "Move point back to indentation of beginning of line.
832
833 Move point to the first non-whitespace character on this line.
834 If point is already there, move to the beginning of the line.
835 Effectively toggle between the first non-whitespace character and
836 the beginning of the line.
837
838 If ARG is not nil or 1, move forward ARG - 1 lines first. If
839 point reaches the beginning or end of the buffer, stop there."
840 (interactive "^p")
841 (validate-setq arg (or arg 1))
842
843 ;; Move lines first
844 (when (/= arg 1)
845 (let ((line-move-visual nil))
846 (forward-line (1- arg))))
847
848 (let ((orig-point (point)))
849 (back-to-indentation)
850 (when (= orig-point (point))
851 (move-beginning-of-line 1))))
852
853 ;; remap C-a to `smarter-move-beginning-of-line'
854 (global-set-key [remap move-beginning-of-line]
855 'smarter-move-beginning-of-line)
856
857 #+END_SRC
858 **** Copy characters from previous line
859 Easily copy characters from the previous nonblank line, starting just
860 above point. With a prefix argument, only copy ARG characters (never
861 past EOL), no argument copies rest of line.
862 #+BEGIN_SRC emacs-lisp
863 (use-package misc
864 :bind ("H-y" . copy-from-above-command))
865 #+END_SRC
866 **** Misc keybindings
867 Open a new X Terminal pointing to the directory of the current
868 buffers path.
869 #+BEGIN_SRC emacs-lisp
870 (bind-key "H-t" 'jj-open-shell)
871 #+END_SRC
872
873 Align code
874 #+BEGIN_SRC emacs-lisp
875 (bind-key "H-a" 'align-code)
876 #+END_SRC
877
878 Insert date
879 #+BEGIN_SRC emacs-lisp
880 (bind-key "C-c d" 'insert-date)
881 #+END_SRC
882
883 Another key for indenting
884 #+BEGIN_SRC emacs-lisp
885 (bind-key "H-i" 'indent-region)
886 #+END_SRC
887
888 Clean all whitespace stuff
889 #+BEGIN_SRC emacs-lisp
890 (bind-key "H-w" 'whitespace-cleanup)
891 #+END_SRC
892
893 Comment/Uncomment
894 #+BEGIN_SRC emacs-lisp
895 (bind-key "H-c" 'comment-dwim)
896 #+END_SRC
897
898 Show keystrokes in progress
899 #+BEGIN_SRC emacs-lisp
900 (validate-setq echo-keystrokes 0.1)
901 #+END_SRC
902 **** Overwrite mode
903 Usually you can press the *Ins*ert key, to get into overwrite mode. I
904 don't like that, have broken much with it and so just forbid it by
905 disabling that.
906 #+BEGIN_SRC emacs-lisp
907 (unbind-key "<insert>")
908 (unbind-key "<kp-insert>")
909 #+END_SRC
910
911 **** Easily navigate sillyCased words
912 #+BEGIN_SRC emacs-lisp
913 (global-subword-mode 1)
914 #+END_SRC
915 **** Delete file of current buffer, then kill buffer
916 [2014-06-14 Sat 23:03]
917 #+BEGIN_SRC emacs-lisp
918 (defun delete-current-buffer-file ()
919 "Removes file connected to current buffer and kills buffer."
920 (interactive)
921 (let ((filename (buffer-file-name))
922 (buffer (current-buffer))
923 (name (buffer-name)))
924 (if (not (and filename (file-exists-p filename)))
925 (ido-kill-buffer)
926 (when (yes-or-no-p "Are you sure you want to remove this file? ")
927 (delete-file filename)
928 (kill-buffer buffer)
929 (message "File '%s' successfully removed" filename)))))
930
931 (bind-key "C-x C-k" 'delete-current-buffer-file)
932 #+END_SRC
933 **** Rename file of current buffer
934 [2014-06-14 Sat 23:04]
935 #+BEGIN_SRC emacs-lisp
936 (defun rename-current-buffer-file ()
937 "Renames current buffer and file it is visiting."
938 (interactive)
939 (let ((name (buffer-name))
940 (filename (buffer-file-name)))
941 (if (not (and filename (file-exists-p filename)))
942 (error "Buffer '%s' is not visiting a file!" name)
943 (let ((new-name (read-file-name "New name: " filename)))
944 (if (get-buffer new-name)
945 (error "A buffer named '%s' already exists!" new-name)
946 (rename-file filename new-name 1)
947 (rename-buffer new-name)
948 (set-visited-file-name new-name)
949 (set-buffer-modified-p nil)
950 (message "File '%s' successfully renamed to '%s'"
951 name (file-name-nondirectory new-name)))))))
952
953 (bind-key "C-x C-S-r" 'rename-current-buffer-file)
954 #+END_SRC
955 **** Quickly find emacs lisp sources
956 [2014-06-22 Sun 23:05]
957 #+BEGIN_SRC emacs-lisp
958 (bind-key "C-l" 'find-library 'help-command)
959 (bind-key "C-f" 'find-function 'help-command)
960 (bind-key "C-k" 'find-function-on-key 'help-command)
961 (bind-key "C-v" 'find-variable 'help-command)
962 #+END_SRC
963 *** Adjust occur
964 [2015-01-26 Mon 16:01]
965 #+BEGIN_SRC emacs-lisp
966 (bind-key "M-s o" 'occur-dwim)
967 #+END_SRC
968 *** Searches and matches should ignore case.
969 #+BEGIN_SRC emacs-lisp
970 (setq-default case-fold-search t)
971 #+END_SRC
972 *** Don't display a cursor in non-selected windows.
973 #+BEGIN_SRC emacs-lisp
974 (setq-default cursor-in-non-selected-windows nil)
975 #+END_SRC
976 *** Modeline filetype endings display
977 What should be displayed in the mode-line for files with those types
978 of line endings.
979 #+BEGIN_SRC emacs-lisp
980 (validate-setq eol-mnemonic-dos "(DOS)")
981 (validate-setq eol-mnemonic-mac "(Mac)")
982 #+END_SRC
983
984 #+BEGIN_SRC emacs-lisp
985 (validate-setq max-lisp-eval-depth 1000)
986 (validate-setq max-specpdl-size 3000)
987 #+END_SRC
988 *** Unfill paragraph
989 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
990 #+BEGIN_SRC emacs-lisp
991 (defun unfill-paragraph ()
992 "Takes a multi-line paragraph and makes it into a single line of text."
993 (interactive)
994 (let ((fill-column (point-max)))
995 (fill-paragraph nil)))
996 (bind-key "H-u" 'unfill-paragraph)
997 #+END_SRC
998
999 #+BEGIN_SRC emacs-lisp
1000 (setq-default indicate-empty-lines t)
1001 (validate-setq sentence-end-double-space nil)
1002 #+END_SRC
1003 *** Hilight annotations in comments, like FIXME/TODO/...
1004 #+BEGIN_SRC emacs-lisp :tangle yes
1005 (add-hook 'prog-mode-hook 'font-lock-comment-annotations)
1006 #+END_SRC
1007 *** Wait a bit longer before considering emacs idle
1008 #+BEGIN_SRC emacs-lisp :tangle yes
1009 (validate-setq idle-update-delay 2)
1010 #+END_SRC
1011 *** Make gnutls a bit safer, the default is an absurdly low 256
1012 #+BEGIN_SRC emacs-lisp :tangle yes
1013 (validate-setq gnutls-min-prime-bits 4096)
1014 #+END_SRC
1015 *** Emacs defaults to using --insecure - and supporting ssl3. No thanks.
1016 #+BEGIN_SRC emacs-lisp :tangle yes
1017 (setq tls-program
1018 ;; Defaults:
1019 ;; '("gnutls-cli --insecure -p %p %h"
1020 ;; "gnutls-cli --insecure -p %p %h --protocols ssl3"
1021 ;; "openssl s_client -connect %h:%p -no_ssl2 -ign_eof")
1022 '("gnutls-cli -p %p %h"
1023 "openssl s_client -connect %h:%p -no_ssl2 -no_ssl3 -ign_eof"))
1024 #+END_SRC
1025 *** Resolve symlinks without asking
1026 #+BEGIN_SRC emacs-lisp :tangle no
1027 (setq-default find-file-visit-truename t)
1028 #+END_SRC
1029
1030 #+BEGIN_SRC emacs-lisp :tangle yes
1031 (setq-default bidi-display-reordering nil)
1032 #+END_SRC
1033
1034 *** When saving a script - make it executable
1035 #+BEGIN_SRC emacs-lisp
1036 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
1037 #+END_SRC
1038
1039 *** Emacs Server
1040 #+BEGIN_SRC emacs-lisp
1041 (use-package server
1042 :init
1043 (progn
1044 (add-hook 'after-init-hook 'server-start)))
1045 #+END_SRC
1046 **** Edit-server for chromium extension "Edit with emacs"
1047 [2015-10-15 Thu 22:32]
1048 #+BEGIN_SRC emacs-lisp :tangle no
1049 (use-package edit-server
1050 :config
1051 (progn
1052 (validate-setq edit-server-new-frame nil)
1053 (edit-server-start)))
1054 #+END_SRC
1055 *** Adjust buffer mode for zsh commandline editing buffers
1056 [2017-03-17 Fr 13:35]
1057 I got a handy zsh setup, using edit-command-line widget, so typing C-x
1058 C-e I end up in emacs with whatever is in my commandline. Save, exit -
1059 and commandline is changed to it. Very nice.
1060 Now I want the buffers of it appear in sh-mode by default
1061 #+BEGIN_SRC emacs-lisp
1062 (add-auto-mode 'sh-mode "zshe.*$")
1063 #+END_SRC
1064 *** No need for lockfiles (foo~)
1065 [2017-12-08 Fri 09:29]
1066 #+BEGIN_SRC emacs-lisp
1067 (setq create-lockfiles nil)
1068 (setq make-backup-files nil)
1069
1070 #+END_SRC
1071 * Customized variables
1072 [2013-05-02 Thu 22:14]
1073 The following contains a set of variables i may reasonably want to
1074 change on other systems - which don't affect the init file loading
1075 process. So I *can* use the customization interface for it...
1076 #+BEGIN_SRC emacs-lisp
1077 (defgroup ganneff nil
1078 "Modify ganneffs settings"
1079 :group 'environment)
1080
1081 (defgroup ganneff-org-mode nil
1082 "Ganneffs org-mode settings"
1083 :tag "Ganneffs org-mode settings"
1084 :group 'ganneff
1085 :link '(custom-group-link "ganneff"))
1086
1087 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
1088 "ID of the organization task."
1089 :tag "Organization Task ID"
1090 :type 'string
1091 :group 'ganneff-org-mode)
1092
1093 (defcustom org-my-archive-expiry-days 2
1094 "The number of days after which a completed task should be auto-archived.
1095 This can be 0 for immediate, or a floating point value."
1096 :tag "Archive expiry days"
1097 :type 'float
1098 :group 'ganneff-org-mode)
1099 #+END_SRC
1100
1101 ** Customized variables
1102 :PROPERTIES:
1103 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
1104 :END:
1105 Of course I want to be able to use the customize interface, and some
1106 things can only be set via it (or so they say). I usually prefer to put
1107 things I keep for a long while into statements somewhere else, not just
1108 custom-set here, but we need it anyways.
1109
1110 #+BEGIN_SRC emacs-lisp
1111 (validate-setq custom-file jj-custom-file)
1112 (safe-load custom-file)
1113 #+END_SRC
1114
1115 The source of this is:
1116 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
1117
1118
1119 * Extra modes, additions, thingies, fun
1120 ** abbrev
1121 A defined abbrev is a word which expands, if you insert it, into some
1122 different text. Abbrevs are defined by the user to expand in specific
1123 ways.
1124 Also see [[http://endlessparentheses.com/ispell-and-abbrev-the-perfect-auto-correct.html][Ispell and Abbrev, the Perfect Auto-Correct]].
1125 #+BEGIN_SRC emacs-lisp :tangle yes
1126 (use-package abbrev
1127 :commands abbrev-mode
1128 :diminish abbrev-mode
1129 :bind (:map ctl-x-map
1130 ("C-i" . endless/ispell-word-then-abbrev))
1131 :init
1132 (progn
1133 (setq-default abbrev-mode t)
1134 (hook-into-modes #'abbrev-mode '(text-mode-hook)))
1135 :config
1136 (progn
1137 (validate-setq save-abbrevs 'silently)
1138 (validate-setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
1139 (if (file-exists-p abbrev-file-name)
1140 (quietly-read-abbrev-file))
1141
1142 (add-hook 'expand-load-hook
1143 (lambda ()
1144 (add-hook 'expand-expand-hook 'indent-according-to-mode)
1145 (add-hook 'expand-jump-hook 'indent-according-to-mode)))
1146
1147 (defun endless/ispell-word-then-abbrev (p)
1148 "Call `ispell-word', then create an abbrev for it.
1149 With prefix P, create local abbrev. Otherwise it will
1150 be global.
1151 If there's nothing wrong with the word at point, keep
1152 looking for a typo until the beginning of buffer. You can
1153 skip typos you don't want to fix with `SPC', and you can
1154 abort completely with `C-g'."
1155 (interactive "P")
1156 (let (bef aft)
1157 (save-excursion
1158 (while (if (validate-setq bef (thing-at-point 'word))
1159 ;; Word was corrected or used quit.
1160 (if (ispell-word nil 'quiet)
1161 nil ; End the loop.
1162 ;; Also end if we reach `bob'.
1163 (not (bobp)))
1164 ;; If there's no word at point, keep looking
1165 ;; until `bob'.
1166 (not (bobp)))
1167 (backward-word))
1168 (validate-setq aft (thing-at-point 'word)))
1169 (if (and aft bef (not (equal aft bef)))
1170 (let ((aft (downcase aft))
1171 (bef (downcase bef)))
1172 (define-abbrev
1173 (if p local-abbrev-table global-abbrev-table)
1174 bef aft)
1175 (message "\"%s\" now expands to \"%s\" %sally"
1176 bef aft (if p "loc" "glob")))
1177 (user-error "No typo at or before point"))))
1178 (validate-setq save-abbrevs 'silently)))
1179 #+END_SRC
1180 ** Atomic chrome, edit text from Chrome in Emacs
1181 [2017-03-09 Do 14:56]
1182 #+BEGIN_SRC emacs-lisp
1183 (use-package atomic-chrome
1184 :ensure t
1185 :init
1186 (progn
1187 (atomic-chrome-start-server)))
1188 #+END_SRC
1189 ** ace-window
1190 [2013-04-21 So 20:27]
1191 Use H-w to switch windows
1192 #+BEGIN_SRC emacs-lisp
1193 (use-package ace-window
1194 :ensure ace-window
1195 :commands ace-window
1196 :bind ("H-w" . ace-window)
1197 :config
1198 (progn
1199 (validate-setq aw-keys '(?a ?s ?d ?f ?j ?k ?l))
1200 ))
1201 #+END_SRC
1202 ** anzu
1203 [2014-06-01 Sun 23:02]
1204 Provides a minor mode which displays current match and total matches
1205 information in the mode-line in various search modes.
1206 #+BEGIN_SRC emacs-lisp
1207 (use-package anzu
1208 :ensure anzu
1209 :diminish anzu-mode
1210 :defer t
1211 :init
1212 (global-anzu-mode 1)
1213 :config
1214 (progn
1215 (validate-setq anzu-search-threshold 1000)
1216 (set-face-attribute 'anzu-mode-line nil :foreground "yellow" :weight 'bold)))
1217 #+END_SRC
1218 ** CANCELLED ansible :CANCELLED:
1219 CLOSED: [2017-08-27 So 15:16]
1220 :LOGBOOK:
1221 - State "CANCELLED" from [2017-08-27 So 15:16]
1222 :END:
1223 [2017-08-26 Sa 14:24]
1224 Something for that horrible tool
1225 #+BEGIN_SRC emacs-lisp :tangle no
1226 (use-package ansible
1227 :ensure t)
1228 #+END_SRC
1229 ** avy-mode
1230 [2013-04-28 So 11:26]
1231 avy is a GNU Emacs package for jumping to visible text using a char-based decision tree.
1232 #+BEGIN_SRC emacs-lisp
1233 (use-package avy
1234 :ensure avy
1235 :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)
1236 :bind (("H-SPC" . avy-goto-char-2)
1237 ("M-g g" . avy-goto-line)
1238 :map isearch-mode-map
1239 ("C-y" . avy-isearch)
1240 )
1241 :config
1242 (progn
1243 (validate-setq avy-all-windows 'all-frames)
1244 (setq avi-keys '(?a ?s ?d ?e ?f ?h ?j ?k ?l ?n ?m ?v ?r ?u) )
1245 ))
1246 #+END_SRC
1247 ** Browser
1248 #+BEGIN_SRC emacs-lisp
1249 (use-package browse-url
1250 :ensure t
1251 :commands (browse-url)
1252 :config
1253 (progn
1254 (validate-setq browse-url-browser-function (quote browse-url-generic))
1255 (validate-setq browse-url-generic-program "/usr/bin/x-www-browser")))
1256 #+END_SRC
1257
1258 ** CANCELLED Emacs shell :CANCELLED:
1259 CLOSED: [2017-08-26 Sa 13:55]
1260 :LOGBOOK:
1261 - State "CANCELLED" from [2017-08-26 Sa 13:55] \\
1262 Not using it at the moment
1263 :END:
1264 Basic settings for emacs integrated shell
1265 #+BEGIN_SRC emacs-lisp
1266 (use-package eshell
1267 :defer t
1268 :defines eshell-path-env
1269 :commands eshell
1270 :init
1271 (progn
1272 (defun eshell-initialize ()
1273 (defun eshell-spawn-external-command (beg end)
1274 "Parse and expand any history references in current input."
1275 (save-excursion
1276 (goto-char end)
1277 (when (looking-back "&!" beg)
1278 (delete-region (match-beginning 0) (match-end 0))
1279 (goto-char beg)
1280 (insert "spawn "))))
1281 (add-hook 'eshell-expand-input-functions 'eshell-spawn-external-command)
1282 (eval-after-load "em-unix"
1283 '(progn
1284 (unintern 'eshell/su)
1285 (unintern 'eshell/sudo))))
1286 (add-hook 'eshell-first-time-mode-hook 'eshell-initialize)
1287 )
1288 :config
1289 (progn
1290 (setq eshell-path-env path-from-shell) ; for eshell users
1291 (defalias 'emacs 'find-file)
1292 (defalias 'ec 'find-file)
1293 (defalias 'e 'find-file)
1294
1295 (use-package f
1296 :ensure f)
1297 (use-package 'em-cmpl)
1298 (use-package 'em-prompt)
1299 (use-package 'em-term)
1300
1301 (validate-setq eshell-cmpl-cycle-completions nil
1302 eshell-save-history-on-exit t
1303 eshell-buffer-maximum-lines 20000
1304 eshell-history-size 350
1305 eshell-buffer-shorthand t
1306 eshell-highlight-prompt t
1307 eshell-plain-echo-behavior t
1308 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
1309
1310 (setenv "PAGER" "cat")
1311 (validate-setq eshell-visual-commands
1312 '("less" "tmux" "htop" "top" "bash" "zsh" "tail"))
1313 (validate-setq eshell-visual-subcommands
1314 '(("git" "log" "l" "diff" "show")))
1315
1316 (add-to-list 'eshell-command-completions-alist
1317 '("gunzip" "gz\\'"))
1318 (add-to-list 'eshell-command-completions-alist
1319 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
1320
1321 (when (not (functionp 'eshell/rgrep))
1322 (defun eshell/rgrep (&rest args)
1323 "Use Emacs grep facility instead of calling external grep."
1324 (eshell-grep "rgrep" args t)))
1325
1326 ;(set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
1327 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
1328 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
1329 (add-hook 'eshell-preoutput-filter-functions
1330 'ansi-color-filter-apply)
1331 ;; Prompt with a bit of help from http://www.emacswiki.org/emacs/EshellPrompt
1332
1333 (defmacro with-face (str &rest properties)
1334 `(propertize ,str 'face (list ,@properties)))
1335
1336 (defun eshell/abbr-pwd ()
1337 (let ((home (getenv "HOME"))
1338 (path (eshell/pwd)))
1339 (cond
1340 ((string-equal home path) "~")
1341 ((f-ancestor-of? home path) (concat "~/" (f-relative path home)))
1342 (path))))
1343
1344 (defun eshell/my-prompt ()
1345 (let ((header-bg "#161616"))
1346 (concat
1347 (with-face user-login-name :foreground "cyan")
1348 (with-face (concat "@" hostname) :foreground "white")
1349 " "
1350 (with-face (eshell/abbr-pwd) :foreground "#009900")
1351 (if (= (user-uid) 0)
1352 (with-face "#" :foreground "red")
1353 (with-face "$" :foreground "#69b7f0"))
1354 " ")))
1355
1356 (use-package eshell-prompt-extras
1357 :ensure t
1358 :init
1359 (progn
1360 (validate-setq eshell-highlight-prompt nil
1361 ;; epe-git-dirty-char "Ϟ"
1362 epe-git-dirty-char "*"
1363 eshell-prompt-function 'epe-theme-dakrone)))
1364
1365 (defun eshell/magit ()
1366 "Function to open magit-status for the current directory"
1367 (interactive)
1368 (magit-status default-directory)
1369 nil)
1370
1371 (validate-setq eshell-prompt-function 'eshell/my-prompt)
1372 (validate-setq eshell-highlight-prompt nil)
1373 (validate-setq eshell-prompt-regexp "^[^#$\n]+[#$] ")))
1374 #+END_SRC
1375
1376 ** keep-buffers
1377 I don't want some buffers to be killed, **scratch** for example.
1378 In the past I had a long function that just recreated them, but the
1379 =keep-buffers= package is easier.
1380 #+BEGIN_SRC emacs-lisp
1381 (use-package keep-buffers
1382 :config
1383 (progn
1384 (keep-buffers-mode 1)
1385 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
1386 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
1387 ))
1388 #+END_SRC
1389
1390 ** midnight mode
1391 #+BEGIN_SRC emacs-lisp
1392 (use-package midnight
1393 :ensure t
1394 :init
1395 (midnight-mode)
1396 :config
1397 (progn
1398 (validate-setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
1399 "*Man " "*Buffer List*"
1400 "*Compile-Log*"
1401 "*info*" "*vc*"
1402 "*vc-diff*" "*diff*"
1403 "*Customize"
1404 "*tramp/" "*debug "
1405 "*magit" "*Calendar"
1406 "*eww*")))
1407 (midnight-delay-set 'midnight-delay (* 14 60 60))
1408 ))
1409 #+END_SRC
1410 ** mic-paren
1411 While I do have the nifty shortcut to jump to the other parentheses,
1412 hilighting them makes it obvious where they are.
1413 #+BEGIN_SRC emacs-lisp
1414 (use-package mic-paren
1415 :ensure t
1416 :config
1417 (paren-activate))
1418 #+END_SRC
1419
1420 ** Paradox
1421 Paradox is a nicer interface to the package system
1422 #+BEGIN_SRC emacs-lisp
1423 (use-package paradox
1424 :ensure t
1425 :commands (paradox-list-packages paradox-install paradox-upgrade-packages paradox-enable)
1426 :config
1427 (progn
1428 (setq paradox-github-token t)
1429 ))
1430 :defer 5
1431 :init
1432 (paradox-enable)
1433
1434 #+END_SRC
1435 ** Shell (ZSH)
1436 [2013-04-23 Tue 16:43]
1437 Shell. zsh in my case.
1438 #+BEGIN_SRC emacs-lisp
1439 (use-package shell
1440 :commands (shell)
1441 :defer t
1442 :config
1443 (progn
1444 (validate-setq shell-file-name "zsh")
1445 (validate-setq shell-command-switch "-c")
1446 (validate-setq explicit-shell-file-name shell-file-name)
1447 (setenv "SHELL" shell-file-name)
1448 (setq explicit-sh-args '("-login" "-i"))
1449 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
1450 (validate-setq comint-scroll-to-bottom-on-input t) ; always insert at the bottom
1451 (validate-setq comint-scroll-to-bottom-on-output t) ; always add output at the bottom
1452 (validate-setq comint-scroll-show-maximum-output t) ; scroll to show max possible output
1453 (validate-setq comint-completion-autolist t) ; show completion list when ambiguous
1454 (validate-setq comint-input-ignoredups t) ; no duplicates in command history
1455 (validate-setq comint-completion-addsuffix t) ; insert space/slash after file completion
1456 (validate-setq comint-buffer-maximum-size 20000) ; max lenght of the buffer in lines
1457 (validate-setq comint-prompt-read-only nil) ; if this is t, it breaks shell-command
1458 ))
1459 #+END_SRC
1460
1461 ** ascii
1462 [2014-05-21 Wed 00:33]
1463 #+BEGIN_SRC emacs-lisp
1464 (use-package ascii
1465 :ensure t
1466 :commands (ascii-on ascii-toggle ascii-display)
1467 :bind (("C-c e A" . ascii-toggle))
1468 :init
1469 (progn
1470 (defun ascii-toggle ()
1471 (interactive)
1472 (defvar ascii-display nil)
1473 (if ascii-display
1474 (ascii-off)
1475 (ascii-on)))))
1476 #+END_SRC
1477 ** auctex
1478 #+BEGIN_SRC emacs-lisp
1479 (use-package tex
1480 :ensure auctex
1481 :mode ("\\.tex\\'" . latex-mode)
1482 :commands (latex-mode LaTeX-mode plain-tex-mode)
1483 :config
1484 (progn
1485 (add-hook 'LaTeX-mode-hook #'LaTeX-preview-setup)
1486 (add-hook 'LaTeX-mode-hook #'flyspell-mode)
1487 (add-hook 'LaTeX-mode-hook #'turn-on-reftex)
1488 (setq TeX-auto-save t
1489 TeX-parse-self t
1490 TeX-save-query nil
1491 TeX-PDF-mode t)
1492 (setq-default TeX-master nil)
1493
1494 ;; Compilation command
1495 (add-hook 'LaTeX-mode-hook (lambda () (setq compile-command "latexmk -pdf")))))
1496 #+END_SRC
1497 ** CANCELLED auto-complete mode :CANCELLED:
1498 CLOSED: [2017-12-08 Fri 15:25]
1499 :LOGBOOK:
1500 - State "CANCELLED" from [2017-12-08 Fri 15:25]
1501 :END:
1502 [2013-04-27 Sa 16:33]
1503 And aren't we all lazy? I definitely am, and I like my emacs doing as
1504 much possible work for me as it can.
1505 So here, auto-complete-mode, which lets emacs do this, based on what I
1506 already had typed.
1507 #+BEGIN_SRC emacs-lisp
1508 (use-package auto-complete
1509 :ensure auto-complete
1510 :commands auto-complete-mode
1511 :bind (("C-n" . ac-next)
1512 ("C-p" . ac-previous)
1513 :map ac-complete-mode-map
1514 ("\t" . ac-expand)
1515 ("\r" . ac-complete)
1516 ("M-n" . ac-next)
1517 ("M-p" . ac-previous)
1518 :map ac-mode-map
1519 ("M-TAB" . auto-complete)
1520 :map ac-completing-map
1521 ("C-s" . ac-isearch))
1522 :init
1523 (progn
1524 (auto-complete-mode t))
1525 :config
1526 (progn
1527 (ac-config-default)
1528 ;; hook AC into completion-at-point
1529 (defun sanityinc/auto-complete-at-point ()
1530 (when (and (not (minibufferp))
1531 (fboundp 'auto-complete-mode)
1532 auto-complete-mode)
1533 (auto-complete)))
1534 (defun set-auto-complete-as-completion-at-point-function ()
1535 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
1536 ;; Exclude very large buffers from dabbrev
1537 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
1538 (< (buffer-size other-buffer) (* 1 1024 1024)))
1539
1540 (use-package pos-tip
1541 :ensure t)
1542
1543 (validate-setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
1544 (validate-setq ac-use-comphist t)
1545 (validate-setq ac-expand-on-auto-complete nil)
1546 (validate-setq ac-dwim t)
1547 (validate-setq ac-auto-start 3)
1548 (validate-setq ac-delay 0.3)
1549 (validate-setq ac-menu-height 15)
1550 (validate-setq ac-quick-help-delay 0.5)
1551 (validate-setq ac-use-fuzzy t)
1552
1553 (ac-flyspell-workaround)
1554
1555 ;; use 't when auto-complete is disabled
1556 (validate-setq tab-always-indent 'complete)
1557 (add-to-list 'completion-styles 'initials t)
1558
1559 ;; Use space and punctuation to accept the current the most likely completion.
1560 (setq auto-completion-syntax-alist (quote (global accept . word)))
1561 ;; Avoid completion for short trivial words.
1562 (setq auto-completion-min-chars (quote (global . 3)))
1563 (setq completion-use-dynamic t)
1564
1565 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
1566
1567 ;; Exclude very large buffers from dabbrev
1568 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
1569
1570 (use-package ac-dabbrev
1571 :ensure t)
1572
1573 (set-default 'ac-sources
1574 '(ac-source-imenu
1575 ac-source-dictionary
1576 ac-source-words-in-buffer
1577 ac-source-words-in-same-mode-buffers
1578 ; ac-source-words-in-all-buffer
1579 ac-source-dabbrev))
1580
1581 (dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
1582 sass-mode yaml-mode csv-mode espresso-mode haskell-mode
1583 html-mode nxml-mode sh-mode smarty-mode clojure-mode go-mode
1584 lisp-mode textile-mode markdown-mode tuareg-mode python-mode
1585 js3-mode css-mode less-css-mode sql-mode ielm-mode))
1586 (add-to-list 'ac-modes mode))
1587
1588 (hook-into-modes 'auto-complete-mode '(latex-mode-hook LaTeX-mode-hook prog-mode-hook html-mode lisp-mode css-mode org-mode-hook))))
1589 #+END_SRC
1590 ** company-mode
1591 [2017-12-08 Fri 09:42]
1592 Auto-completion comp any mode.
1593 #+BEGIN_SRC emacs-lisp
1594 (use-package company
1595 :ensure t
1596 :defer t
1597 :diminish company-mode
1598 :init (global-company-mode)
1599 :config
1600 (progn
1601 ;; Use Company for completion
1602 (bind-key [remap completion-at-point] #'company-complete company-mode-map)
1603 (global-company-mode)
1604
1605 (setq company-dabbrev-downcase nil)
1606 (setq company-echo-delay 0)
1607 (setq company-idle-delay 0.2)
1608 (setq company-minimum-prefix-length 2)
1609 (setq company-require-match nil)
1610 (setq company-selection-wrap-around t)
1611 (setq company-show-numbers t)
1612 (setq company-tooltip-align-annotations t)
1613 (setq company-tooltip-flip-when-above t)
1614 (setq company-tooltip-limit 10)
1615 (setq company-transformers '(company-sort-by-occurrence)) ; weight by frequency
1616 ))
1617
1618 (use-package company-quickhelp ; Documentation popups for Company
1619 :ensure t
1620 :defer t
1621 :init (add-hook 'global-company-mode-hook #'company-quickhelp-mode))
1622
1623 (use-package company-statistics
1624 :ensure t
1625 :config
1626 (add-hook 'after-init-hook 'company-statistics-mode))
1627
1628 (use-package company-go
1629 :ensure t
1630 :defer t
1631 :init
1632 (with-eval-after-load 'company
1633 (add-to-list 'company-backends 'company-go)))
1634
1635 (use-package company-auctex
1636 :ensure t)
1637
1638 (use-package company-jedi
1639 :ensure t)
1640 #+END_SRC
1641
1642 ** auto-revert
1643 When files change outside emacs for whatever reason I want emacs to deal
1644 with it. Not to have to revert buffers myself
1645 #+BEGIN_SRC emacs-lisp
1646 (use-package autorevert
1647 :commands auto-revert-mode
1648 :diminish auto-revert-mode
1649 :init
1650 (progn
1651 (validate-setq global-auto-revert-mode t)
1652 (setq global-auto-revert-non-file-buffers t)
1653 (global-auto-revert-mode)))
1654 #+END_SRC
1655
1656 ** CANCELLED backups :CANCELLED:
1657 CLOSED: [2017-08-26 Sa 14:41]
1658 Emacs should keep backup copies of files I edit, but I do not want them
1659 to clutter up the filesystem everywhere. So I put them into one defined
1660 place, backup-directory, which even contains my username (for systems
1661 where =temporary-file-directory= is not inside my home).
1662 #+BEGIN_SRC emacs-lisp :tangle no
1663 (use-package backups-mode
1664 :load-path "elisp/backups-mode"
1665 :disabled t
1666 :bind (("\C-cv" . save-version)
1667 ("\C-cb" . list-backups)
1668 ("\C-ck" . kill-buffer-prompt)
1669 ("\C-cw" . backup-walker-start))
1670 :init
1671 (progn
1672 (validate-setq backup-directory jj-backup-directory)
1673 ; (validate-setq tramp-backup-directory (concat jj-backup-directory "/tramp"))
1674 ; (if (not (file-exists-p tramp-backup-directory))
1675 ; (make-directory tramp-backup-directory))
1676 ; (validate-setq tramp-backup-directory-alist `((".*" . ,tramp-backup-directory)))
1677 (validate-setq backup-directory-alist `(("." . ,jj-backup-directory)))
1678 (validate-setq auto-save-list-file-prefix (concat jj-backup-directory ".auto-saves-"))
1679 (validate-setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
1680
1681 (validate-setq version-control t) ;; Use version numbers for backups
1682 (validate-setq kept-new-versions 10) ;; Number of newest versions to keep
1683 (validate-setq kept-old-versions 2) ;; Number of oldest versions to keep
1684 (validate-setq delete-old-versions t) ;; Ask to delete excess backup versions?
1685 (validate-setq backup-by-copying t)
1686 (validate-setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
1687 (validate-setq make-backup-files t)
1688
1689 (defadvice kill-buffer (around kill-buffer)
1690 "Always save before killing a file buffer"
1691 (when (and (buffer-modified-p)
1692 (buffer-file-name)
1693 (file-exists-p (buffer-file-name)))
1694 (save-buffer))
1695 ad-do-it)
1696 (ad-activate 'kill-buffer)
1697
1698 (defadvice save-buffers-kill-emacs (around save-buffers-kill-emacs)
1699 "Always save before killing emacs"
1700 (save-some-buffers t)
1701 ad-do-it)
1702 (ad-activate 'save-buffers-kill-emacs)
1703
1704 (defun kill-buffer-prompt ()
1705 "Allows one to kill a buffer without saving it.
1706 This is necessary since once you start backups-mode all file based buffers
1707 are saved automatically when they are killed"
1708 (interactive)
1709 (if (and (buffer-modified-p) (buffer-file-name) (file-exists-p (buffer-file-name)) (y-or-n-p "Save buffer?"))
1710 (save-buffer)
1711 (set-buffer-modified-p nil))
1712 (kill-buffer))
1713
1714 (validate-setq backup-enable-predicate
1715 (lambda (name)
1716 (and (normal-backup-enable-predicate name)
1717 (not
1718 (let ((method (file-remote-p name 'method)))
1719 (when (stringp method)
1720 (member method '("su" "sudo"))))))))))
1721
1722 #+END_SRC
1723 ** CANCELLED browse-kill-ring :CANCELLED:
1724 CLOSED: [2017-08-26 Sat 14:46]
1725 :LOGBOOK:
1726 - State "CANCELLED" from [2017-08-26 Sat 14:46] \\
1727 deactivated
1728 :END:
1729 [2014-12-11 Thu 11:31]
1730 Currently replaced with counsel, see Ivy
1731 #+BEGIN_SRC emacs-lisp :tangle no
1732 (use-package browse-kill-ring
1733 :ensure t
1734 :commands (browse-kill-ring browse-kill-ring-mode)
1735 :bind ("M-y" . browse-kill-ring)
1736 )
1737 #+END_SRC
1738 ** CANCELLED calendar :CANCELLED:
1739 CLOSED: [2017-08-26 Sat 14:47]
1740 :LOGBOOK:
1741 - State "CANCELLED" from [2017-08-26 Sat 14:47]
1742 :END:
1743 [2014-06-10 Tue 22:20]
1744 #+BEGIN_SRC emacs-lisp
1745 (use-package calendar
1746 :commands (cal/insert)
1747 :bind ("C-c c" . cal/insert)
1748 :config
1749 (progn
1750 ; Weeks start on Monday, not sunday.
1751 (validate-setq calendar-week-start-day 1)
1752 (validate-setq calendar-date-style 'european)
1753
1754 ; Display ISO week numbers in Calendar Mode
1755 (copy-face font-lock-constant-face 'calendar-iso-week-face)
1756 (set-face-attribute 'calendar-iso-week-face nil :height 0.7)
1757 (validate-setq calendar-intermonth-text
1758 '(propertize
1759 (format "%2d"
1760 (car
1761 (calendar-iso-from-absolute
1762 (calendar-absolute-from-gregorian (list month day year)))))
1763 'font-lock-face 'calendar-iso-week-face))
1764 (copy-face 'default 'calendar-iso-week-header-face)
1765 (set-face-attribute 'calendar-iso-week-header-face nil :height 0.7)
1766 (validate-setq calendar-intermonth-header
1767 (propertize "Wk" ; or e.g. "KW" in Germany
1768 'font-lock-face 'calendar-iso-week-header-face))))
1769
1770 #+END_SRC
1771 ** corral
1772 [2015-10-15 Thu 11:34]
1773 Corral is a lightweight package that lets you quickly wrap parentheses
1774 and other delimiters around text, intuitively surrounding what you
1775 want it to using just two commands.
1776 #+BEGIN_SRC emacs-lisp
1777 (use-package corral
1778 :ensure corral
1779 :bind (("C-c c" . hydra-corral/body))
1780 :config
1781 (progn
1782 ; Interpret # and * as part of the word
1783 (validate-setq corral-syntax-entries '((?# "_")
1784 (?* "_")
1785 (?$ ".")
1786 (?/ ".")))
1787 (defhydra hydra-corral (:columns 4)
1788 "Corral"
1789 ("(" corral-parentheses-backward "Back")
1790 (")" corral-parentheses-forward "Forward")
1791 ("[" corral-brackets-backward "Back")
1792 ("]" corral-brackets-forward "Forward")
1793 ("{" corral-braces-backward "Back")
1794 ("}" corral-braces-forward "Forward")
1795 ("\"" corral-double-quotes-backward "Back")
1796 ("2" corral-double-quotes-forward "Forward")
1797 ("'" corral-single-quotes-backward "Back")
1798 ("#" corral-single-quotes-forward "Forward")
1799 ("." hydra-repeat "Repeat"))
1800 ))
1801 #+END_SRC
1802 ** crontab-mode
1803 [2013-05-21 Tue 23:18]
1804 #+BEGIN_SRC emacs-lisp
1805 (use-package crontab-mode
1806 :ensure crontab-mode
1807 :commands crontab-mode
1808 :mode ("\\.?cron\\(tab\\)?\\'" . crontab-mode))
1809 #+END_SRC
1810
1811 ** CANCELLED css :CANCELLED:
1812 CLOSED: [2017-08-26 Sat 14:50]
1813 :LOGBOOK:
1814 - State "CANCELLED" from [2017-08-26 Sat 14:50] \\
1815 web mode it is
1816 :END:
1817 web-mode takes over, see [[*web-mode][web-mode]]
1818 #+BEGIN_SRC emacs-lisp :tangle no
1819 (use-package css-mode
1820 :mode ("\\.css\\'" . css-mode)
1821 :defer t
1822 :config
1823 (progn
1824 ;;; CSS flymake
1825 (use-package flymake-css
1826 :ensure flymake-css
1827 :config
1828 (progn
1829 (defun maybe-flymake-css-load ()
1830 "Activate flymake-css as necessary, but not in derived modes."
1831 (when (eq major-mode 'css-mode)
1832 (flymake-css-load)))
1833 (add-hook 'css-mode-hook 'maybe-flymake-css-load)))
1834 ;;; Auto-complete CSS keywords
1835 (eval-after-load 'auto-complete
1836 '(progn
1837 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
1838 (add-hook hook 'ac-css-mode-setup))))))
1839 #+END_SRC
1840
1841 ** cua
1842 I know that this lets it look "more like windows", but I don't much care
1843 about its paste/copy/cut keybindings, the really nice part is the great
1844 support for rectangular regions, which I started to use a lot since I
1845 know this mode. The normal keybindings for those are just to useless.
1846 #+BEGIN_SRC emacs-lisp
1847 (cua-mode t)
1848 (validate-setq cua-enable-cua-keys (quote shift))
1849 #+END_SRC
1850
1851 Luckily cua-mode easily supports this, with the following line I just
1852 get the CUA selection and rectangle stuff, not the keybindings. Yes,
1853 even though the above =cua-enable-cua-keys= setting would only enable
1854 them if the selection is done when the region was marked with a shifted
1855 movement keys.
1856 #+BEGIN_SRC emacs-lisp
1857 (cua-selection-mode t)
1858 #+END_SRC
1859
1860 ** Debian related
1861 #+BEGIN_SRC emacs-lisp
1862 (require 'dpkg-dev-el-loaddefs nil 'noerror)
1863 (require 'debian-el-loaddefs nil 'noerror)
1864
1865 (setq debian-changelog-full-name "Joerg Jaspert")
1866 (setq debian-changelog-mailing-address "joerg@debian.org")
1867 #+END_SRC
1868
1869 ** diff-mode
1870 #+BEGIN_SRC emacs-lisp
1871 (use-package diff-mode
1872 :commands diff-mode
1873 :mode (("\\.diff" . diff-mode)))
1874 #+END_SRC
1875
1876 ** dired & co
1877 #+BEGIN_SRC emacs-lisp
1878 (use-package dired
1879 :commands (dired dired-other-window dired-other-frame dired-noselect
1880 dired-mode dired-jump)
1881 :defines (dired-omit-regexp-orig)
1882 :bind (:map dired-mode-map
1883 ("F" . find-name-dired)
1884 ("/" . dired-narrow))
1885 :defer
1886 :init
1887 (progn
1888 (setq diredp-hide-details-initially-flag nil))
1889 :config
1890 (progn
1891 (validate-setq dired-auto-revert-buffer (quote dired-directory-changed-p))
1892 (validate-setq dired-dwim-target t)
1893 (validate-setq dired-listing-switches "-alh")
1894 (validate-setq dired-listing-switches "-alXh --group-directories-first")
1895 (validate-setq dired-recursive-copies (quote top))
1896 (validate-setq dired-recursive-deletes (quote top))
1897
1898 (use-package dired+
1899 :load-path "elisp/local")
1900
1901 (use-package dired-x
1902 :init
1903 (progn
1904 (validate-setq dired-guess-shell-alist-user
1905 '(("\\.pdf\\'" "mupdf")
1906 ("\\.\\(?:djvu\\|eps\\)\\'" "evince")
1907 ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "eog")
1908 ("\\.\\(?:xcf\\)\\'" "gimp")
1909 ("\\.csv\\'" "libreoffice")
1910 ("\\.tex\\'" "pdflatex" "latex")
1911 ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\)\\(?:\\.part\\)?\\'" "vlc")
1912 ("\\.html?\\'" "conkeror")))))
1913
1914 (use-package dired-single
1915 :ensure dired-single
1916 :bind (:map dired-mode-map
1917 ("<return>" . dired-single-buffer)
1918 ("<mouse-1>" . dired-single-buffer))
1919 :init
1920 (progn
1921 (bind-key "^"
1922 (function
1923 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
1924
1925 (use-package wdired
1926 :ensure wdired
1927 :bind (:map dired-mode-map
1928 ("r" . wdired-change-to-wdired-mode))
1929 :config
1930 (progn
1931 (setq wdired-allow-to-change-permissions t)))
1932
1933 (use-package dired-narrow
1934 :ensure t
1935 :diminish dired-narrow-mode
1936 :bind (:map dired-mode-map
1937 ("/" . dired-narrow)))
1938
1939 (use-package gnus-dired
1940 :commands (gnus-dired-attach gnus-dired-mode)
1941 :bind (:map dired-mode-map
1942 ("a" . gnus-dired-attach)))
1943
1944 (use-package runner
1945 :ensure runner)
1946
1947 (defvar mark-files-cache (make-hash-table :test #'equal))
1948
1949 (defun mark-similar-versions (name)
1950 (let ((pat name))
1951 (if (string-match "^\\(.+?\\)-[0-9._-]+$" pat)
1952 (validate-setq pat (match-string 1 pat)))
1953 (or (gethash pat mark-files-cache)
1954 (ignore (puthash pat t mark-files-cache)))))
1955
1956 (defun dired-mark-similar-version ()
1957 (interactive)
1958 (validate-setq mark-files-cache (make-hash-table :test #'equal))
1959 (dired-mark-sexp '(mark-similar-versions name)))
1960
1961 (defun dired-package-initialize ()
1962 (unless (featurep 'runner)
1963 (bind-key "M-!" 'async-shell-command dired-mode-map)
1964 (unbind-key "M-s f" dired-mode-map)
1965
1966 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1967 "Make sure to remove \"Omit\" from the modeline."
1968 (diminish 'dired-omit-mode) dired-mode-map)
1969
1970 ;; Omit files that Git would ignore
1971 (defun dired-omit-regexp ()
1972 (let ((file (expand-file-name ".git"))
1973 parent-dir)
1974 (while (and (not (file-exists-p file))
1975 (progn
1976 (validate-setq parent-dir
1977 (file-name-directory
1978 (directory-file-name
1979 (file-name-directory file))))
1980 ;; Give up if we are already at the root dir.
1981 (not (string= (file-name-directory file)
1982 parent-dir))))
1983 ;; Move up to the parent dir and try again.
1984 (validate-setq file (expand-file-name ".git" parent-dir)))
1985 ;; If we found a change log in a parent, use that.
1986 (if (file-exists-p file)
1987 (let ((regexp (funcall dired-omit-regexp-orig))
1988 (omitted-files
1989 (shell-command-to-string "git clean -d -x -n")))
1990 (if (= 0 (length omitted-files))
1991 regexp
1992 (concat
1993 regexp
1994 (if (> (length regexp) 0)
1995 "\\|" "")
1996 "\\("
1997 (mapconcat
1998 #'(lambda (str)
1999 (concat
2000 "^"
2001 (regexp-quote
2002 (substring str 13
2003 (if (= ?/ (aref str (1- (length str))))
2004 (1- (length str))
2005 nil)))
2006 "$"))
2007 (split-string omitted-files "\n" t)
2008 "\\|")
2009 "\\)")))
2010 (funcall dired-omit-regexp-orig))))))
2011
2012 (add-hook 'dired-mode-hook 'dired-package-initialize)
2013
2014 (defun dired-double-jump (first-dir second-dir)
2015 (interactive
2016 (list (read-directory-name "First directory: "
2017 (expand-file-name "~")
2018 nil nil "/Downloads/")
2019 (read-directory-name "Second directory: "
2020 (expand-file-name "~")
2021 nil nil "/")))
2022 (dired first-dir)
2023 (dired-other-window second-dir))
2024 (bind-key "C-c J" 'dired-double-jump)
2025
2026 (defun dired-back-to-top ()
2027 (interactive)
2028 (goto-char (point-min))
2029 (dired-next-line 4))
2030
2031 (define-key dired-mode-map
2032 (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
2033
2034 (defun dired-jump-to-bottom ()
2035 (interactive)
2036 (goto-char (point-max))
2037 (dired-next-line -1))
2038
2039 (define-key dired-mode-map
2040 (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)))
2041
2042 #+END_SRC
2043 ** discover-my-major
2044 [2014-06-01 Sun 23:32]
2045 Discover key bindings and their meaning for the current Emacs major mode.
2046 #+BEGIN_SRC emacs-lisp
2047 (use-package discover-my-major
2048 :ensure discover-my-major
2049 :commands discover-my-major
2050 :bind ("C-h C-m" . discover-my-major))
2051 #+END_SRC
2052 ** easypg
2053 EasyPG is a GnuPG interface for Emacs.
2054 Bookmark: [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
2055 #+BEGIN_SRC emacs-lisp
2056 (use-package epa-file
2057 :config
2058 (progn
2059 (epa-file-enable)
2060 ;; I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
2061 (defadvice epg--start (around advice-epg-disable-agent disable)
2062 "Don't allow epg--start to use gpg-agent in plain text
2063 terminals . "
2064 (if (display-graphic-p)
2065 ad-do-it
2066 (let ((agent (getenv "GPG_AGENT_INFO")))
2067 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
2068 ad-do-it
2069 (setenv "GPG_AGENT_INFO" agent))))
2070 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
2071 (ad-activate 'epg--start)
2072 ))
2073 #+END_SRC
2074 ** ediff
2075 [2013-04-21 So 20:36]
2076 ediff - don't start another frame
2077 #+BEGIN_SRC emacs-lisp
2078 (use-package ediff
2079 :init
2080 (progn
2081 (defvar ctl-period-equals-map)
2082 (define-prefix-command 'ctl-period-equals-map)
2083 (bind-key "C-. =" 'ctl-period-equals-map)
2084 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
2085
2086 :bind (("C-. = b" . ediff-buffers)
2087 ("C-. = B" . ediff-buffers3)
2088 ("C-. = =" . ediff-files)
2089 ("C-. = f" . ediff-files)
2090 ("C-. = F" . ediff-files3)
2091 ("C-. = r" . ediff-revision)
2092 ("C-. = p" . ediff-patch-file)
2093 ("C-. = P" . ediff-patch-buffer)
2094 ("C-. = l" . ediff-regions-linewise)
2095 ("C-. = w" . ediff-regions-wordwise))
2096 :config (progn
2097 (validate-setq ediff-window-setup-function 'ediff-setup-windows-plain)
2098 (validate-setq ediff-split-window-function 'split-window-horizontally)
2099 )
2100 )
2101 #+END_SRC
2102 ** CANCELLED edit-server :CANCELLED:
2103 CLOSED: [2017-08-26 Sat 14:55]
2104 :LOGBOOK:
2105 - State "CANCELLED" from [2017-08-26 Sat 14:55] \\
2106 no more workinng
2107 :END:
2108 [2015-12-16 Wed 22:13]
2109 Allows chromium to "send" files (textbox inputs) to emacs to edit.
2110 #+BEGIN_SRC emacs-lisp :tangle no
2111 (use-package edit-server
2112 :ensure t
2113 :if window-system
2114 :config
2115 (progn
2116 (validate-setq edit-server-new-frame t)
2117 (edit-server-start)))
2118 #+END_SRC
2119 ** CANCELLED emms :CANCELLED:
2120 CLOSED: [2017-08-26 Sat 14:55]
2121 :LOGBOOK:
2122 - State "CANCELLED" from [2017-08-26 Sat 14:55]
2123 :END:
2124
2125 EMMS is the Emacs Multimedia System.
2126 #+BEGIN_SRC emacs-lisp :tangle no
2127 (require 'emms-source-file)
2128 (require 'emms-source-playlist)
2129 (require 'emms-info)
2130 (require 'emms-cache)
2131 (require 'emms-playlist-mode)
2132 (require 'emms-playing-time)
2133 (require 'emms-player-mpd)
2134 (require 'emms-playlist-sort)
2135 (require 'emms-mark)
2136 (require 'emms-browser)
2137 (require 'emms-lyrics)
2138 (require 'emms-last-played)
2139 (require 'emms-score)
2140 (require 'emms-tag-editor)
2141 (require 'emms-history)
2142 (require 'emms-i18n)
2143
2144 (validate-setq emms-playlist-default-major-mode 'emms-playlist-mode)
2145 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
2146 (emms-playing-time 1)
2147 (emms-lyrics 1)
2148 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
2149 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
2150 (emms-score 1)
2151 (when (fboundp 'emms-cache) ; work around compiler warning
2152 (emms-cache 1))
2153 (validate-setq emms-score-default-score 3)
2154
2155 (defun emms-mpd-init ()
2156 "Connect Emms to mpd."
2157 (interactive)
2158 (emms-player-mpd-connect))
2159
2160 ;; players
2161 (require 'emms-player-mpd)
2162 (validate-setq emms-player-mpd-server-name "localhost")
2163 (validate-setq emms-player-mpd-server-port "6600")
2164 (add-to-list 'emms-info-functions 'emms-info-mpd)
2165 (add-to-list 'emms-player-list 'emms-player-mpd)
2166 (validate-setq emms-volume-change-function 'emms-volume-mpd-change)
2167 (validate-setq emms-player-mpd-sync-playlist t)
2168
2169 (validate-setq emms-source-file-default-directory "/var/lib/mpd/music")
2170 (validate-setq emms-player-mpd-music-directory "/var/lib/mpd/music")
2171 (validate-setq emms-info-auto-update t)
2172 (validate-setq emms-lyrics-scroll-p t)
2173 (validate-setq emms-lyrics-display-on-minibuffer t)
2174 (validate-setq emms-lyrics-display-on-modeline nil)
2175 (validate-setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
2176
2177 (validate-setq emms-last-played-format-alist
2178 '(((emms-last-played-seconds-today) . "%H:%M")
2179 (604800 . "%a %H:%M") ; this week
2180 ((emms-last-played-seconds-month) . "%d.%m.%Y")
2181 ((emms-last-played-seconds-year) . "%d.%m.%Y")
2182 (t . "Never played")))
2183
2184 ;; Playlist format
2185 (defun my-describe (track)
2186 (let* ((empty "...")
2187 (name (emms-track-name track))
2188 (type (emms-track-type track))
2189 (short-name (file-name-nondirectory name))
2190 (play-count (or (emms-track-get track 'play-count) 0))
2191 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
2192 (artist (or (emms-track-get track 'info-artist) empty))
2193 (year (emms-track-get track 'info-year))
2194 (playing-time (or (emms-track-get track 'info-playing-time) 0))
2195 (min (/ playing-time 60))
2196 (sec (% playing-time 60))
2197 (album (or (emms-track-get track 'info-album) empty))
2198 (tracknumber (emms-track-get track 'info-tracknumber))
2199 (short-name (file-name-sans-extension
2200 (file-name-nondirectory name)))
2201 (title (or (emms-track-get track 'info-title) short-name))
2202 (rating (emms-score-get-score name))
2203 (rate-char ?☭)
2204 )
2205 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
2206 (emms-last-played-format-date last-played)
2207 artist
2208 year
2209 album
2210 (if (and tracknumber ; tracknumber
2211 (not (zerop (string-to-number tracknumber))))
2212 (format "%02d" (string-to-number tracknumber))
2213 "")
2214 title
2215 play-count
2216 (make-string rating rate-char)))
2217 )
2218
2219 (validate-setq emms-track-description-function 'my-describe)
2220
2221 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
2222 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
2223 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
2224 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
2225 (global-set-key (kbd "H-<f9> x") 'emms-start)
2226 (global-set-key (kbd "H-<f9> v") 'emms-stop)
2227 (global-set-key (kbd "H-<f9> n") 'emms-next)
2228 (global-set-key (kbd "H-<f9> p") 'emms-previous)
2229 (global-set-key (kbd "H-<f9> o") 'emms-show)
2230 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
2231 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
2232 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
2233 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
2234 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
2235
2236 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
2237 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
2238 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
2239 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
2240
2241 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
2242 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
2243 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
2244 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
2245
2246 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
2247 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
2248 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
2249 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
2250
2251 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
2252 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
2253 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
2254 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
2255 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
2256 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
2257
2258 (define-key emms-playlist-mode-map "x" 'emms-start)
2259 (define-key emms-playlist-mode-map "v" 'emms-stop)
2260 (define-key emms-playlist-mode-map "n" 'emms-next)
2261 (define-key emms-playlist-mode-map "p" 'emms-previous)
2262
2263 (validate-setq emms-playlist-buffer-name "*EMMS Playlist*"
2264 emms-playlist-mode-open-playlists t)
2265
2266 ;; Faces
2267 (if (window-system)
2268 ((lambda ()
2269 (set-face-attribute
2270 'emms-browser-artist-face nil
2271 :family "Arno Pro")
2272 )
2273 ))
2274
2275 (validate-setq emms-player-mpd-supported-regexp
2276 (or (emms-player-mpd-get-supported-regexp)
2277 (concat "\\`http://\\|"
2278 (emms-player-simple-regexp
2279 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
2280 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
2281
2282 #+END_SRC
2283 ** CANCELLED Emacs shell :CANCELLED:
2284 CLOSED: [2017-08-26 Sat 14:56]
2285 :LOGBOOK:
2286 - State "CANCELLED" from [2017-08-26 Sat 14:56]
2287 :END:
2288 Basic settings for emacs integrated shell
2289 #+BEGIN_SRC emacs-lisp :tangle no
2290 (use-package eshell
2291 :defer t
2292 :commands eshell
2293 :init
2294 (progn
2295 (defun eshell-initialize ()
2296 (defun eshell-spawn-external-command (beg end)
2297 "Parse and expand any history references in current input."
2298 (save-excursion
2299 (goto-char end)
2300 (when (looking-back "&!" beg)
2301 (delete-region (match-beginning 0) (match-end 0))
2302 (goto-char beg)
2303 (insert "spawn "))))
2304 (add-hook 'eshell-expand-input-functions 'eshell-spawn-external-command)
2305 (eval-after-load "em-unix"
2306 '(progn
2307 (unintern 'eshell/su)
2308 (unintern 'eshell/sudo))))
2309 (add-hook 'eshell-first-time-mode-hook 'eshell-initialize)
2310 )
2311 :config
2312 (progn
2313 (defalias 'emacs 'find-file)
2314 (defalias 'ec 'find-file)
2315 (defalias 'e 'find-file)
2316
2317 (use-package f
2318 :ensure f)
2319 (use-package 'em-cmpl)
2320 (use-package 'em-prompt)
2321 (use-package 'em-term)
2322
2323 (validate-setq eshell-cmpl-cycle-completions nil
2324 eshell-save-history-on-exit t
2325 eshell-buffer-maximum-lines 20000
2326 eshell-history-size 350
2327 eshell-buffer-shorthand t
2328 eshell-highlight-prompt t
2329 eshell-plain-echo-behavior t
2330 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
2331
2332 (setenv "PAGER" "cat")
2333 (validate-setq eshell-visual-commands
2334 '("less" "tmux" "htop" "top" "bash" "zsh" "tail"))
2335 (validate-setq eshell-visual-subcommands
2336 '(("git" "log" "l" "diff" "show")))
2337
2338 (add-to-list 'eshell-command-completions-alist
2339 '("gunzip" "gz\\'"))
2340 (add-to-list 'eshell-command-completions-alist
2341 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
2342
2343 (when (not (functionp 'eshell/rgrep))
2344 (defun eshell/rgrep (&rest args)
2345 "Use Emacs grep facility instead of calling external grep."
2346 (eshell-grep "rgrep" args t)))
2347
2348 ;(set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
2349 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
2350 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
2351 (add-hook 'eshell-preoutput-filter-functions
2352 'ansi-color-filter-apply)
2353 ;; Prompt with a bit of help from http://www.emacswiki.org/emacs/EshellPrompt
2354
2355 (defmacro with-face (str &rest properties)
2356 `(propertize ,str 'face (list ,@properties)))
2357
2358 (defun eshell/abbr-pwd ()
2359 (let ((home (getenv "HOME"))
2360 (path (eshell/pwd)))
2361 (cond
2362 ((string-equal home path) "~")
2363 ((f-ancestor-of? home path) (concat "~/" (f-relative path home)))
2364 (path))))
2365
2366 (defun eshell/my-prompt ()
2367 (let ((header-bg "#161616"))
2368 (concat
2369 (with-face user-login-name :foreground "cyan")
2370 (with-face (concat "@" hostname) :foreground "white")
2371 " "
2372 (with-face (eshell/abbr-pwd) :foreground "#009900")
2373 (if (= (user-uid) 0)
2374 (with-face "#" :foreground "red")
2375 (with-face "$" :foreground "#69b7f0"))
2376 " ")))
2377
2378 (use-package eshell-prompt-extras
2379 :ensure t
2380 :init
2381 (progn
2382 (validate-setq eshell-highlight-prompt nil
2383 ;; epe-git-dirty-char "Ϟ"
2384 epe-git-dirty-char "*"
2385 eshell-prompt-function 'epe-theme-dakrone)))
2386
2387 (defun eshell/magit ()
2388 "Function to open magit-status for the current directory"
2389 (interactive)
2390 (magit-status default-directory)
2391 nil)
2392
2393 (validate-setq eshell-prompt-function 'eshell/my-prompt)
2394 (validate-setq eshell-highlight-prompt nil)
2395 (validate-setq eshell-prompt-regexp "^[^#$\n]+[#$] ")))
2396
2397 #+END_SRC
2398
2399 ** CANCELLED ethan-wspace :CANCELLED:
2400 CLOSED: [2017-08-26 Sat 14:57]
2401 :LOGBOOK:
2402 - State "CANCELLED" from [2017-08-26 Sat 14:57]
2403 :END:
2404 [2014-06-01 Sun 15:00]
2405 Proper whitespace handling
2406 #+BEGIN_SRC emacs-lisp :tangle no
2407 (use-package ethan-wspace
2408 :ensure ethan-wspace
2409 :diminish (ethan-wspace-mode . "ew")
2410 :init
2411 (global-ethan-wspace-mode 1))
2412 #+END_SRC
2413 ** Eww - Emacs browser
2414 [2016-10-03 Mo 21:30]
2415 Eww - Emacs browser (needs emacs 24.4 or higher)
2416 #+BEGIN_SRC emacs-lisp
2417 (use-package eww
2418 :bind (("M-s M-w" . eww-search-words)
2419 :map eww-mode-map
2420 (":" . eww) ; Go to URL
2421 ("h" . eww-list-histories) ; View history
2422 :map eww-text-map ; For single line text fields
2423 ("<backtab>" . shr-previous-link) ; S-TAB Jump to previous link on the page
2424 ("<C-return>" . eww-submit)
2425 :map eww-textarea-map ; For multi-line text boxes
2426 ("<backtab>" . shr-previous-link)
2427 ("<C-return>" . eww-submit)
2428 :map eww-checkbox-map
2429 ("<down-mouse-1>" . eww-toggle-checkbox)
2430 :map shr-map
2431 ("w" . modi/eww-copy-url-dwim)
2432 :map eww-link-keymap
2433 ("w" . modi/eww-copy-url-dwim))
2434
2435 :config
2436 (progn
2437 ;; Make the binding for `revert-buffer' do `eww-reload' in eww-mode
2438 (define-key eww-mode-map [remap revert-buffer] #'eww-reload)
2439
2440 ;; (validate-setq eww-search-prefix "https://duckduckgo.com/html/?q=")
2441 (validate-setq eww-search-prefix "https://www.google.com/search?q=")
2442 (validate-setq eww-download-directory "~/Downloads")
2443 ;; (validate-setq eww-form-checkbox-symbol "[ ]")
2444 (validate-setq eww-form-checkbox-symbol "☐") ; Unicode hex 2610
2445 ;; (validate-setq eww-form-checkbox-selected-symbol "[X]")
2446 (validate-setq eww-form-checkbox-selected-symbol "☑") ; Unicode hex 2611
2447 ;; Improve the contract of pages like Google results
2448 ;; http://emacs.stackexchange.com/q/2955/115
2449 (setq shr-color-visible-luminance-min 80) ; default = 40
2450
2451 ;; Auto-rename new eww buffers
2452 ;; http://ergoemacs.org/emacs/emacs_eww_web_browser.html
2453 (defun xah-rename-eww-hook ()
2454 "Rename eww browser's buffer so sites open in new page."
2455 (rename-buffer "eww" t))
2456 (add-hook 'eww-mode-hook #'xah-rename-eww-hook)
2457
2458 ;; If the current buffer is an eww buffer, "M-x eww" will always reuse the
2459 ;; current buffer to load the new page. Below advice will make "C-u M-x eww"
2460 ;; force a new eww buffer even when the current buffer is an eww buffer.
2461 ;; The above `xah-rename-eww-hook' fix is still needed in order to create
2462 ;; uniquely named eww buffers.
2463 ;; http://emacs.stackexchange.com/a/24477/115
2464 (defun modi/force-new-eww-buffer (orig-fun &rest args)
2465 "When prefix argument is used, a new eww buffer will be created.
2466 This is regardless of whether the current buffer is an eww buffer. "
2467 (if current-prefix-arg
2468 (with-temp-buffer
2469 (apply orig-fun args))
2470 (apply orig-fun args)))
2471 (advice-add 'eww :around #'modi/force-new-eww-buffer)
2472
2473 ;; Override the default definition of `eww-search-words'
2474 (defun eww-search-words (&optional beg end)
2475 "Search the web for the text between the point and marker.
2476 See the `eww-search-prefix' variable for the search engine used."
2477 (interactive "r")
2478 (if (use-region-p)
2479 (eww (buffer-substring beg end))
2480 (eww (modi/get-symbol-at-point))))
2481
2482 ;; eww-lnum
2483 ;; https://github.com/m00natic/eww-lnum
2484 (use-package eww-lnum
2485 :ensure t
2486 :bind (:map eww-mode-map
2487 ("f" . eww-lnum-follow)
2488 ("U" . eww-lnum-universal)))
2489
2490 ;; org-eww
2491 ;; Copy text from html page for pasting in org mode file/buffer
2492 ;; e.g. Copied HTML hyperlinks get converted to [[link][desc]] for org mode.
2493 ;; http://emacs.stackexchange.com/a/8191/115
2494 (use-package org-eww
2495 :bind (:map eww-mode-map
2496 ("o" . org-eww-copy-for-org-mode)))
2497
2498 ;; Auto-refreshing eww buffer whenever the html file it's showing changes
2499 ;; http://emacs.stackexchange.com/a/2566/115
2500 (defvar modi/eww--file-notify-descriptors-list ()
2501 "List to store file-notify descriptor for all files that have an
2502 associated auto-reloading eww buffer.")
2503
2504 (defun modi/advice-eww-open-file-to-auto-reload (orig-fun &rest args)
2505 "When `eww-open-file' is called with \\[universal-argument], open
2506 the file in eww and also add `file-notify' watch for it so that the eww
2507 buffer auto-reloads when the HTML file changes."
2508 (prog1
2509 (apply orig-fun args)
2510 (when current-prefix-arg ; C-u M-x eww-open-file
2511 (require 'filenotify)
2512 (let ((file-name (car args)))
2513 (file-notify-add-watch file-name
2514 '(change attribute-change)
2515 #'modi/file-notify-callback-eww-reload)
2516 ;; Show the HTML file and its rendered form in eww side-by-side
2517 (find-file-other-window file-name))
2518 ;; Redefine the `q' binding in `eww-mode-map'
2519 (bind-key "q" #'modi/eww-quit-and-update-fn-descriptors eww-mode-map))))
2520 (advice-add 'eww-open-file :around #'modi/advice-eww-open-file-to-auto-reload)
2521
2522 (defun modi/file-notify-callback-eww-reload (event)
2523 "On getting triggered, switch to the eww buffer, reload and switch
2524 back to the working buffer. Also save the `file-notify-descriptor' of the
2525 triggering event."
2526 (let* ((working-buffer (buffer-name)))
2527 (switch-to-buffer-other-window "eww")
2528 (eww-reload)
2529 (switch-to-buffer-other-window working-buffer))
2530 ;; `(car event)' will return the event descriptor
2531 (add-to-list 'modi/eww--file-notify-descriptors-list (car event)))
2532
2533 (defun modi/eww-quit-and-update-fn-descriptors ()
2534 "When quitting `eww', first remove any saved file-notify descriptors
2535 specific to eww, while also updating `modi/eww--file-notify-descriptors-list'."
2536 (interactive)
2537 (dotimes (index (safe-length modi/eww--file-notify-descriptors-list))
2538 (file-notify-rm-watch (pop modi/eww--file-notify-descriptors-list)))
2539 (quit-window :kill))))
2540
2541 ;; Default eww key bindings
2542 ;; |-----------+---------------------------------------------------------------------|
2543 ;; | Key | Function |
2544 ;; |-----------+---------------------------------------------------------------------|
2545 ;; | & | Browse the current URL with an external browser. |
2546 ;; | - | Begin a negative numeric argument for the next command. |
2547 ;; | 0 .. 9 | Part of the numeric argument for the next command. |
2548 ;; | C | Display a buffer listing the current URL cookies, if there are any. |
2549 ;; | H | List the eww-histories. |
2550 ;; | F | Toggle font between variable-width and fixed-width. |
2551 ;; | G | Go to a URL |
2552 ;; | R | Readable mode |
2553 ;; | S | List eww buffers |
2554 ;; | d | Download URL under point to `eww-download-directory'. |
2555 ;; | g | Reload the current page. |
2556 ;; | q | Quit WINDOW and bury its buffer. |
2557 ;; | v | `eww-view-source' |
2558 ;; | w | `eww-copy-page-url' |
2559 ;; |-----------+---------------------------------------------------------------------|
2560 ;; | b | Add the current page to the bookmarks. |
2561 ;; | B | Display the bookmark list. |
2562 ;; | M-n | Visit the next bookmark |
2563 ;; | M-p | Visit the previous bookmark |
2564 ;; |-----------+---------------------------------------------------------------------|
2565 ;; | t | Go to the page marked `top'. |
2566 ;; | u | Go to the page marked `up'. |
2567 ;; |-----------+---------------------------------------------------------------------|
2568 ;; | n | Go to the page marked `next'. |
2569 ;; | p | Go to the page marked `previous'. |
2570 ;; |-----------+---------------------------------------------------------------------|
2571 ;; | l | Go to the previously displayed page. |
2572 ;; | r | Go to the next displayed page. |
2573 ;; |-----------+---------------------------------------------------------------------|
2574 ;; | TAB | Move point to next link on the page. |
2575 ;; | S-TAB | Move point to previous link on the page. |
2576 ;; |-----------+---------------------------------------------------------------------|
2577 ;; | SPC | Scroll up |
2578 ;; | DEL/Bkspc | Scroll down |
2579 ;; | S-SPC | Scroll down |
2580 ;; |-----------+---------------------------------------------------------------------|
2581 #+END_SRC
2582
2583 #+results:
2584
2585 ** exec path from shell
2586 [2017-04-01 Sat 23:27]
2587 #+BEGIN_SRC emacs-lisp
2588 (use-package exec-path-from-shell
2589 :ensure t
2590 :config
2591 (progn
2592 (exec-path-from-shell-initialize)
2593 (exec-path-from-shell-copy-env "GOPATH")))
2594 #+END_SRC
2595 ** expand-region
2596 [2014-06-01 Sun 15:16]
2597 #+BEGIN_SRC emacs-lisp
2598 (use-package expand-region
2599 :ensure expand-region
2600 :bind ("C-M-+" . er/expand-region)
2601 :commands er/expand-region)
2602 #+END_SRC
2603 ** NEXT eyebrowse
2604 :LOGBOOK:
2605 - State "NEXT" from "CANCELLED" [2017-09-16 Sat 23:06]
2606 - State "CANCELLED" from [2017-08-26 Sat 15:06]
2607 :END:
2608 [2017-04-29 Sat 13:18]
2609 [[https://github.com/wasamasa/eyebrowse][Eyebrowse]] is a global minor mode for Emacs that allows you to manage
2610 your window configurations in a simple manner, just like tiling window
2611 managers like i3wm with their workspaces do. It displays their current
2612 state in the modeline by default. The behaviour is modeled after
2613 ranger, a file manager written in Python.
2614 #+BEGIN_SRC emacs-lisp
2615 (use-package eyebrowse
2616 :ensure t
2617 :config
2618 (progn
2619 (validate-setq eyebrowse-mode-line-separator " "
2620 eyebrowse-new-workspace t)
2621 (eyebrowse-setup-opinionated-keys)
2622 (setq eyebrowse-new-workspace t)
2623 (eyebrowse-mode t)
2624 ))
2625 #+END_SRC
2626
2627 ** CANCELLED filladapt :CANCELLED:
2628 CLOSED: [2017-12-10 So 14:58]
2629 :LOGBOOK:
2630 - State "CANCELLED" from [2017-12-10 So 14:58] \\
2631 Old style backquotes
2632 :END:
2633 [2013-05-02 Thu 00:04]
2634 Filladapt by KyleJones enhances Emacs’ fill functions by guessing a
2635 fill prefix, such as a comment sequence in program code, and handling
2636 bullet points like “1.” or “*”.
2637 #+BEGIN_SRC emacs-lisp :tangle no
2638 (use-package filladapt
2639 :load-path ("elisp/local")
2640 :diminish filladapt-mode
2641 :init
2642 (setq-default filladapt-mode t))
2643 #+END_SRC
2644 ** flycheck
2645 [2013-04-28 So 22:21]
2646 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
2647 As the one time I tried Flymake i wasn't happy, thats easy to
2648 understand for me.
2649 #+BEGIN_SRC emacs-lisp
2650 (use-package flycheck
2651 :ensure flycheck
2652 :diminish flycheck-mode
2653 :bind (("M-n" . next-error)
2654 ("M-p" . previous-error))
2655 :config
2656 (progn
2657 (use-package flycheck-color-mode-line
2658 :ensure flycheck-color-mode-line)
2659 (validate-setq flycheck-highlighting-mode 'nil)
2660 (validate-setq flycheck-flake8-maximum-line-length '150)
2661 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
2662 (validate-setq flycheck-sh-shellcheck-executable "/usr/bin/shellcheck -e 2086")
2663 (add-hook 'find-file-hook
2664 (lambda ()
2665 (when (not (equal 'emacs-lisp-mode major-mode))
2666 (flycheck-mode))))
2667 ))
2668 #+END_SRC
2669 ** font-lock
2670 Obviously emacs can do syntax hilighting. For more things than you ever
2671 heard about.
2672 And I want to have it everywhere.
2673 #+BEGIN_SRC emacs-lisp
2674 (use-package font-lock
2675 :init
2676 (progn
2677 (global-font-lock-mode 1)
2678 (validate-setq font-lock-maximum-decoration t)
2679 (validate-setq jit-lock-defer-time nil)
2680 (validate-setq jit-lock-stealth-nice 0.1)
2681 (validate-setq jit-lock-stealth-time 0.2)
2682 (validate-setq jit-lock-stealth-verbose nil)))
2683 #+END_SRC
2684 ** CANCELLED form-feed-mode :CANCELLED:
2685 CLOSED: [2017-08-26 Sat 15:07]
2686 :LOGBOOK:
2687 - State "CANCELLED" from [2017-08-26 Sat 15:07]
2688 :END:
2689 [2015-08-31 Mon 11:27]
2690 Display nice lines instead of page breaks
2691 #+BEGIN_SRC emacs-lisp :tangle no
2692 (use-package form-feed
2693 :ensure t
2694 )
2695 #+END_SRC
2696 ** CANCELLED git commit mode :CANCELLED:
2697 CLOSED: [2017-08-26 Sat 15:07]
2698 :LOGBOOK:
2699 - State "CANCELLED" from [2017-08-26 Sat 15:07]
2700 :END:
2701 #+BEGIN_SRC emacs-lisp :tangle no
2702 (use-package git-commit
2703 :commands git-commit
2704 :mode ("COMMIT_EDITMSG" . git-commit-mode))
2705 #+END_SRC
2706
2707 ** CANCELLED git rebase mode :CANCELLED:
2708 CLOSED: [2017-08-26 Sat 15:07]
2709 :LOGBOOK:
2710 - State "CANCELLED" from [2017-08-26 Sat 15:07]
2711 :END:
2712 #+BEGIN_SRC emacs-lisp :tangle no
2713 (use-package git-rebase
2714 :commands git-rebase
2715 :mode ("git-rebase-todo" . git-rebase-mode))
2716 #+END_SRC
2717 ** git-gutter+
2718 [2014-05-21 Wed 22:56]
2719 #+BEGIN_SRC emacs-lisp
2720 (use-package git-gutter+
2721 :ensure git-gutter+
2722 :diminish git-gutter+-mode
2723 :bind (("C-x n" . git-gutter+-next-hunk)
2724 ("C-x p" . git-gutter+-previous-hunk)
2725 ("C-x v =" . git-gutter+-show-hunk)
2726 ("C-x r" . git-gutter+-revert-hunks)
2727 ("C-x s" . git-gutter+-stage-hunks)
2728 ("C-x c" . git-gutter+-commit)
2729 )
2730 :init
2731 (progn
2732 (setq git-gutter+-disabled-modes '(org-mode))
2733 (global-git-gutter+-mode 1))
2734 :config
2735 (progn
2736 (use-package git-gutter-fringe+
2737 :ensure git-gutter-fringe+
2738 :config
2739 (progn
2740 (validate-setq git-gutter-fr+-side 'right-fringe)
2741 ;(git-gutter-fr+-minimal)
2742 ))))
2743 #+END_SRC
2744 ** git-messenger
2745 [2015-02-22 Sun 14:00]
2746 Provides function that popup commit message at current line. This is
2747 useful when you want to know why this line was changed.
2748 #+BEGIN_SRC emacs-lisp
2749 (use-package git-messenger
2750 :ensure git-messenger
2751 :commands (git-messenger:popup-message)
2752 :bind (("C-x v p" . git-messenger:popup-message))
2753 :config
2754 (progn
2755 (bind-key "m" 'git-messenger:copy-message git-messenger-map)
2756 (add-hook 'git-messenger:popup-buffer-hook 'magit-revision-mode)
2757 (validate-setq git-messenger:show-detail t)))
2758 #+END_SRC
2759 ** git timemachine
2760 [2014-07-23 Mi 12:57]
2761 Browse historic versions of a file with p (previous) and n (next).
2762 #+BEGIN_SRC emacs-lisp
2763 (use-package git-timemachine
2764 :ensure git-timemachine
2765 :commands git-timemachine)
2766 #+END_SRC
2767 ** Mail handling
2768 *** bbdb
2769 [2017-06-27 Di 23:10]
2770 #+BEGIN_SRC emacs-lisp
2771 (use-package bbdb
2772 :ensure t
2773 :commands (bbdb bbdb-insinuate-gnus bbdb-initialize)
2774 :config
2775 (progn
2776 (use-package bbdb-message)
2777 (use-package bbdb-gnus)
2778 (use-package bbdb-com)
2779
2780 (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus)
2781
2782 (setq bbdb-add-mails t)
2783 (setq bbdb-canonicalize-redundant-mails t)
2784 (setq bbdb-complete-mail-allow-cycling t)
2785 (setq bbdb-complete-name-allow-cycling t)
2786 (setq bbdb-completion-type 'primary-or-name)
2787 (setq bbdb-dwim-net-address-allow-redundancy t)
2788 (setq bbdb-default-area-code 661)
2789 (setq bbdb-dial-local-prefix "0")
2790 (setq bbdb-file-coding-system 'utf-8)
2791 (setq bbdb-hashtable-size 104729)
2792 (setq bbdb-ignore-messages-alist '(("To" . "\\(\\(\\(joerg\\)\\(\\.jaspert\\)?\\)\\|root\\|gnus|gf\\)@\\(debian\\.org\\|ganneff\\.de\\|debconf\\.org\\|spi-inc\\.org\\|nsb-software.de\\)")))
2793 (setq bbdb-new-mails-primary t)
2794 (setq bbdb-notice-auto-save-file t)
2795 (setq bbdb-notice-mail-hook 'bbdb-auto-notes-hook)
2796 (setq bbdb-phone-style nil)
2797 (setq bbdb-pop-up-window-size 6)
2798 (setq bbdb-user-mail-names "\\(\\(\\(joerg\\)\\(\\.jaspert\\)?\\)\\|root\\|gnus\\|gf\\)@\\(debian\\.org\\|ganneff\\.de\\|debconf\\.org\\|spi-inc\\.org\\|nsb-software.de\\)")
2799 (setq bbdb/gnus-summary-known-poster-mark "+")
2800 (setq bbdb/gnus-summary-mark-known-posters t)
2801 (setq bbdb/gnus-summary-prefer-real-names t)
2802 (setq bbdb/news-auto-create-p 'bbdb-ignore-most-messages-hook)
2803 (setq bbdb-auto-notes-rules
2804 '(("user-agent" (".*" interface 0))
2805 ("Organization" (".*" company 0))
2806 ("x-mailer" (".*" interface 0))
2807 ("x-newsreader" (".*" interface 0))
2808 ("X-URL" (".*" url 0))
2809 ("newsgroups" ("\\\\([^,]*\\\\),?" posted-to "\\\\1" t))
2810 ("xref" ("\\\\b[^ ]+:[0-9]+.*" seen-in 0))))
2811 (put 'seen-in 'field-separator "; ")
2812 (put 'interface 'field-seperator "; ")
2813 )
2814 (use-package counsel-bbdb
2815 :ensure t)
2816 )
2817 #+END_SRC
2818
2819 *** gnus
2820 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
2821 what I want every emacs to know.
2822 #+BEGIN_SRC emacs-lisp
2823 (use-package gnus
2824 :commands (gnus)
2825 :bind (("C-c g" . gnus)
2826 :map gnus-summary-mode-map
2827 ("<f6>" . jj-forward-spam)
2828 ("C-<f1>" . jj-move-mail-spambox)
2829 ("C-<f2>" . jj-copy-mail-hambox)
2830 ("C-c x" . gnus-scum-expunge)
2831 :map gnus-group-mode-map
2832 ("GG" . notmuch-search)
2833 :map notmuch-show-mode-map
2834 ("C-c C-c" . lld-notmuch-goto-message-in-gnus)
2835 )
2836 :init
2837 (progn
2838 (after 'gnus
2839 (jj-init-theme))
2840 )
2841 :config
2842 (progn
2843 (bbdb-initialize)
2844 ; When emacs exits, gnus does too, no need to ask me
2845 (defun exit-gnus-on-exit ()
2846 (if (and (fboundp 'gnus-group-exit)
2847 (gnus-alive-p))
2848 (with-current-buffer (get-buffer "*Group*")
2849 (gnus-group-exit))))
2850 (add-hook 'kill-emacs-hook 'exit-gnus-on-exit)
2851
2852 ;; prettier summary buffers
2853
2854 (setq gnus-sum-thread-tree-indent " ") ;; " "
2855 (setq gnus-sum-thread-tree-root "\u229e ") ;; "⊞ "
2856 (setq gnus-sum-thread-tree-false-root "\u22a1 ") ;; "⊡ "
2857 (setq gnus-sum-thread-tree-single-indent " ") ;; " "
2858 (setq gnus-sum-thread-tree-vertical " \u2502") ;; " │"
2859 (setq gnus-sum-thread-tree-leaf-with-other " \u251c\u2500 ") ;; " ├─ "
2860 (setq gnus-sum-thread-tree-single-leaf " \u2570\u2500 ") ;; " ╰─ "
2861
2862 (use-package gnus-cite
2863 :config
2864 (progn
2865 (defface dwa/mail-citation '((((class color)
2866 (background dark))
2867 (:background "#383838"))
2868 (((class color)
2869 (background light))
2870 (:background "#efefef")))
2871 "Mail citation base face.")
2872 (loop for x in gnus-cite-face-list do
2873 (set-face-attribute x nil ':inherit 'dwa/mail-citation))))
2874
2875 (use-package time-date
2876 :config
2877 (setq message-citation-line-function 'september-citation-line))
2878
2879 (setq message-subscribed-address-functions
2880 '(gnus-find-subscribed-addresses))
2881
2882 (if (string-match system-name "delenn.ganneff.de")
2883 (progn
2884 (setq imap-ssl-program "openssl s_client -no_ssl2 -no_ssl3 -tls1 -connect %s:%p")
2885
2886 (use-package notmuch
2887 :config
2888 (setq notmuch-search-oldest-first nil))
2889 (use-package org-gnus)
2890
2891 (setq gnus-secondary-select-methods
2892 '((nnml "")
2893
2894 (nnimap "nsb"
2895 (nnimap-address "localhost")
2896 (nnimap-user "nsb@auth")
2897 (nnimap-nov-is-evil t)
2898 (nnimap-stream network)
2899 (nnir-search-engine notmuch)
2900 )
2901 (nnimap "gmail"
2902 (nnimap-address "localhost")
2903 (nnimap-user "gmail@auth")
2904 (nnimap-stream network)
2905 (nnimap-nov-is-evil t)
2906 (nnir-search-engine notmuch)
2907 )
2908 ))
2909 ;;** Von wo holt Gnus News
2910 (setq gnus-select-method '(nnimap "ganneff"
2911 (nnimap-address "localhost")
2912 (nnimap-user "ganneff@auth")
2913 (nnimap-stream network)
2914 (nnimap-nov-is-evil t)
2915 (nnir-search-engine notmuch)
2916 ))
2917 ;;** Kopien aller Mails/News speichern
2918 (setq gnus-message-archive-group
2919 '((if (message-news-p)
2920 "nnfolder+archive:Sentnews"
2921 "nnimap+ganneff:Sentmail")))
2922 )
2923 )
2924 (setq nnir-mail-backend (nth 1 gnus-secondary-select-methods))
2925
2926 ;;** dont always read the active file.
2927 (setq gnus-read-active-file 'some)
2928
2929 ;;** nnimap nich cachen, ebenso nnml
2930 (setq gnus-uncacheable-groups "^\\(nnml\\|nnimap\\)")
2931
2932 ;;** Bei langsamer Anbindung dies auf t setzen
2933 (setq gnus-asynchronous t)
2934
2935 ;;** Mein Gnus soll regelmaessig nach neuen Mails/News schauen.
2936 (gnus-demon-add-handler 'us-get-only-mail 20 10)
2937 (gnus-demon-init)
2938
2939 ;; Set the default value of `mm-discouraged-alternatives'.
2940 (eval-after-load "gnus-sum"
2941 '(add-to-list
2942 'gnus-newsgroup-variables
2943 '(mm-discouraged-alternatives
2944 . '("text/html" "text/richtext"))))
2945
2946 ;; Display `text/html' parts in `nnrss' groups only.
2947 (add-to-list
2948 'gnus-parameters
2949 '("\\`nnrss:" (mm-discouraged-alternatives nil)))
2950
2951 ;;** Message Size Limit
2952 (setq message-send-mail-partially-limit 5000000)
2953
2954 (setq message-send-mail-function 'message-send-mail-with-sendmail)
2955 (setq smtpmail-default-smtp-server "localhost")
2956 (setq message-sendmail-envelope-from 'header)
2957
2958 ;;** Keinen Sender Header zufuegen !
2959 (add-to-list 'message-syntax-checks '(sender . disabled))
2960
2961 ;;** Auto-Subscribe
2962 (setq gnus-auto-subscribed-groups
2963 (concat gnus-auto-subscribed-groups
2964 "\\|^nnimap*"))
2965
2966 ;;** Kaputte Subjects Aw: Statt Re: fixen:
2967 (setq message-subject-re-regexp "^[ ]*\\([RrAaFf][EeWw]:[ ]*\\)*[ ]*")
2968
2969 ;;** Immer Gruppen nach Topics anzeigen
2970 (add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
2971
2972 ;;** Summary Anzeige umdefinieren.
2973 (setq gnus-summary-line-format "%U%R%z (%4k) %uy%* %B%(%[ %-22,22f %]%) %s\n")
2974 (setq gnus-summary-gather-subject-limit 'fuzzy)
2975
2976 ;;** Und die Gruppenanzeige will ich auch anders. Will sehen wann ich zuletzt da reingesehen hab.
2977 (setq gnus-group-line-format
2978 "%M%S%p%P %4ux/%4i/%6R: %(%-55,55ug%3O%)%l <%2,2~(cut 6)d.%2,2~(cut 4)d.%2,2~(cut 2)d>\n")
2979
2980 ;;** Different topic lines
2981 (setq gnus-topic-line-format "%i[ %u&topic-line; ] %v\n")
2982
2983 ;;** Für die umdefinierte Gruppenanzeige muss Gnus aber einen Timestamp in der Gruppe speichern.
2984 (add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp)
2985
2986 ;;** Ich will manchmal den Empfänger statt des Absenders sehen
2987 (setq gnus-extra-headers '(To Newsgroups Newsgroup Cc))
2988 (setq nnmail-extra-headers gnus-extra-headers)
2989 (setq gnus-ignored-from-addresses '("\\(\\(\\(joerg\\)\\(\\.jaspert\\)?\\)\\|root\\|gf\\)@\\(debian\\.org\\|ganneff\\.de\\|debconf\\.org\\|spi-inc\\.org\\|nsb-software\\.de\\|dlh\\.de\\)"))
2990
2991 ;; Don't send to these address in wide reply.
2992 (setq message-dont-reply-to-names (append '("notifications@github\\.com"
2993 ".*@noreply\\.github\\.com"
2994 )
2995 gnus-ignored-from-addresses))
2996
2997 ;;** Threads um 2 Zeichen einruecken.
2998 (setq gnus-thread-indent-level 1)
2999
3000 ;;** Posting Styles. Nettes Feature
3001 (setq gnus-posting-styles
3002 '(
3003 (".*"
3004 (from "Joerg Jaspert <joerg@ganneff.de>")) ; Globale Einstellung
3005 ("Allgemein.Sabrina"
3006 (from "Joerg (悠軻) Jaspert <joerg@debian.org>"))
3007 ("Debian.Private"
3008 (from "Joerg Jaspert <joerg@debian.org>")
3009 (signature-file "~/.signature.private"))
3010 ("dlh"
3011 (from "Joerg Jaspert <joerg@nsb-software.de>")
3012 (signature-file "~/.signature.nsb")
3013 (organization "NSB Nguyen Softwareentwicklung & beratung GmbH")
3014 (gcc "nnimap+nsb:Sent"))
3015 ("nnimap\\+nsb:.*"
3016 (from "Joerg Jaspert <joerg@nsb-software.de>")
3017 (signature-file "~/.signature.nsb")
3018 (organization "NSB Nguyen Softwareentwicklung & beratung GmbH")
3019 (gcc "nnimap+nsb:Sent"))
3020 ("nnimap\\+nsb:shared.gf.*"
3021 (from "Joerg Jaspert <gf@nsb-software.de>"))
3022 ("Debian"
3023 (from "Joerg Jaspert <joerg@debian.org>"))
3024 ("Debian.AM"
3025 (Gcc "nnimap+ganneff:Debian.AM"))
3026 ("Debian.DAM"
3027 (reply-to "Debian Account Managers <da-manager@debian.org>"))
3028 ("Debconf"
3029 (from "Joerg Jaspert <joerg@debconf.org>"))
3030 ("Bugs"
3031 (from "Joerg Jaspert <joerg@debian.org>"))
3032 ("SPI"
3033 (from "Joerg Jaspert <joerg@debian.org>"))
3034 ))
3035
3036
3037 ;;** Ich will die Header in den Nachrichten sehen die ich schreibe.
3038 (setq message-generate-headers-first t)
3039
3040 ;;** Und immer schoen Header zufuegen.
3041 (setq message-default-headers (concat "Organization: Ganneff\n"))
3042 (add-hook 'message-send-hook 'my-message-add-content)
3043
3044 ;;** Und Courtesy-Mails wollen wir schon mal grad gar nicht
3045 (add-hook 'message-header-setup-hook 'my-message-header-setup-hook)
3046
3047 ;;** Antworten auf meine Nachrichten hervorheben, hochscoren
3048 (add-hook 'message-sent-hook 'gnus-score-followup-article)
3049 (add-hook 'message-sent-hook 'gnus-score-followup-thread)
3050
3051 ;;** In Forwards bitte das Subject aufraeumen
3052 (setq message-wash-forwarded-subjects t)
3053
3054 ;;** Zitieren ohne Sig. Ausser Idioten sind zu doof die korrekt abzutrennen.
3055 (setq message-cite-function 'message-cite-original-without-signature)
3056
3057 ;;** Grosse Newsgroups. Gnus fragt da laestigerweise immer nach.
3058 ;;** Aber da ich viele grosse Gruppen und nen schnellen Rechner habe
3059 ;;** soll der erst recht spaet nachfragen. Erst wenns wirklich fies wird.
3060 (setq gnus-large-newsgroup "15000")
3061
3062 ;;** Beim Betreten einer Gruppe keinen Artikel auswählen. Gegen Adaptive Scoring iss des !
3063 (setq gnus-auto-select-first nil)
3064
3065 ;;** Wenn ich in einer Gruppe fertig bin soll Gnus nich fragen ob ich in
3066 ;;** die naechste will. Es soll einfach tun.
3067 (setq gnus-auto-select-next 'quietly)
3068
3069 ;;** Hervorhebungen (Unterstrichen und Fett bei "_X_" und "*X*")
3070 (add-hook 'gnus-article-display-hook 'gnus-article-emphasize t)
3071
3072 ;;** Gnus Visible Headers
3073 (setq gnus-visible-headers
3074 '("^From:"
3075 "^Newsgroups:"
3076 "^Subject:"
3077 "^Date:"
3078 "^Followup-To:"
3079 "^Reply-To:"
3080 "^Organization:"
3081 "^Summary:"
3082 "^Keywords:"
3083 "^To:"
3084 "^[BGF]?Cc:"
3085 "^Posted-To:"
3086 "^Mail-Copies-To:"
3087 "^Apparently-To:"
3088 "^X-Gnus-Warning:"
3089 "^Resent-From:"
3090 "^Xref:"
3091 "^X-Spam-Status:"
3092 "^X-Sent:"
3093 "^X-Mailer:"
3094 "^X-Newsreader:"
3095 "^X-User-Agent:"
3096 "^User-Agent:"))
3097
3098 ;;; Order of headers
3099 (setq gnus-sorted-header-list '("^From:"
3100 "^Subject:"
3101 "^Summary:"
3102 "^Keywords:"
3103 "^Newsgroups:"
3104 "^Followup-To:"
3105 "^To:"
3106 "^Cc:"
3107 "^Date:"
3108 "^Organization:"
3109 "^User-Agent:"
3110 "^X-Mailer:"
3111 "^X-Newsreader:"))
3112
3113 ;;** Automagischen Zeilenumbruch bei News/Mailangabe nach 72 Zeichen. SO wies sein soll.
3114 (add-hook 'message-mode-hook
3115 (lambda ()
3116 (setq fill-column 72)
3117 (turn-on-auto-fill)
3118 (epa-mail-mode 1)
3119 ))
3120
3121 ;;** Save gnus score files. Ziemlich doof wenn nicht
3122 (setq gnus-save-score t)
3123
3124 ;;** Score Einstellungen. Welches Global File und woher die Scores holen.
3125 (setq gnus-global-score-files '("~/News/all.SCORE"))
3126 (setq gnus-score-find-score-files-function '(gnus-score-find-bnews bbdb/gnus-score))
3127
3128 ;;** Adaptives Scoring
3129 (setq gnus-use-adaptive-scoring t)
3130 (defvar gnus-default-adaptive-score-alist
3131 '((gnus-unread-mark)
3132 (gnus-ticked-mark (from 5))
3133 (gnus-dormant-mark (from 6))
3134 (gnus-del-mark (subject -5))
3135 (gnus-read-mark (from 5) (subject 3))
3136 (gnus-expirable-mark (from -2) (subject -2))
3137 (gnus-killed-mark (from -2) (subject -4))
3138 (gnus-kill-file-mark)
3139 (gnus-ancient-mark)
3140 (gnus-low-score-mark)
3141 (gnus-catchup-mark (subject -3))
3142 ))
3143
3144 ;;** Damit ich nicht mit Megabytegrossen Scorefiles rummachen muss, muss bei Adaptive-Scoring
3145 ;;** der Kram automagisch gelöscht werden. Sonst hats keinen Sinn !
3146 (setq gnus-decay-scores t)
3147
3148 ;;** Artikel mit weniger Score werden nicht angezeigt
3149 (setq gnus-summary-expunge-below -1000)
3150
3151 ;;** work around unimplemented handling of multiple similar attachments
3152 ;;** (recommended by ShengHuo Zhu Fri 20 Jul 2001 13:14)
3153 (setq gnus-mime-display-multipart-related-as-mixed t)
3154
3155 ;;** Bilderchen direkt anzeigen.
3156 (setq mm-inline-large-images t)
3157
3158 ;;** ueberfluessige Leerzeilen loeschen
3159 (setq gnus-treat-strip-trailing-blank-lines t)
3160 (setq gnus-treat-strip-leading-blank-lines t)
3161
3162 ;;** Falsch gebaute Attachments ? Nich mit mir. Nuja, UUE wech. Was solls. Will ich eh nich haben
3163 (setq mm-uu-configure-list '((uu . disabled)))
3164
3165 ;; (use-package message-utils
3166 ;; :commands (message-mark-inserted-region message-mark-insert-file message-strip-subject-was message-change-subject message-xpost-fup2 message-add-archive-header message-reduce-to-to-cc)
3167 ;; :bind ((:map message-mode-map
3168 ;; ("C-c m" . message-mark-inserted-region)
3169 ;; ("C-c f" . message-mark-insert-file)
3170 ;; ("C-c x" . message-xpost-fup2)
3171 ;; ("C-c s" . message-change-subject)
3172 ;; ("C-c a" . message-add-archive-header)
3173 ;; ("C-c t" . message-reduce-to-to-cc)
3174 ;; )))
3175 ;(add-hook 'message-header-setup-hook 'message-strip-subject-was)
3176 ;(add-hook 'message-setup-hook 'message-utils-setup)
3177
3178 ;;** Nun das Paket um einfachst Fussnoten eingeben zu können.
3179 (use-package footnote
3180 :commands (footnote-mode)
3181 :config
3182 (setq footnote-body-tag-spacing 1
3183 footnote-spaced-footnotes nil
3184 footnote-style 'numeric-latin
3185 footnote-section-tag "Fussnoten: "))
3186 (add-hook 'message-mode-hook 'footnote-mode)
3187
3188 ;;** Meine Smileys mag ich gelb
3189 (use-package smiley
3190 :init
3191 (progn
3192 (setq gnus-treat-display-smileys t)
3193 (setq smiley-flesh-color "Yellow")
3194 (setq smiley-data-directory "~/emacs/etc/smilies/")))
3195
3196 (use-package mml-sec
3197 :commands (sign-or-crypt)
3198 :config
3199 (progn
3200 (setq mm-verify-option 'always)
3201 ;; Keine extra Signatur erzeugen.
3202 (mml-signencrypt-style "pgpmime" 'combined)
3203 (setq mml-secure-openpgp-sign-with-sender 't)
3204 (setq gpg-unabbrev-trust-alist
3205 '(("TRUST_UNDEFINED" . trust-undefined)
3206 ("TRUST_NEVER" . trust-none)
3207 ("TRUST_MARGINAL" . trust-marginal)
3208 ("TRUST_FULLY" . trust-full)
3209 ("TRUST_ULTIMATE" . trust-ultimate)))
3210 ))
3211 (add-hook 'gnus-message-setup-hook 'sign-or-crypt)
3212
3213 ;;** utf-8, coding systems
3214 (setq mm-coding-system-priorities
3215 '(iso-latin-1 iso-latin-9 utf-8))
3216
3217 (unify-8859-on-encoding-mode 1)
3218 (unify-8859-on-decoding-mode 1)
3219 (prefer-coding-system 'latin-9)
3220 (prefer-coding-system 'latin-1)
3221 (prefer-coding-system 'utf-8)
3222
3223 ;;** org-mode
3224 (add-hook 'message-mode-hook 'orgstruct++-mode 'append)
3225 (add-hook 'message-mode-hook 'orgtbl-mode 'append)
3226
3227 (use-package message-x
3228 :load-path "elisp/local")
3229
3230 (use-package randomsig
3231 :bind (:map message-mode-map
3232 ("C-c s" . randomsig-replace-sig)
3233 ("C-c S" . randomsig-select-sig))
3234 :config
3235 (progn
3236 (setq randomsig-dir "/home/joerg/sigs")
3237 (setq message-signature 'randomsig-signature)))
3238
3239 (use-package sieve
3240 :mode ("\\.siv\\'" . sieve-mode)
3241 :config
3242 (require 'gnus-sieve)
3243 )
3244
3245 (setq gnus-use-correct-string-widths nil)
3246
3247 (setq nnrss-wash-html-in-text-plain-parts t)
3248 (setq canlock-password "canlockjjaspert")
3249 (setq canlock-sha1-function (quote canlock-sha1-with-openssl))
3250 (setq canlock-sha1-function-for-verify (quote canlock-sha1-with-openssl))
3251 (setq gnus-agent nil)
3252 (setq gnus-article-banner-alist (quote ((banner-perl . "^--.?
3253 .+
3254 .+
3255 .+
3256 .+
3257 .+
3258 Die Nutzung von.+html") (banner-debian . "^--.?
3259 To UNSUBSCRIBE.*
3260 .*@lists.debian.org$") (banner-debian-de . "^--.?
3261 -+
3262 Um sich aus der Liste auszutragen.+
3263 .+
3264 .+
3265 .+
3266 -+$\\|[0-9]+ eingetragene Mitglieder in dieser Liste.") (banner-sourceforge . "^_+
3267 .+@lists.sourceforge.net
3268 http://lists.sourceforge.net.+
3269 .+
3270 $") (banner-amavis . "^_+
3271 .+AMaViS-.*
3272 .*
3273 .*
3274 .*amavis-faq.php3$"))))
3275 (setq gnus-article-sort-functions (quote (gnus-article-sort-by-number gnus-article-sort-by-score gnus-article-sort-by-date)))
3276 (setq gnus-article-x-face-command (quote gnus-display-x-face-in-from))
3277 (setq gnus-boring-article-headers (quote (empty newsgroups followup-to reply-to)))
3278 (setq gnus-build-sparse-threads nil)
3279 (setq gnus-buttonized-mime-types '("multipart/signed"))
3280 (setq
3281 ;; collaps long citations
3282 ;; (w/ `gnus-treat-hide-citation t' or `W W c'):
3283 gnus-cited-closed-text-button-line-format
3284 "%(%{... [ %n lines (%l chars) of citation hidden, click here to expand ] ...%}%)\n"
3285 gnus-cited-lines-visible '(3 . 6) ; (top . bottom)
3286 ;; [...]
3287 gnus-treat-hide-citation t)
3288
3289 (setq gnus-default-article-saver (quote gnus-summary-save-in-file))
3290 ; (setq gnus-default-charset (quote iso-8859-1))
3291 (setq gnus-generate-tree-function (quote gnus-generate-vertical-tree))
3292 (setq gnus-group-charset-alist (quote (("\\(^\\|:\\)hk\\>\\|\\(^\\|:\\)tw\\>\\|\\<big5\\>" cn-big5) ("\\(^\\|:\\)cn\\>\\|\\<chinese\\>" cn-gb-2312) ("\\(^\\|:\\)fj\\>\\|\\(^\\|:\\)japan\\>" iso-2022-jp-2) ("\\(^\\|:\\)tnn\\>\\|\\(^\\|:\\)pin\\>\\|\\(^\\|:\\)sci.lang.japan" iso-2022-7bit) ("\\(^\\|:\\)relcom\\>" koi8-r) ("\\(^\\|:\\)fido7\\>" koi8-r) ("\\(^\\|:\\)\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2) ("\\(^\\|:\\)israel\\>" iso-8859-1) ("\\(^\\|:\\)han\\>" euc-kr) ("\\(^\\|:\\)alt.chinese.text.big5\\>" chinese-big5) ("\\(^\\|:\\)soc.culture.vietnamese\\>" vietnamese-viqr) ("\\(^\\|:\\)\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1))))
3293 (setq gnus-group-name-charset-group-alist (quote ((".*" . iso-8859-1))))
3294 (setq gnus-group-name-charset-method-alist (quote ((nntp . iso-8859-1))))
3295 (setq gnus-group-posting-charset-alist (quote (("^\\(no\\|fr\\)\\.[^,]*\\(,[
3296 ]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1)) ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[
3297 ]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r)) (message-this-is-mail nil nil) (message-this-is-news nil t))))(setq gnus-gcc-mark-as-read t)
3298 (setq gnus-list-identifiers "\\[\\(a-zA-Z\\)+\\]")
3299 (setq gnus-message-replyencrypt nil)
3300 (setq gnus-message-replysign nil)
3301 (setq gnus-novice-user nil)
3302 (setq gnus-refer-thread-limit t)
3303 (setq gnus-save-duplicate-list t)
3304 (setq gnus-simplify-ignored-prefixes nil)
3305 (setq gnus-summary-exit-hook (quote (gnus-summary-bubble-group)))
3306 (setq gnus-summary-mode-line-format "Gnus: %g [%A] %Z - killed: %E")
3307 (setq gnus-suppress-duplicates t)
3308 (setq gnus-thread-indent-level 2)
3309 (setq gnus-thread-sort-functions (quote (gnus-thread-sort-by-number gnus-thread-sort-by-score gnus-thread-sort-by-date)))
3310 (setq gnus-treat-capitalize-sentences nil)
3311 (setq gnus-treat-date-local (quote head))
3312 (setq gnus-treat-display-picons nil)
3313 (setq gnus-treat-display-xface (quote head))
3314 (setq gnus-treat-fill-article nil)
3315 (setq gnus-treat-fill-long-lines nil)
3316 (setq gnus-treat-from-picon (quote head))
3317 (setq gnus-treat-mail-picon (quote head))
3318 (setq gnus-treat-newsgroups-picon (quote head))
3319 (setq gnus-treat-strip-pgp (quote head))
3320 (setq gnus-treat-unsplit-urls t)
3321 (setq gnus-treat-x-pgp-sig (quote head))
3322 (setq gnus-use-picons t)
3323 (setq gnus-uu-post-encode-method (quote gnus-uu-post-encode-mime))
3324 (setq message-archive-note "X-No-Archive: Yes")
3325 ;(setq message-default-charset (quote iso-8859-1))
3326 (setq message-make-forward-subject-function (quote message-forward-subject-fwd))
3327 (setq message-max-buffers 5)
3328 (setq message-send-hook (quote (my-message-add-content)))
3329 (setq message-subscribed-regexps (quote (".*@lists.*" ".*@postfix.org" ".*@nongnu.org")))
3330 (setq message-use-followup-to (quote use))
3331 (setq mm-automatic-display (quote ("text/plain" "text/enriched" "text/richtext" "image/jpeg" "text/x-vcard" "image/pjepg" "image/.*" "message/delivery-status" "multipart/.*" "message/rfc822" "text/x-patch" "application/pgp-signature" "application/emacs-lisp" "application/x-pkcs7-signature" "application/pkcs7-signature" "application/x-pkcs7-mime" "application/pkcs7-mime" "application/pgp")))
3332 (setq mm-body-charset-encoding-alist (quote ((iso-2022-jp . 7bit) (iso-2022-jp-2 . 7bit) (iso-8859-1 . 8bit) (iso-8859-15 . 8bit))))
3333 (setq mm-decrypt-option (quote known))
3334 (setq mm-inlined-types (quote ("image/jpeg" "image/.*" "text/.*" "message/delivery-status" "message/rfc822" "message/partial" "message/external-body" "application/emacs-lisp" "application/x-emacs-lisp" "application/pgp-signature" "application/x-pkcs7-signature" "application/pkcs7-signature" "application/x-pkcs7-mime" "application/pkcs7-mime" "application/pgp")))
3335 (setq mm-verify-option (quote always))
3336 (setq nnimap-authinfo-file "~/.nnimap")
3337 (setq gnus-save-newsrc-file nil)
3338 (setq gnus-read-newsrc-file nil)
3339 (setq gnus-always-read-dribble-file t)
3340
3341 (setq gnus-refer-article-method
3342 '(current
3343 (nnweb "refer" (nnweb-type dejanews))))
3344
3345 ))
3346
3347 #+END_SRC
3348 ** go-mode
3349 [2017-03-11 Sat 20:06]
3350 The go language, see golang.org
3351 #+BEGIN_SRC emacs-lisp
3352 (use-package go-mode
3353 :ensure t
3354 :bind (("M-." . godef-jump)
3355 ("M-*" . pop-tag-mark))
3356 :config
3357 (progn
3358 (defun my-go-mode-hook ()
3359 (interactive)
3360 (add-hook 'before-save-hook 'gofmt-before-save)
3361 ; Customize compile command to run go build
3362 (if (not (string-match "go" compile-command))
3363 (set (make-local-variable 'compile-command)
3364 "go build -v && go test -v && go vet"))
3365 ; Use goimports instead of go-fmt
3366 (setq gofmt-command "goimports")
3367 )
3368 (add-hook 'go-mode-hook 'my-go-mode-hook)
3369 (use-package go-autocomplete
3370 :ensure t)
3371 (use-package go-eldoc
3372 :ensure t
3373 :config
3374 (progn
3375 (add-hook 'go-mode-hook 'go-eldoc-setup)))
3376 (use-package go-guru
3377 :ensure t
3378 :config
3379 (progn
3380 (go-guru-hl-identifier-mode)
3381 (setq go-guru-command "golang-guru")))
3382 ))
3383 #+END_SRC
3384 ** golden ratio
3385 [2015-02-20 Fri 16:27]
3386 When working with many windows at the same time, each window has a
3387 size that is not convenient for editing.
3388
3389 golden-ratio helps on this issue by resizing automatically the windows
3390 you are working on to the size specified in the "Golden Ratio". The
3391 window that has the main focus will have the perfect size for editing,
3392 while the ones that are not being actively edited will be re-sized to
3393 a smaller size that doesn't get in the way, but at the same time will
3394 be readable enough to know it's content.
3395 #+BEGIN_SRC emacs-lisp
3396 (use-package golden-ratio
3397 :ensure golden-ratio
3398 :diminish golden-ratio-mode
3399 :init
3400 (progn
3401 (golden-ratio-mode 1)
3402 (validate-setq golden-ratio-exclude-buffer-names '("*LV*" "*guide-key*" "*Ediff Control Panel*"))
3403 (validate-setq golden-ratio-exclude-modes '("calendar-mode" "gnus-summary-mode"
3404 "gnus-article-mode" "calc-mode" "calc-trail-mode"
3405 "bbdb-mode"))
3406 ))
3407 #+END_SRC
3408 ** goto last change
3409 [2015-02-22 Sun 13:28]
3410 Move point through buffer-undo-list positions.
3411 #+BEGIN_SRC emacs-lisp
3412 (use-package goto-last-change
3413 :commands (goto-last-change)
3414 :bind (("M-g l" . goto-last-change))
3415 )
3416 #+END_SRC
3417 ** guide-key
3418 [2014-06-11 Wed 22:27]
3419 guide-key.el displays the available key bindings automatically and
3420 dynamically.
3421
3422 For whatever reason I like this more than icicles <backtab> completion
3423 for this.
3424 #+BEGIN_SRC emacs-lisp
3425 (use-package guide-key
3426 :ensure guide-key
3427 :diminish guide-key-mode
3428 :config
3429 (progn
3430 (validate-setq guide-key/guide-key-sequence '("C-x" "C-c" "M-g" "M-s"))
3431 (guide-key-mode 1)
3432 (validate-setq guide-key/recursive-key-sequence-flag t)
3433 (validate-setq guide-key/popup-window-position 'bottom)
3434 (validate-setq guide-key/idle-delay 0.5)))
3435
3436 #+END_SRC
3437
3438 ** highlighting modes
3439 [2014-05-21 Wed 23:51]
3440 #+BEGIN_SRC emacs-lisp
3441 (use-package hi-lock
3442 :bind (("M-o l" . highlight-lines-matching-regexp)
3443 ("M-o r" . highlight-regexp)
3444 ("M-o w" . highlight-phrase)
3445 ("M-o u" . unhighlight-regexp)))
3446
3447 (use-package hilit-chg
3448 :bind ("M-o C" . highlight-changes-mode))
3449
3450 (use-package highlight-indentation
3451 :ensure t
3452 :commands 'highlight-indentation-mode
3453 :init
3454 (hook-into-modes 'highlight-indentation-mode '(yaml-mode-hook python-mode-hook))
3455 (hook-into-modes 'highlight-indentation-current-column-mode '(yaml-mode-hook python-mode-hook))
3456 :config
3457 (set-face-background 'highlight-indentation-face "#283d83")
3458 (set-face-background 'highlight-indentation-current-column-face "#285f85")
3459 )
3460 #+END_SRC
3461 ** hippie-exp
3462 Crazy way of completion. It looks at the word before point and then
3463 tries to expand it in various ways.
3464 #+BEGIN_SRC emacs-lisp
3465 (use-package hippie-exp
3466 :bind ("M-/" . hippie-expand)
3467 :commands hippie-expand
3468 :config
3469 (progn
3470 (validate-setq hippie-expand-try-functions-list '(try-expand-dabbrev
3471 try-expand-dabbrev-all-buffers
3472 try-expand-dabbrev-from-kill
3473 try-complete-file-name-partially
3474 try-complete-file-name
3475 try-expand-all-abbrevs try-expand-list
3476 try-expand-line
3477 try-complete-lisp-symbol-partially
3478 try-complete-lisp-symbol))))
3479 #+END_SRC
3480 ** CANCELLED html-helper :CANCELLED:
3481 CLOSED: [2017-08-26 Sat 15:09]
3482 :LOGBOOK:
3483 - State "CANCELLED" from [2017-08-26 Sat 15:09]
3484 :END:
3485 Replaced by web-mode [[*web-mode][web-mode]]
3486 #+BEGIN_SRC emacs-lisp :tangle no
3487 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
3488 (add-auto-mode 'html-helper-mode "\\.html$")
3489 (add-auto-mode 'html-helper-mode "\\.asp$")
3490 (add-auto-mode 'html-helper-mode "\\.phtml$")
3491 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
3492 (defalias 'html-mode 'html-helper-mode)
3493 #+END_SRC
3494 ** hydra
3495 [2015-01-26 Mon 15:50]
3496 This is a package for GNU Emacs that can be used to tie related
3497 commands into a family of short bindings with a common prefix - a
3498 Hydra.
3499
3500 Once you summon the Hydra through the prefixed binding (the body + any
3501 one head), all heads can be called in succession with only a short
3502 extension.
3503
3504 The Hydra is vanquished once Hercules, any binding that isn't the
3505 Hydra's head, arrives. Note that Hercules, besides vanquishing the
3506 Hydra, will still serve his orignal purpose, calling his proper
3507 command. This makes the Hydra very seamless, it's like a minor mode
3508 that disables itself auto-magically.
3509 #+BEGIN_SRC emacs-lisp
3510 (use-package hydra
3511 :ensure hydra
3512 :init
3513 (progn
3514 (validate-setq hydra-is-helpful t)
3515 (validate-setq hydra-lv t)
3516
3517 (defhydra hydra-error (:color red)
3518 "goto-error"
3519 ("h" first-error "first")
3520 ("j" next-error "next")
3521 ("k" previous-error "prev")
3522 ("v" recenter-top-bottom "recenter")
3523 ("q" nil "quit"))
3524 (bind-key "M-g e" 'hydra-error/body)
3525
3526 (defhydra hydra-gnus (:color red)
3527 "gnus functions"
3528 ("m" gnus-uu-mark-thread "mark thread")
3529 ("d" gnus-summary-delete-article "delete article(s)")
3530 ("r" gnus-summary-mark-as-read-forward "mark read")
3531 ("n" gnus-summary-next-thread "next thread")
3532 ("p" gnus-summary-prev-thread "previous thread")
3533 ("g" gnus-summary-next-group "next group")
3534 ("l" gnus-recenter "recenter")
3535 ("x" gnus-summary-limit-to-unread "unread")
3536 ("q" nil "quit"))
3537 (bind-key "C-c h" 'hydra-gnus/body)
3538
3539 (defhydra hydra-launcher (:color blue)
3540 "Launch"
3541 ("h" man "man")
3542 ("r" (browse-url "http://www.reddit.com/r/emacs/") "reddit")
3543 ("w" (browse-url "http://www.emacswiki.org/") "emacswiki")
3544 ("s" shell "shell")
3545 ("q" nil "cancel"))
3546 (bind-key "M-g r" 'hydra-launcher/body)
3547
3548 ; whitespace mode gets loaded late, so variable may not be there yet. Workaround...
3549 (defvar whitespace-mode nil)
3550 (defhydra hydra-toggle (:color pink)
3551 "
3552 _a_ abbrev-mode: % 4`abbrev-mode^^^^ _f_ auto-fill-mode: %`auto-fill-function
3553 _c_ auto-complete-mode: % 4`auto-complete-mode _r_ auto-revert-mode: %`auto-revert-mode
3554 _d_ debug-on-error: % 4`debug-on-error^ _t_ truncate-lines: %`truncate-lines
3555 _w_ whitespace-mode: % 4`whitespace-mode _g_ golden-ratio-mode: %`golden-ratio-mode
3556 _l_ linum-mode: % 4`linum-mode _k_ linum relative: %`linum-format
3557
3558 "
3559 ("a" abbrev-mode nil)
3560 ("c" auto-complete-mode nil)
3561 ("i" aggressive-indent-mode nil)
3562 ("d" toggle-debug-on-error nil)
3563 ("f" auto-fill-mode nil)
3564 ("g" golden-ratio-mode nil)
3565 ("t" toggle-truncate-lines nil)
3566 ("w" whitespace-mode nil)
3567 ("r" auto-revert-mode nil)
3568 ("l" linum-mode nil)
3569 ("k" linum-relative-toggle nil)
3570 ("q" nil "cancel"))
3571 (bind-key "C-c C-v" 'hydra-toggle/body)
3572 ))
3573
3574
3575 #+END_SRC
3576 ** ibuffer
3577 [2014-05-21 Wed 23:54]
3578 #+BEGIN_SRC emacs-lisp
3579 (use-package ibuffer
3580 :bind (("C-h h" . ibuffer)
3581 ("C-x C-b" . ibuffer)
3582 ("<XF86WebCam>" . ibuffer)
3583 :map ibuffer-mode-map
3584 ("s" . isearch-forward-regexp)
3585 ("." . ibuffer-invert-sorting)
3586 ("i" . ibuffer-magit-status)
3587 ("G" . ibuffer-magit-status))
3588 :commands (ibuffer)
3589 :defines (ibuffer-filtering-alist
3590 ibuffer-filter-groups ibuffer-compile-formats ibuffer-git-column-length
3591 ibuffer-show-empty-filter-groups ibuffer-saved-filter-groups)
3592 :config
3593 (progn
3594 (defvar my-ibufffer-separator " • ")
3595 (validate-setq ibuffer-filter-group-name-face 'variable-pitch
3596 ibuffer-use-header-line t)
3597 (unbind-key "M-o" ibuffer-mode-map)
3598
3599 (use-package f
3600 :ensure f)
3601
3602 (use-package ibuffer-vc
3603 :ensure t
3604 :commands
3605 (ibuffer-vc-set-filter-groups-by-vc-root
3606 ibuffer-vc-generate-filter-groups-by-vc-root))
3607
3608 (use-package ibuffer-tramp
3609 :ensure t
3610 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
3611 ibuffer-tramp-set-filter-groups-by-tramp-connection))
3612 ;; Switching to ibuffer puts the cursor on the most recent buffer
3613 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
3614 "Open ibuffer with cursor pointed to most recent buffer name"
3615 (let ((recent-buffer-name (buffer-name)))
3616 ad-do-it
3617 (ibuffer-update nil t)
3618 (unless (string= recent-buffer-name "*Ibuffer*")
3619 (ibuffer-jump-to-buffer recent-buffer-name))))
3620
3621 (defun ibuffer-magit-status ()
3622 (interactive)
3623 (--when-let (get-buffer "*Ibuffer*")
3624 (with-current-buffer it
3625 (let* ((selected-buffer (ibuffer-current-buffer))
3626 (buffer-path (with-current-buffer
3627 selected-buffer
3628 (or (buffer-file-name)
3629 list-buffers-directory
3630 default-directory)))
3631 (default-directory
3632 (if (file-regular-p buffer-path)
3633 (file-name-directory buffer-path)
3634 buffer-path)))
3635 (magit-status default-directory)))))
3636
3637 (validate-setq ibuffer-directory-abbrev-alist
3638 (-uniq
3639 (-flatten
3640 (--map
3641 (list
3642 (cons (f-slash (f-expand (cdr it))) my-ibufffer-separator)
3643 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
3644 '(
3645 ("dak" . "/develop/dak/")
3646 ("org" . "~/org/")
3647 ("config" . "~/.emacs.d/config/")
3648 ("tmp" . "~/tmp/")
3649 ("systmp" . "/tmp/")
3650 ("puppet" . "~/git/puppet")
3651 ("git" . "~/git/")
3652 )))))
3653
3654 (use-package ibuffer-git
3655 :ensure t)
3656 (use-package ibuffer-vc
3657 :ensure t)
3658
3659 (define-ibuffer-column size-h
3660 (:name "Size" :inline t)
3661 (cond
3662 ((> (buffer-size) 1000)
3663 (format "%7.1fk" (/ (buffer-size) 1000.0)))
3664 ((> (buffer-size) 1000000)
3665 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
3666 (t
3667 (format "%8d" (buffer-size)))))
3668
3669 (use-package ibuf-ext
3670 :config
3671 (validate-setq ibuffer-old-time 12))
3672
3673 (define-ibuffer-filter filename2
3674 "Toggle current view to buffers with filename matching QUALIFIER."
3675 (:description "filename2"
3676 :reader (read-from-minibuffer "Filter by filename (regexp): "))
3677 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
3678 (ibuffer-awhen (with-current-buffer buf
3679 (or buffer-file-name
3680 default-directory))
3681 (string-match qualifier it)))
3682
3683 (defvar ibuffer-magit-filter-groups nil)
3684 (defun ibuffer-magit-define-filter-groups ()
3685 (when (and (not ibuffer-magit-filter-groups)
3686 (boundp 'magit-repo-dirs))
3687 (validate-setq ibuffer-magit-filter-groups
3688 (--map (list
3689 (concat "git:: "
3690 (file-name-nondirectory (directory-file-name it)))
3691 `(filename2 . ,it))
3692 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
3693
3694 (defun ibuffer-set-filter-groups-by-root ()
3695 (interactive)
3696 ;; (ibuffer-projectile-define-filter-groups)
3697 ;; (ibuffer-magit-define-filter-groups)
3698 (validate-setq ibuffer-filter-groups
3699 (-concat
3700 ;; ibuffer-projectile-filter-groups
3701 ibuffer-magit-filter-groups
3702
3703 '(("MORE"
3704 (or (mode . magit-log-edit-mode)
3705 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
3706 (name . "^\\*Pymacs\\*$")
3707 (name . "^\\*helm.*\\*")
3708 (name . "^\\*Compile-log\\*$")
3709 (name . "^\\*Ido Completions\\*$")
3710 (name . "^\\*magit-\\(process\\)\\*$")
3711 (name . "^ "))))
3712 '(("Tramp"
3713 (or
3714 (name . "^\\*\\(tramp/.*\\)\\*$"))))
3715 '(("EMACS"
3716 (or
3717 (name . "^\\*scratch")
3718 (name . "^\\*Messages")
3719 (name . "^\\*Help")
3720 )))
3721 (ibuffer-vc-generate-filter-groups-by-vc-root)
3722 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
3723
3724 (defun toggle-ibuffer-filter-groups ()
3725 "DOCSTRING"
3726 (interactive)
3727 (let ((ibuf (get-buffer "*Ibuffer*")))
3728 (when ibuf
3729 (with-current-buffer ibuf
3730 (let ((selected-buffer (ibuffer-current-buffer)))
3731 (if (not ibuffer-filter-groups)
3732 (ibuffer-set-filter-groups-by-root)
3733 (validate-setq ibuffer-filter-groups nil))
3734 (pop-to-buffer ibuf)
3735 (ibuffer-update nil t)
3736 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
3737
3738 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
3739
3740 (defun ibuffer-back-to-top ()
3741 (interactive)
3742 (beginning-of-buffer)
3743 (next-line 3))
3744
3745 (defun ibuffer-jump-to-bottom ()
3746 (interactive)
3747 (end-of-buffer)
3748 (beginning-of-line)
3749 (next-line -2))
3750
3751 (define-key ibuffer-mode-map
3752 (vector 'remap 'end-of-buffer) 'ibuffer-jump-to-bottom)
3753 (define-key ibuffer-mode-map
3754 (vector 'remap 'beginning-of-buffer) 'ibuffer-back-to-top)
3755
3756 (setq ibuffer-default-sorting-mode 'recency)
3757 (setq ibuffer-eliding-string "…"
3758 ibuffer-compile-formats t
3759 ibuffer-git-column-length 6
3760 ibuffer-show-empty-filter-groups nil
3761 ibuffer-default-directory "~/"
3762 )
3763
3764 (validate-setq ibuffer-formats '((mark vc-status-mini
3765 " "
3766 (git-status 8 8 :left)
3767 " "
3768 read-only modified
3769 " "
3770 (name 18 18 :left :elide)
3771 " "
3772 (size-h 9 -1 :right)
3773 " "
3774 (mode 16 16 :left :elide)
3775 " " filename-and-process)
3776 (mark " "
3777 (git-status 8 8 :left)
3778 " "
3779 (name 16 -1)
3780 " " filename)
3781 ))
3782
3783 (validate-setq ibuffer-saved-filter-groups
3784 (quote (("flat")
3785 ("default"
3786 ("dired" (mode . dired-mode))
3787 ("perl" (mode . cperl-mode))
3788 ("puppet" (or
3789 (mode . puppet-mode)
3790 (mode . yaml-mode)))
3791 ("ruby" (mode . ruby-mode))
3792 ("emacs" (or
3793 (name . "^\\*scratch\\*$")
3794 (name . "^\\*Compile-log\\*$")
3795 (name . "^\\*Completions\\*$")
3796 (name . "^\\*Messages\\*$")
3797 (name . "^\\*Backtrace\\*$")
3798 (name . "^\\*Packages*\\*$")
3799 (name . "^\\*Help*\\*$")
3800 (mode . grep-mode)
3801 ))
3802 ("gnus" (or
3803 (mode . message-mode)
3804 (mode . bbdb-mode)
3805 (mode . mail-mode)
3806 (mode . gnus-group-mode)
3807 (mode . gnus-summary-mode)
3808 (mode . gnus-article-mode)
3809 (name . "^\\.bbdb$")
3810 (name . "^\\.newsrc-dribble")))
3811 ("org agenda" (or
3812 (mode . org-agenda-mode)
3813 (name . "^*Org Agenda")))
3814 ("org" (or
3815 (filename . ".*/org/.*")
3816 ;(mode . org-agenda-mode)
3817 (name . "^diary$")))
3818 ("scm" (or
3819 (mode . magit-status-mode)
3820 (mode . magit-log-mode)
3821 (mode . magit-diff-mode)
3822 (mode . magit-refs-mode)
3823 (mode . magit-revision-mode)
3824 (mode . vc-annotate-mode)))
3825 ("Tramp" (or
3826 (name . "^\\*\\(tramp/.*\\)\\*$")))
3827 ("code" (or
3828 (mode . emacs-lisp-mode)
3829 (mode . python-mode)
3830 (mode . ruby-mode)
3831 (mode . coffee-mode)
3832 (mode . js-mode)
3833 (mode . js2-mode)
3834 (mode . actionscript-mode)
3835 (mode . java-mode)
3836 (mode . sh-mode)
3837 (mode . haskell-mode)
3838 (mode . html-mode)
3839 (mode . web-mode)
3840 (mode . haml-mode)
3841 (mode . nxml-mode)
3842 (mode . go-mode)
3843 (mode . rust-mode)
3844 (mode . css-mode)))
3845 ("other" (or
3846 (mode . magit-log-edit-mode)
3847 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
3848 ("categorized"
3849 ;; -------------------------------------------------
3850 ;; programming languages #1
3851 ("code" (or
3852 (mode . emacs-lisp-mode)
3853 (mode . python-mode)
3854 (mode . ruby-mode)
3855 (mode . coffee-mode)
3856 (mode . js-mode)
3857 (mode . js2-mode)
3858 (mode . actionscript-mode)
3859 (mode . java-mode)
3860 (mode . sh-mode)
3861 (mode . haskell-mode)
3862 (mode . html-mode)
3863 (mode . web-mode)
3864 (mode . haml-mode)
3865 (mode . nxml-mode)
3866 (mode . go-mode)
3867 (mode . rust-mode)
3868 (mode . css-mode)))
3869 ;; -------------------------------------------------
3870 ;; configuration/data files
3871 ("conf" (or
3872 (mode . json-mode)
3873 (mode . yaml-mode)
3874 (mode . conf-mode)))
3875 ;; -------------------------------------------------
3876 ;; text/notetaking/org
3877 ("org agenda" (mode . org-agenda-mode))
3878 ("org" (or
3879 (mode . org-mode)
3880 (name . "^\\*Calendar\\*$")
3881 (name . "^diary$")))
3882 ("text misc" (or
3883 (mode . text-mode)
3884 (mode . rst-mode)
3885 (mode . markdown-mode)))
3886 ;; -------------------------------------------------
3887 ;; media
3888 ("media" (or
3889 (mode . image-mode)))
3890 ;; -------------------------------------------------
3891 ;; misc
3892 ("w3m" (mode . w3m-mode))
3893 ("scm" (or
3894 (mode . magit-status-mode)
3895 (mode . magit-log-mode)
3896 (mode . vc-annotate-mode)))
3897 ("dired" (mode . dired-mode))
3898 ("help" (or
3899 (mode . Info-mode)
3900 (mode . help-mode)
3901 (mode . Man-mode)
3902 (name . "^\\*Personal Keybindings\\*$")))
3903 ("Tramp" (or
3904 (name . "^\\*\\(tramp/.*\\)\\*$")))
3905 ;; -------------------------------------------------
3906 ;; *buffer* buffers
3907 ("MORE" (or (mode . magit-log-edit-mode)
3908 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
3909 (name . "^\\*Pymacs\\*$")
3910 (name . "^\\*Compile-log\\*$")
3911 (name . "^\\*Completions\\*$")
3912 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
3913 (name . "^ ")))
3914 ("*buffer*" (name . "\\*.*\\*"))))))
3915
3916 (add-hook 'ibuffer-mode-hook
3917 (lambda ()
3918 (ibuffer-auto-mode 1)
3919 (ibuffer-switch-to-saved-filter-groups "default")))
3920
3921 ;; Unless you turn this variable on you will be prompted every time
3922 ;; you want to delete a buffer, even unmodified ones, which is way
3923 ;; too cautious for most people. You’ll still be prompted for
3924 ;; confirmation when deleting modified buffers after the option has
3925 ;; been turned off.
3926 (validate-setq ibuffer-expert t)
3927 ))
3928 #+END_SRC
3929 ** ivy-mode, swiper, counsel
3930 [2015-10-16 Fri 16:28]
3931 Full docs at http://oremacs.com/swiper/
3932 #+BEGIN_SRC emacs-lisp
3933 (use-package swiper
3934 :ensure swiper
3935 :bind (("C-s" . swiper)
3936 ("C-r" . swiper)
3937 ("C-c r" . ivy-resume)
3938 ("<f7>" . ivy-resume))
3939 :config
3940 (progn
3941 ;(ivy-mode 1)
3942 (validate-setq ivy-use-virtual-buffers t)
3943 (setq ivy-count-format "(%d/%d) ")
3944 ;;advise swiper to recenter on exit
3945 (defun bjm-swiper-recenter (&rest args)
3946 "recenter display after swiper"
3947 (recenter)
3948 )
3949 (advice-add 'swiper :after #'bjm-swiper-recenter)
3950 ))
3951 #+END_SRC
3952 counsel is a collection of Ivy enhanced versions of common Emacs
3953 commands, see https://github.com/abo-abo/swiper
3954 #+BEGIN_SRC emacs-lisp
3955 (use-package counsel
3956 :ensure t
3957 :bind (("M-y" . counsel-yank-pop)
3958 ("M-x" . counsel-M-x)
3959 ("C-x C-f" . counsel-find-file)
3960 ("<f1> f" . counsel-describe-function)
3961 ("<f1> u" . counsel-unicode-char)
3962 ("C-c j" . counsel-git-grep)
3963 :map ivy-minibuffer-map
3964 ("M-y" . ivy-next-line)))
3965 #+END_SRC
3966 ** icicles
3967 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
3968 ‘TAB’ completion is to typing things manually every time.”]]
3969 #+BEGIN_SRC emacs-lisp
3970 (use-package icicles
3971 :load-path "elisp/icicles"
3972 :config
3973 (icy-mode 1))
3974 #+END_SRC
3975 ** CANCELLED icomplete :CANCELLED:
3976 CLOSED: [2017-08-26 Sat 14:44]
3977 :LOGBOOK:
3978 - State "CANCELLED" from [2017-08-26 Sat 14:44] \\
3979 ivy and icomplete dont work together
3980 :END:
3981 Incremental mini-buffer completion preview: Type in the minibuffer,
3982 list of matching commands is echoed
3983 #+BEGIN_SRC emacs-lisp
3984 (icomplete-mode 99)
3985 #+END_SRC
3986 ** iedit
3987 [2014-05-26 Mon 22:49]
3988 #+BEGIN_SRC emacs-lisp
3989 (use-package iedit
3990 :ensure iedit
3991 :commands (iedit-mode)
3992 :defer t
3993 :bind (("C-;" . iedit-mode)
3994 ("C-," . iedit-mode-toggle-on-function))
3995 )
3996
3997 #+END_SRC
3998 ** info stuff
3999 [2014-05-20 Tue 23:35]
4000 #+BEGIN_SRC emacs-lisp
4001 (use-package info
4002 :bind ("C-h C-i" . info-lookup-symbol)
4003 :commands info-lookup-symbol
4004 :config
4005 (progn
4006 ;; (defadvice info-setup (after load-info+ activate)
4007 ;; (use-package info+))
4008
4009 (defadvice Info-exit (after remove-info-window activate)
4010 "When info mode is quit, remove the window."
4011 (if (> (length (window-list)) 1)
4012 (delete-window)))))
4013
4014 (use-package info-look
4015 :commands info-lookup-add-help)
4016 #+END_SRC
4017 ** ispell
4018 [2016-11-13 Sun 13:22]
4019 #+BEGIN_SRC emacs-lisp
4020 (use-package ispell
4021 :defer t
4022 :config
4023 (progn
4024 (validate-setq ispell-personal-dictionary (expand-file-name "~/flydict" jj-cache-dir))
4025
4026 (validate-setq ispell-dictionary "de_DE")
4027 (validate-setq ispell-program-name "hunspell")
4028 (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC"))
4029 (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_EXAMPLE" . "#\\+END_EXAMPLE"))
4030 ))
4031 #+END_SRC
4032 ** linum (line number)
4033 Various modes should have line numbers in front of each line.
4034
4035 But then there are some where it would just be deadly - like org-mode,
4036 gnus, so we have a list of modes where we don't want to see it.
4037 #+BEGIN_SRC emacs-lisp
4038 (use-package linum
4039 :diminish linum-mode
4040 :config
4041 (progn
4042 (validate-setq linum-format "%3d ")
4043 (setq linum-mode-inhibit-modes-list '(org-mode
4044 eshell-mode
4045 shell-mode
4046 gnus-group-mode
4047 gnus-summary-mode
4048 gnus-article-mode))
4049
4050 (defadvice linum-on (around linum-on-inhibit-for-modes)
4051 "Stop the load of linum-mode for some major modes."
4052 (unless (member major-mode linum-mode-inhibit-modes-list)
4053 ad-do-it))
4054
4055 (ad-activate 'linum-on)
4056
4057 (use-package linum-relative
4058 :ensure linum-relative
4059 :init
4060 (progn
4061 (validate-setq linum-format 'dynamic)
4062 )))
4063 :init
4064 (global-linum-mode 1))
4065
4066 (use-package hlinum
4067 :ensure t
4068 :config
4069 (progn
4070 (hlinum-activate)))
4071 #+END_SRC
4072
4073 ** lisp editing stuff
4074
4075 [2013-04-21 So 21:00]
4076 I'm not doing much of it, except for my emacs and gnus configs, but
4077 then I like it nice too...
4078 #+BEGIN_SRC emacs-lisp
4079 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
4080 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
4081
4082 (defun remove-elc-on-save ()
4083 "If you're saving an elisp file, likely the .elc is no longer valid."
4084 (make-local-variable 'after-save-hook)
4085 (add-hook 'after-save-hook
4086 (lambda ()
4087 (if (file-exists-p (concat buffer-file-name "c"))
4088 (delete-file (concat buffer-file-name "c"))))))
4089
4090 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
4091 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
4092
4093 (use-package paredit
4094 :ensure paredit
4095 :diminish paredit-mode " π")
4096
4097 (setq lisp-coding-hook 'lisp-coding-defaults)
4098 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
4099
4100 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
4101 (add-hook 'emacs-lisp-mode-hook (lambda ()
4102 (run-hooks 'prelude-emacs-lisp-mode-hook)))
4103
4104
4105 (after "elisp-slime-nav"
4106 '(diminish 'elisp-slime-nav-mode))
4107 (after "rainbow-mode"
4108 '(diminish 'rainbow-mode))
4109 (after "eldoc"
4110 '(diminish 'eldoc-mode))
4111 #+END_SRC
4112 ** lua
4113 [2016-10-27 Thu 17:49]
4114 Lua editing
4115 #+BEGIN_SRC emacs-lisp
4116 (use-package lua-mode
4117 :ensure t
4118 :commands lua-mode
4119 :mode ("\\.lua" . lua-mode))
4120 #+END_SRC
4121 ** magit
4122 [2013-04-21 So 20:48]
4123 magit is a mode for interacting with git.
4124 #+BEGIN_SRC emacs-lisp
4125 (use-package magit
4126 :ensure magit
4127 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
4128 magit-git-repo-p magit-list-repos)
4129 :bind (("C-x g" . magit-status)
4130 ("C-x G" . magit-status-with-prefix)
4131 :map magit-status-mode-map
4132 ("q" . magit-quit-session ))
4133
4134 :config
4135 (progn
4136 (setq magit-repository-directories '("~/devel"
4137 "~/git/"
4138 ))
4139 (setq magit-repository-directories-depth 4)
4140 (setq magit-log-auto-more t)
4141 (setq magit-completing-read-function 'ivy-completing-read)
4142
4143 ; VC shouldnt do anything with git
4144 (setq vc-handled-backends (delq 'Git vc-handled-backends))
4145
4146 (use-package magit-blame
4147 :commands magit-blame-mode)
4148
4149 (add-hook 'magit-mode-hook 'hl-line-mode)
4150 (defun magit-status-with-prefix ()
4151 (interactive)
4152 (let ((current-prefix-arg '(4)))
4153 (call-interactively 'magit-status)))
4154 (setenv "GIT_PAGER" "")
4155
4156 (unbind-key "M-h" magit-mode-map)
4157 (unbind-key "M-s" magit-mode-map)
4158 (add-to-list 'magit-no-confirm 'stage-all-changes)
4159 (setq magit-push-always-verify nil)
4160
4161 (add-hook 'magit-log-edit-mode-hook
4162 #'(lambda ()
4163 (set-fill-column 72)
4164 (flyspell-mode)))
4165
4166 (add-hook 'git-rebase-mode-hook
4167 #'(lambda ()
4168 (smartscan-mode 0))
4169 )
4170 (defadvice magit-status (around magit-fullscreen activate)
4171 (window-configuration-to-register :magit-fullscreen)
4172 ad-do-it
4173 (delete-other-windows))
4174
4175 (defun magit-quit-session ()
4176 "Restores the previous window configuration and kills the magit buffer"
4177 (interactive)
4178 (kill-buffer)
4179 (jump-to-register :magit-fullscreen))
4180
4181 (defun magit-rebase-unpushed (commit &optional args)
4182 "Start an interactive rebase sequence over all unpushed commits."
4183 (interactive (list (magit-get-tracked-branch)
4184 (magit-rebase-arguments)))
4185 (if (setq commit (magit-rebase-interactive-assert commit))
4186 (magit-run-git-sequencer "rebase" "-i" commit args)
4187 (magit-log-select
4188 `(lambda (commit)
4189 (magit-rebase-interactive (concat commit "^") (list ,@args))))))
4190
4191 (magit-define-popup-action 'magit-rebase-popup ?l "Rebase unpushed" 'magit-rebase-unpushed)
4192 ))
4193 #+END_SRC
4194 ** markdown-mode
4195 [2014-05-20 Tue 23:04]
4196 #+BEGIN_SRC emacs-lisp
4197 (use-package markdown-mode
4198 :ensure t
4199 :mode (("\\.md\\'" . markdown-mode)
4200 ("\\.mdwn\\'" . markdown-mode))
4201 :defer t)
4202 #+END_SRC
4203 ** message
4204 #+BEGIN_SRC emacs-lisp
4205 (use-package message
4206 :config
4207 (progn
4208 (validate-setq message-kill-buffer-on-exit t)))
4209 #+END_SRC
4210 ** CANCELLED mingus :CANCELLED:
4211 CLOSED: [2017-08-26 Sat 15:18]
4212 :LOGBOOK:
4213 - State "CANCELLED" from [2017-08-26 Sat 15:18]
4214 :END:
4215 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
4216
4217 I want to access it from anywhere using =F6=.
4218 #+BEGIN_SRC emacs-lisp :tangle no
4219 (use-package mingus-stays-home
4220 :bind ( "<f6>" . mingus)
4221 :defer t
4222 :config
4223 (progn
4224 (validate-setq mingus-dired-add-keys t)
4225 (validate-setq mingus-mode-always-modeline nil)
4226 (validate-setq mingus-mode-line-show-elapsed-percentage nil)
4227 (validate-setq mingus-mode-line-show-volume nil)
4228 (validate-setq mingus-mpd-config-file "/etc/mpd.conf")
4229 (validate-setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
4230 (validate-setq mingus-mpd-root "/share/music/")))
4231 #+END_SRC
4232
4233 ** miniedit
4234 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
4235 #+BEGIN_SRC emacs-lisp
4236 (use-package miniedit
4237 :ensure miniedit
4238 :commands miniedit
4239 :config
4240 (progn
4241 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
4242 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
4243 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
4244 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
4245 ))
4246 #+END_SRC
4247
4248 ** CANCELLED mmm-mode :CANCELLED:
4249 CLOSED: [2017-08-26 Sat 15:18]
4250 :LOGBOOK:
4251 - State "CANCELLED" from [2017-08-26 Sat 15:18]
4252 :END:
4253 [2013-05-21 Tue 23:39]
4254 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
4255 coexist in one buffer.
4256 #+BEGIN_SRC emacs-lisp :tangle no
4257 (use-package mmm-auto
4258 :ensure mmm-mode
4259 :init
4260 (progn
4261 (validate-setq mmm-global-mode 'buffers-with-submode-classes)
4262 (validate-setq mmm-submode-decoration-level 2)
4263 (eval-after-load 'mmm-vars
4264 '(progn
4265 (mmm-add-group
4266 'html-css
4267 '((css-cdata
4268 :submode css-mode
4269 :face mmm-code-submode-face
4270 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
4271 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
4272 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
4273 @ "\n" _ "\n" @ "</script>" @)))
4274 (css
4275 :submode css-mode
4276 :face mmm-code-submode-face
4277 :front "<style[^>]*>[ \t]*\n?"
4278 :back "[ \t]*</style>"
4279 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
4280 @ "\n" _ "\n" @ "</style>" @)))
4281 (css-inline
4282 :submode css-mode
4283 :face mmm-code-submode-face
4284 :front "style=\""
4285 :back "\"")))
4286 (dolist (mode (list 'html-mode 'nxml-mode))
4287 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
4288 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
4289 ))))
4290 #+END_SRC
4291
4292 ** mo-git-blame
4293 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
4294 Emacs]].
4295 #+BEGIN_SRC emacs-lisp
4296 (use-package mo-git-blame
4297 :ensure mo-git-blame
4298 :commands (mo-git-blame-current
4299 mo-git-blame-file)
4300 :config
4301 (progn
4302 (validate-setq mo-git-blame-blame-window-width 25)))
4303 #+END_SRC
4304
4305 ** CANCELLED multiple cursors :CANCELLED:
4306 CLOSED: [2017-08-26 Sat 15:18]
4307 :LOGBOOK:
4308 - State "CANCELLED" from [2017-08-26 Sat 15:18]
4309 :END:
4310 [2013-04-08 Mon 23:57]
4311 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
4312 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
4313 #+BEGIN_SRC emacs-lisp :tangle no
4314 (use-package multiple-cursors
4315 :ensure multiple-cursors
4316 :defer t
4317 :commands (mc/remove-fake-cursors
4318 mc/create-fake-cursor-at-point
4319 mc/pop-state-from-overlay
4320 mc/maybe-multiple-cursors-mode)
4321 :defines (multiple-cursors-mode
4322 mc--read-char
4323 mc--read-quoted-char
4324 rectangular-region-mode)
4325 :bind (("C-S-c C-S-c" . mc/edit-lines)
4326 ("C->" . mc/mark-next-like-this)
4327 ("C-<" . mc/mark-previous-like-this)
4328 ("C-c C-<" . mc/mark-all-like-this)
4329 ("C-c i" . mc/insert-numbers))
4330 :config
4331 (progn
4332 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
4333 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
4334 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
4335 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
4336 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
4337 (validate-setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
4338 #+END_SRC
4339 ** neotree
4340 [2014-08-27 Wed 17:15]
4341 A emacs tree plugin
4342 #+BEGIN_SRC emacs-lisp
4343 (use-package neotree
4344 :ensure neotree
4345 :defer t
4346 :bind (("<f8>" . neotree-toggle))
4347 :commands (neotree-find
4348 neotree-toggle
4349 neotree)
4350 :config
4351 (progn
4352 (bind-key "^" 'neotree-select-up-node neotree-mode-map)
4353 (validate-setq neo-smart-open t)))
4354
4355 #+END_SRC
4356 ** notmuch
4357 [2016-10-24 Mon 18:18]
4358 Nice email search
4359 #+BEGIN_SRC emacs-lisp
4360 (use-package notmuch
4361 :ensure t
4362 :defer t
4363 :commands (notmuch)
4364 :config
4365 (progn
4366 (validate-setq notmuch-search-oldest-first nil)
4367 (use-package counsel-notmuch
4368 :ensure t)))
4369 #+END_SRC
4370 ** nxml
4371 [2013-05-22 Wed 22:02]
4372 nxml-mode is a major mode for editing XML.
4373 #+BEGIN_SRC emacs-lisp
4374 (use-package nxml-mode
4375 :mode (("web.config$" . xml-mode)
4376 ("\\.xml" . xml-mode)
4377 ("\\.xsd" . xml-mode)
4378 ("\\.sch" . xml-mode)
4379 ("\\.rng" . xml-mode)
4380 ("\\.xslt" . xml-mode)
4381 ("\\.svg" . xml-mode)
4382 ("\\.rss" . xml-mode)
4383 ("\\.gpx" . xml-mode)
4384 ("\\.tcx" . xml-mode))
4385 :defer t
4386 :config
4387 (progn
4388 (setq nxml-child-indent 4)
4389 (setq nxml-slash-auto-complete-flag t)
4390 ;(add-hook 'nxml-mode-hook (lambda () (emmet-mode t)))
4391
4392 (fset 'xml-mode 'nxml-mode)
4393 (validate-setq nxml-slash-auto-complete-flag t)
4394
4395 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
4396 (defun pp-xml-region (begin end)
4397 "Pretty format XML markup in region. The function inserts
4398 linebreaks to separate tags that have nothing but whitespace
4399 between them. It then indents the markup by using nxml's
4400 indentation rules."
4401 (interactive "r")
4402 (save-excursion
4403 (nxml-mode)
4404 (goto-char begin)
4405 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
4406 (backward-char) (insert "\n"))
4407 (indent-region begin end)))
4408
4409 ;;----------------------------------------------------------------------------
4410 ;; Integration with tidy for html + xml
4411 ;;----------------------------------------------------------------------------
4412 ;; tidy is autoloaded
4413 (eval-after-load 'tidy
4414 '(progn
4415 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
4416 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
4417 ))))
4418
4419 #+END_SRC
4420 ** org :FIXME:
4421 *** General settings
4422 [2013-04-28 So 17:06]
4423
4424 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
4425 it is quite extensive. Nevertheless, it starts out small, loading it.
4426 #+BEGIN_SRC emacs-lisp
4427 (require 'org)
4428 #+END_SRC
4429
4430 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
4431 that we need org-protocol.
4432 #+BEGIN_SRC emacs-lisp
4433 (require 'org-protocol)
4434 #+END_SRC
4435
4436 *** Agenda
4437
4438 My current =org-agenda-files= variable only includes a set of
4439 directories.
4440 #+BEGIN_SRC emacs-lisp
4441 (setq org-agenda-files (quote ("~/org/"
4442 "~/org/nsb"
4443 )))
4444 (setq org-default-notes-file "~/org/notes.org")
4445 #+END_SRC
4446 =org-mode= manages the =org-agenda-files= variable automatically using
4447 =C-c [= and =C-c ]= to add and remove files respectively. However,
4448 this replaces my directory list with a list of explicit filenames
4449 instead and is not what I want. If this occurs then adding a new org
4450 file to any of the above directories will not contribute to my agenda
4451 and I will probably miss something important.
4452
4453 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
4454 prevent messing up my list of directories in the =org-agenda-files=
4455 variable. I just add and remove directories manually here. Changing
4456 the list of directories in =org-agenda-files= happens very rarely
4457 since new files in existing directories are automatically picked up.
4458
4459 #+BEGIN_SRC emacs-lisp
4460 ;; Keep tasks with dates on the global todo lists
4461 (setq org-agenda-todo-ignore-with-date nil)
4462
4463 ;; Keep tasks with deadlines on the global todo lists
4464 (setq org-agenda-todo-ignore-deadlines nil)
4465
4466 ;; Keep tasks with scheduled dates on the global todo lists
4467 (setq org-agenda-todo-ignore-scheduled nil)
4468
4469 ;; Keep tasks with timestamps on the global todo lists
4470 (setq org-agenda-todo-ignore-timestamp nil)
4471
4472 ;; Remove completed deadline tasks from the agenda view
4473 (setq org-agenda-skip-deadline-if-done t)
4474
4475 ;; Remove completed scheduled tasks from the agenda view
4476 (setq org-agenda-skip-scheduled-if-done t)
4477
4478 ;; Remove completed items from search results
4479 (setq org-agenda-skip-timestamp-if-done t)
4480
4481 ;; Include agenda archive files when searching for things
4482 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
4483
4484 ;; Show all future entries for repeating tasks
4485 (setq org-agenda-repeating-timestamp-show-all t)
4486
4487 ;; Show all agenda dates - even if they are empty
4488 (setq org-agenda-show-all-dates t)
4489
4490 ;; Sorting order for tasks on the agenda
4491 (setq org-agenda-sorting-strategy
4492 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
4493 (todo category-up priority-down effort-up)
4494 (tags category-up priority-down effort-up)
4495 (search category-up))))
4496
4497 ;; Start the weekly agenda on Monday
4498 (setq org-agenda-start-on-weekday 1)
4499
4500 ;; Enable display of the time grid so we can see the marker for the current time
4501 (setq org-agenda-time-grid (quote ((daily today remove-match)
4502 #("----------------" 0 16 (org-heading t))
4503 (0800 1000 1200 1400 1500 1700 1900 2100))))
4504
4505 ;; Display tags farther right
4506 (setq org-agenda-tags-column -102)
4507
4508 ; position the habit graph on the agenda to the right of the default
4509 (setq org-habit-graph-column 50)
4510
4511 ; turn habits back on
4512 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
4513
4514 ;;
4515 ;; Agenda sorting functions
4516 ;;
4517 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
4518
4519
4520 (setq org-deadline-warning-days 30)
4521
4522 ;; Always hilight the current agenda line
4523 (add-hook 'org-agenda-mode-hook
4524 '(lambda () (hl-line-mode 1))
4525 'append)
4526 #+END_SRC
4527
4528 #+BEGIN_SRC emacs-lisp
4529 (setq org-agenda-persistent-filter t)
4530 (add-hook 'org-agenda-mode-hook
4531 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
4532 'append)
4533
4534 (add-hook 'org-agenda-mode-hook
4535 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
4536 'append)
4537
4538 (add-hook 'org-agenda-mode-hook
4539 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
4540 'append)
4541
4542 (add-hook 'org-agenda-mode-hook
4543 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
4544 'append)
4545
4546 (add-hook 'org-agenda-mode-hook
4547 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
4548 'append)
4549
4550 ; Rebuild the reminders everytime the agenda is displayed
4551 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
4552
4553 ;(if (file-exists-p "~/org/refile.org")
4554 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
4555
4556 ; Activate appointments so we get notifications
4557 (appt-activate t)
4558
4559 (setq org-agenda-log-mode-items (quote (closed clock state)))
4560 (if (> emacs-major-version 23)
4561 (setq org-agenda-span 3)
4562 (setq org-agenda-ndays 3))
4563
4564 (setq org-agenda-show-all-dates t)
4565 (setq org-agenda-start-on-weekday nil)
4566 (setq org-deadline-warning-days 14)
4567
4568 #+END_SRC
4569 *** Global keybindings.
4570 Start off by defining a series of keybindings.
4571
4572 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
4573 setup manually, not by org-mode. Also turn off =C-c ;=, which
4574 comments headlines - a function never used.
4575 #+BEGIN_SRC emacs-lisp
4576 (add-hook 'org-mode-hook
4577 (lambda ()
4578 (org-defkey org-mode-map "\C-c[" 'undefined)
4579 (org-defkey org-mode-map "\C-c]" 'undefined)
4580 (org-defkey org-mode-map "\C-c;" 'undefined))
4581 'append)
4582 #+END_SRC
4583
4584 And now a largish set of keybindings...
4585 #+BEGIN_SRC emacs-lisp
4586 (bind-key "C-c l" 'org-store-link)
4587 (bind-key "C-c a" 'org-agenda)
4588 ;(bind-key "C-c b" 'org-iswitchb)
4589 (define-key mode-specific-map [?a] 'org-agenda)
4590
4591 (bind-key "<f12>" 'org-agenda)
4592 (bind-key "<f5>" 'bh/org-todo)
4593 (bind-key "<S-f5>" 'bh/widen)
4594 ;(bind-key "<f7>" 'bh/set-truncate-lines)
4595 ;(bind-key "<f8>" 'org-cycle-agenda-files)
4596
4597 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
4598 (bind-key "<f9> b" 'bbdb)
4599 (bind-key "<f9> c" 'calendar)
4600 (bind-key "<f9> f" 'boxquote-insert-file)
4601 (bind-key "<f9> h" 'bh/hide-other)
4602 (bind-key "<f9> n" 'org-narrow-to-subtree)
4603 (bind-key "<f9> w" 'widen)
4604 (bind-key "<f9> u" 'bh/narrow-up-one-level)
4605 (bind-key "<f9> I" 'bh/punch-in)
4606 (bind-key "<f9> O" 'bh/punch-out)
4607 (bind-key "<f9> H" 'jj/punch-in-hw)
4608 (bind-key "<f9> W" 'jj/punch-out-hw)
4609 (bind-key "<f9> o" 'bh/make-org-scratch)
4610 (bind-key "<f9> p" 'bh/phone-call)
4611 (bind-key "<f9> r" 'boxquote-region)
4612 (bind-key "<f9> s" 'bh/switch-to-scratch)
4613 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
4614 (bind-key "<f9> T" 'tabify)
4615 (bind-key "<f9> U" 'untabify)
4616 (bind-key "<f9> v" 'visible-mode)
4617 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
4618 (bind-key "C-<f9>" 'previous-buffer)
4619 (bind-key "C-<f10>" 'next-buffer)
4620 (bind-key "M-<f9>" 'org-toggle-inline-images)
4621 ;(bind-key "C-x n r" 'narrow-to-region)
4622 (bind-key "<f11>" 'org-clock-goto)
4623 (bind-key "C-<f11>" 'org-clock-in)
4624 (bind-key "C-M-r" 'org-capture)
4625 ;(bind-key "C-c r" 'org-capture)
4626 (bind-key "C-S-<f12>" 'bh/save-then-publish)
4627 ;(bind-key "C-k" 'jj-org-kill-line org-mode-map)
4628
4629 #+END_SRC
4630
4631 *** Tasks, States, Todo fun
4632
4633 First we define the global todo keywords.
4634 #+BEGIN_SRC emacs-lisp
4635 (setq org-todo-keywords
4636 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
4637 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
4638
4639 (setq org-todo-keyword-faces
4640 (quote (("TODO" :foreground "red" :weight bold)
4641 ("NEXT" :foreground "light blue" :weight bold)
4642 ("DONE" :foreground "forest green" :weight bold)
4643 ("WAITING" :foreground "orange" :weight bold)
4644 ("HOLD" :foreground "orange" :weight bold)
4645 ("DELEGATED" :foreground "yellow" :weight bold)
4646 ("CANCELLED" :foreground "dark green" :weight bold)
4647 ("PHONE" :foreground "dark green" :weight bold))))
4648 #+END_SRC
4649
4650 **** Fast Todo Selection
4651 Fast todo selection allows changing from any task todo state to any
4652 other state directly by selecting the appropriate key from the fast
4653 todo selection key menu.
4654 #+BEGIN_SRC emacs-lisp
4655 (setq org-use-fast-todo-selection t)
4656 #+END_SRC
4657 Changing a task state is done with =C-c C-t KEY=
4658
4659 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
4660
4661 The setting
4662 #+BEGIN_SRC emacs-lisp
4663 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
4664 #+END_SRC
4665 allows changing todo states with S-left and S-right skipping all of
4666 the normal processing when entering or leaving a todo state. This
4667 cycles through the todo states but skips setting timestamps and
4668 entering notes which is very convenient when all you want to do is fix
4669 up the status of an entry.
4670
4671 **** Todo State Triggers
4672 I have a few triggers that automatically assign tags to tasks based on
4673 state changes. If a task moves to =CANCELLED= state then it gets a
4674 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
4675 =CANCELLED= tag. These are used for filtering tasks in agenda views
4676 which I'll talk about later.
4677
4678 The triggers break down to the following rules:
4679
4680 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
4681 - Moving a task to =WAITING= adds a =WAITING= tag
4682 - Moving a task to =HOLD= adds a =WAITING= tag
4683 - Moving a task to a done state removes a =WAITING= tag
4684 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
4685 - Moving a task to =NEXT= removes a =WAITING= tag
4686 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
4687
4688 The tags are used to filter tasks in the agenda views conveniently.
4689 #+BEGIN_SRC emacs-lisp
4690 (setq org-todo-state-tags-triggers
4691 (quote (("CANCELLED" ("CANCELLED" . t))
4692 ("WAITING" ("WAITING" . t))
4693 ("HOLD" ("WAITING" . t) ("HOLD" . t))
4694 (done ("WAITING") ("HOLD"))
4695 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
4696 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
4697 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
4698 #+END_SRC
4699
4700 *** Capturing new tasks
4701 Org capture replaces the old remember mode.
4702 #+BEGIN_SRC emacs-lisp
4703 (setq org-directory "~/org")
4704 (setq org-default-notes-file "~/org/refile.org")
4705
4706 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
4707 ;; see http://orgmode.org/manual/Template-elements.html
4708 (setq org-capture-templates
4709 (quote (("t" "todo" entry (file "~/org/refile.org")
4710 "* TODO %?\nAdded: %U\n"
4711 :clock-in t :clock-resume t)
4712 ("l" "linktodo" entry (file "~/org/refile.org")
4713 "* TODO %?\nAdded: %U\n%a\n"
4714 :clock-in t :clock-resume t)
4715 ("r" "respond" entry (file "~/org/refile.org")
4716 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
4717 :clock-in t :clock-resume t :immediate-finish t)
4718 ("n" "note" entry (file "~/org/refile.org")
4719 "* %? :NOTE:\nAdded: %U\n%a\n"
4720 :clock-in t :clock-resume t)
4721 ("d" "Delegated" entry (file "~/org/refile.org")
4722 "* DELEGATED %?\nAdded: %U\n%a\n"
4723 :clock-in t :clock-resume t)
4724 ("j" "Journal" entry (file+datetree "~/org/diary.org")
4725 "* %?\nAdded: %U\n"
4726 :clock-in t :clock-resume t)
4727 ("w" "org-protocol" entry (file "~/org/refile.org")
4728 "* TODO Review %c\nAdded: %U\n"
4729 :immediate-finish t)
4730 ("p" "Phone call" entry (file "~/org/refile.org")
4731 "* PHONE %? :PHONE:\nAdded: %U"
4732 :clock-in t :clock-resume t)
4733 ("x" "Bookmark link" entry (file "~/org/refile.org")
4734 "* Bookmark: %c\n%i\nAdded: %U\n"
4735 :immediate-finish t)
4736 ("h" "Habit" entry (file "~/org/refile.org")
4737 "* 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")
4738 )))
4739 #+END_SRC
4740
4741 Capture mode now handles automatically clocking in and out of a
4742 capture task. This all works out of the box now without special hooks.
4743 When I start a capture mode task the task is clocked in as specified
4744 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
4745 resumes on the original clocking task.
4746
4747 The quick clocking in and out of capture mode tasks (often it takes
4748 less than a minute to capture some new task details) can leave
4749 empty clock drawers in my tasks which aren't really useful.
4750 The following prevents this.
4751 #+BEGIN_SRC emacs-lisp :tangle no
4752 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
4753 #+END_SRC
4754
4755 *** Refiling
4756 All my newly captured entries end up in =refile.org= and want to be
4757 moved over to the right place. The following is the setup for it.
4758 #+BEGIN_SRC emacs-lisp
4759 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
4760 (setq org-refile-targets (quote ((nil :maxlevel . 9)
4761 (org-agenda-files :maxlevel . 9))))
4762
4763 ; Use full outline paths for refile targets - we file directly with IDO
4764 (setq org-refile-use-outline-path t)
4765
4766 ; Targets complete directly with IDO
4767 (setq org-outline-path-complete-in-steps nil)
4768
4769 ; Allow refile to create parent tasks with confirmation
4770 (setq org-refile-allow-creating-parent-nodes (quote confirm))
4771
4772 ; Use IDO for both buffer and file completion and ido-everywhere to t
4773 (setq org-completion-use-ido t)
4774 (setq org-completion-use-iswitchb nil)
4775 :; Use IDO for both buffer and file completion and ido-everywhere to t
4776 ;(setq ido-everywhere t)
4777 ;(setq ido-max-directory-size 100000)
4778 ;(ido-mode (quote both))
4779 ; Use the current window when visiting files and buffers with ido
4780 (setq ido-default-file-method 'selected-window)
4781 (setq ido-default-buffer-method 'selected-window)
4782
4783 ;;;; Refile settings
4784 (setq org-refile-target-verify-function 'bh/verify-refile-target)
4785 #+END_SRC
4786
4787 *** Custom agenda
4788 Agenda view is the central place for org-mode interaction...
4789 #+BEGIN_SRC emacs-lisp
4790 ;; Do not dim blocked tasks
4791 (setq org-agenda-dim-blocked-tasks nil)
4792 ;; Compact the block agenda view
4793 (setq org-agenda-compact-blocks t)
4794
4795 ;; Custom agenda command definitions
4796 (setq org-agenda-custom-commands
4797 (quote (("N" "Notes" tags "NOTE"
4798 ((org-agenda-overriding-header "Notes")
4799 (org-tags-match-list-sublevels t)))
4800 ("h" "Habits" tags-todo "STYLE=\"habit\""
4801 ((org-agenda-overriding-header "Habits")
4802 (org-agenda-sorting-strategy
4803 '(todo-state-down effort-up category-keep))))
4804 (" " "Agenda"
4805 ((agenda "" nil)
4806 (tags "REFILE"
4807 ((org-agenda-overriding-header "Tasks to Refile")
4808 (org-tags-match-list-sublevels nil)))
4809 (tags-todo "-HOLD-CANCELLED/!"
4810 ((org-agenda-overriding-header "Projects")
4811 (org-agenda-skip-function 'bh/skip-non-projects)
4812 (org-agenda-sorting-strategy
4813 '(category-keep))))
4814 (tags-todo "-CANCELLED/!"
4815 ((org-agenda-overriding-header "Stuck Projects")
4816 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
4817 (tags-todo "-WAITING-CANCELLED/!NEXT"
4818 ((org-agenda-overriding-header "Next Tasks")
4819 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
4820 (org-agenda-todo-ignore-scheduled t)
4821 (org-agenda-todo-ignore-deadlines t)
4822 (org-agenda-todo-ignore-with-date t)
4823 (org-tags-match-list-sublevels t)
4824 (org-agenda-sorting-strategy
4825 '(todo-state-down effort-up category-keep))))
4826 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
4827 ((org-agenda-overriding-header "Tasks")
4828 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
4829 (org-agenda-todo-ignore-scheduled t)
4830 (org-agenda-todo-ignore-deadlines t)
4831 (org-agenda-todo-ignore-with-date t)
4832 (org-agenda-sorting-strategy
4833 '(category-keep))))
4834 (tags-todo "-CANCELLED+WAITING/!"
4835 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
4836 (org-agenda-skip-function 'bh/skip-stuck-projects)
4837 (org-tags-match-list-sublevels nil)
4838 (org-agenda-todo-ignore-scheduled 'future)
4839 (org-agenda-todo-ignore-deadlines 'future)))
4840 (tags "-REFILE/"
4841 ((org-agenda-overriding-header "Tasks to Archive")
4842 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
4843 (org-tags-match-list-sublevels nil))))
4844 nil)
4845 ("r" "Tasks to Refile" tags "REFILE"
4846 ((org-agenda-overriding-header "Tasks to Refile")
4847 (org-tags-match-list-sublevels nil)))
4848 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
4849 ((org-agenda-overriding-header "Stuck Projects")
4850 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
4851 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
4852 ((org-agenda-overriding-header "Next Tasks")
4853 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
4854 (org-agenda-todo-ignore-scheduled t)
4855 (org-agenda-todo-ignore-deadlines t)
4856 (org-agenda-todo-ignore-with-date t)
4857 (org-tags-match-list-sublevels t)
4858 (org-agenda-sorting-strategy
4859 '(todo-state-down effort-up category-keep))))
4860 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
4861 ((org-agenda-overriding-header "Tasks")
4862 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
4863 (org-agenda-sorting-strategy
4864 '(category-keep))))
4865 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
4866 ((org-agenda-overriding-header "Projects")
4867 (org-agenda-skip-function 'bh/skip-non-projects)
4868 (org-agenda-sorting-strategy
4869 '(category-keep))))
4870 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
4871 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
4872 (org-tags-match-list-sublevels nil))
4873 ("A" "Tasks to Archive" tags "-REFILE/"
4874 ((org-agenda-overriding-header "Tasks to Archive")
4875 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
4876 (org-tags-match-list-sublevels nil))))))
4877
4878 ; Overwrite the current window with the agenda
4879 (setq org-agenda-window-setup 'current-window)
4880
4881 #+END_SRC
4882
4883 *** Time
4884 #+BEGIN_SRC emacs-lisp
4885 ;;
4886 ;; Resume clocking task when emacs is restarted
4887 (org-clock-persistence-insinuate)
4888 ;;
4889 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
4890 (setq org-clock-history-length 36)
4891 ;; Resume clocking task on clock-in if the clock is open
4892 (setq org-clock-in-resume t)
4893 ;; Change tasks to NEXT when clocking in
4894 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
4895 ;; Separate drawers for clocking and logs
4896 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
4897 ;; Save clock data and state changes and notes in the LOGBOOK drawer
4898 (setq org-clock-into-drawer t)
4899 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
4900 (setq org-clock-out-remove-zero-time-clocks t)
4901 ;; Clock out when moving task to a done state
4902 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
4903 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
4904 (setq org-clock-persist t)
4905 ;; Do not prompt to resume an active clock
4906 (setq org-clock-persist-query-resume nil)
4907 ;; Enable auto clock resolution for finding open clocks
4908 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
4909 ;; Include current clocking task in clock reports
4910 (setq org-clock-report-include-clocking-task t)
4911
4912 ; use discrete minute intervals (no rounding) increments
4913 (setq org-time-stamp-rounding-minutes (quote (1 1)))
4914
4915 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
4916
4917 (setq bh/keep-clock-running nil)
4918
4919 (setq org-agenda-clock-consistency-checks
4920 (quote (:max-duration "4:00"
4921 :min-duration 0
4922 :max-gap 0
4923 :gap-ok-around ("4:00"))))
4924
4925 #+END_SRC
4926
4927 **** Setting a default clock task
4928 Per default the =** Organization= task in my tasks.org file receives
4929 misc clock time. This is the task I clock in on when I punch in at the
4930 start of my work day with =F9-I=. Punching-in anywhere clocks in this
4931 Organization task as the default task.
4932
4933 If I want to change the default clocking task I just visit the
4934 new task in any org buffer and clock it in with =C-u C-u C-c C-x
4935 C-i=. Now this new task that collects miscellaneous clock
4936 minutes when the clock would normally stop.
4937
4938 You can quickly clock in the default clocking task with =C-u C-c
4939 C-x C-i d=. Another option is to repeatedly clock out so the
4940 clock moves up the project tree until you clock out the
4941 top-level task and the clock moves to the default task.
4942
4943 **** Reporting
4944 #+BEGIN_SRC emacs-lisp
4945 ;; Agenda clock report parameters
4946 (setq org-agenda-clockreport-parameter-plist
4947 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
4948
4949 ;; Agenda log mode items to display (closed and state changes by default)
4950 (setq org-agenda-log-mode-items (quote (closed state)))
4951 #+END_SRC
4952 **** Task estimates, column view
4953 Setup column view globally with the following headlines
4954 #+BEGIN_SRC emacs-lisp
4955 ; Set default column view headings: Task Effort Clock_Summary
4956 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
4957 #+END_SRC
4958 Setup the estimate for effort values.
4959 #+BEGIN_SRC emacs-lisp
4960 ; global Effort estimate values
4961 ; global STYLE property values for completion
4962 (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")
4963 ("STYLE_ALL" . "habit"))))
4964 #+END_SRC
4965
4966 *** Tags
4967 Tags are mostly used for filtering inside the agenda.
4968 #+BEGIN_SRC emacs-lisp
4969 ; Tags with fast selection keys
4970 (setq org-tag-alist (quote ((:startgroup)
4971 ("@errand" . ?e)
4972 ("@office" . ?o)
4973 ("@home" . ?H)
4974 (:endgroup)
4975 ("PHONE" . ?p)
4976 ("WAITING" . ?w)
4977 ("HOLD" . ?h)
4978 ("PERSONAL" . ?P)
4979 ("WORK" . ?W)
4980 ("ORG" . ?O)
4981 ("PRIVATE" . ?N)
4982 ("crypt" . ?E)
4983 ("MARK" . ?M)
4984 ("NOTE" . ?n)
4985 ("CANCELLED" . ?c)
4986 ("FLAGGED" . ??))))
4987
4988 ; Allow setting single tags without the menu
4989 (setq org-fast-tag-selection-single-key (quote expert))
4990
4991 ; For tag searches ignore tasks with scheduled and deadline dates
4992 (setq org-agenda-tags-todo-honor-ignore-options t)
4993 #+END_SRC
4994
4995 *** Archiving
4996 #+BEGIN_SRC emacs-lisp
4997 (setq org-archive-mark-done nil)
4998 (setq org-archive-location "%s_archive::* Archived Tasks")
4999 #+END_SRC
5000
5001 *** org-babel
5002 #+BEGIN_SRC emacs-lisp
5003 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
5004 (setq org-plantuml-jar-path "~/java/plantuml.jar")
5005
5006 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
5007
5008 ; Make babel results blocks lowercase
5009 (setq org-babel-results-keyword "results")
5010
5011 (org-babel-do-load-languages
5012 (quote org-babel-load-languages)
5013 (quote ((emacs-lisp . t)
5014 (awk . t)
5015 (css . t)
5016 (makefile . t)
5017 (perl . t)
5018 (ruby . t)
5019 (dot . t)
5020 (ditaa . t)
5021 (R . t)
5022 (python . t)
5023 (ruby . t)
5024 (gnuplot . t)
5025 (clojure . t)
5026 (shell . t)
5027 (ledger . t)
5028 (org . t)
5029 (plantuml . t)
5030 (latex . t))))
5031
5032 ; Do not prompt to confirm evaluation
5033 ; This may be dangerous - make sure you understand the consequences
5034 ; of setting this -- see the docstring for details
5035 (setq org-confirm-babel-evaluate nil)
5036
5037 ; Use fundamental mode when editing plantuml blocks with C-c '
5038 (add-t