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