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