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