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