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