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