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