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