fold anything
[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 ** corral
1670 [2015-10-15 Thu 11:34]
1671 Corral is a lightweight package that lets you quickly wrap parentheses
1672 and other delimiters around text, intuitively surrounding what you
1673 want it to using just two commands.
1674 #+BEGIN_SRC emacs-lisp
1675 (use-package corral
1676 :ensure corral
1677 :bind (("C-c c" . hydra-corral/body))
1678 :config
1679 (progn
1680 ; Interpret # and * as part of the word
1681 (setq corral-syntax-entries '((?# "_")
1682 (?* "_")
1683 (?$ ".")
1684 (?/ ".")))
1685 (defhydra hydra-corral (:columns 4)
1686 "Corral"
1687 ("(" corral-parentheses-backward "Back")
1688 (")" corral-parentheses-forward "Forward")
1689 ("[" corral-brackets-backward "Back")
1690 ("]" corral-brackets-forward "Forward")
1691 ("{" corral-braces-backward "Back")
1692 ("}" corral-braces-forward "Forward")
1693 ("\"" corral-double-quotes-backward "Back")
1694 ("2" corral-double-quotes-forward "Forward")
1695 ("'" corral-single-quotes-backward "Back")
1696 ("#" corral-single-quotes-forward "Forward")
1697 ("." hydra-repeat "Repeat"))
1698 ))
1699 #+END_SRC
1700 ** crontab-mode
1701 [2013-05-21 Tue 23:18]
1702 #+BEGIN_SRC emacs-lisp
1703 (use-package crontab-mode
1704 :ensure crontab-mode
1705 :commands crontab-mode
1706 :mode ("\\.?cron\\(tab\\)?\\'" . crontab-mode))
1707 #+END_SRC
1708
1709 ** cua
1710 I know that this lets it look "more like windows", but I don't much care
1711 about its paste/copy/cut keybindings, the really nice part is the great
1712 support for rectangular regions, which I started to use a lot since I
1713 know this mode. The normal keybindings for those are just to useless.
1714 #+BEGIN_SRC emacs-lisp
1715 (cua-mode t)
1716 (setq cua-enable-cua-keys (quote shift))
1717 #+END_SRC
1718
1719 Luckily cua-mode easily supports this, with the following line I just
1720 get the CUA selection and rectangle stuff, not the keybindings. Yes,
1721 even though the above =cua-enable-cua-keys= setting would only enable
1722 them if the selection is done when the region was marked with a shifted
1723 movement keys.
1724 #+BEGIN_SRC emacs-lisp
1725 (cua-selection-mode t)
1726 #+END_SRC
1727
1728 ** Debian related
1729 #+BEGIN_SRC emacs-lisp
1730 (require 'dpkg-dev-el-loaddefs nil 'noerror)
1731 (require 'debian-el-loaddefs nil 'noerror)
1732
1733 (setq debian-changelog-full-name "Joerg Jaspert")
1734 (setq debian-changelog-mailing-address "joerg@debian.org")
1735 #+END_SRC
1736
1737 ** diff-mode
1738 #+BEGIN_SRC emacs-lisp
1739 (use-package diff-mode
1740 :commands diff-mode
1741 :mode (("\\.diff" . diff-mode)))
1742 #+END_SRC
1743
1744 ** dired & co
1745 #+BEGIN_SRC emacs-lisp
1746 (use-package dired
1747 :commands (dired dired-other-window dired-other-frame dired-noselect
1748 dired-mode dired-jump)
1749 :defines (dired-omit-regexp-orig)
1750 :bind (:map dired-mode-map
1751 ("F" . find-name-dired)
1752 ("/" . dired-narrow)
1753 ("r" . wdired-change-to-wdired-mode))
1754 :defer
1755 :init
1756 (progn
1757 (setq diredp-hide-details-initially-flag nil))
1758 :config
1759 (progn
1760 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
1761 (setq dired-dwim-target t)
1762 (setq dired-listing-switches "-alh")
1763 (setq dired-listing-switches "-alXh --group-directories-first")
1764 (setq dired-recursive-copies (quote top))
1765 (setq dired-recursive-deletes (quote top))
1766
1767 (use-package dired+
1768 :load-path "elisp/local")
1769
1770 (use-package dired-x
1771 :init
1772 (progn
1773 (setq dired-guess-shell-alist-user
1774 '(("\\.pdf\\'" "mupdf")
1775 ("\\.\\(?:djvu\\|eps\\)\\'" "evince")
1776 ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "eog")
1777 ("\\.\\(?:xcf\\)\\'" "gimp")
1778 ("\\.csv\\'" "libreoffice")
1779 ("\\.tex\\'" "pdflatex" "latex")
1780 ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\)\\(?:\\.part\\)?\\'" "vlc")
1781 ("\\.html?\\'" "conkeror")))))
1782
1783 (use-package dired-single
1784 :ensure dired-single
1785 :bind (:map dired-mode-map
1786 ("<return>" . dired-single-buffer)
1787 ("<mouse-1>" . dired-single-buffer))
1788 :init
1789 (progn
1790 (bind-key "^"
1791 (function
1792 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
1793
1794 (use-package wdired
1795 :ensure wdired
1796 :commands (wdired-change-to-wdired-mode)
1797 :config
1798 (progn
1799 (setq wdired-allow-to-change-permissions t)))
1800
1801 (use-package dired-narrow
1802 :ensure t
1803 :diminish dired-narrow-mode
1804 :bind (:map dired-mode-map
1805 ("/" . dired-narrow)))
1806
1807 (use-package gnus-dired
1808 :commands (gnus-dired-attach gnus-dired-mode)
1809 :bind (:map dired-mode-map
1810 ("a" . gnus-dired-attach)))
1811
1812 (use-package runner
1813 :ensure runner)
1814
1815 (defvar mark-files-cache (make-hash-table :test #'equal))
1816
1817 (defun mark-similar-versions (name)
1818 (let ((pat name))
1819 (if (string-match "^\\(.+?\\)-[0-9._-]+$" pat)
1820 (setq pat (match-string 1 pat)))
1821 (or (gethash pat mark-files-cache)
1822 (ignore (puthash pat t mark-files-cache)))))
1823
1824 (defun dired-mark-similar-version ()
1825 (interactive)
1826 (setq mark-files-cache (make-hash-table :test #'equal))
1827 (dired-mark-sexp '(mark-similar-versions name)))
1828
1829 (defun dired-package-initialize ()
1830 (unless (featurep 'runner)
1831 (bind-key "M-!" 'async-shell-command dired-mode-map)
1832 (unbind-key "M-s f" dired-mode-map)
1833
1834 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1835 "Make sure to remove \"Omit\" from the modeline."
1836 (diminish 'dired-omit-mode) dired-mode-map)
1837
1838 ;; Omit files that Git would ignore
1839 (defun dired-omit-regexp ()
1840 (let ((file (expand-file-name ".git"))
1841 parent-dir)
1842 (while (and (not (file-exists-p file))
1843 (progn
1844 (setq parent-dir
1845 (file-name-directory
1846 (directory-file-name
1847 (file-name-directory file))))
1848 ;; Give up if we are already at the root dir.
1849 (not (string= (file-name-directory file)
1850 parent-dir))))
1851 ;; Move up to the parent dir and try again.
1852 (setq file (expand-file-name ".git" parent-dir)))
1853 ;; If we found a change log in a parent, use that.
1854 (if (file-exists-p file)
1855 (let ((regexp (funcall dired-omit-regexp-orig))
1856 (omitted-files
1857 (shell-command-to-string "git clean -d -x -n")))
1858 (if (= 0 (length omitted-files))
1859 regexp
1860 (concat
1861 regexp
1862 (if (> (length regexp) 0)
1863 "\\|" "")
1864 "\\("
1865 (mapconcat
1866 #'(lambda (str)
1867 (concat
1868 "^"
1869 (regexp-quote
1870 (substring str 13
1871 (if (= ?/ (aref str (1- (length str))))
1872 (1- (length str))
1873 nil)))
1874 "$"))
1875 (split-string omitted-files "\n" t)
1876 "\\|")
1877 "\\)")))
1878 (funcall dired-omit-regexp-orig))))))
1879
1880 (add-hook 'dired-mode-hook 'dired-package-initialize)
1881
1882 ;; (defun dired-double-jump (first-dir second-dir)
1883 ;; (interactive
1884 ;; (list (read-directory-name "First directory: "
1885 ;; (expand-file-name "~")
1886 ;; nil nil "~/Downloads/")
1887 ;; (read-directory-name "Second directory: "
1888 ;; (expand-file-name "~")
1889 ;; nil nil "~/")))
1890 ;; (dired first-dir)
1891 ;; (dired-other-window second-dir))
1892 ;; (bind-key "C-c J" 'dired-double-jump)
1893
1894 (defun dired-back-to-top ()
1895 (interactive)
1896 (goto-char (point-min))
1897 (dired-next-line 4))
1898
1899 (define-key dired-mode-map
1900 (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
1901
1902 (defun dired-jump-to-bottom ()
1903 (interactive)
1904 (goto-char (point-max))
1905 (dired-next-line -1))
1906
1907 (define-key dired-mode-map
1908 (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)))
1909
1910 #+END_SRC
1911 ** discover-my-major
1912 [2014-06-01 Sun 23:32]
1913 Discover key bindings and their meaning for the current Emacs major mode.
1914 #+BEGIN_SRC emacs-lisp
1915 (use-package discover-my-major
1916 :ensure discover-my-major
1917 :commands discover-my-major
1918 :bind ("C-h C-m" . discover-my-major))
1919 #+END_SRC
1920 ** easypg
1921 EasyPG is a GnuPG interface for Emacs.
1922 Bookmark: [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1923 #+BEGIN_SRC emacs-lisp
1924 (use-package epa-file
1925 :config
1926 (progn
1927 (epa-file-enable)
1928 ;; I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1929 (defadvice epg--start (around advice-epg-disable-agent disable)
1930 "Don't allow epg--start to use gpg-agent in plain text
1931 terminals . "
1932 (if (display-graphic-p)
1933 ad-do-it
1934 (let ((agent (getenv "GPG_AGENT_INFO")))
1935 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
1936 ad-do-it
1937 (setenv "GPG_AGENT_INFO" agent))))
1938 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
1939 (ad-activate 'epg--start)
1940 ))
1941 #+END_SRC
1942 ** ediff
1943 [2013-04-21 So 20:36]
1944 ediff - don't start another frame
1945 #+BEGIN_SRC emacs-lisp
1946 (use-package ediff
1947 :init
1948 (progn
1949 (defvar ctl-period-equals-map)
1950 (define-prefix-command 'ctl-period-equals-map)
1951 (bind-key "C-. =" 'ctl-period-equals-map)
1952 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
1953
1954 :bind (("C-. = b" . ediff-buffers)
1955 ("C-. = B" . ediff-buffers3)
1956 ("C-. = =" . ediff-files)
1957 ("C-. = f" . ediff-files)
1958 ("C-. = F" . ediff-files3)
1959 ("C-. = r" . ediff-revision)
1960 ("C-. = p" . ediff-patch-file)
1961 ("C-. = P" . ediff-patch-buffer)
1962 ("C-. = l" . ediff-regions-linewise)
1963 ("C-. = w" . ediff-regions-wordwise))
1964 :config (progn
1965 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1966 (setq ediff-split-window-function 'split-window-horizontally)
1967 )
1968 )
1969 #+END_SRC
1970 ** Eww - Emacs browser
1971 [2016-10-03 Mo 21:30]
1972 Eww - Emacs browser (needs emacs 24.4 or higher)
1973 #+BEGIN_SRC emacs-lisp
1974 (use-package eww
1975 :bind (("M-s M-w" . eww-search-words)
1976 :map eww-mode-map
1977 (":" . eww) ; Go to URL
1978 ("h" . eww-list-histories) ; View history
1979 :map eww-text-map ; For single line text fields
1980 ("<backtab>" . shr-previous-link) ; S-TAB Jump to previous link on the page
1981 ("<C-return>" . eww-submit)
1982 :map eww-textarea-map ; For multi-line text boxes
1983 ("<backtab>" . shr-previous-link)
1984 ("<C-return>" . eww-submit)
1985 :map eww-checkbox-map
1986 ("<down-mouse-1>" . eww-toggle-checkbox)
1987 :map shr-map
1988 ("w" . modi/eww-copy-url-dwim)
1989 :map eww-link-keymap
1990 ("w" . modi/eww-copy-url-dwim))
1991
1992 :config
1993 (progn
1994 ;; Make the binding for `revert-buffer' do `eww-reload' in eww-mode
1995 (define-key eww-mode-map [remap revert-buffer] #'eww-reload)
1996
1997 ;; (setq eww-search-prefix "https://duckduckgo.com/html/?q=")
1998 (setq eww-search-prefix "https://www.google.com/search?q=")
1999 (setq eww-download-directory "~/Downloads")
2000 ;; (setq eww-form-checkbox-symbol "[ ]")
2001 (setq eww-form-checkbox-symbol "☐") ; Unicode hex 2610
2002 ;; (setq eww-form-checkbox-selected-symbol "[X]")
2003 (setq eww-form-checkbox-selected-symbol "☑") ; Unicode hex 2611
2004 ;; Improve the contract of pages like Google results
2005 ;; http://emacs.stackexchange.com/q/2955/115
2006 (setq shr-color-visible-luminance-min 80) ; default = 40
2007
2008 ;; Auto-rename new eww buffers
2009 ;; http://ergoemacs.org/emacs/emacs_eww_web_browser.html
2010 (defun xah-rename-eww-hook ()
2011 "Rename eww browser's buffer so sites open in new page."
2012 (rename-buffer "eww" t))
2013 (add-hook 'eww-mode-hook #'xah-rename-eww-hook)
2014
2015 ;; If the current buffer is an eww buffer, "M-x eww" will always reuse the
2016 ;; current buffer to load the new page. Below advice will make "C-u M-x eww"
2017 ;; force a new eww buffer even when the current buffer is an eww buffer.
2018 ;; The above `xah-rename-eww-hook' fix is still needed in order to create
2019 ;; uniquely named eww buffers.
2020 ;; http://emacs.stackexchange.com/a/24477/115
2021 (defun modi/force-new-eww-buffer (orig-fun &rest args)
2022 "When prefix argument is used, a new eww buffer will be created.
2023 This is regardless of whether the current buffer is an eww buffer. "
2024 (if current-prefix-arg
2025 (with-temp-buffer
2026 (apply orig-fun args))
2027 (apply orig-fun args)))
2028 (advice-add 'eww :around #'modi/force-new-eww-buffer)
2029
2030 ;; Override the default definition of `eww-search-words'
2031 (defun eww-search-words (&optional beg end)
2032 "Search the web for the text between the point and marker.
2033 See the `eww-search-prefix' variable for the search engine used."
2034 (interactive "r")
2035 (if (use-region-p)
2036 (eww (buffer-substring beg end))
2037 (eww (modi/get-symbol-at-point))))
2038
2039 ;; eww-lnum
2040 ;; https://github.com/m00natic/eww-lnum
2041 (use-package eww-lnum
2042 :ensure t
2043 :bind (:map eww-mode-map
2044 ("f" . eww-lnum-follow)
2045 ("U" . eww-lnum-universal)))
2046
2047 ;; org-eww
2048 ;; Copy text from html page for pasting in org mode file/buffer
2049 ;; e.g. Copied HTML hyperlinks get converted to [[link][desc]] for org mode.
2050 ;; http://emacs.stackexchange.com/a/8191/115
2051 (use-package org-eww
2052 :bind (:map eww-mode-map
2053 ("o" . org-eww-copy-for-org-mode)))
2054
2055 ;; Auto-refreshing eww buffer whenever the html file it's showing changes
2056 ;; http://emacs.stackexchange.com/a/2566/115
2057 (defvar modi/eww--file-notify-descriptors-list ()
2058 "List to store file-notify descriptor for all files that have an
2059 associated auto-reloading eww buffer.")
2060
2061 (defun modi/advice-eww-open-file-to-auto-reload (orig-fun &rest args)
2062 "When `eww-open-file' is called with \\[universal-argument], open
2063 the file in eww and also add `file-notify' watch for it so that the eww
2064 buffer auto-reloads when the HTML file changes."
2065 (prog1
2066 (apply orig-fun args)
2067 (when current-prefix-arg ; C-u M-x eww-open-file
2068 (require 'filenotify)
2069 (let ((file-name (car args)))
2070 (file-notify-add-watch file-name
2071 '(change attribute-change)
2072 #'modi/file-notify-callback-eww-reload)
2073 ;; Show the HTML file and its rendered form in eww side-by-side
2074 (find-file-other-window file-name))
2075 ;; Redefine the `q' binding in `eww-mode-map'
2076 (bind-key "q" #'modi/eww-quit-and-update-fn-descriptors eww-mode-map))))
2077 (advice-add 'eww-open-file :around #'modi/advice-eww-open-file-to-auto-reload)
2078
2079 (defun modi/file-notify-callback-eww-reload (event)
2080 "On getting triggered, switch to the eww buffer, reload and switch
2081 back to the working buffer. Also save the `file-notify-descriptor' of the
2082 triggering event."
2083 (let* ((working-buffer (buffer-name)))
2084 (switch-to-buffer-other-window "eww")
2085 (eww-reload)
2086 (switch-to-buffer-other-window working-buffer))
2087 ;; `(car event)' will return the event descriptor
2088 (add-to-list 'modi/eww--file-notify-descriptors-list (car event)))
2089
2090 (defun modi/eww-quit-and-update-fn-descriptors ()
2091 "When quitting `eww', first remove any saved file-notify descriptors
2092 specific to eww, while also updating `modi/eww--file-notify-descriptors-list'."
2093 (interactive)
2094 (dotimes (index (safe-length modi/eww--file-notify-descriptors-list))
2095 (file-notify-rm-watch (pop modi/eww--file-notify-descriptors-list)))
2096 (quit-window :kill))))
2097
2098 ;; Default eww key bindings
2099 ;; |-----------+---------------------------------------------------------------------|
2100 ;; | Key | Function |
2101 ;; |-----------+---------------------------------------------------------------------|
2102 ;; | & | Browse the current URL with an external browser. |
2103 ;; | - | Begin a negative numeric argument for the next command. |
2104 ;; | 0 .. 9 | Part of the numeric argument for the next command. |
2105 ;; | C | Display a buffer listing the current URL cookies, if there are any. |
2106 ;; | H | List the eww-histories. |
2107 ;; | F | Toggle font between variable-width and fixed-width. |
2108 ;; | G | Go to a URL |
2109 ;; | R | Readable mode |
2110 ;; | S | List eww buffers |
2111 ;; | d | Download URL under point to `eww-download-directory'. |
2112 ;; | g | Reload the current page. |
2113 ;; | q | Quit WINDOW and bury its buffer. |
2114 ;; | v | `eww-view-source' |
2115 ;; | w | `eww-copy-page-url' |
2116 ;; |-----------+---------------------------------------------------------------------|
2117 ;; | b | Add the current page to the bookmarks. |
2118 ;; | B | Display the bookmark list. |
2119 ;; | M-n | Visit the next bookmark |
2120 ;; | M-p | Visit the previous bookmark |
2121 ;; |-----------+---------------------------------------------------------------------|
2122 ;; | t | Go to the page marked `top'. |
2123 ;; | u | Go to the page marked `up'. |
2124 ;; |-----------+---------------------------------------------------------------------|
2125 ;; | n | Go to the page marked `next'. |
2126 ;; | p | Go to the page marked `previous'. |
2127 ;; |-----------+---------------------------------------------------------------------|
2128 ;; | l | Go to the previously displayed page. |
2129 ;; | r | Go to the next displayed page. |
2130 ;; |-----------+---------------------------------------------------------------------|
2131 ;; | TAB | Move point to next link on the page. |
2132 ;; | S-TAB | Move point to previous link on the page. |
2133 ;; |-----------+---------------------------------------------------------------------|
2134 ;; | SPC | Scroll up |
2135 ;; | DEL/Bkspc | Scroll down |
2136 ;; | S-SPC | Scroll down |
2137 ;; |-----------+---------------------------------------------------------------------|
2138 #+END_SRC
2139
2140 #+results:
2141
2142 ** exec path from shell
2143 [2017-04-01 Sat 23:27]
2144 #+BEGIN_SRC emacs-lisp
2145 (use-package exec-path-from-shell
2146 :ensure t
2147 :config
2148 (progn
2149 ;; Import additional environment variables beyond just $PATH
2150 (dolist (var '("PYTHONPATH" ; Python modules
2151 "INFOPATH" ; Info directories
2152 "JAVA_OPTS" ; Options for java processes
2153 "RUST_SRC_PATH" ; Rust sources, for racer
2154 "CARGO_HOME" ; Cargo home, for racer
2155 "GOPATH"
2156 "GPG_TTY"
2157 "GPG_AGENT_INFO"
2158 "SSH_AUTH_SOCK"
2159 "SSH_AGENT_PID"
2160 ))
2161 (add-to-list 'exec-path-from-shell-variables var))
2162 (exec-path-from-shell-initialize)))
2163 #+END_SRC
2164 ** expand-region
2165 [2014-06-01 Sun 15:16]
2166 #+BEGIN_SRC emacs-lisp
2167 (use-package expand-region
2168 :ensure expand-region
2169 :bind ("C-M-+" . er/expand-region)
2170 :commands er/expand-region)
2171 #+END_SRC
2172 ** eyebrowse :CANCELLED:
2173 :LOGBOOK:
2174 - State "NEXT" from "CANCELLED" [2017-09-16 Sat 23:06]
2175 - State "CANCELLED" from [2017-08-26 Sat 15:06]
2176 :END:
2177 [2017-04-29 Sat 13:18]
2178 [[https://github.com/wasamasa/eyebrowse][Eyebrowse]] is a global minor mode for Emacs that allows you to manage
2179 your window configurations in a simple manner, just like tiling window
2180 managers like i3wm with their workspaces do. It displays their current
2181 state in the modeline by default. The behaviour is modeled after
2182 ranger, a file manager written in Python.
2183 #+BEGIN_SRC emacs-lisp :tangle no
2184 (use-package eyebrowse
2185 :ensure t
2186 :config
2187 (progn
2188 (setq eyebrowse-mode-line-separator " "
2189 eyebrowse-new-workspace t)
2190 (eyebrowse-setup-opinionated-keys)
2191 (setq eyebrowse-new-workspace t)
2192 (eyebrowse-mode t)
2193 ))
2194 #+END_SRC
2195
2196 ** flycheck
2197 [2013-04-28 So 22:21]
2198 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
2199 As the one time I tried Flymake i wasn't happy, thats easy to
2200 understand for me.
2201 #+BEGIN_SRC emacs-lisp
2202 (use-package flycheck
2203 :ensure flycheck
2204 :diminish flycheck-mode
2205 :bind (("M-n" . next-error)
2206 ("M-p" . previous-error))
2207 :config
2208 (progn
2209 (use-package flycheck-color-mode-line
2210 :ensure flycheck-color-mode-line)
2211 (setq flycheck-highlighting-mode 'nil)
2212 (setq flycheck-flake8-maximum-line-length '150)
2213 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
2214 (setq flycheck-sh-shellcheck-executable "/usr/bin/shellcheck -e 2086")
2215 (add-hook 'find-file-hook
2216 (lambda ()
2217 (when (not (equal 'emacs-lisp-mode major-mode))
2218 (flycheck-mode))))
2219 ))
2220 #+END_SRC
2221 ** font-lock
2222 Obviously emacs can do syntax hilighting. For more things than you ever
2223 heard about.
2224 And I want to have it everywhere.
2225 #+BEGIN_SRC emacs-lisp
2226 (use-package font-lock
2227 :init
2228 (progn
2229 (global-font-lock-mode 1)
2230 (setq font-lock-maximum-decoration t)
2231 (setq jit-lock-defer-time nil)
2232 (setq jit-lock-stealth-nice 0.1)
2233 (setq jit-lock-stealth-time 0.2)
2234 (setq jit-lock-stealth-verbose nil)))
2235 #+END_SRC
2236 ** git-gutter+
2237 [2014-05-21 Wed 22:56]
2238 #+BEGIN_SRC emacs-lisp
2239 (use-package git-gutter+
2240 :ensure git-gutter+
2241 :diminish git-gutter+-mode
2242 :bind (("C-x n" . git-gutter+-next-hunk)
2243 ("C-x p" . git-gutter+-previous-hunk)
2244 ("C-x v =" . git-gutter+-show-hunk)
2245 ("C-x r" . git-gutter+-revert-hunks)
2246 ("C-x s" . git-gutter+-stage-hunks)
2247 ("C-x c" . git-gutter+-commit)
2248 )
2249 :init
2250 (progn
2251 (setq git-gutter+-disabled-modes '(org-mode))
2252 (global-git-gutter+-mode 1))
2253 :config
2254 (progn
2255 (use-package git-gutter-fringe+
2256 :ensure git-gutter-fringe+
2257 :config
2258 (progn
2259 (setq git-gutter-fr+-side 'right-fringe)
2260 ;(git-gutter-fr+-minimal)
2261 ))))
2262 #+END_SRC
2263 ** git-messenger
2264 [2015-02-22 Sun 14:00]
2265 Provides function that popup commit message at current line. This is
2266 useful when you want to know why this line was changed.
2267 #+BEGIN_SRC emacs-lisp
2268 (use-package git-messenger
2269 :ensure git-messenger
2270 :commands (git-messenger:popup-message)
2271 :bind (("C-x v p" . git-messenger:popup-message))
2272 :config
2273 (progn
2274 (bind-key "m" 'git-messenger:copy-message git-messenger-map)
2275 (add-hook 'git-messenger:popup-buffer-hook 'magit-revision-mode)
2276 (setq git-messenger:show-detail t)))
2277 #+END_SRC
2278 ** git timemachine
2279 [2014-07-23 Mi 12:57]
2280 Browse historic versions of a file with p (previous) and n (next).
2281 #+BEGIN_SRC emacs-lisp
2282 (use-package git-timemachine
2283 :ensure git-timemachine
2284 :commands git-timemachine)
2285 #+END_SRC
2286 ** Mail handling
2287 *** bbdb
2288 [2017-06-27 Di 23:10]
2289 #+BEGIN_SRC emacs-lisp
2290 (use-package bbdb
2291 :ensure t
2292 :commands (bbdb bbdb-insinuate-gnus bbdb-initialize)
2293 :config
2294 (progn
2295 (use-package bbdb-message)
2296 (use-package bbdb-gnus)
2297 (use-package bbdb-com)
2298
2299 (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus)
2300
2301 (setq bbdb-add-mails t)
2302 (setq bbdb-ignore-redundant-mails t)
2303 (setq bbdb-complete-mail-allow-cycling t)
2304 (setq bbdb-complete-name-allow-cycling t)
2305 (setq bbdb-completion-type 'primary-or-name)
2306 (setq bbdb-dwim-net-address-allow-redundancy t)
2307 (setq bbdb-default-area-code 661)
2308 (setq bbdb-dial-local-prefix "0")
2309 (setq bbdb-file-coding-system 'utf-8)
2310 (setq bbdb-hashtable-size 104729)
2311 (setq bbdb-ignore-messages-alist '(("To" . "\\(\\(\\(joerg\\)\\(\\.jaspert\\)?\\)\\|root\\|gnus|gf\\)@\\(debian\\.org\\|ganneff\\.de\\|debconf\\.org\\|spi-inc\\.org\\|nsb-software.de\\)")))
2312 (setq bbdb-new-mails-primary t)
2313 (setq bbdb-notice-auto-save-file t)
2314 (setq bbdb-notice-mail-hook 'bbdb-auto-notes-hook)
2315 (setq bbdb-phone-style nil)
2316 (setq bbdb-pop-up-window-size 6)
2317 (setq bbdb-user-mail-names "\\(\\(\\(joerg\\)\\(\\.jaspert\\)?\\)\\|root\\|gnus\\|gf\\)@\\(debian\\.org\\|ganneff\\.de\\|debconf\\.org\\|spi-inc\\.org\\|nsb-software.de\\)")
2318 (setq bbdb/gnus-summary-known-poster-mark "+")
2319 (setq bbdb/gnus-summary-mark-known-posters t)
2320 (setq bbdb/gnus-summary-prefer-real-names t)
2321 (setq bbdb/news-auto-create-p 'bbdb-ignore-most-messages-hook)
2322 (setq bbdb-auto-notes-rules
2323 '(("user-agent" (".*" interface 0))
2324 ("Organization" (".*" company 0))
2325 ("x-mailer" (".*" interface 0))
2326 ("x-newsreader" (".*" interface 0))
2327 ("X-URL" (".*" url 0))
2328 ("newsgroups" ("\\\\([^,]*\\\\),?" posted-to "\\\\1" t))
2329 ("xref" ("\\\\b[^ ]+:[0-9]+.*" seen-in 0))))
2330 (put 'seen-in 'field-separator "; ")
2331 (put 'interface 'field-seperator "; ")
2332 )
2333 (use-package counsel-bbdb
2334 :ensure t)
2335 )
2336 #+END_SRC
2337
2338 *** gnus
2339 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
2340 what I want every emacs to know.
2341 #+BEGIN_SRC emacs-lisp
2342 (use-package gnus
2343 :commands (gnus)
2344 :bind (("C-c g" . gnus)
2345 :map gnus-summary-mode-map
2346 ("<f6>" . jj-forward-spam)
2347 ("C-<f1>" . jj-move-mail-spambox)
2348 ("C-<f2>" . jj-copy-mail-hambox)
2349 ("C-c x" . gnus-scum-expunge)
2350 :map gnus-group-mode-map
2351 ("GG" . notmuch-search)
2352 )
2353 :init
2354 (progn
2355 (after 'gnus
2356 (jj-init-theme))
2357 )
2358 :config
2359 (progn
2360 (bbdb-initialize)
2361 ; When emacs exits, gnus does too, no need to ask me
2362 (defun exit-gnus-on-exit ()
2363 (if (and (fboundp 'gnus-group-exit)
2364 (gnus-alive-p))
2365 (with-current-buffer (get-buffer "*Group*")
2366 (gnus-group-exit))))
2367 (add-hook 'kill-emacs-hook 'exit-gnus-on-exit)
2368
2369 ;; prettier summary buffers
2370
2371 (setq gnus-sum-thread-tree-indent " ") ;; " "
2372 (setq gnus-sum-thread-tree-root "\u229e ") ;; "⊞ "
2373 (setq gnus-sum-thread-tree-false-root "\u22a1 ") ;; "⊡ "
2374 (setq gnus-sum-thread-tree-single-indent " ") ;; " "
2375 (setq gnus-sum-thread-tree-vertical " \u2502") ;; " │"
2376 (setq gnus-sum-thread-tree-leaf-with-other " \u251c\u2500 ") ;; " ├─ "
2377 (setq gnus-sum-thread-tree-single-leaf " \u2570\u2500 ") ;; " ╰─ "
2378
2379 (use-package gnus-cite
2380 :config
2381 (progn
2382 (defface dwa/mail-citation '((((class color)
2383 (background dark))
2384 (:background "#383838"))
2385 (((class color)
2386 (background light))
2387 (:background "#efefef")))
2388 "Mail citation base face.")
2389 (loop for x in gnus-cite-face-list do
2390 (set-face-attribute x nil ':inherit 'dwa/mail-citation))))
2391
2392 (setq message-subscribed-address-functions
2393 '(gnus-find-subscribed-addresses))
2394
2395 (if (string-match (system-name) "delenn.ganneff.de")
2396 (progn
2397 (setq imap-ssl-program "openssl s_client -no_ssl2 -no_ssl3 -tls1 -connect %s:%p")
2398
2399 (use-package org-gnus)
2400
2401 (setq gnus-secondary-select-methods
2402 '((nnml "")
2403
2404 (nnimap "nsb"
2405 (nnimap-address "localhost")
2406 (nnimap-user "nsb@auth")
2407 (nnimap-nov-is-evil t)
2408 (nnimap-stream network)
2409 (nnir-search-engine notmuch)
2410 )
2411 (nnimap "gmail"
2412 (nnimap-address "localhost")
2413 (nnimap-user "gmail@auth")
2414 (nnimap-stream network)
2415 (nnimap-nov-is-evil t)
2416 (nnir-search-engine notmuch)
2417 )
2418 ))
2419 ;;** Von wo holt Gnus News
2420 (setq gnus-select-method '(nnimap "ganneff"
2421 (nnimap-address "localhost")
2422 (nnimap-user "ganneff@auth")
2423 (nnimap-stream network)
2424 (nnimap-nov-is-evil t)
2425 (nnir-search-engine notmuch)
2426 ))
2427 ;;** Kopien aller Mails/News speichern
2428 (setq gnus-message-archive-group
2429 '((if (message-news-p)
2430 "nnfolder+archive:Sentnews"
2431 "nnimap+ganneff:Sentmail")))
2432 )
2433 )
2434 (setq nnir-mail-backend (nth 1 gnus-secondary-select-methods))
2435
2436 ;;** dont always read the active file.
2437 (setq gnus-read-active-file 'some)
2438
2439 ;;** nnimap nich cachen, ebenso nnml
2440 (setq gnus-uncacheable-groups "^\\(nnml\\|nnimap\\)")
2441
2442 ;;** Bei langsamer Anbindung dies auf t setzen
2443 (setq gnus-asynchronous t)
2444
2445 ;;** Mein Gnus soll regelmaessig nach neuen Mails/News schauen.
2446 (gnus-demon-add-handler 'us-get-only-mail 20 10)
2447 (gnus-demon-init)
2448
2449 ;; Set the default value of `mm-discouraged-alternatives'.
2450 (eval-after-load "gnus-sum"
2451 '(add-to-list
2452 'gnus-newsgroup-variables
2453 '(mm-discouraged-alternatives
2454 . '("text/html" "text/richtext"))))
2455
2456 ;; Display `text/html' parts in `nnrss' groups only.
2457 (add-to-list
2458 'gnus-parameters
2459 '("\\`nnrss:" (mm-discouraged-alternatives nil)))
2460
2461 ;;** Auto-Subscribe
2462 (setq gnus-auto-subscribed-groups
2463 (concat gnus-auto-subscribed-groups
2464 "\\|^nnimap*"))
2465
2466 ;;** Immer Gruppen nach Topics anzeigen
2467 (add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
2468
2469 ;;** Summary Anzeige umdefinieren.
2470 (setq gnus-summary-line-format "%U%R%z (%4k) %uy%* %B%(%[ %-22,22f %]%) %s\n")
2471 (setq gnus-summary-gather-subject-limit 'fuzzy)
2472
2473 ;;** Und die Gruppenanzeige will ich auch anders. Will sehen wann ich zuletzt da reingesehen hab.
2474 (setq gnus-group-line-format
2475 "%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")
2476
2477 ;;** Different topic lines
2478 (setq gnus-topic-line-format "%i[ %u&topic-line; ] %v\n")
2479
2480 ;;** Für die umdefinierte Gruppenanzeige muss Gnus aber einen Timestamp in der Gruppe speichern.
2481 (add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp)
2482
2483 ;;** Ich will manchmal den Empfänger statt des Absenders sehen
2484 (setq gnus-extra-headers '(To Newsgroups Newsgroup Cc))
2485 (setq nnmail-extra-headers gnus-extra-headers)
2486 (setq gnus-ignored-from-addresses '("\\(\\(\\(joerg\\)\\(\\.jaspert\\)?\\)\\|root\\|gf\\)@\\(debian\\.org\\|ganneff\\.de\\|debconf\\.org\\|spi-inc\\.org\\|nsb-software\\.de\\|dlh\\.de\\)"))
2487
2488 ;; Don't send to these address in wide reply.
2489 (setq message-dont-reply-to-names (append '("notifications@github\\.com"
2490 ".*@noreply\\.github\\.com"
2491 )
2492 gnus-ignored-from-addresses))
2493
2494 ;;** Threads um 2 Zeichen einruecken.
2495 (setq gnus-thread-indent-level 1)
2496
2497 ;;** Posting Styles. Nettes Feature
2498 (setq gnus-posting-styles
2499 '(
2500 (".*"
2501 (from "Joerg Jaspert <joerg@ganneff.de>")) ; Globale Einstellung
2502 ("Allgemein.Sabrina"
2503 (from "Joerg (悠軻) Jaspert <joerg@debian.org>"))
2504 ("Debian.Private"
2505 (from "Joerg Jaspert <joerg@debian.org>")
2506 (signature-file "~/.signature.private"))
2507 ("dlh"
2508 (from "Joerg Jaspert <joerg@nsb-software.de>")
2509 (signature-file "~/.signature.nsb")
2510 (organization "NSB Nguyen Softwareentwicklung & beratung GmbH")
2511 (gcc "nnimap+nsb:Sent"))
2512 ("nnimap\\+nsb:.*"
2513 (from "Joerg Jaspert <joerg@nsb-software.de>")
2514 (signature-file "~/.signature.nsb")
2515 (organization "NSB Nguyen Softwareentwicklung & beratung GmbH")
2516 (gcc "nnimap+nsb:Sent"))
2517 ("nnimap\\+nsb:shared.gf.*"
2518 (from "Joerg Jaspert <gf@nsb-software.de>"))
2519 ("Debian"
2520 (from "Joerg Jaspert <joerg@debian.org>"))
2521 ("Debian.AM"
2522 (Gcc "nnimap+ganneff:Debian.AM"))
2523 ("Debian.DAM"
2524 (reply-to "Debian Account Managers <da-manager@debian.org>"))
2525 ("Debconf"
2526 (from "Joerg Jaspert <joerg@debconf.org>"))
2527 ("Bugs"
2528 (from "Joerg Jaspert <joerg@debian.org>"))
2529 ("SPI"
2530 (from "Joerg Jaspert <joerg@debian.org>"))
2531 ))
2532
2533
2534 ;;** Antworten auf meine Nachrichten hervorheben, hochscoren
2535 (add-hook 'message-sent-hook 'gnus-score-followup-article)
2536 (add-hook 'message-sent-hook 'gnus-score-followup-thread)
2537
2538 ;;** Grosse Newsgroups. Gnus fragt da laestigerweise immer nach.
2539 ;;** Aber da ich viele grosse Gruppen und nen schnellen Rechner habe
2540 ;;** soll der erst recht spaet nachfragen. Erst wenns wirklich fies wird.
2541 (setq gnus-large-newsgroup "15000")
2542
2543 ;;** Beim Betreten einer Gruppe keinen Artikel auswählen. Gegen Adaptive Scoring iss des !
2544 (setq gnus-auto-select-first nil)
2545
2546 ;;** Wenn ich in einer Gruppe fertig bin soll Gnus nich fragen ob ich in
2547 ;;** die naechste will. Es soll einfach tun.
2548 (setq gnus-auto-select-next 'quietly)
2549
2550 ;;** Hervorhebungen (Unterstrichen und Fett bei "_X_" und "*X*")
2551 (add-hook 'gnus-article-display-hook 'gnus-article-emphasize t)
2552
2553 ;;** Gnus Visible Headers
2554 (setq gnus-visible-headers
2555 '("^From:"
2556 "^Newsgroups:"
2557 "^Subject:"
2558 "^Date:"
2559 "^Followup-To:"
2560 "^Mail-Followup-To:"
2561 "^Reply-To:"
2562 "^Organization:"
2563 "^Summary:"
2564 "^Keywords:"
2565 "^To:"
2566 "^[BGF]?Cc:"
2567 "^Posted-To:"
2568 "^Mail-Copies-To:"
2569 "^Apparently-To:"
2570 "^X-Gnus-Warning:"
2571 "^Resent-From:"
2572 "^Xref:"
2573 "^X-Spam-Status:"
2574 "^X-Sent:"
2575 "^X-Mailer:"
2576 "^X-Newsreader:"
2577 "^X-User-Agent:"
2578 "^User-Agent:"))
2579
2580 ;;; Order of headers
2581 (setq gnus-sorted-header-list '("^From:"
2582 "^Subject:"
2583 "^Summary:"
2584 "^Keywords:"
2585 "^Newsgroups:"
2586 "^Followup-To:"
2587 "^To:"
2588 "^Cc:"
2589 "^Date:"
2590 "^Organization:"
2591 "^User-Agent:"
2592 "^X-Mailer:"
2593 "^X-Newsreader:"))
2594
2595 ;;** Save gnus score files. Ziemlich doof wenn nicht
2596 (setq gnus-save-score t)
2597
2598 ;;** Score Einstellungen. Welches Global File und woher die Scores holen.
2599 (setq gnus-global-score-files '("~/News/all.SCORE"))
2600 (setq gnus-score-find-score-files-function '(gnus-score-find-bnews bbdb/gnus-score))
2601
2602 ;;** Adaptives Scoring
2603 (setq gnus-use-adaptive-scoring t)
2604 (defvar gnus-default-adaptive-score-alist
2605 '((gnus-unread-mark)
2606 (gnus-ticked-mark (from 5))
2607 (gnus-dormant-mark (from 6))
2608 (gnus-del-mark (subject -5))
2609 (gnus-read-mark (from 5) (subject 3))
2610 (gnus-expirable-mark (from -2) (subject -2))
2611 (gnus-killed-mark (from -2) (subject -4))
2612 (gnus-kill-file-mark)
2613 (gnus-ancient-mark)
2614 (gnus-low-score-mark)
2615 (gnus-catchup-mark (subject -3))
2616 ))
2617
2618 ;;** Damit ich nicht mit Megabytegrossen Scorefiles rummachen muss, muss bei Adaptive-Scoring
2619 ;;** der Kram automagisch gelöscht werden. Sonst hats keinen Sinn !
2620 (setq gnus-decay-scores t)
2621
2622 ;;** Artikel mit weniger Score werden nicht angezeigt
2623 (setq gnus-summary-expunge-below -1000)
2624
2625 ;;** work around unimplemented handling of multiple similar attachments
2626 ;;** (recommended by ShengHuo Zhu Fri 20 Jul 2001 13:14)
2627 (setq gnus-mime-display-multipart-related-as-mixed t)
2628
2629 ;;** Bilderchen direkt anzeigen.
2630 (setq mm-inline-large-images t)
2631
2632 ;;** ueberfluessige Leerzeilen loeschen
2633 (setq gnus-treat-strip-trailing-blank-lines t)
2634 (setq gnus-treat-strip-leading-blank-lines t)
2635
2636 ;;** Falsch gebaute Attachments ? Nich mit mir. Nuja, UUE wech. Was solls. Will ich eh nich haben
2637 (setq mm-uu-configure-list '((uu . disabled)))
2638
2639 ;; (use-package message-utils
2640 ;; :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)
2641 ;; :bind ((:map message-mode-map
2642 ;; ("C-c m" . message-mark-inserted-region)
2643 ;; ("C-c f" . message-mark-insert-file)
2644 ;; ("C-c x" . message-xpost-fup2)
2645 ;; ("C-c s" . message-change-subject)
2646 ;; ("C-c a" . message-add-archive-header)
2647 ;; ("C-c t" . message-reduce-to-to-cc)
2648 ;; )))
2649 ;(add-hook 'message-header-setup-hook 'message-strip-subject-was)
2650 ;(add-hook 'message-setup-hook 'message-utils-setup)
2651
2652 ;;** Meine Smileys mag ich gelb
2653 (use-package smiley
2654 :init
2655 (progn
2656 (setq gnus-treat-display-smileys t)
2657 (setq smiley-flesh-color "Yellow")
2658 (setq smiley-data-directory "~/emacs/etc/smilies/")))
2659
2660 ;;** utf-8, coding systems
2661 (setq mm-coding-system-priorities
2662 '(iso-latin-1 iso-latin-9 utf-8))
2663
2664 (use-package sieve
2665 :mode ("\\.siv\\'" . sieve-mode)
2666 :config
2667 (require 'gnus-sieve)
2668 )
2669
2670 (setq gnus-use-correct-string-widths nil)
2671
2672 (setq nnrss-wash-html-in-text-plain-parts t)
2673 (setq canlock-password "canlockjjaspert")
2674 (setq canlock-sha1-function (quote canlock-sha1-with-openssl))
2675 (setq canlock-sha1-function-for-verify (quote canlock-sha1-with-openssl))
2676 (setq gnus-agent nil)
2677 (setq gnus-article-banner-alist (quote ((banner-perl . "^--.?
2678 .+
2679 .+
2680 .+
2681 .+
2682 .+
2683 Die Nutzung von.+html") (banner-debian . "^--.?
2684 To UNSUBSCRIBE.*
2685 .*@lists.debian.org$") (banner-debian-de . "^--.?
2686 -+
2687 Um sich aus der Liste auszutragen.+
2688 .+
2689 .+
2690 .+
2691 -+$\\|[0-9]+ eingetragene Mitglieder in dieser Liste.") (banner-sourceforge . "^_+
2692 .+@lists.sourceforge.net
2693 http://lists.sourceforge.net.+
2694 .+
2695 $") (banner-amavis . "^_+
2696 .+AMaViS-.*
2697 .*
2698 .*
2699 .*amavis-faq.php3$"))))
2700 (setq gnus-article-sort-functions (quote (gnus-article-sort-by-number gnus-article-sort-by-score gnus-article-sort-by-date)))
2701 (setq gnus-article-x-face-command (quote gnus-display-x-face-in-from))
2702 (setq gnus-boring-article-headers (quote (empty newsgroups followup-to reply-to)))
2703 (setq gnus-build-sparse-threads nil)
2704 (setq gnus-buttonized-mime-types '("multipart/signed"))
2705 (setq
2706 ;; collaps long citations
2707 ;; (w/ `gnus-treat-hide-citation t' or `W W c'):
2708 gnus-cited-closed-text-button-line-format
2709 "%(%{... [ %n lines (%l chars) of citation hidden, click here to expand ] ...%}%)\n"
2710 gnus-cited-lines-visible '(3 . 6) ; (top . bottom)
2711 ;; [...]
2712 gnus-treat-hide-citation t)
2713
2714 (setq gnus-default-article-saver (quote gnus-summary-save-in-file))
2715 ; (setq gnus-default-charset (quote iso-8859-1))
2716 (setq gnus-generate-tree-function (quote gnus-generate-vertical-tree))
2717 (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))))
2718 (setq gnus-group-name-charset-group-alist (quote ((".*" . iso-8859-1))))
2719 (setq gnus-group-name-charset-method-alist (quote ((nntp . iso-8859-1))))
2720 (setq gnus-group-posting-charset-alist (quote (("^\\(no\\|fr\\)\\.[^,]*\\(,[
2721 ]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1)) ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[
2722 ]*\\(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)
2723 (setq gnus-list-identifiers "\\[\\(a-zA-Z\\)+\\]")
2724 (setq gnus-message-replyencrypt nil)
2725 (setq gnus-message-replysign nil)
2726 (setq gnus-novice-user nil)
2727 (setq gnus-refer-thread-limit t)
2728 (setq gnus-save-duplicate-list t)
2729 (setq gnus-simplify-ignored-prefixes nil)
2730 (setq gnus-summary-exit-hook (quote (gnus-summary-bubble-group)))
2731 (setq gnus-summary-mode-line-format "Gnus: %g [%A] %Z - killed: %E")
2732 (setq gnus-suppress-duplicates t)
2733 (setq gnus-thread-indent-level 2)
2734 (setq gnus-thread-sort-functions (quote (gnus-thread-sort-by-number gnus-thread-sort-by-score gnus-thread-sort-by-date)))
2735 (setq gnus-treat-capitalize-sentences nil)
2736 (setq gnus-treat-date-local (quote head))
2737 (setq gnus-treat-display-picons nil)
2738 (setq gnus-treat-display-x-face (quote head))
2739 (setq gnus-treat-fill-article nil)
2740 (setq gnus-treat-fill-long-lines nil)
2741 (setq gnus-treat-from-picon (quote head))
2742 (setq gnus-treat-mail-picon (quote head))
2743 (setq gnus-treat-newsgroups-picon (quote head))
2744 (setq gnus-treat-unsplit-urls t)
2745 (setq gnus-treat-x-pgp-sig (quote head))
2746 (setq gnus-use-picons t)
2747 (setq gnus-uu-post-encode-method (quote gnus-uu-post-encode-mime))
2748 (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")))
2749 (setq mm-body-charset-encoding-alist (quote ((iso-2022-jp . 7bit) (iso-2022-jp-2 . 7bit) (iso-8859-1 . 8bit) (iso-8859-15 . 8bit))))
2750 (setq mm-decrypt-option (quote known))
2751 (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")))
2752 (setq mm-verify-option (quote always))
2753 (setq nnimap-authinfo-file "~/.nnimap")
2754 (setq gnus-save-newsrc-file nil)
2755 (setq gnus-read-newsrc-file nil)
2756 (setq gnus-always-read-dribble-file t)
2757
2758 (setq gnus-refer-article-method
2759 '(current
2760 (nnweb "refer" (nnweb-type dejanews))))
2761
2762 ))
2763
2764 #+END_SRC
2765 ** go-mode
2766 [2017-03-11 Sat 20:06]
2767 The go language, see golang.org
2768 #+BEGIN_SRC emacs-lisp
2769 (use-package go-mode
2770 :ensure t
2771 :bind (("M-." . godef-jump)
2772 ("M-*" . pop-tag-mark))
2773 :config
2774 (progn
2775 (defun my-go-mode-hook ()
2776 (interactive)
2777 (add-hook 'before-save-hook 'gofmt-before-save)
2778 ; Customize compile command to run go build
2779 (if (not (string-match "go" compile-command))
2780 (set (make-local-variable 'compile-command)
2781 "go build -v && go test -v && go vet"))
2782 ; Use goimports instead of go-fmt
2783 (setq gofmt-command "goimports")
2784 )
2785 (add-hook 'go-mode-hook 'my-go-mode-hook)
2786 (use-package go-autocomplete
2787 :ensure t)
2788 (use-package go-eldoc
2789 :ensure t
2790 :config
2791 (progn
2792 (add-hook 'go-mode-hook 'go-eldoc-setup)))
2793 (use-package go-guru
2794 :ensure t
2795 :config
2796 (progn
2797 (go-guru-hl-identifier-mode)
2798 (setq go-guru-command "golang-guru")))
2799 ))
2800 #+END_SRC
2801 ** golden ratio
2802 [2015-02-20 Fri 16:27]
2803 When working with many windows at the same time, each window has a
2804 size that is not convenient for editing.
2805
2806 golden-ratio helps on this issue by resizing automatically the windows
2807 you are working on to the size specified in the "Golden Ratio". The
2808 window that has the main focus will have the perfect size for editing,
2809 while the ones that are not being actively edited will be re-sized to
2810 a smaller size that doesn't get in the way, but at the same time will
2811 be readable enough to know it's content.
2812 #+BEGIN_SRC emacs-lisp
2813 (use-package golden-ratio
2814 :ensure golden-ratio
2815 :diminish (golden-ratio-mode . "ⓖ")
2816 :commands (golden-ratio-mode golden-ratio)
2817 :bind (("C-c t g" . my-toggle-golden-ratio))
2818 :init
2819 (progn
2820 (defun my-toggle-golden-ratio ()
2821 (interactive)
2822 (if (bound-and-true-p golden-ratio-mode)
2823 (progn
2824 (golden-ratio-mode -1)
2825 (balance-windows))
2826 (golden-ratio-mode)
2827 (golden-ratio)))
2828 (golden-ratio-mode 1)
2829 )
2830 :config
2831 (progn
2832 (setq golden-ratio-exclude-buffer-names '("*LV*" "*guide-key*" "*Ediff Control Panel*"))
2833 (setq golden-ratio-exclude-modes '("calendar-mode"
2834 "gnus-summary-mode"
2835 "gnus-article-mode"
2836 "calc-mode"
2837 "calc-trail-mode"
2838 "bbdb-mode"
2839 "notmuch-message-mode"
2840 "dired-mode"
2841 "ediff-mode"
2842 ))
2843 (setq golden-ratio-exclude-buffer-regexp `(,(rx bos "*which-key*" eos)
2844 ,(rx bos "*NeoTree*" eos)))
2845 (setq golden-ratio-extra-commands '(windmove-up
2846 windmove-down
2847 windmove-left
2848 windmove-right
2849 ace-window
2850 ace-delete-window
2851 ace-select-window
2852 ace-swap-window
2853 ace-maximize-window))))
2854 #+END_SRC
2855 ** goto last change
2856 [2015-02-22 Sun 13:28]
2857 Move point through buffer-undo-list positions.
2858 #+BEGIN_SRC emacs-lisp
2859 (use-package goto-last-change
2860 :commands (goto-last-change)
2861 :bind (("M-g l" . goto-last-change))
2862 )
2863 #+END_SRC
2864 ** CANCELLED guide-key :CANCELLED:
2865 CLOSED: [2018-12-30 Sun 17:09]
2866 :LOGBOOK:
2867 - State "CANCELLED" from [2018-12-30 Sun 17:09] \\
2868 ersetzt von which-key
2869 :END:
2870 [2014-06-11 Wed 22:27]
2871 guide-key.el displays the available key bindings automatically and
2872 dynamically.
2873
2874 For whatever reason I like this more than icicles <backtab> completion
2875 for this.
2876 #+BEGIN_SRC emacs-lisp
2877 (use-package guide-key
2878 :ensure guide-key
2879 :diminish guide-key-mode
2880 :disable t
2881 :config
2882 (progn
2883 (setq guide-key/guide-key-sequence '("C-x" "C-c" "M-g" "M-s"))
2884 (guide-key-mode 1)
2885 (setq guide-key/recursive-key-sequence-flag t)
2886 (setq guide-key/popup-window-position 'bottom)
2887 (setq guide-key/idle-delay 0.5)))
2888
2889 #+END_SRC
2890
2891 ** highlighting modes
2892 [2014-05-21 Wed 23:51]
2893 #+BEGIN_SRC emacs-lisp
2894 (use-package hi-lock
2895 :bind (("M-o l" . highlight-lines-matching-regexp)
2896 ("M-o r" . highlight-regexp)
2897 ("M-o w" . highlight-phrase)
2898 ("M-o u" . unhighlight-regexp)))
2899
2900 (use-package hilit-chg
2901 :bind ("M-o C" . highlight-changes-mode))
2902
2903 (use-package highlight-indentation
2904 :ensure t
2905 :commands 'highlight-indentation-mode
2906 :init
2907 (hook-into-modes 'highlight-indentation-mode '(yaml-mode-hook python-mode-hook))
2908 (hook-into-modes 'highlight-indentation-current-column-mode '(yaml-mode-hook python-mode-hook))
2909 :config
2910 (set-face-background 'highlight-indentation-face "#283d83")
2911 (set-face-background 'highlight-indentation-current-column-face "#285f85")
2912 )
2913
2914 (use-package highlight-numbers ; Fontify number literals
2915 :ensure t
2916 :init (add-hook 'prog-mode-hook #'highlight-numbers-mode))
2917 :defer t
2918
2919 #+END_SRC
2920 ** hippie-exp
2921 Crazy way of completion. It looks at the word before point and then
2922 tries to expand it in various ways.
2923 #+BEGIN_SRC emacs-lisp
2924 (use-package hippie-exp
2925 :bind ("M-/" . hippie-expand)
2926 :commands hippie-expand
2927 :config
2928 (progn
2929 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
2930 try-expand-dabbrev-all-buffers
2931 try-expand-dabbrev-from-kill
2932 try-complete-file-name-partially
2933 try-complete-file-name
2934 try-expand-all-abbrevs try-expand-list
2935 try-expand-line
2936 try-complete-lisp-symbol-partially
2937 try-complete-lisp-symbol))))
2938 #+END_SRC
2939 ** hydra
2940 [2015-01-26 Mon 15:50]
2941 This is a package for GNU Emacs that can be used to tie related
2942 commands into a family of short bindings with a common prefix - a
2943 Hydra.
2944
2945 Once you summon the Hydra through the prefixed binding (the body + any
2946 one head), all heads can be called in succession with only a short
2947 extension.
2948
2949 The Hydra is vanquished once Hercules, any binding that isn't the
2950 Hydra's head, arrives. Note that Hercules, besides vanquishing the
2951 Hydra, will still serve his orignal purpose, calling his proper
2952 command. This makes the Hydra very seamless, it's like a minor mode
2953 that disables itself auto-magically.
2954 #+BEGIN_SRC emacs-lisp
2955 (use-package hydra
2956 :ensure hydra
2957 :init
2958 (progn
2959 (setq hydra-is-helpful t)
2960 (setq hydra-lv t)
2961
2962 (defhydra hydra-error (:color red)
2963 "goto-error"
2964 ("h" first-error "first")
2965 ("j" next-error "next")
2966 ("k" previous-error "prev")
2967 ("v" recenter-top-bottom "recenter")
2968 ("q" nil "quit"))
2969 (bind-key "M-g e" 'hydra-error/body)
2970
2971 ;; (defhydra hydra-gnus (:color red)
2972 ;; "gnus functions"
2973 ;; ("m" gnus-uu-mark-thread "mark thread")
2974 ;; ("d" gnus-summary-delete-article "delete article(s)")
2975 ;; ("r" gnus-summary-mark-as-read-forward "mark read")
2976 ;; ("n" gnus-summary-next-thread "next thread")
2977 ;; ("p" gnus-summary-prev-thread "previous thread")
2978 ;; ("g" gnus-summary-next-group "next group")
2979 ;; ("l" gnus-recenter "recenter")
2980 ;; ("x" gnus-summary-limit-to-unread "unread")
2981 ;; ("q" nil "quit"))
2982 ;; (bind-key "C-c h" 'hydra-gnus/body)
2983
2984 (defhydra hydra-launcher (:color blue)
2985 "Launch"
2986 ("h" man "man")
2987 ("r" (browse-url "http://www.reddit.com/r/emacs/") "reddit")
2988 ("w" (browse-url "http://www.emacswiki.org/") "emacswiki")
2989 ("s" shell "shell")
2990 ("q" nil "cancel"))
2991 (bind-key "M-g r" 'hydra-launcher/body)
2992
2993 ; whitespace mode gets loaded late, so variable may not be there yet. Workaround...
2994 (defvar whitespace-mode nil)
2995 (defhydra hydra-toggle (:color pink)
2996 "
2997 _a_ abbrev-mode: % 4`abbrev-mode^^^^ _f_ auto-fill-mode: %`auto-fill-function
2998 _c_ auto-complete-mode: % 4`auto-complete-mode _r_ auto-revert-mode: %`auto-revert-mode
2999 _d_ debug-on-error: % 4`debug-on-error^ _t_ truncate-lines: %`truncate-lines
3000 _w_ whitespace-mode: % 4`whitespace-mode _g_ golden-ratio-mode: %`golden-ratio-mode
3001 _l_ linum-mode: % 4`linum-mode _k_ linum relative: %`linum-format
3002
3003 "
3004 ("a" abbrev-mode nil)
3005 ("c" auto-complete-mode nil)
3006 ; ("i" aggressive-indent-mode nil)
3007 ("d" toggle-debug-on-error nil)
3008 ("f" auto-fill-mode nil)
3009 ("g" golden-ratio-mode nil)
3010 ("t" toggle-truncate-lines nil)
3011 ("w" whitespace-mode nil)
3012 ("r" auto-revert-mode nil)
3013 ("l" linum-mode nil)
3014 ("k" linum-relative-toggle nil)
3015 ("q" nil "cancel"))
3016 (bind-key "C-c C-v" 'hydra-toggle/body)
3017 ))
3018
3019
3020 #+END_SRC
3021 ** ibuffer
3022 [2014-05-21 Wed 23:54]
3023 #+BEGIN_SRC emacs-lisp
3024 (use-package ibuffer
3025 :bind (("C-h h" . ibuffer)
3026 ("C-x C-b" . ibuffer)
3027 ("<XF86WebCam>" . ibuffer)
3028 :map ibuffer-mode-map
3029 ("s" . isearch-forward-regexp)
3030 ("." . ibuffer-invert-sorting)
3031 ("i" . ibuffer-magit-status)
3032 ("G" . ibuffer-magit-status))
3033 :commands (ibuffer)
3034 :defines (ibuffer-filtering-alist
3035 ibuffer-filter-groups ibuffer-compile-formats ibuffer-git-column-length
3036 ibuffer-show-empty-filter-groups ibuffer-saved-filter-groups)
3037 :config
3038 (progn
3039 (defvar my-ibufffer-separator " • ")
3040 (setq ibuffer-filter-group-name-face 'variable-pitch
3041 ibuffer-use-header-line t)
3042 (unbind-key "M-o" ibuffer-mode-map)
3043
3044 (use-package f
3045 :ensure f)
3046
3047 (use-package ibuffer-vc
3048 :ensure t
3049 :commands
3050 (ibuffer-vc-set-filter-groups-by-vc-root
3051 ibuffer-vc-generate-filter-groups-by-vc-root))
3052
3053 (use-package ibuffer-tramp
3054 :ensure t
3055 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
3056 ibuffer-tramp-set-filter-groups-by-tramp-connection))
3057 ;; Switching to ibuffer puts the cursor on the most recent buffer
3058 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
3059 "Open ibuffer with cursor pointed to most recent buffer name"
3060 (let ((recent-buffer-name (buffer-name)))
3061 ad-do-it
3062 (ibuffer-update nil t)
3063 (unless (string= recent-buffer-name "*Ibuffer*")
3064 (ibuffer-jump-to-buffer recent-buffer-name))))
3065
3066 (defun ibuffer-magit-status ()
3067 (interactive)
3068 (--when-let (get-buffer "*Ibuffer*")
3069 (with-current-buffer it
3070 (let* ((selected-buffer (ibuffer-current-buffer))
3071 (buffer-path (with-current-buffer
3072 selected-buffer
3073 (or (buffer-file-name)
3074 list-buffers-directory
3075 default-directory)))
3076 (default-directory
3077 (if (file-regular-p buffer-path)
3078 (file-name-directory buffer-path)
3079 buffer-path)))
3080 (magit-status-internal default-directory)))))
3081
3082 (setq ibuffer-directory-abbrev-alist
3083 (-uniq
3084 (-flatten
3085 (--map
3086 (list
3087 (cons (f-slash (f-expand (cdr it))) my-ibufffer-separator)
3088 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
3089 '(
3090 ("dak" . "/develop/dak/")
3091 ("org" . "~/org/")
3092 ("config" . "~/.emacs.d/config/")
3093 ("tmp" . "~/tmp/")
3094 ("systmp" . "/tmp/")
3095 ("puppet" . "~/git/puppet")
3096 ("git" . "~/git/")
3097 )))))
3098
3099 (use-package ibuffer-git
3100 :ensure t)
3101 (use-package ibuffer-vc
3102 :ensure t)
3103
3104 (define-ibuffer-column size-h
3105 (:name "Size" :inline t)
3106 (cond
3107 ((> (buffer-size) 1000)
3108 (format "%7.1fk" (/ (buffer-size) 1000.0)))
3109 ((> (buffer-size) 1000000)
3110 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
3111 (t
3112 (format "%8d" (buffer-size)))))
3113
3114 (use-package ibuf-ext
3115 :config
3116 (setq ibuffer-old-time 12))
3117
3118 (define-ibuffer-filter filename2
3119 "Toggle current view to buffers with filename matching QUALIFIER."
3120 (:description "filename2"
3121 :reader (read-from-minibuffer "Filter by filename (regexp): "))
3122 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
3123 (ibuffer-awhen (with-current-buffer buf
3124 (or buffer-file-name
3125 default-directory))
3126 (string-match qualifier it)))
3127
3128 (defvar ibuffer-magit-filter-groups nil)
3129 (defun ibuffer-magit-define-filter-groups ()
3130 (when (and (not ibuffer-magit-filter-groups)
3131 (boundp 'magit-repo-dirs))
3132 (setq ibuffer-magit-filter-groups
3133 (--map (list
3134 (concat "git:: "
3135 (file-name-nondirectory (directory-file-name it)))
3136 `(filename2 . ,it))
3137 (mapcar 'cdr (magit-list-repos))))))
3138
3139 (defun ibuffer-set-filter-groups-by-root ()
3140 (interactive)
3141 ;; (ibuffer-projectile-define-filter-groups)
3142 ;; (ibuffer-magit-define-filter-groups)
3143 (setq ibuffer-filter-groups
3144 (-concat
3145 ;; ibuffer-projectile-filter-groups
3146 ibuffer-magit-filter-groups
3147
3148 '(("MORE"
3149 (or (mode . magit-log-edit-mode)
3150 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
3151 (name . "^\\*Pymacs\\*$")
3152 (name . "^\\*helm.*\\*")
3153 (name . "^\\*Compile-log\\*$")
3154 (name . "^\\*Ido Completions\\*$")
3155 (name . "^\\*magit-\\(process\\)\\*$")
3156 (name . "^ "))))
3157 '(("Tramp"
3158 (or
3159 (name . "^\\*\\(tramp/.*\\)\\*$"))))
3160 '(("EMACS"
3161 (or
3162 (name . "^\\*scratch")
3163 (name . "^\\*Messages")
3164 (name . "^\\*Help")
3165 )))
3166 (ibuffer-vc-generate-filter-groups-by-vc-root)
3167 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
3168
3169 (defun toggle-ibuffer-filter-groups ()
3170 "DOCSTRING"
3171 (interactive)
3172 (let ((ibuf (get-buffer "*Ibuffer*")))
3173 (when ibuf
3174 (with-current-buffer ibuf
3175 (let ((selected-buffer (ibuffer-current-buffer)))
3176 (if (not ibuffer-filter-groups)
3177 (ibuffer-set-filter-groups-by-root)
3178 (setq ibuffer-filter-groups nil))
3179 (pop-to-buffer ibuf)
3180 (ibuffer-update nil t)
3181 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
3182
3183 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
3184
3185 (defun ibuffer-back-to-top ()
3186 (interactive)
3187 (goto-char (point-min))
3188 (forward-line 3))
3189
3190 (defun ibuffer-jump-to-bottom ()
3191 (interactive)
3192 (goto-char (point-max))
3193 (beginning-of-line)
3194 (forward-line -2))
3195
3196 (define-key ibuffer-mode-map
3197 (vector 'remap 'end-of-buffer) 'ibuffer-jump-to-bottom)
3198 (define-key ibuffer-mode-map
3199 (vector 'remap 'beginning-of-buffer) 'ibuffer-back-to-top)
3200
3201 (setq ibuffer-default-sorting-mode 'recency)
3202 (setq ibuffer-eliding-string "…"
3203 ibuffer-compile-formats t
3204 ibuffer-git-column-length 6
3205 ibuffer-show-empty-filter-groups nil
3206 ibuffer-default-directory "~/"
3207 )
3208
3209 (setq ibuffer-formats '((mark vc-status-mini
3210 " "
3211 (git-status 8 8 :left)
3212 " "
3213 read-only modified
3214 " "
3215 (name 18 18 :left :elide)
3216 " "
3217 (size-h 9 -1 :right)
3218 " "
3219 (mode 16 16 :left :elide)
3220 " " filename-and-process)
3221 (mark " "
3222 (git-status 8 8 :left)
3223 " "
3224 (name 16 -1)
3225 " " filename)
3226 ))
3227
3228 (setq ibuffer-saved-filter-groups
3229 (quote (("flat")
3230 ("default"
3231 ("dired" (mode . dired-mode))
3232 ("perl" (mode . cperl-mode))
3233 ("puppet" (or
3234 (mode . puppet-mode)
3235 (mode . yaml-mode)))
3236 ("ruby" (mode . ruby-mode))
3237 ("emacs" (or
3238 (name . "^\\*scratch\\*$")
3239 (name . "^\\*Compile-log\\*$")
3240 (name . "^\\*Completions\\*$")
3241 (name . "^\\*Messages\\*$")
3242 (name . "^\\*Backtrace\\*$")
3243 (name . "^\\*Packages*\\*$")
3244 (name . "^\\*Help*\\*$")
3245 (mode . grep-mode)
3246 ))
3247 ("gnus" (or
3248 (mode . message-mode)
3249 (mode . bbdb-mode)
3250 (mode . mail-mode)
3251 (mode . gnus-group-mode)
3252 (mode . gnus-summary-mode)
3253 (mode . gnus-article-mode)
3254 (name . "^\\.bbdb$")
3255 (name . "^\\.newsrc-dribble")))
3256 ("org agenda" (or
3257 (mode . org-agenda-mode)
3258 (name . "^*Org Agenda")))
3259 ("org" (or
3260 (filename . ".*/org/.*")
3261 ;(mode . org-agenda-mode)
3262 (name . "^diary$")))
3263 ("scm" (or
3264 (mode . magit-status-mode)
3265 (mode . magit-log-mode)
3266 (mode . magit-diff-mode)
3267 (mode . magit-refs-mode)
3268 (mode . magit-revision-mode)
3269 (mode . vc-annotate-mode)))
3270 ("Tramp" (or
3271 (name . "^\\*\\(tramp/.*\\)\\*$")))
3272 ("code" (or
3273 (mode . emacs-lisp-mode)
3274 (mode . python-mode)
3275 (mode . ruby-mode)
3276 (mode . coffee-mode)
3277 (mode . js-mode)
3278 (mode . js2-mode)
3279 (mode . actionscript-mode)
3280 (mode . java-mode)
3281 (mode . sh-mode)
3282 (mode . haskell-mode)
3283 (mode . html-mode)
3284 (mode . web-mode)
3285 (mode . haml-mode)
3286 (mode . nxml-mode)
3287 (mode . go-mode)
3288 (mode . rust-mode)
3289 (mode . css-mode)))
3290 ("other" (or
3291 (mode . magit-log-edit-mode)
3292 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
3293 ("categorized"
3294 ;; -------------------------------------------------
3295 ;; programming languages #1
3296 ("code" (or
3297 (mode . emacs-lisp-mode)
3298 (mode . python-mode)
3299 (mode . ruby-mode)
3300 (mode . coffee-mode)
3301 (mode . js-mode)
3302 (mode . js2-mode)
3303 (mode . actionscript-mode)
3304 (mode . java-mode)
3305 (mode . sh-mode)
3306 (mode . haskell-mode)
3307 (mode . html-mode)
3308 (mode . web-mode)
3309 (mode . haml-mode)
3310 (mode . nxml-mode)
3311 (mode . go-mode)
3312 (mode . rust-mode)
3313 (mode . css-mode)))
3314 ;; -------------------------------------------------
3315 ;; configuration/data files
3316 ("conf" (or
3317 (mode . json-mode)
3318 (mode . yaml-mode)
3319 (mode . conf-mode)))
3320 ;; -------------------------------------------------
3321 ;; text/notetaking/org
3322 ("org agenda" (mode . org-agenda-mode))
3323 ("org" (or
3324 (mode . org-mode)
3325 (name . "^\\*Calendar\\*$")
3326 (name . "^diary$")))
3327 ("text misc" (or
3328 (mode . text-mode)
3329 (mode . rst-mode)
3330 (mode . markdown-mode)))
3331 ;; -------------------------------------------------
3332 ;; media
3333 ("media" (or
3334 (mode . image-mode)))
3335 ;; -------------------------------------------------
3336 ;; misc
3337 ("w3m" (mode . w3m-mode))
3338 ("scm" (or
3339 (mode . magit-status-mode)
3340 (mode . magit-log-mode)
3341 (mode . vc-annotate-mode)))
3342 ("dired" (mode . dired-mode))
3343 ("help" (or
3344 (mode . Info-mode)
3345 (mode . help-mode)
3346 (mode . Man-mode)
3347 (name . "^\\*Personal Keybindings\\*$")))
3348 ("Tramp" (or
3349 (name . "^\\*\\(tramp/.*\\)\\*$")))
3350 ;; -------------------------------------------------
3351 ;; *buffer* buffers
3352 ("MORE" (or (mode . magit-log-edit-mode)
3353 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
3354 (name . "^\\*Pymacs\\*$")
3355 (name . "^\\*Compile-log\\*$")
3356 (name . "^\\*Completions\\*$")
3357 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
3358 (name . "^ ")))
3359 ("*buffer*" (name . "\\*.*\\*"))))))
3360
3361 (add-hook 'ibuffer-mode-hook
3362 (lambda ()
3363 (ibuffer-auto-mode 1)
3364 (ibuffer-switch-to-saved-filter-groups "default")))
3365
3366 ;; Unless you turn this variable on you will be prompted every time
3367 ;; you want to delete a buffer, even unmodified ones, which is way
3368 ;; too cautious for most people. You’ll still be prompted for
3369 ;; confirmation when deleting modified buffers after the option has
3370 ;; been turned off.
3371 (setq ibuffer-expert t)
3372 ))
3373 #+END_SRC
3374 ** ivy-mode, swiper, counsel
3375 [2015-10-16 Fri 16:28]
3376 Full docs at http://oremacs.com/swiper/
3377 #+BEGIN_SRC emacs-lisp
3378 (use-package swiper
3379 :ensure swiper
3380 :bind (("C-s" . swiper)
3381 ("C-r" . swiper)
3382 ("C-c r" . ivy-resume)
3383 ("<f7>" . ivy-resume))
3384 :config
3385 (progn
3386 ;(ivy-mode 1)
3387 (setq ivy-use-virtual-buffers t)
3388 (setq ivy-count-format "(%d/%d) ")
3389 (setq ivy-initial-inputs-alist nil)
3390 ;;advise swiper to recenter on exit
3391 (defun bjm-swiper-recenter (&rest args)
3392 "recenter display after swiper"
3393 (recenter)
3394 )
3395 (advice-add 'swiper :after #'bjm-swiper-recenter)
3396 ))
3397 #+END_SRC
3398 counsel is a collection of Ivy enhanced versions of common Emacs
3399 commands, see https://github.com/abo-abo/swiper
3400 #+BEGIN_SRC emacs-lisp
3401 (use-package counsel
3402 :ensure t
3403 :bind (("M-y" . counsel-yank-pop)
3404 ("M-x" . counsel-M-x)
3405 ("C-x C-f" . counsel-find-file)
3406 ("<f1> f" . counsel-describe-function)
3407 ("<f1> u" . counsel-unicode-char)
3408 ("C-c j" . counsel-git-grep)
3409 :map ivy-minibuffer-map
3410 ("M-y" . ivy-forward-line)))
3411 #+END_SRC
3412 ** icicles
3413 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
3414 ‘TAB’ completion is to typing things manually every time.”]]
3415 #+BEGIN_SRC emacs-lisp
3416 (use-package icicles
3417 :load-path "elisp/icicles"
3418 :config
3419 (icy-mode 1))
3420 #+END_SRC
3421 ** iedit
3422 [2014-05-26 Mon 22:49]
3423 #+BEGIN_SRC emacs-lisp
3424 (use-package iedit
3425 :ensure iedit
3426 :commands (iedit-mode)
3427 :defer t
3428 :bind (("C-;" . iedit-mode)
3429 ("C-," . iedit-mode-toggle-on-function))
3430 )
3431
3432 #+END_SRC
3433 ** info stuff
3434 [2014-05-20 Tue 23:35]
3435 #+BEGIN_SRC emacs-lisp
3436 (use-package info
3437 :bind ("C-h C-i" . info-lookup-symbol)
3438 :commands info-lookup-symbol
3439 :config
3440 (progn
3441 ;; (defadvice info-setup (after load-info+ activate)
3442 ;; (use-package info+))
3443
3444 (defadvice Info-exit (after remove-info-window activate)
3445 "When info mode is quit, remove the window."
3446 (if (> (length (window-list)) 1)
3447 (delete-window)))))
3448
3449 (use-package info-look
3450 :commands info-lookup-add-help)
3451 #+END_SRC
3452 ** ispell
3453 [2016-11-13 Sun 13:22]
3454 #+BEGIN_SRC emacs-lisp
3455 (use-package ispell
3456 :defer t
3457 :config
3458 (progn
3459 (setq ispell-personal-dictionary (expand-file-name "~/flydict" jj-cache-dir))
3460
3461 (setq ispell-dictionary "de_DE")
3462 (setq ispell-program-name "hunspell")
3463 (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC"))
3464 (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_EXAMPLE" . "#\\+END_EXAMPLE"))
3465 ))
3466 #+END_SRC
3467 ** json mode
3468 [2018-12-30 Sun 23:20]
3469 #+BEGIN_SRC emacs-lisp
3470 (use-package json-mode ; JSON files
3471 :ensure t
3472 :defer t
3473 :mode ("config.data" . json-mode)
3474 :config
3475 (progn ; https://github.com/skeeto/.emacs.d
3476 (setf json-reformat:pretty-string? t
3477 json-reformat:indent-width 2)
3478 (define-key json-mode-map (kbd "M-q")
3479 (lambda ()
3480 (interactive)
3481 (if (region-active-p)
3482 (call-interactively #'json-reformat-region)
3483 (json-reformat-region (point-min) (point-max)))))
3484
3485 (add-hook 'json-mode-hook
3486 ;; Fix JSON mode indentation
3487 (lambda () (setq-local js-indent-level 4)))))
3488 #+END_SRC
3489 ** linum (line number)
3490 Various modes should have line numbers in front of each line.
3491
3492 But then there are some where it would just be deadly - like org-mode,
3493 gnus, so we have a list of modes where we don't want to see it.
3494 #+BEGIN_SRC emacs-lisp
3495 (if (version<= "26.0.50" emacs-version )
3496 (progn
3497 (global-display-line-numbers-mode 1)
3498 (add-hook 'gnus-group-mode-hook (lambda (&optional dummy) (display-line-numbers-mode -1)))
3499 (add-hook 'gnus-summary-mode-hook (lambda (&optional dummy) (display-line-numbers-mode -1)))
3500 (add-hook 'gnus-article-mode-hook (lambda (&optional dummy) (display-line-numbers-mode -1))))
3501 (progn
3502 ; Old emacs versions
3503 (use-package linum
3504 :diminish linum-mode
3505 :defines (linum-mode-inhibit-modes-list)
3506 :config
3507 (progn
3508 (setq linum-format "%3d ")
3509 (setq linum-mode-inhibit-modes-list '(org-mode
3510 eshell-mode
3511 shell-mode
3512 gnus-group-mode
3513 gnus-summary-mode
3514 gnus-article-mode))
3515
3516 (defadvice linum-on (around linum-on-inhibit-for-modes)
3517 "Stop the load of linum-mode for some major modes."
3518 (unless (member major-mode linum-mode-inhibit-modes-list)
3519 ad-do-it))
3520
3521 (ad-activate 'linum-on)
3522
3523 (use-package linum-relative
3524 :ensure linum-relative
3525 :init
3526 (progn
3527 (setq linum-format 'dynamic)
3528 )))
3529 :init
3530 (global-linum-mode 1))
3531
3532 (use-package hlinum
3533 :ensure t
3534 :config
3535 (progn
3536 (hlinum-activate)))
3537 ))
3538 #+END_SRC
3539
3540 ** lisp editing stuff
3541
3542 [2013-04-21 So 21:00]
3543 I'm not doing much of it, except for my emacs and gnus configs, but
3544 then I like it nice too...
3545 #+BEGIN_SRC emacs-lisp
3546 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
3547 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
3548
3549 (defun remove-elc-on-save ()
3550 "If you're saving an elisp file, likely the .elc is no longer valid."
3551 (make-local-variable 'after-save-hook)
3552 (add-hook 'after-save-hook
3553 (lambda ()
3554 (if (file-exists-p (concat buffer-file-name "c"))
3555 (delete-file (concat buffer-file-name "c"))))))
3556
3557 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
3558 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
3559
3560 (use-package paredit
3561 :ensure paredit
3562 :diminish paredit-mode " π")
3563
3564 (setq lisp-coding-hook 'lisp-coding-defaults)
3565 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
3566
3567 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
3568 (add-hook 'emacs-lisp-mode-hook (lambda ()
3569 (run-hooks 'prelude-emacs-lisp-mode-hook)))
3570
3571
3572 (after "elisp-slime-nav"
3573 '(diminish 'elisp-slime-nav-mode))
3574 (after "rainbow-mode"
3575 '(diminish 'rainbow-mode))
3576 (after "eldoc"
3577 '(diminish 'eldoc-mode))
3578 #+END_SRC
3579 ** lua
3580 [2016-10-27 Thu 17:49]
3581 Lua editing
3582 #+BEGIN_SRC emacs-lisp
3583 (use-package lua-mode
3584 :ensure t
3585 :commands lua-mode
3586 :mode ("\\.lua" . lua-mode))
3587 #+END_SRC
3588 ** magit
3589 [2013-04-21 So 20:48]
3590 magit is a mode for interacting with git.
3591 #+BEGIN_SRC emacs-lisp
3592 (use-package magit
3593 :ensure magit
3594 :commands (magit-log-other magit-run-gitk magit-run-git-gui magit-status
3595 magit-git-repo-p magit-list-repos)
3596 :bind (("C-x g" . magit-status)
3597 ("C-x G" . magit-status-with-prefix)
3598 :map magit-status-mode-map
3599 ("q" . magit-quit-session ))
3600
3601 :config
3602 (progn
3603 (setq magit-repository-directories '(("~/devel" . 4)
3604 ("~/git/" . 4)
3605 ))
3606 (setq magit-log-auto-more t)
3607 (setq magit-completing-read-function 'ivy-completing-read)
3608
3609 ; VC shouldnt do anything with git
3610 (setq vc-handled-backends (delq 'Git vc-handled-backends))
3611
3612 (use-package magit-blame
3613 :commands magit-blame-mode)
3614
3615 (add-hook 'magit-mode-hook 'hl-line-mode)
3616 (defun magit-status-with-prefix ()
3617 (interactive)
3618 (let ((current-prefix-arg '(4)))
3619 (call-interactively 'magit-status)))
3620 (setenv "GIT_PAGER" "")
3621
3622 (unbind-key "M-h" magit-mode-map)
3623 (unbind-key "M-s" magit-mode-map)
3624 (add-to-list 'magit-no-confirm 'stage-all-changes)
3625 (setq magit-push-always-verify nil)
3626
3627 (add-hook 'magit-log-edit-mode-hook
3628 #'(lambda ()
3629 (set-fill-column 72)
3630 (flyspell-mode)))
3631
3632 (add-hook 'git-rebase-mode-hook
3633 #'(lambda ()
3634 (smartscan-mode 0))
3635 )
3636 (defadvice magit-status (around magit-fullscreen activate)
3637 (window-configuration-to-register :magit-fullscreen)
3638 ad-do-it
3639 (delete-other-windows))
3640
3641 (defun magit-quit-session ()
3642 "Restores the previous window configuration and kills the magit buffer"
3643 (interactive)
3644 (kill-buffer)
3645 (jump-to-register :magit-fullscreen))
3646
3647 (use-package forge
3648 :ensure t
3649 :config
3650 (progn
3651 (setq gitlab.salsa.debian.org.user "joerg")
3652 ))
3653 ))
3654 #+END_SRC
3655 ** markdown-mode
3656 [2014-05-20 Tue 23:04]
3657 #+BEGIN_SRC emacs-lisp
3658 (use-package markdown-mode
3659 :ensure t
3660 :mode (("\\.md\\'" . markdown-mode)
3661 ("\\.mdwn\\'" . markdown-mode))
3662 :defer t)
3663 #+END_SRC
3664 ** message
3665 #+BEGIN_SRC emacs-lisp
3666 (use-package message
3667 :commands (message-mode)
3668 :after (notmuch)
3669 :bind (:map notmuch-message-mode-map
3670 ("C-c M-m" . 'my-message-mark-inserted-region)
3671 ("C-c h" . 'harden-newlines))
3672 :config
3673 (progn
3674 (setq message-kill-buffer-on-exit t)
3675
3676 (use-package time-date
3677 :config
3678 (setq message-citation-line-function 'september-citation-line))
3679
3680 ;;** Message Size Limit
3681 (setq message-send-mail-partially-limit 5000000)
3682
3683 (setq message-send-mail-function 'message-send-mail-with-sendmail)
3684 (setq smtpmail-default-smtp-server "localhost")
3685 (setq message-sendmail-envelope-from 'header)
3686
3687 ;;** Keinen Sender Header zufuegen !
3688 (add-to-list 'message-syntax-checks '(sender . disabled))
3689
3690 ;;** Kaputte Subjects Aw: Statt Re: fixen:
3691 (setq message-subject-re-regexp "^[ ]*\\([RrAaFf][EeWw]:[ ]*\\)*[ ]*")
3692
3693 ;;** Ich will die Header in den Nachrichten sehen die ich schreibe.
3694 (setq message-generate-headers-first t)
3695
3696 ;;** Und immer schoen Header zufuegen.
3697 (setq message-default-headers (concat "Organization: Ganneff\n"))
3698 (add-hook 'message-send-hook 'my-message-add-content)
3699
3700 ;;** Und Courtesy-Mails wollen wir schon mal grad gar nicht
3701 (add-hook 'message-header-setup-hook 'my-message-header-setup-hook)
3702
3703 ;;** In Forwards bitte das Subject aufraeumen
3704 (setq message-wash-forwarded-subjects t)
3705
3706 ;;** Zitieren ohne Sig. Ausser Idioten sind zu doof die korrekt abzutrennen.
3707 (setq message-cite-function 'message-cite-original-without-signature)
3708
3709 ;;** Automagischen Zeilenumbruch bei News/Mailangabe.
3710 (add-hook 'message-mode-hook
3711 (lambda ()
3712 (setq fill-column 72)
3713 (turn-on-auto-fill)
3714 (epa-mail-mode 1)
3715 ))
3716 (add-hook 'notmuch-message-mode-hook
3717 (lambda ()
3718 (setq fill-column 72)
3719 (turn-on-auto-fill)
3720 (epa-mail-mode 1)
3721 ))
3722 (setq fill-flowed-encode-column 78)
3723
3724 ;;** org-mode
3725 (add-hook 'message-mode-hook 'orgstruct++-mode 'append)
3726 (add-hook 'message-mode-hook 'orgtbl-mode 'append)
3727
3728 (setq message-forward-as-mime t)
3729 (use-package message-x
3730 :load-path "elisp/local")
3731
3732 (use-package randomsig
3733 :bind (:map message-mode-map
3734 ("C-c s" . randomsig-replace-sig)
3735 ("C-c S" . randomsig-select-sig))
3736 :config
3737 (progn
3738 (setq randomsig-dir "/home/joerg/sigs")
3739 (setq message-signature 'randomsig-signature)))
3740
3741 (setq message-archive-note "X-No-Archive: Yes")
3742 (setq message-make-forward-subject-function (quote message-forward-subject-fwd))
3743 (setq message-max-buffers 5)
3744 (setq message-send-hook (quote (my-message-add-content)))
3745 (setq message-subscribed-regexps (quote (".*@lists.*" ".*@postfix.org" ".*@nongnu.org")))
3746 (setq message-use-followup-to (quote use))
3747
3748 ; use format=flowed mail style, see
3749 (require 'messages-are-flowing)
3750 (setq mml-enable-flowed t)
3751 (add-hook 'message-mode-hook #'messages-are-flowing-use-and-mark-hard-newlines)
3752
3753 ; A function to mark newlines as hard newlines for format=flowed stuff
3754 (defun harden-newlines (beg end)
3755 (interactive "r")
3756 (save-excursion
3757 (save-restriction
3758 (narrow-to-region beg end)
3759 (goto-char (point-min))
3760 (while (search-forward "\n" nil t)
3761 (put-text-property (1- (point)) (point) 'hard t)))))
3762
3763 (defun harden-message-buffer ()
3764 (interactive)
3765 (save-excursion
3766 (message-goto-body)
3767 (message "Hardening body")
3768 (while (search-forward "\n" nil t)
3769 (put-text-property (1- (point)) (point) 'hard t))))
3770
3771 (add-hook 'message-send-hook 'harden-message-buffer)
3772 (add-hook 'notmuch-mua-send-hook 'harden-message-buffer)
3773 ; In format=flowed our enclosing tags must end with a hard newline
3774 (defun my-message-mark-inserted-region (beg end &optional verbatim)
3775 "Mark some region in the current article with enclosing tags.
3776 See `message-mark-insert-begin' and `message-mark-insert-end'.
3777 If VERBATIM, use slrn style verbatim marks (\"#v+\" and \"#v-\")."
3778 (interactive "r\nP")
3779 (save-excursion
3780 ;; add to the end of the region first, otherwise end would be invalid
3781 (goto-char end)
3782 (insert (if verbatim "#v-\n" message-mark-insert-end))
3783 (put-text-property (1- (point)) (point) 'hard t)
3784 (goto-char beg)
3785 (insert (if verbatim "#v+\n" message-mark-insert-begin))
3786 (put-text-property (1- (point)) (point) 'hard t)
3787 )
3788
3789 ;;** Nun das Paket um einfachst Fussnoten eingeben zu können.
3790 (use-package footnote
3791 :commands (footnote-mode)
3792 :config
3793 (setq footnote-body-tag-spacing 1
3794 footnote-spaced-footnotes nil
3795 footnote-style 'numeric-latin
3796 footnote-section-tag "Footnotes:"))
3797 (add-hook 'message-mode-hook 'footnote-mode))
3798 ))
3799 #+END_SRC
3800 ** mml
3801 [2018-12-31 Mon 13:28]
3802 #+BEGIN_SRC emacs-lisp
3803 (use-package mml
3804 :config
3805 (progn
3806 ;; http://mbork.pl/2015-11-28_Fixing_mml-attach-file_using_advice
3807 (defun mml-attach-file--go-to-eob (orig-fun &rest args)
3808 "Go to the end of buffer before attaching files."
3809 (save-excursion
3810 (save-restriction
3811 (widen)
3812 (goto-char (point-max))
3813 (apply orig-fun args))))
3814
3815 (advice-add 'mml-attach-file :around #'mml-attach-file--go-to-eob)
3816 (setq mm-verify-option 'always)
3817 ))
3818 (use-package mml-sec
3819 :commands (sign-or-crypt)
3820 :hook ((message-setup gnus-message-setup notmuch-message-setup) . sign-or-crypt)
3821 :config
3822 (progn
3823 ;; Keine extra Signatur erzeugen.
3824 (mml-signencrypt-style "pgpmime" 'combined)
3825 (setq mml-secure-openpgp-sign-with-sender 't)
3826 (setq gpg-unabbrev-trust-alist
3827 '(("TRUST_UNDEFINED" . trust-undefined)
3828 ("TRUST_NEVER" . trust-none)
3829 ("TRUST_MARGINAL" . trust-marginal)
3830 ("TRUST_FULLY" . trust-full)
3831 ("TRUST_ULTIMATE" . trust-ultimate)))
3832 ))
3833 #+END_SRC
3834 ** miniedit
3835 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
3836 #+BEGIN_SRC emacs-lisp
3837 (use-package miniedit
3838 :ensure miniedit
3839 :commands miniedit
3840 :config
3841 (progn
3842 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
3843 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
3844 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
3845 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
3846 ))
3847 #+END_SRC
3848
3849 ** mo-git-blame
3850 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
3851 Emacs]].
3852 #+BEGIN_SRC emacs-lisp
3853 (use-package mo-git-blame
3854 :ensure mo-git-blame
3855 :commands (mo-git-blame-current
3856 mo-git-blame-file)
3857 :config
3858 (progn
3859 (setq mo-git-blame-blame-window-width 25)))
3860 #+END_SRC
3861
3862 ** CANCELLED multiple cursors :CANCELLED:
3863 CLOSED: [2017-08-26 Sat 15:18]
3864 :LOGBOOK:
3865 - State "CANCELLED" from [2017-08-26 Sat 15:18]
3866 :END:
3867 [2013-04-08 Mon 23:57]
3868 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
3869 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
3870 #+BEGIN_SRC emacs-lisp :tangle no
3871 (use-package multiple-cursors
3872 :ensure multiple-cursors
3873 :defer t
3874 :commands (mc/remove-fake-cursors
3875 mc/create-fake-cursor-at-point
3876 mc/pop-state-from-overlay
3877 mc/maybe-multiple-cursors-mode)
3878 :defines (multiple-cursors-mode
3879 mc--read-char
3880 mc--read-quoted-char
3881 rectangular-region-mode)
3882 :bind (("C-S-c C-S-c" . mc/edit-lines)
3883 ("C->" . mc/mark-next-like-this)
3884 ("C-<" . mc/mark-previous-like-this)
3885 ("C-c C-<" . mc/mark-all-like-this)
3886 ("C-c i" . mc/insert-numbers))
3887 :config
3888 (progn
3889 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
3890 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
3891 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
3892 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
3893 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
3894 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
3895 #+END_SRC
3896 ** neotree
3897 [2014-08-27 Wed 17:15]
3898 A emacs tree plugin
3899 #+BEGIN_SRC emacs-lisp
3900 (use-package neotree
3901 :ensure neotree
3902 :defer t
3903 :bind (("<f8>" . neotree-toggle))
3904 :commands (neotree-find
3905 neotree-toggle
3906 neotree)
3907 :config
3908 (progn
3909 (bind-key "^" 'neotree-select-up-node neotree-mode-map)
3910 (setq neo-smart-open t)))
3911
3912 #+END_SRC
3913 ** notmuch
3914 [2016-10-24 Mon 18:18]
3915 Nice email search and interface
3916 #+BEGIN_SRC emacs-lisp
3917 (use-package notmuch
3918 :ensure t
3919 :commands (notmuch)
3920 :bind (("C-c n" . notmuch)
3921 :map notmuch-show-mode-map
3922 ("C-c C-c" . lld-notmuch-goto-message-in-gnus)
3923 :map notmuch-common-keymap
3924 ("G" . nil)
3925 ("s" . nil)
3926 )
3927 :init
3928 (progn
3929 (after 'notmuch
3930 (jj-init-theme)))
3931 :config
3932 (progn
3933 (setq notmuch-search-oldest-first nil)
3934
3935 (setq smtpmail-default-smtp-server "localhost")
3936
3937 (setq notmuch-search-oldest-first nil)
3938 (setq notmuch-search-result-format
3939 '(("date" . "%12s ")
3940 ("count" . "%7s ")
3941 ("authors" . "%-30s ")
3942 ("subject" . "%s ")
3943 ("tags" . "(%s)")
3944 ))
3945 (setq notmuch-hello-thousands-separator ".")
3946 (setq notmuch-tree-show-out t)
3947 (setq notmuch-always-prompt-for-sender t)
3948 (setq notmuch-crypto-process-mime t)
3949 (setq notmuch-fcc-dirs
3950 (quote
3951 ((".*@nsb-software.de" . "nsb/.Sent")
3952 ("da-manager@debian.org" . "ganneff/.Sentmail.DAM")
3953 (".*" . "ganneff/.Sentmail"))))
3954
3955 (setq notmuch-message-headers (quote ("Subject"
3956 "To"
3957 "Cc"
3958 "Bcc"
3959 "Date"
3960 "^Followup-To"
3961 "Mail-Followup-To"
3962 "Reply-To"
3963 "^Organization"
3964 "^Summary"
3965 "^Keywords"
3966 "^Posted-To"
3967 "^Mail-Copies-To"
3968 "^Apparently-To"
3969 "^X-Gnus-Warning"
3970 "^Resent-From"
3971 "^X-Spam-Status"
3972 "^X-Sent"
3973 "^X-Mailer"
3974 "^X-Newsreader"
3975 "^X-User-Agent"
3976 "^User-Agent" )))
3977
3978 (setq notmuch-show-all-tags-list nil)
3979 (setq notmuch-show-mark-read-tags (list "-unread" "-inbox"))
3980
3981 (setq notmuch-saved-searches '(
3982 ( :name "Nagios" :query "from:nagios@ AND tag:unread")
3983 ( :name "Debian BTS" :query "from:@bugs.debian.org AND tag:unread")
3984 ( :name "FTPMaster" :query "from:ftpmaster@ftp-master.debian.org AND tag:unread")
3985 ( :name "Mirror logs" :query "(from:archvsync@* OR from:mirror+arrakis@*) AND tag:mirrors AND tag:logs AND tag:unread")
3986 ( :name "Cron" :query "from:cron@ AND tag:unread")
3987 ( :name "List Admin" :query "subject:moderator request AND tag:unread")
3988 (: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)")
3989 ( :name "Inbox NSB" :query "(tag:inbox AND tag:nsb) AND NOT (tag:ganeti OR tag:lists/ganeti)")
3990 ( :name "Inbox All" :query "tag:inbox")
3991 (:key "n" :name "New Mail" :query "tag:new" )
3992 (:key "u" :name "Unread All" :query "tag:unread")
3993 ( :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)")
3994 ( :name "Unread Ganneff" :query "tag:unread AND tag:ganneff AND NOT ( \
3995 ( from:gitlab@salsa.debian.org AND subject:dak ) OR \
3996 ( ( tag:planet OR tag:kommerz OR from:cron@ OR from:archvsync@* OR \
3997 from:ftpmaster@ftp-master.debian.org OR from:nagios@ OR from:@bugs.debian.org \
3998 OR tag:lists/* OR from:support@hetzner.com) )")
3999 (:key "f" :name "Flagged" :query "tag:flagged")
4000 (:key "s" :name "Sent Ganneff" :query "tag:sent AND tag:ganneff OR tag:sent AND ( from:ganneff.de OR from:debian.org )")
4001 ( :name "Sent NSB" :query "tag:sent AND tag:nsb OR tag:sent AND from:nsb-software.de")
4002 ( :name "Sent DAM" :query "folder:ganneff/.Sentmail.DAM")
4003 (:key "g" :name "NSB GF" :query "tag:nsb AND tag:gf AND tag:unread")
4004 (:key "f" :name "Important" :query "tag:important")
4005 (:key "t" :name "TODO" :query "tag:todo")
4006 (:key "k" :name "Kommerz" :query "tag:kommerz AND tag:unread")
4007 (:key "d" :name "DA-Manager" :query "to:da-manager@debian.org AND (tag:todo OR tag:unread)")
4008 ( :name "Planet Debian" :query "to:planet@debian.org AND tag:unread")
4009 ( :name "Kommerz" :query "tag:Kommerz AND (tag:unread OR tag:inbox OR tag:flagged)" :sort-order oldest-first)
4010 ( :name "VH Unread" :query "(tag:unread OR tag:inbox) \
4011 AND ((from:nguyen@nsb-software.de OR to:nguyen@nsb-software.de \
4012 OR from:info@nsb-software.de OR to:info@nsb-software.de \
4013 OR from:van-hien.nguyen@dlh.de OR to:van-hien.nguyen@dlh.de \
4014 OR from:van-hien.nguyen.sp@dlh.de OR to:van-hien.nguyen.sp@dlh.de) \
4015 AND (tag:sent OR tag:sentmail OR tag:to-me))")
4016 ( :name "VH All" :query "(from:nguyen@nsb-software.de OR to:nguyen@nsb-software.de \
4017 OR from:info@nsb-software.de OR to:info@nsb-software.de \
4018 OR from:van-hien.nguyen@dlh.de OR to:van-hien.nguyen@dlh.de \
4019 OR from:van-hien.nguyen.sp@dlh.de OR to:van-hien.nguyen.sp@dlh.de) \
4020 AND (tag:sent OR tag:sentmail OR tag:to-me)")
4021 ( :name "D-Devel-Announce" :query "tag:lists/debian-devel-announce and tag:unread")
4022 ( :name "D-Devel" :query "tag:lists/debian-devel and tag:unread")
4023 ( :name "D-Project" :query "tag:lists/debian-project and tag:unread")
4024 ( :name "D-Private" :query "tag:lists/debian-private and tag:unread")
4025 ( :name "D-Vote" :query "tag:lists/debian-vote and tag:unread")
4026 ( :name "O-Staff" :query "tag:lists/oftc-staff and tag:unread")
4027 ( :name "O-Noc" :query "tag:lists/oftc-noc and tag:unread")
4028 ( :name "LugFD" :query "tag:lists/lugfd and tag:unread")
4029 ( :name "Gitlab Dak" :query "from:gitlab@salsa.debian.org AND subject:dak and tag:unread")
4030 ( :name "TODO" :query "tag:TODO")
4031 (:key "2" :name "Unread 2weeks" :query "date:2weeks...today AND tag:unread")
4032 ( :name "Dienstpläne" :query "date:4weeks...today AND tag:dienstplan")
4033 (:key "m" :name "To me" :query "tag:to-me")
4034 (:key "l" :name "Lists" :query "tag:lists AND tag:unread")
4035 ( :name "Hetzner Support" :query "from:support@hetzner.com AND tag:unread")
4036 ( :name "Ganeti" :query "(tag:ganeti OR tag:lists/ganeti) AND tag:unread")
4037 ( :name "MIA" :query "tag:mia AND tag:unread")
4038 ( :name "SPAM" :query "folder:ganneff/.SPAM AND tag:spam")
4039 ( :name "Drafts" :query "tag:draft")
4040 ; (:key "a" :name "all mail" :query "*")
4041 ))
4042
4043 (setq notmuch-search-line-faces
4044 (quote
4045 (("deleted" :foreground "tomato")
4046 ("unread" :weight bold)
4047 ("flagged" :foreground "wheat"))))
4048
4049 (setq notmuch-show-insert-text/plain-hook
4050 (quote
4051 (notmuch-wash-convert-inline-patch-to-part notmuch-wash-tidy-citations
4052 notmuch-wash-elide-blank-lines
4053 notmuch-wash-excerpt-citations
4054 )))
4055
4056 (setq notmuch-print-mechanism 'notmuch-print-muttprint/evince)
4057 (setq notmuch-tagging-keys '(("a" notmuch-archive-tags "Archive")
4058 ("u" notmuch-show-mark-read-tags "Mark read")
4059 ("f" ("+flagged") "Flag")
4060 ("s" ("+spam" "-inbox" "-unread" "-learnham" "-moveham") "Mark as spam")
4061 ("d" ("+deleted" "-inbox" "-unread") "Delete")))
4062
4063 (defun jj-forward (prefix)
4064 (interactive "P")
4065 (let ((message-forward-as-mime nil))
4066 (notmuch-show-forward-open-messages prefix)))
4067 (define-key notmuch-show-mode-map "F" 'jj-forward)
4068 (define-key notmuch-show-mode-map "f" 'notmuch-show-forward-message)
4069
4070 ; Toggle deleted tag on a message in search/show
4071 (define-key notmuch-search-mode-map "d"
4072 (lambda (N)
4073 "toggle deleted tag for message"
4074 (interactive "p")
4075 (setq num 0)
4076 (while (< num N)
4077 (setq num (1+ num))
4078 (if (member "deleted" (notmuch-search-get-tags))
4079 (notmuch-search-tag (list "-deleted"))
4080 (notmuch-search-tag (list "+deleted" "-unread" "-inbox")))
4081 (forward-line))))
4082 (define-key notmuch-show-mode-map "d"
4083 (lambda ()
4084 "toggle deleted tag for message"
4085 (interactive "p")
4086 (if (member "deleted" (notmuch-show-get-tags))
4087 (notmuch-show-tag (list "-deleted"))
4088 (notmuch-show-tag (list "+deleted" "-unread" "-inbox")))
4089 (notmuch-show-next-open-message t)))
4090
4091 ; Toggle spam tag on a message in search/show
4092 (define-key notmuch-search-mode-map "s"
4093 (lambda (N)
4094 "toggle spam tag for message"
4095 (interactive "p")
4096 (setq num 0)
4097 (while (< num N)
4098 (setq num (1+ num))
4099 (if (member "spam" (notmuch-search-get-tags))
4100 (notmuch-search-tag (list "-spam" "+learnham" "+moveham"))
4101 (notmuch-search-tag (list "+spam" "-unread" "-inbox")))
4102 (forward-line))))
4103 (define-key notmuch-show-mode-map "s"
4104 (lambda ()
4105 "toggle spam tag for message"
4106 (interactive)
4107 (if (member "spam" (notmuch-show-get-tags))
4108 (notmuch-show-tag (list "-spam" "+learnham" "+moveham"))
4109 (notmuch-show-tag (list "+spam" "-unread" "-inbox")))
4110 (notmuch-show-next-open-message t)))
4111 (define-key notmuch-tree-mode-map "s"
4112 (lambda (N)
4113 "toggle spam tag for message"
4114 (interactive "p")
4115 (setq num 0)
4116 (while (< num N)
4117 (setq num (1+ num))
4118 (if (member "spam" (notmuch-tree-get-tags))
4119 (notmuch-tree-tag (list "-spam" "+learnham" "+moveham"))
4120 (notmuch-tree-tag (list "+spam" "-unread" "-inbox")))
4121 (forward-line))))
4122
4123 ; Toggle learnham tag on a message in search/show
4124 (define-key notmuch-search-mode-map "h"
4125 (lambda (N)
4126 "toggle learnham tag for message"
4127 (interactive "p")
4128 (setq num 0)
4129 (while (< num N)
4130 (setq num (1+ num))
4131 (if (member "learnham" (notmuch-search-get-tags))
4132 (notmuch-search-tag (list "-learnham"))
4133 (notmuch-search-tag (list "+learnham" "-spam" "+moveham")))
4134 (forward-line))))
4135 (define-key notmuch-show-mode-map "h"
4136 (lambda ()
4137 "toggle learnham tag for message"
4138 (interactive)
4139 (if (member "learnham" (notmuch-show-get-tags))
4140 (notmuch-show-tag (list "-learnham"))
4141 (notmuch-show-tag (list "+learnham" "-spam" "+moveham")))
4142 (notmuch-show-next-open-message t)))
4143