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