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