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