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