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