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