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