Lotsa changes
[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
1297 (use-package dired-single
1298 :ensure dired-single
1299 :init
1300 (progn
1301 (bind-key "<return>" 'dired-single-buffer dired-mode-map)
1302 (bind-key "<mouse-1>" 'dired-single-buffer-mouse dired-mode-map)
1303 (bind-key "^"
1304 (function
1305 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
1306
1307 (use-package wdired
1308 :ensure wdired
1309 :init
1310 (progn
1311 (setq wdired-allow-to-change-permissions t)
1312 (bind-key "r" 'wdired-change-to-wdired-mode dired-mode-map)))
1313
1314 (use-package gnus-dired
1315 :init
1316 (progn
1317 (require 'gnus-dired)
1318 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
1319 (bind-key "a" 'gnus-dired-attach dired-mode-map)))
1320
1321 (bind-key "M-!" 'async-shell-command dired-mode-map)
1322 (unbind-key "M-s f" dired-mode-map)
1323
1324 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1325 "Make sure to remove \"Omit\" from the modeline."
1326 (diminish 'dired-omit-mode) dired-mode-map)
1327
1328 ;; Omit files that Git would ignore
1329 (defun dired-omit-regexp ()
1330 (let ((file (expand-file-name ".git"))
1331 parent-dir)
1332 (while (and (not (file-exists-p file))
1333 (progn
1334 (setq parent-dir
1335 (file-name-directory
1336 (directory-file-name
1337 (file-name-directory file))))
1338 ;; Give up if we are already at the root dir.
1339 (not (string= (file-name-directory file)
1340 parent-dir))))
1341 ;; Move up to the parent dir and try again.
1342 (setq file (expand-file-name ".git" parent-dir)))
1343 ;; If we found a change log in a parent, use that.
1344 (if (file-exists-p file)
1345 (let ((regexp (funcall dired-omit-regexp-orig))
1346 (omitted-files
1347 (shell-command-to-string "git clean -d -x -n")))
1348 (if (= 0 (length omitted-files))
1349 regexp
1350 (concat
1351 regexp
1352 (if (> (length regexp) 0)
1353 "\\|" "")
1354 "\\("
1355 (mapconcat
1356 #'(lambda (str)
1357 (concat
1358 "^"
1359 (regexp-quote
1360 (substring str 13
1361 (if (= ?/ (aref str (1- (length str))))
1362 (1- (length str))
1363 nil)))
1364 "$"))
1365 (split-string omitted-files "\n" t)
1366 "\\|")
1367 "\\)")))
1368 (funcall dired-omit-regexp-orig))))))
1369
1370 (add-hook 'dired-mode-hook 'dired-package-initialize)
1371
1372 (defun dired-double-jump (first-dir second-dir)
1373 (interactive
1374 (list (read-directory-name "First directory: "
1375 (expand-file-name "~")
1376 nil nil "dl/")
1377 (read-directory-name "Second directory: "
1378 (expand-file-name "~")
1379 nil nil "Archives/")))
1380 (dired first-dir)
1381 (dired-other-window second-dir))
1382 (bind-key "C-c J" 'dired-double-jump)))
1383
1384 #+END_SRC
1385
1386 ** easypg
1387 EasyPG is a GnuPG interface for Emacs.
1388 #+BEGIN_SRC emacs-lisp :tangle yes
1389 (require 'epa-file)
1390 (epa-file-enable)
1391 #+END_SRC
1392
1393 I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1394 #+BEGIN_SRC emacs-lisp :tangle yes
1395 (defadvice epg--start (around advice-epg-disable-agent disable)
1396 "Don't allow epg--start to use gpg-agent in plain text
1397 terminals."
1398 (if (display-graphic-p)
1399 ad-do-it
1400 (let ((agent (getenv "GPG_AGENT_INFO")))
1401 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
1402 ad-do-it
1403 (setenv "GPG_AGENT_INFO" agent))))
1404 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
1405 (ad-activate 'epg--start)
1406 #+END_SRC
1407 ** ediff
1408 [2013-04-21 So 20:36]
1409 ediff - don't start another frame
1410 #+BEGIN_SRC elisp
1411 (use-package ediff
1412 :pre-init
1413 (progn
1414 (defvar ctl-period-equals-map)
1415 (define-prefix-command 'ctl-period-equals-map)
1416 (bind-key "C-. =" 'ctl-period-equals-map)
1417
1418 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
1419
1420 :bind (("C-. = b" . ediff-buffers)
1421 ("C-. = B" . ediff-buffers3)
1422 ("C-. = =" . ediff-files)
1423 ("C-. = f" . ediff-files)
1424 ("C-. = F" . ediff-files3)
1425 ("C-. = r" . ediff-revision)
1426 ("C-. = p" . ediff-patch-file)
1427 ("C-. = P" . ediff-patch-buffer)
1428 ("C-. = l" . ediff-regions-linewise)
1429 ("C-. = w" . ediff-regions-wordwise)))
1430 #+END_SRC
1431 ** emms
1432 EMMS is the Emacs Multimedia System.
1433 #+BEGIN_SRC emacs-lisp :tangle no
1434 (require 'emms-source-file)
1435 (require 'emms-source-playlist)
1436 (require 'emms-info)
1437 (require 'emms-cache)
1438 (require 'emms-playlist-mode)
1439 (require 'emms-playing-time)
1440 (require 'emms-player-mpd)
1441 (require 'emms-playlist-sort)
1442 (require 'emms-mark)
1443 (require 'emms-browser)
1444 (require 'emms-lyrics)
1445 (require 'emms-last-played)
1446 (require 'emms-score)
1447 (require 'emms-tag-editor)
1448 (require 'emms-history)
1449 (require 'emms-i18n)
1450
1451 (setq emms-playlist-default-major-mode 'emms-playlist-mode)
1452 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
1453 (emms-playing-time 1)
1454 (emms-lyrics 1)
1455 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
1456 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
1457 (emms-score 1)
1458 (when (fboundp 'emms-cache) ; work around compiler warning
1459 (emms-cache 1))
1460 (setq emms-score-default-score 3)
1461
1462 (defun emms-mpd-init ()
1463 "Connect Emms to mpd."
1464 (interactive)
1465 (emms-player-mpd-connect))
1466
1467 ;; players
1468 (require 'emms-player-mpd)
1469 (setq emms-player-mpd-server-name "localhost")
1470 (setq emms-player-mpd-server-port "6600")
1471 (add-to-list 'emms-info-functions 'emms-info-mpd)
1472 (add-to-list 'emms-player-list 'emms-player-mpd)
1473 (setq emms-volume-change-function 'emms-volume-mpd-change)
1474 (setq emms-player-mpd-sync-playlist t)
1475
1476 (setq emms-source-file-default-directory "/var/lib/mpd/music")
1477 (setq emms-player-mpd-music-directory "/var/lib/mpd/music")
1478 (setq emms-info-auto-update t)
1479 (setq emms-lyrics-scroll-p t)
1480 (setq emms-lyrics-display-on-minibuffer t)
1481 (setq emms-lyrics-display-on-modeline nil)
1482 (setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
1483
1484 (setq emms-last-played-format-alist
1485 '(((emms-last-played-seconds-today) . "%H:%M")
1486 (604800 . "%a %H:%M") ; this week
1487 ((emms-last-played-seconds-month) . "%d.%m.%Y")
1488 ((emms-last-played-seconds-year) . "%d.%m.%Y")
1489 (t . "Never played")))
1490
1491 ;; Playlist format
1492 (defun my-describe (track)
1493 (let* ((empty "...")
1494 (name (emms-track-name track))
1495 (type (emms-track-type track))
1496 (short-name (file-name-nondirectory name))
1497 (play-count (or (emms-track-get track 'play-count) 0))
1498 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
1499 (artist (or (emms-track-get track 'info-artist) empty))
1500 (year (emms-track-get track 'info-year))
1501 (playing-time (or (emms-track-get track 'info-playing-time) 0))
1502 (min (/ playing-time 60))
1503 (sec (% playing-time 60))
1504 (album (or (emms-track-get track 'info-album) empty))
1505 (tracknumber (emms-track-get track 'info-tracknumber))
1506 (short-name (file-name-sans-extension
1507 (file-name-nondirectory name)))
1508 (title (or (emms-track-get track 'info-title) short-name))
1509 (rating (emms-score-get-score name))
1510 (rate-char ?☭)
1511 )
1512 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
1513 (emms-last-played-format-date last-played)
1514 artist
1515 year
1516 album
1517 (if (and tracknumber ; tracknumber
1518 (not (zerop (string-to-number tracknumber))))
1519 (format "%02d" (string-to-number tracknumber))
1520 "")
1521 title
1522 play-count
1523 (make-string rating rate-char)))
1524 )
1525
1526 (setq emms-track-description-function 'my-describe)
1527
1528 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
1529 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
1530 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
1531 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
1532 (global-set-key (kbd "H-<f9> x") 'emms-start)
1533 (global-set-key (kbd "H-<f9> v") 'emms-stop)
1534 (global-set-key (kbd "H-<f9> n") 'emms-next)
1535 (global-set-key (kbd "H-<f9> p") 'emms-previous)
1536 (global-set-key (kbd "H-<f9> o") 'emms-show)
1537 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
1538 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
1539 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
1540 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
1541 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
1542
1543 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
1544 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
1545 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
1546 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
1547
1548 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
1549 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
1550 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
1551 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
1552
1553 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
1554 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
1555 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
1556 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
1557
1558 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
1559 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
1560 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
1561 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
1562 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
1563 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
1564
1565 (define-key emms-playlist-mode-map "x" 'emms-start)
1566 (define-key emms-playlist-mode-map "v" 'emms-stop)
1567 (define-key emms-playlist-mode-map "n" 'emms-next)
1568 (define-key emms-playlist-mode-map "p" 'emms-previous)
1569
1570 (setq emms-playlist-buffer-name "*EMMS Playlist*"
1571 emms-playlist-mode-open-playlists t)
1572
1573 ;; Faces
1574 (if (window-system)
1575 ((lambda ()
1576 (set-face-attribute
1577 'emms-browser-artist-face nil
1578 :family "Arno Pro")
1579 )
1580 ))
1581
1582 (setq emms-player-mpd-supported-regexp
1583 (or (emms-player-mpd-get-supported-regexp)
1584 (concat "\\`http://\\|"
1585 (emms-player-simple-regexp
1586 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
1587 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
1588
1589 #+END_SRC
1590 ** ethan-wspace
1591 [2014-06-01 Sun 15:00]
1592 Proper whitespace handling
1593 #+BEGIN_SRC emacs-lisp :tangle yes
1594 (use-package ethan-wspace
1595 :ensure ethan-wspace
1596 :diminish (ethan-wspace-mode . "ew")
1597 :init
1598 (global-ethan-wspace-mode 1))
1599
1600
1601
1602 #+END_SRC
1603 ** expand-region
1604 [2014-06-01 Sun 15:16]
1605 #+BEGIN_SRC emacs-lisp :tangle yes
1606 (use-package expand-region
1607 :ensure expand-region
1608 :bind ("C-M-+" . er/expand-region))
1609 #+END_SRC
1610 ** filladapt
1611 [2013-05-02 Thu 00:04]
1612 #+BEGIN_SRC emacs-lisp :tangle yes
1613 (use-package filladapt
1614 :diminish filladapt-mode
1615 :init
1616 (setq-default filladapt-mode t))
1617 #+END_SRC
1618 ** flycheck
1619 [2013-04-28 So 22:21]
1620 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
1621 As the one time I tried Flymake i wasn't happy, thats easy to
1622 understand for me.
1623 #+BEGIN_SRC emacs-lisp :tangle yes
1624 (use-package flycheck
1625 :ensure flycheck
1626 :bind (("M-n" . next-error)
1627 ("M-p" . previous-error))
1628 :init
1629 (progn
1630 (add-hook 'find-file-hook
1631 (lambda ()
1632 (when (not (equal 'emacs-lisp-mode major-mode))
1633 (flycheck-mode)))))
1634 :config
1635 (progn
1636 (use-package flycheck-color-mode-line
1637 :ensure flycheck-color-mode-line)
1638 (setq flycheck-highlighting-mode nil)
1639 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
1640 ))
1641 #+END_SRC
1642 ** font-lock
1643 Obviously emacs can do syntax hilighting. For more things than you ever
1644 heard about.
1645 And I want to have it everywhere.
1646 #+BEGIN_SRC emacs-lisp :tangle yes
1647 (use-package font-lock
1648 :init
1649 (progn
1650 (global-font-lock-mode 1)
1651 (setq font-lock-maximum-decoration t)))
1652 #+END_SRC
1653 ** git commit mode
1654 #+BEGIN_SRC emacs-lisp :tangle yes
1655 (use-package git-commit-mode
1656 :ensure git-commit-mode
1657 :commands git-commit-mode
1658 :mode ("COMMIT_EDITMSG" . git-commit-mode))
1659 #+END_SRC
1660
1661 ** git rebase mode
1662 #+BEGIN_SRC emacs-lisp :tangle yes
1663 (use-package git-rebase-mode
1664 :ensure git-rebase-mode
1665 :commands git-rebase-mode
1666 :mode ("git-rebase-todo" . git-rebase-mode))
1667 #+END_SRC
1668 ** git-gutter+
1669 [2014-05-21 Wed 22:56]
1670 #+BEGIN_SRC emacs-lisp :tangle yes
1671 (use-package git-gutter+
1672 :ensure git-gutter+
1673 :diminish git-gutter+-mode
1674 :bind (("C-x n" . git-gutter+-next-hunk)
1675 ("C-x p" . git-gutter+-previous-hunk)
1676 ("C-x v =" . git-gutter+-show-hunk)
1677 ("C-x r" . git-gutter+-revert-hunks)
1678 ("C-x s" . git-gutter+-stage-hunks)
1679 ("C-x c" . git-gutter+-commit)
1680 )
1681 :init
1682 (progn
1683 (setq git-gutter+-disabled-modes '(org-mode)))
1684 :config
1685 (progn
1686 (use-package git-gutter-fringe+
1687 :ensure git-gutter-fringe+
1688 :config
1689 (progn
1690 (setq git-gutter-fr+-side 'right-fringe)
1691 ;(git-gutter-fr+-minimal)
1692 ))
1693 (global-git-gutter+-mode 1)))
1694
1695 #+END_SRC
1696 ** gnus
1697 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
1698 what I want every emacs to know.
1699 #+BEGIN_SRC emacs-lisp :tangle yes
1700 (bind-key "C-c g" 'gnus) ; Start gnus with M-n
1701 (after 'gnus
1702 (jj-init-theme)
1703 )
1704 #+END_SRC
1705
1706 ** highlight mode
1707 [2014-05-21 Wed 23:51]
1708 #+BEGIN_SRC emacs-lisp :tangle yes
1709 (use-package hi-lock
1710 :bind (("M-o l" . highlight-lines-matching-regexp)
1711 ("M-o r" . highlight-regexp)
1712 ("M-o w" . highlight-phrase)))
1713
1714 ;;;_ , hilit-chg
1715
1716 (use-package hilit-chg
1717 :bind ("M-o C" . highlight-changes-mode))
1718
1719 #+END_SRC
1720 ** hippie-exp
1721 Crazy way of completion. It looks at the word before point and then
1722 tries to expand it in various ways.
1723 #+BEGIN_SRC emacs-lisp :tangle yes
1724 (use-package hippie-exp
1725 :defer t
1726 :bind ("M-/" . hippie-expand)
1727 :init
1728 (progn
1729 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
1730 try-expand-dabbrev-all-buffers
1731 try-expand-dabbrev-from-kill
1732 try-complete-file-name-partially
1733 try-complete-file-name
1734 try-expand-all-abbrevs try-expand-list
1735 try-expand-line
1736 try-complete-lisp-symbol-partially
1737 try-complete-lisp-symbol))))
1738 #+END_SRC
1739 ** html-helper
1740 Instead of default /html-mode/ I use /html-helper-mode/.
1741 #+BEGIN_SRC emacs-lisp :tangle yes
1742 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
1743 (add-auto-mode 'html-helper-mode "\\.html$")
1744 (add-auto-mode 'html-helper-mode "\\.asp$")
1745 (add-auto-mode 'html-helper-mode "\\.phtml$")
1746 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
1747 (defalias 'html-mode 'html-helper-mode)
1748 #+END_SRC
1749
1750 ** ibuffer
1751 [2014-05-21 Wed 23:54]
1752 #+BEGIN_SRC emacs-lisp :tangle yes
1753 (use-package ibuffer
1754 :defer t
1755 :bind (("C-h h" . ibuffer)
1756 ("C-x C-b" . ibuffer)
1757 ("<XF86WebCam>" . ibuffer)
1758 )
1759 :commands ibuffer
1760 :init
1761 (progn
1762 (defvar my-ibufffer-separator " • ")
1763 (setq ibuffer-filter-group-name-face 'variable-pitch
1764 ibuffer-use-header-line t
1765 ibuffer-old-time 12)
1766 (use-package ibuffer-vc
1767 :ensure t
1768 :commands
1769 (ibuffer-vc-set-filter-groups-by-vc-root
1770 ibuffer-vc-generate-filter-groups-by-vc-root))
1771 (use-package ibuffer-tramp
1772 :ensure t
1773 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
1774 ibuffer-tramp-set-filter-groups-by-tramp-connection))
1775 ;; Switching to ibuffer puts the cursor on the most recent buffer
1776 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
1777 "Open ibuffer with cursor pointed to most recent buffer name"
1778 (let ((recent-buffer-name (buffer-name)))
1779 ad-do-it
1780 (ibuffer-update nil t)
1781 (unless (string= recent-buffer-name "*Ibuffer*")
1782 (ibuffer-jump-to-buffer recent-buffer-name)))))
1783 :config
1784 (progn
1785 (unbind-key "M-o" ibuffer-mode-map)
1786 (bind-key "s" 'isearch-forward-regexp ibuffer-mode-map)
1787 (bind-key "." 'ibuffer-invert-sorting ibuffer-mode-map)
1788
1789 (defun ibuffer-magit-status ()
1790 (interactive)
1791 (--when-let (get-buffer "*Ibuffer*")
1792 (with-current-buffer it
1793 (let* ((selected-buffer (ibuffer-current-buffer))
1794 (buffer-path (with-current-buffer
1795 selected-buffer
1796 (or (buffer-file-name)
1797 list-buffers-directory
1798 default-directory)))
1799 (default-directory
1800 (if (file-regular-p buffer-path)
1801 (file-name-directory buffer-path)
1802 buffer-path)))
1803 (magit-status default-directory)))))
1804 (bind-key "i" 'ibuffer-magit-status ibuffer-mode-map)
1805 (bind-key "G" 'ibuffer-magit-status ibuffer-mode-map)
1806
1807 (setq ibuffer-directory-abbrev-alist
1808 (-uniq
1809 (-flatten
1810 (--map
1811 (list
1812 (cons (f-slash (f-expand (cdr it))) (concat (car it) my-ibufffer-separator))
1813 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
1814
1815 '(
1816 ("dak" . "/develop/dak/")
1817 ("org" . "~/org/")
1818 ("config" . "~/.emacs.d/config/")
1819 ("tmp" . "~/tmp/")
1820 ("systmp" . "/tmp/")
1821 ("puppet" . "~/git/puppet")
1822 ("git" . "~/git/")
1823 )))))
1824
1825 (use-package ibuffer-git
1826 :ensure t)
1827 (use-package ibuffer-vc
1828 :ensure t)
1829
1830 (define-ibuffer-column size-h
1831 (:name "Size" :inline t)
1832 (cond
1833 ((> (buffer-size) 1000)
1834 (format "%7.1fk" (/ (buffer-size) 1000.0)))
1835 ((> (buffer-size) 1000000)
1836 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
1837 (t
1838 (format "%8d" (buffer-size)))))
1839
1840 (require 'ibuf-ext)
1841 (define-ibuffer-filter filename2
1842 "Toggle current view to buffers with filename matching QUALIFIER."
1843 (:description "filename2"
1844 :reader (read-from-minibuffer "Filter by filename (regexp): "))
1845 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
1846 (ibuffer-awhen (with-current-buffer buf
1847 (or buffer-file-name
1848 default-directory))
1849 (string-match qualifier it)))
1850
1851 (defvar ibuffer-magit-filter-groups nil)
1852 (defun ibuffer-magit-define-filter-groups ()
1853 (when (and (not ibuffer-magit-filter-groups)
1854 (boundp 'magit-repo-dirs))
1855 (setq ibuffer-magit-filter-groups
1856 (--map (list
1857 (concat "git:: "
1858 (file-name-nondirectory (directory-file-name it)))
1859 `(filename2 . ,it))
1860 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
1861
1862 (defun ibuffer-set-filter-groups-by-root ()
1863 (interactive)
1864 ;; (ibuffer-projectile-define-filter-groups)
1865 ;; (ibuffer-magit-define-filter-groups)
1866 (setq ibuffer-filter-groups
1867 (-concat
1868 ;; ibuffer-projectile-filter-groups
1869 ibuffer-magit-filter-groups
1870
1871 '(("MORE"
1872 (or (mode . magit-log-edit-mode)
1873 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
1874 (name . "^\\*Pymacs\\*$")
1875 (name . "^\\*helm.*\\*")
1876 (name . "^\\*Compile-log\\*$")
1877 (name . "^\\*Ido Completions\\*$")
1878 (name . "^\\*magit-\\(process\\)\\*$")
1879 (name . "^ "))))
1880 '(("EMACS"
1881 (or
1882 (name . "^\\*scratch")
1883 (name . "^\\*Messages")
1884 (name . "^\\*Help")
1885 )))
1886 (ibuffer-vc-generate-filter-groups-by-vc-root)
1887 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
1888
1889 (defun toggle-ibuffer-filter-groups ()
1890 "DOCSTRING"
1891 (interactive)
1892 (let ((ibuf (get-buffer "*Ibuffer*")))
1893 (when ibuf
1894 (with-current-buffer ibuf
1895 (let ((selected-buffer (ibuffer-current-buffer)))
1896 (if (not ibuffer-filter-groups)
1897 (ibuffer-set-filter-groups-by-root)
1898 (setq ibuffer-filter-groups nil))
1899 (pop-to-buffer ibuf)
1900 (ibuffer-update nil t)
1901 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
1902
1903 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
1904
1905 (setq ibuffer-default-sorting-mode 'recency
1906 ibuffer-eliding-string "…"
1907 ibuffer-compile-formats t
1908 ibuffer-git-column-length 6
1909 ibuffer-show-empty-filter-groups nil
1910 ibuffer-default-directory "~/"
1911 )
1912 (setq ibuffer-formats '((mark vc-status-mini
1913 " "
1914 (git-status 8 8 :left)
1915 " "
1916 read-only modified
1917 " "
1918 (name 18 18 :left :elide)
1919 " "
1920 (size-h 9 -1 :right)
1921 " "
1922 (mode 16 16 :left :elide)
1923 " " filename-and-process)
1924 (mark " "
1925 (git-status 8 8 :left)
1926 " "
1927 (name 16 -1)
1928 " " filename)
1929 ))
1930
1931 (setq ibuffer-saved-filter-groups
1932 (quote (("flat")
1933 ("default"
1934 ("dired" (mode . dired-mode))
1935 ("perl" (mode . cperl-mode))
1936 ("puppet" (or
1937 (mode . puppet-mode)
1938 (mode . yaml-mode)))
1939 ("ruby" (mode . ruby-mode))
1940 ("emacs" (or
1941 (name . "^\\*scratch\\*$")
1942 (name . "^\\*Compile-log\\*$")
1943 (name . "^\\*Completions\\*$")
1944 (name . "^\\*Messages\\*$")
1945 (name . "^\\*Backtrace\\*$")
1946 (name . "^\\*Packages*\\*$")
1947 (name . "^\\*Help*\\*$")
1948 ))
1949 ("gnus" (or
1950 (mode . message-mode)
1951 (mode . bbdb-mode)
1952 (mode . mail-mode)
1953 (mode . gnus-group-mode)
1954 (mode . gnus-summary-mode)
1955 (mode . gnus-article-mode)
1956 (name . "^\\.bbdb$")
1957 (name . "^\\.newsrc-dribble")))
1958 ("org" (or
1959 (filename . ".*/org/.*")
1960 (mode . org-agenda-mode)
1961 (name . "^diary$")))
1962 ("other" (or
1963 (mode . magit-log-edit-mode)
1964 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
1965 ("categorized"
1966 ;; -------------------------------------------------
1967 ;; programming languages #1
1968 ("code" (or
1969 (mode . emacs-lisp-mode)
1970 (mode . python-mode)
1971 (mode . ruby-mode)
1972 (mode . coffee-mode)
1973 (mode . js-mode)
1974 (mode . js2-mode)
1975 (mode . actionscript-mode)
1976 (mode . java-mode)
1977 (mode . sh-mode)
1978 (mode . haskell-mode)
1979 (mode . html-mode)
1980 (mode . web-mode)
1981 (mode . haml-mode)
1982 (mode . nxml-mode)
1983 (mode . css-mode)))
1984 ;; -------------------------------------------------
1985 ;; configuration/data files
1986 ("conf" (or
1987 (mode . json-mode)
1988 (mode . yaml-mode)
1989 (mode . conf-mode)))
1990 ;; -------------------------------------------------
1991 ;; text/notetaking/org
1992 ("org agenda" (mode . org-agenda-mode))
1993 ("org" (or
1994 (mode . org-mode)
1995 (name . "^\\*Calendar\\*$")
1996 (name . "^diary$")))
1997 ("text misc" (or
1998 (mode . text-mode)
1999 (mode . rst-mode)
2000 (mode . markdown-mode)))
2001 ;; -------------------------------------------------
2002 ;; media
2003 ("media" (or
2004 (mode . image-mode)))
2005 ;; -------------------------------------------------
2006 ;; misc
2007 ("w3m" (mode . w3m-mode))
2008 ("scm" (or
2009 (mode . magit-status-mode)
2010 (mode . magit-log-mode)
2011 (mode . vc-annotate-mode)))
2012 ("dired" (mode . dired-mode))
2013 ("help" (or
2014 (mode . Info-mode)
2015 (mode . help-mode)
2016 (mode . Man-mode)
2017 (name . "^\\*Personal Keybindings\\*$")))
2018 ;; -------------------------------------------------
2019 ;; *buffer* buffers
2020 ("MORE" (or (mode . magit-log-edit-mode)
2021 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2022 (name . "^\\*Pymacs\\*$")
2023 (name . "^\\*Compile-log\\*$")
2024 (name . "^\\*Completions\\*$")
2025 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
2026 (name . "^ ")))
2027 ("*buffer*" (name . "\\*.*\\*"))))))
2028
2029 (add-hook 'ibuffer-mode-hook
2030 (lambda ()
2031 (ibuffer-auto-mode 1)
2032 (ibuffer-switch-to-saved-filter-groups "default")))
2033
2034 ;; Unless you turn this variable on you will be prompted every time
2035 ;; you want to delete a buffer, even unmodified ones, which is way
2036 ;; too cautious for most people. You’ll still be prompted for
2037 ;; confirmation when deleting modified buffers after the option has
2038 ;; been turned off.
2039 (setq ibuffer-expert t)
2040
2041 ))
2042 #+END_SRC
2043 ** icicles
2044 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
2045 ‘TAB’ completion is to typing things manually every time.”]]
2046 #+BEGIN_SRC emacs-lisp :tangle yes
2047 (use-package icicles
2048 :load-path "elisp/icicle/"
2049 :init
2050 (icy-mode 1))
2051 #+END_SRC
2052 ** icomplete
2053 Incremental mini-buffer completion preview: Type in the minibuffer,
2054 list of matching commands is echoed
2055 #+BEGIN_SRC emacs-lisp :tangle yes
2056 (icomplete-mode 99)
2057 #+END_SRC
2058 ** iedit
2059 [2014-05-26 Mon 22:49]
2060 #+BEGIN_SRC emacs-lisp :tangle yes
2061 (use-package iedit
2062 :ensure iedit
2063 :commands (iedit-mode)
2064 :defer t
2065 :bind (("C-;" . iedit-mode)
2066 ("C-," . iedit-mode-toggle-on-function))
2067 )
2068
2069 #+END_SRC
2070 ** info stuff
2071 [2014-05-20 Tue 23:35]
2072 #+BEGIN_SRC emacs-lisp :tangle yes
2073 (use-package info
2074 :bind ("C-h C-i" . info-lookup-symbol)
2075
2076 :config
2077 (progn
2078 ;; (defadvice info-setup (after load-info+ activate)
2079 ;; (use-package info+))
2080
2081 (defadvice Info-exit (after remove-info-window activate)
2082 "When info mode is quit, remove the window."
2083 (if (> (length (window-list)) 1)
2084 (delete-window)))))
2085
2086 (use-package info-look
2087 :commands info-lookup-add-help)
2088 #+END_SRC
2089 ** linum (line number)
2090 Various modes should have line numbers in front of each line.
2091
2092 But then there are some where it would just be deadly - like org-mode,
2093 gnus, so we have a list of modes where we don't want to see it.
2094 #+BEGIN_SRC emacs-lisp :tangle yes
2095 (use-package linum
2096 :diminish linum-mode
2097 :config
2098 (progn
2099 (setq linum-format "%3d ")
2100 (setq linum-mode-inhibit-modes-list '(org-mode
2101 eshell-mode
2102 shell-mode
2103 gnus-group-mode
2104 gnus-summary-mode
2105 gnus-article-mode))
2106
2107 (defadvice linum-on (around linum-on-inhibit-for-modes)
2108 "Stop the load of linum-mode for some major modes."
2109 (unless (member major-mode linum-mode-inhibit-modes-list)
2110 ad-do-it))
2111
2112 (ad-activate 'linum-on))
2113 :init
2114 (global-linum-mode 1))
2115 #+END_SRC
2116
2117 ** lisp editing stuff
2118 [2013-04-21 So 21:00]
2119 I'm not doing much of it, except for my emacs and gnus configs, but
2120 then I like it nice too...
2121 #+BEGIN_SRC emacs-lisp :tangle yes
2122 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
2123
2124 (defun remove-elc-on-save ()
2125 "If you're saving an elisp file, likely the .elc is no longer valid."
2126 (make-local-variable 'after-save-hook)
2127 (add-hook 'after-save-hook
2128 (lambda ()
2129 (if (file-exists-p (concat buffer-file-name "c"))
2130 (delete-file (concat buffer-file-name "c"))))))
2131
2132 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
2133 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
2134
2135 (use-package paredit
2136 :ensure paredit
2137 :diminish paredit-mode " π")
2138
2139 (setq lisp-coding-hook 'lisp-coding-defaults)
2140 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2141
2142 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2143 (add-hook 'emacs-lisp-mode-hook (lambda ()
2144 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2145
2146 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
2147
2148 (after "elisp-slime-nav"
2149 '(diminish 'elisp-slime-nav-mode))
2150 (after "rainbow-mode"
2151 '(diminish 'rainbow-mode))
2152 (after "eldoc"
2153 '(diminish 'eldoc-mode))
2154 #+END_SRC
2155
2156 ** magit
2157 [2013-04-21 So 20:48]
2158 magit is a mode for interacting with git.
2159 #+BEGIN_SRC emacs-lisp :tangle yes
2160 (use-package magit
2161 :ensure magit
2162 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
2163 magit-git-repo-p magit-list-repos)
2164 :defer t
2165 :bind (("C-x g" . magit-status)
2166 ("C-x G" . magit-status-with-prefix))
2167 :init
2168 (progn
2169 (setq magit-commit-signoff t
2170 magit-repo-dirs '("~/git"
2171 "/develop/vcs/"
2172 "/develop/Debian/"
2173 )
2174 magit-repo-dirs-depth 4
2175 magit-log-auto-more t)
2176 (use-package magit-blame
2177 :commands magit-blame-mode)
2178
2179 (add-hook 'magit-mode-hook 'hl-line-mode)
2180 (defun magit-status-with-prefix ()
2181 (interactive)
2182 (let ((current-prefix-arg '(4)))
2183 (call-interactively 'magit-status)))
2184 )
2185 :config
2186 (progn
2187 (setenv "GIT_PAGER" "")
2188
2189 (unbind-key "M-h" magit-mode-map)
2190 (unbind-key "M-s" magit-mode-map)
2191
2192 (add-hook 'magit-log-edit-mode-hook
2193 #'(lambda ()
2194 (set-fill-column 72)
2195 (flyspell-mode)))
2196
2197 (use-package magit-filenotify
2198 :ensure magit-filenotify
2199 :diminish (magit-filenotify-mode "MF")
2200 :commands (magit-filenotify-mode)
2201 :init
2202 (progn
2203 (add-hook 'magit-mode-hook 'magit-filenotify-mode))
2204 )
2205
2206 (use-package magit-svn
2207 :ensure magit-svn
2208 :commands (magit-svn-mode
2209 turn-on-magit-svn))
2210
2211 (use-package magit-find-file
2212 :ensure magit-find-file
2213 :defer t
2214 :init
2215 (progn
2216 (bind-key "C-x C-f" 'magit-find-file-completing-read magit-mode-map)))))
2217 #+END_SRC
2218 ** markdown-mode
2219 [2014-05-20 Tue 23:04]
2220 #+BEGIN_SRC emacs-lisp :tangle yes
2221 (use-package markdown-mode
2222 :mode (("\\.md\\'" . markdown-mode)
2223 ("\\.mdwn\\'" . markdown-mode))
2224 :defer t)
2225 #+END_SRC
2226 ** message
2227 #+BEGIN_SRC emacs-lisp :tangle yes
2228 (require 'message)
2229 (setq message-kill-buffer-on-exit t)
2230 #+END_SRC
2231 ** mingus
2232 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2233
2234 I want to access it from anywhere using =F6=.
2235 #+BEGIN_SRC emacs-lisp :tangle yes
2236 (use-package mingus-stays-home
2237 :bind ( "<f6>" . mingus)
2238 :defer t
2239 :config
2240 (progn
2241 (setq mingus-dired-add-keys t)
2242 (setq mingus-mode-always-modeline nil)
2243 (setq mingus-mode-line-show-elapsed-percentage nil)
2244 (setq mingus-mode-line-show-volume nil)
2245 (setq mingus-mpd-config-file "/etc/mpd.conf")
2246 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2247 (setq mingus-mpd-root "/share/music/")))
2248 #+END_SRC
2249
2250 ** miniedit
2251 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
2252 #+BEGIN_SRC emacs-lisp :tangle yes
2253 (use-package miniedit
2254 :ensure miniedit
2255 :config
2256 (progn
2257 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
2258 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
2259 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
2260 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
2261 ))
2262 #+END_SRC
2263
2264 ** mmm-mode
2265 [2013-05-21 Tue 23:39]
2266 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
2267 coexist in one buffer.
2268 #+BEGIN_SRC emacs-lisp :tangle yes
2269 (use-package mmm-auto
2270 :ensure mmm-mode
2271 :init
2272 (progn
2273 (setq mmm-global-mode 'buffers-with-submode-classes)
2274 (setq mmm-submode-decoration-level 2)
2275 (eval-after-load 'mmm-vars
2276 '(progn
2277 (mmm-add-group
2278 'html-css
2279 '((css-cdata
2280 :submode css-mode
2281 :face mmm-code-submode-face
2282 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
2283 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
2284 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2285 @ "\n" _ "\n" @ "</script>" @)))
2286 (css
2287 :submode css-mode
2288 :face mmm-code-submode-face
2289 :front "<style[^>]*>[ \t]*\n?"
2290 :back "[ \t]*</style>"
2291 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2292 @ "\n" _ "\n" @ "</style>" @)))
2293 (css-inline
2294 :submode css-mode
2295 :face mmm-code-submode-face
2296 :front "style=\""
2297 :back "\"")))
2298 (dolist (mode (list 'html-mode 'nxml-mode))
2299 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
2300 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
2301 ))))
2302 #+END_SRC
2303
2304 ** mo-git-blame
2305 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2306 Emacs]].
2307
2308 #+BEGIN_SRC emacs-lisp :tangle yes
2309 (use-package mo-git-blame
2310 :ensure mo-git-blame
2311 :commands (mo-git-blame-current
2312 mo-git-blame-file)
2313 :config
2314 (progn
2315 (setq mo-git-blame-blame-window-width 25)))
2316 #+END_SRC
2317
2318 ** multiple cursors
2319 [2013-04-08 Mon 23:57]
2320 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2321 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2322 #+BEGIN_SRC emacs-lisp :tangle yes
2323 (use-package multiple-cursors
2324 :ensure multiple-cursors
2325 :defer t
2326 :commands (mc/remove-fake-cursors
2327 mc/create-fake-cursor-at-point
2328 mc/pop-state-from-overlay
2329 mc/maybe-multiple-cursors-mode)
2330 :bind (("C-S-c C-S-c" . mc/edit-lines)
2331 ("C->" . mc/mark-next-like-this)
2332 ("C-<" . mc/mark-previous-like-this)
2333 ("C-c C-<" . mc/mark-all-like-this))
2334 :config
2335 (progn
2336 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
2337 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
2338 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
2339 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
2340 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
2341 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
2342 #+END_SRC
2343 ** nxml
2344 [2013-05-22 Wed 22:02]
2345 nxml-mode is a major mode for editing XML.
2346 #+BEGIN_SRC emacs-lisp :tangle yes
2347 (add-auto-mode
2348 'nxml-mode
2349 (concat "\\."
2350 (regexp-opt
2351 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2352 "gpx" "tcx"))
2353 "\\'"))
2354 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2355 (fset 'xml-mode 'nxml-mode)
2356 (setq nxml-slash-auto-complete-flag t)
2357
2358 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2359 (defun pp-xml-region (begin end)
2360 "Pretty format XML markup in region. The function inserts
2361 linebreaks to separate tags that have nothing but whitespace
2362 between them. It then indents the markup by using nxml's
2363 indentation rules."
2364 (interactive "r")
2365 (save-excursion
2366 (nxml-mode)
2367 (goto-char begin)
2368 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2369 (backward-char) (insert "\n"))
2370 (indent-region begin end)))
2371
2372 ;;----------------------------------------------------------------------------
2373 ;; Integration with tidy for html + xml
2374 ;;----------------------------------------------------------------------------
2375 ;; tidy is autoloaded
2376 (eval-after-load 'tidy
2377 '(progn
2378 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2379 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2380 ))
2381
2382 #+END_SRC
2383 ** org :FIXME:
2384 *** General settings
2385 [2013-04-28 So 17:06]
2386
2387 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
2388 it is quite extensive. Nevertheless, it starts out small, loading it.
2389 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2390 (require 'org)
2391 #+END_SRC
2392
2393 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
2394 that we need org-protocol.
2395 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2396 (require 'org-protocol)
2397 #+END_SRC
2398
2399 *** Agenda
2400
2401 My current =org-agenda-files= variable only includes a set of
2402 directories.
2403 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2404 (setq org-agenda-files (quote ("~/org/"
2405 "~/org/debian"
2406 "~/org/debconf"
2407 "~/org/spi"
2408 "~/org/nsb"
2409 )))
2410 (setq org-default-notes-file "~/org/notes.org")
2411 #+END_SRC
2412 =org-mode= manages the =org-agenda-files= variable automatically using
2413 =C-c [= and =C-c ]= to add and remove files respectively. However,
2414 this replaces my directory list with a list of explicit filenames
2415 instead and is not what I want. If this occurs then adding a new org
2416 file to any of the above directories will not contribute to my agenda
2417 and I will probably miss something important.
2418
2419 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
2420 prevent messing up my list of directories in the =org-agenda-files=
2421 variable. I just add and remove directories manually here. Changing
2422 the list of directories in =org-agenda-files= happens very rarely
2423 since new files in existing directories are automatically picked up.
2424
2425 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2426 ;; Keep tasks with dates on the global todo lists
2427 (setq org-agenda-todo-ignore-with-date nil)
2428
2429 ;; Keep tasks with deadlines on the global todo lists
2430 (setq org-agenda-todo-ignore-deadlines nil)
2431
2432 ;; Keep tasks with scheduled dates on the global todo lists
2433 (setq org-agenda-todo-ignore-scheduled nil)
2434
2435 ;; Keep tasks with timestamps on the global todo lists
2436 (setq org-agenda-todo-ignore-timestamp nil)
2437
2438 ;; Remove completed deadline tasks from the agenda view
2439 (setq org-agenda-skip-deadline-if-done t)
2440
2441 ;; Remove completed scheduled tasks from the agenda view
2442 (setq org-agenda-skip-scheduled-if-done t)
2443
2444 ;; Remove completed items from search results
2445 (setq org-agenda-skip-timestamp-if-done t)
2446
2447 ;; Include agenda archive files when searching for things
2448 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
2449
2450 ;; Show all future entries for repeating tasks
2451 (setq org-agenda-repeating-timestamp-show-all t)
2452
2453 ;; Show all agenda dates - even if they are empty
2454 (setq org-agenda-show-all-dates t)
2455
2456 ;; Sorting order for tasks on the agenda
2457 (setq org-agenda-sorting-strategy
2458 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
2459 (todo category-up priority-down effort-up)
2460 (tags category-up priority-down effort-up)
2461 (search category-up))))
2462
2463 ;; Start the weekly agenda on Monday
2464 (setq org-agenda-start-on-weekday 1)
2465
2466 ;; Enable display of the time grid so we can see the marker for the current time
2467 (setq org-agenda-time-grid (quote ((daily today remove-match)
2468 #("----------------" 0 16 (org-heading t))
2469 (0800 1000 1200 1400 1500 1700 1900 2100))))
2470
2471 ;; Display tags farther right
2472 (setq org-agenda-tags-column -102)
2473
2474 ; position the habit graph on the agenda to the right of the default
2475 (setq org-habit-graph-column 50)
2476
2477 ; turn habits back on
2478 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
2479
2480 ;;
2481 ;; Agenda sorting functions
2482 ;;
2483 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
2484
2485
2486 (setq org-deadline-warning-days 30)
2487
2488 ;; Always hilight the current agenda line
2489 (add-hook 'org-agenda-mode-hook
2490 '(lambda () (hl-line-mode 1))
2491 'append)
2492 #+END_SRC
2493
2494 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2495 (setq org-agenda-persistent-filter t)
2496 (add-hook 'org-agenda-mode-hook
2497 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
2498 'append)
2499
2500 (add-hook 'org-agenda-mode-hook
2501 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
2502 'append)
2503
2504 (add-hook 'org-agenda-mode-hook
2505 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
2506 'append)
2507
2508 (add-hook 'org-agenda-mode-hook
2509 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
2510 'append)
2511
2512 (add-hook 'org-agenda-mode-hook
2513 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
2514 'append)
2515
2516 ; Rebuild the reminders everytime the agenda is displayed
2517 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
2518
2519 ;(if (file-exists-p "~/org/refile.org")
2520 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
2521
2522 ; Activate appointments so we get notifications
2523 (appt-activate t)
2524
2525 (setq org-agenda-log-mode-items (quote (closed clock state)))
2526 (if (> emacs-major-version 23)
2527 (setq org-agenda-span 3)
2528 (setq org-agenda-ndays 3))
2529
2530 (setq org-agenda-show-all-dates t)
2531 (setq org-agenda-start-on-weekday nil)
2532 (setq org-deadline-warning-days 14)
2533
2534 #+END_SRC
2535 *** Global keybindings.
2536 Start off by defining a series of keybindings.
2537
2538 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
2539 setup manually, not by org-mode. Also turn off =C-c ;=, which
2540 comments headlines - a function never used.
2541 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2542 (add-hook 'org-mode-hook
2543 (lambda ()
2544 (org-defkey org-mode-map "\C-c[" 'undefined)
2545 (org-defkey org-mode-map "\C-c]" 'undefined)
2546 (org-defkey org-mode-map "\C-c;" 'undefined))
2547 'append)
2548 #+END_SRC
2549
2550 And now a largish set of keybindings...
2551 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2552 (bind-key "C-c l" 'org-store-link)
2553 (bind-key "C-c a" 'org-agenda)
2554 ;(bind-key "C-c b" 'org-iswitchb)
2555 (define-key mode-specific-map [?a] 'org-agenda)
2556
2557 (bind-key "<f12>" 'org-agenda)
2558 (bind-key "<f5>" 'bh/org-todo)
2559 (bind-key "<S-f5>" 'bh/widen)
2560 (bind-key "<f7>" 'bh/set-truncate-lines)
2561 (bind-key "<f8>" 'org-cycle-agenda-files)
2562
2563 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
2564 (bind-key "<f9> b" 'bbdb)
2565 (bind-key "<f9> c" 'calendar)
2566 (bind-key "<f9> f" 'boxquote-insert-file)
2567 (bind-key "<f9> h" 'bh/hide-other)
2568 (bind-key "<f9> n" 'org-narrow-to-subtree)
2569 (bind-key "<f9> w" 'widen)
2570 (bind-key "<f9> u" 'bh/narrow-up-one-level)
2571 (bind-key "<f9> I" 'bh/punch-in)
2572 (bind-key "<f9> O" 'bh/punch-out)
2573 (bind-key "<f9> H" 'jj/punch-in-hw)
2574 (bind-key "<f9> W" 'jj/punch-out-hw)
2575 (bind-key "<f9> o" 'bh/make-org-scratch)
2576 (bind-key "<f9> p" 'bh/phone-call)
2577 (bind-key "<f9> r" 'boxquote-region)
2578 (bind-key "<f9> s" 'bh/switch-to-scratch)
2579 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
2580 (bind-key "<f9> T" 'tabify)
2581 (bind-key "<f9> U" 'untabify)
2582 (bind-key "<f9> v" 'visible-mode)
2583 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
2584 (bind-key "C-<f9>" 'previous-buffer)
2585 (bind-key "C-<f10>" 'next-buffer)
2586 (bind-key "M-<f9>" 'org-toggle-inline-images)
2587 ;(bind-key "C-x n r" 'narrow-to-region)
2588 (bind-key "<f11>" 'org-clock-goto)
2589 (bind-key "C-<f11>" 'org-clock-in)
2590 (bind-key "C-M-r" 'org-capture)
2591 (bind-key "C-c r" 'org-capture)
2592 (bind-key "C-S-<f12>" 'bh/save-then-publish)
2593 (bind-key "C-k" 'jj-org-kill-line org-mode-map)
2594
2595 #+END_SRC
2596
2597 *** Tasks, States, Todo fun
2598
2599 First we define the global todo keywords.
2600 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2601 (setq org-todo-keywords
2602 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
2603 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
2604
2605 (setq org-todo-keyword-faces
2606 (quote (("TODO" :foreground "red" :weight bold)
2607 ("NEXT" :foreground "light blue" :weight bold)
2608 ("DONE" :foreground "forest green" :weight bold)
2609 ("WAITING" :foreground "orange" :weight bold)
2610 ("HOLD" :foreground "orange" :weight bold)
2611 ("DELEGATED" :foreground "yellow" :weight bold)
2612 ("CANCELLED" :foreground "dark green" :weight bold)
2613 ("PHONE" :foreground "dark green" :weight bold))))
2614 #+END_SRC
2615
2616 **** Fast Todo Selection
2617 Fast todo selection allows changing from any task todo state to any
2618 other state directly by selecting the appropriate key from the fast
2619 todo selection key menu.
2620 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2621 (setq org-use-fast-todo-selection t)
2622 #+END_SRC
2623 Changing a task state is done with =C-c C-t KEY=
2624
2625 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
2626
2627 The setting
2628 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2629 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
2630 #+END_SRC
2631 allows changing todo states with S-left and S-right skipping all of
2632 the normal processing when entering or leaving a todo state. This
2633 cycles through the todo states but skips setting timestamps and
2634 entering notes which is very convenient when all you want to do is fix
2635 up the status of an entry.
2636
2637 **** Todo State Triggers
2638 I have a few triggers that automatically assign tags to tasks based on
2639 state changes. If a task moves to =CANCELLED= state then it gets a
2640 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
2641 =CANCELLED= tag. These are used for filtering tasks in agenda views
2642 which I'll talk about later.
2643
2644 The triggers break down to the following rules:
2645
2646 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
2647 - Moving a task to =WAITING= adds a =WAITING= tag
2648 - Moving a task to =HOLD= adds a =WAITING= tag
2649 - Moving a task to a done state removes a =WAITING= tag
2650 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
2651 - Moving a task to =NEXT= removes a =WAITING= tag
2652 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
2653
2654 The tags are used to filter tasks in the agenda views conveniently.
2655 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2656 (setq org-todo-state-tags-triggers
2657 (quote (("CANCELLED" ("CANCELLED" . t))
2658 ("WAITING" ("WAITING" . t))
2659 ("HOLD" ("WAITING" . t) ("HOLD" . t))
2660 (done ("WAITING") ("HOLD"))
2661 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
2662 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
2663 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
2664 #+END_SRC
2665
2666 *** Capturing new tasks
2667 Org capture replaces the old remember mode.
2668 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2669 (setq org-directory "~/org")
2670 (setq org-default-notes-file "~/org/refile.org")
2671
2672 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
2673 ;; see http://orgmode.org/manual/Template-elements.html
2674 (setq org-capture-templates
2675 (quote (("t" "todo" entry (file "~/org/refile.org")
2676 "* TODO %?\nAdded: %U\n"
2677 :clock-in t :clock-resume t)
2678 ("l" "linktodo" entry (file "~/org/refile.org")
2679 "* TODO %?\nAdded: %U\n%a\n"
2680 :clock-in t :clock-resume t)
2681 ("r" "respond" entry (file "~/org/refile.org")
2682 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
2683 :clock-in t :clock-resume t :immediate-finish t)
2684 ("n" "note" entry (file "~/org/refile.org")
2685 "* %? :NOTE:\nAdded: %U\n%a\n"
2686 :clock-in t :clock-resume t)
2687 ("d" "Delegated" entry (file "~/org/refile.org")
2688 "* DELEGATED %?\nAdded: %U\n%a\n"
2689 :clock-in t :clock-resume t)
2690 ("j" "Journal" entry (file+datetree "~/org/diary.org")
2691 "* %?\nAdded: %U\n"
2692 :clock-in t :clock-resume t)
2693 ("w" "org-protocol" entry (file "~/org/refile.org")
2694 "* TODO Review %c\nAdded: %U\n"
2695 :immediate-finish t)
2696 ("p" "Phone call" entry (file "~/org/refile.org")
2697 "* PHONE %? :PHONE:\nAdded: %U"
2698 :clock-in t :clock-resume t)
2699 ("x" "Bookmark link" entry (file "~/org/refile.org")
2700 "* Bookmark: %c\n%i\nAdded: %U\n"
2701 :immediate-finish t)
2702 ("h" "Habit" entry (file "~/org/refile.org")
2703 "* 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")
2704 )))
2705 #+END_SRC
2706
2707 Capture mode now handles automatically clocking in and out of a
2708 capture task. This all works out of the box now without special hooks.
2709 When I start a capture mode task the task is clocked in as specified
2710 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
2711 resumes on the original clocking task.
2712
2713 The quick clocking in and out of capture mode tasks (often it takes
2714 less than a minute to capture some new task details) can leave
2715 empty clock drawers in my tasks which aren't really useful.
2716 The following prevents this.
2717 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2718 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
2719 #+END_SRC
2720
2721 *** Refiling
2722 All my newly captured entries end up in =refile.org= and want to be
2723 moved over to the right place. The following is the setup for it.
2724 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2725 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
2726 (setq org-refile-targets (quote ((nil :maxlevel . 9)
2727 (org-agenda-files :maxlevel . 9))))
2728
2729 ; Use full outline paths for refile targets - we file directly with IDO
2730 (setq org-refile-use-outline-path t)
2731
2732 ; Targets complete directly with IDO
2733 (setq org-outline-path-complete-in-steps nil)
2734
2735 ; Allow refile to create parent tasks with confirmation
2736 (setq org-refile-allow-creating-parent-nodes (quote confirm))
2737
2738 ; Use IDO for both buffer and file completion and ido-everywhere to t
2739 (setq org-completion-use-ido t)
2740 (setq org-completion-use-iswitchb nil)
2741 :; Use IDO for both buffer and file completion and ido-everywhere to t
2742 ;(setq ido-everywhere t)
2743 ;(setq ido-max-directory-size 100000)
2744 ;(ido-mode (quote both))
2745 ; Use the current window when visiting files and buffers with ido
2746 (setq ido-default-file-method 'selected-window)
2747 (setq ido-default-buffer-method 'selected-window)
2748
2749 ;;;; Refile settings
2750 (setq org-refile-target-verify-function 'bh/verify-refile-target)
2751 #+END_SRC
2752
2753 *** Custom agenda
2754 Agenda view is the central place for org-mode interaction...
2755 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2756 ;; Do not dim blocked tasks
2757 (setq org-agenda-dim-blocked-tasks nil)
2758 ;; Compact the block agenda view
2759 (setq org-agenda-compact-blocks t)
2760
2761 ;; Custom agenda command definitions
2762 (setq org-agenda-custom-commands
2763 (quote (("N" "Notes" tags "NOTE"
2764 ((org-agenda-overriding-header "Notes")
2765 (org-tags-match-list-sublevels t)))
2766 ("h" "Habits" tags-todo "STYLE=\"habit\""
2767 ((org-agenda-overriding-header "Habits")
2768 (org-agenda-sorting-strategy
2769 '(todo-state-down effort-up category-keep))))
2770 (" " "Agenda"
2771 ((agenda "" nil)
2772 (tags "REFILE"
2773 ((org-agenda-overriding-header "Tasks to Refile")
2774 (org-tags-match-list-sublevels nil)))
2775 (tags-todo "-HOLD-CANCELLED/!"
2776 ((org-agenda-overriding-header "Projects")
2777 (org-agenda-skip-function 'bh/skip-non-projects)
2778 (org-agenda-sorting-strategy
2779 '(category-keep))))
2780 (tags-todo "-CANCELLED/!"
2781 ((org-agenda-overriding-header "Stuck Projects")
2782 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
2783 (tags-todo "-WAITING-CANCELLED/!NEXT"
2784 ((org-agenda-overriding-header "Next Tasks")
2785 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
2786 (org-agenda-todo-ignore-scheduled t)
2787 (org-agenda-todo-ignore-deadlines t)
2788 (org-agenda-todo-ignore-with-date t)
2789 (org-tags-match-list-sublevels t)
2790 (org-agenda-sorting-strategy
2791 '(todo-state-down effort-up category-keep))))
2792 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
2793 ((org-agenda-overriding-header "Tasks")
2794 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
2795 (org-agenda-todo-ignore-scheduled t)
2796 (org-agenda-todo-ignore-deadlines t)
2797 (org-agenda-todo-ignore-with-date t)
2798 (org-agenda-sorting-strategy
2799 '(category-keep))))
2800 (tags-todo "-CANCELLED+WAITING/!"
2801 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
2802 (org-agenda-skip-function 'bh/skip-stuck-projects)
2803 (org-tags-match-list-sublevels nil)
2804 (org-agenda-todo-ignore-scheduled 'future)
2805 (org-agenda-todo-ignore-deadlines 'future)))
2806 (tags "-REFILE/"
2807 ((org-agenda-overriding-header "Tasks to Archive")
2808 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
2809 (org-tags-match-list-sublevels nil))))
2810 nil)
2811 ("r" "Tasks to Refile" tags "REFILE"
2812 ((org-agenda-overriding-header "Tasks to Refile")
2813 (org-tags-match-list-sublevels nil)))
2814 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
2815 ((org-agenda-overriding-header "Stuck Projects")
2816 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
2817 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
2818 ((org-agenda-overriding-header "Next Tasks")
2819 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
2820 (org-agenda-todo-ignore-scheduled t)
2821 (org-agenda-todo-ignore-deadlines t)
2822 (org-agenda-todo-ignore-with-date t)
2823 (org-tags-match-list-sublevels t)
2824 (org-agenda-sorting-strategy
2825 '(todo-state-down effort-up category-keep))))
2826 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
2827 ((org-agenda-overriding-header "Tasks")
2828 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
2829 (org-agenda-sorting-strategy
2830 '(category-keep))))
2831 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
2832 ((org-agenda-overriding-header "Projects")
2833 (org-agenda-skip-function 'bh/skip-non-projects)
2834 (org-agenda-sorting-strategy
2835 '(category-keep))))
2836 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
2837 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
2838 (org-tags-match-list-sublevels nil))
2839 ("A" "Tasks to Archive" tags "-REFILE/"
2840 ((org-agenda-overriding-header "Tasks to Archive")
2841 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
2842 (org-tags-match-list-sublevels nil))))))
2843
2844 ; Overwrite the current window with the agenda
2845 (setq org-agenda-window-setup 'current-window)
2846
2847 #+END_SRC
2848
2849 *** Time
2850 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2851 ;;
2852 ;; Resume clocking task when emacs is restarted
2853 (org-clock-persistence-insinuate)
2854 ;;
2855 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
2856 (setq org-clock-history-length 36)
2857 ;; Resume clocking task on clock-in if the clock is open
2858 (setq org-clock-in-resume t)
2859 ;; Change tasks to NEXT when clocking in
2860 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
2861 ;; Separate drawers for clocking and logs
2862 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
2863 ;; Save clock data and state changes and notes in the LOGBOOK drawer
2864 (setq org-clock-into-drawer t)
2865 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
2866 (setq org-clock-out-remove-zero-time-clocks t)
2867 ;; Clock out when moving task to a done state
2868 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
2869 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
2870 (setq org-clock-persist t)
2871 ;; Do not prompt to resume an active clock
2872 (setq org-clock-persist-query-resume nil)
2873 ;; Enable auto clock resolution for finding open clocks
2874 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
2875 ;; Include current clocking task in clock reports
2876 (setq org-clock-report-include-clocking-task t)
2877
2878 ; use discrete minute intervals (no rounding) increments
2879 (setq org-time-stamp-rounding-minutes (quote (1 1)))
2880
2881 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
2882
2883 (setq bh/keep-clock-running nil)
2884
2885 (setq org-agenda-clock-consistency-checks
2886 (quote (:max-duration "4:00"
2887 :min-duration 0
2888 :max-gap 0
2889 :gap-ok-around ("4:00"))))
2890
2891 #+END_SRC
2892
2893 **** Setting a default clock task
2894 Per default the =** Organization= task in my tasks.org file receives
2895 misc clock time. This is the task I clock in on when I punch in at the
2896 start of my work day with =F9-I=. Punching-in anywhere clocks in this
2897 Organization task as the default task.
2898
2899 If I want to change the default clocking task I just visit the
2900 new task in any org buffer and clock it in with =C-u C-u C-c C-x
2901 C-i=. Now this new task that collects miscellaneous clock
2902 minutes when the clock would normally stop.
2903
2904 You can quickly clock in the default clocking task with =C-u C-c
2905 C-x C-i d=. Another option is to repeatedly clock out so the
2906 clock moves up the project tree until you clock out the
2907 top-level task and the clock moves to the default task.
2908
2909 **** Reporting
2910 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2911 ;; Agenda clock report parameters
2912 (setq org-agenda-clockreport-parameter-plist
2913 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
2914
2915 ;; Agenda log mode items to display (closed and state changes by default)
2916 (setq org-agenda-log-mode-items (quote (closed state)))
2917 #+END_SRC
2918 **** Task estimates, column view
2919 Setup column view globally with the following headlines
2920 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2921 ; Set default column view headings: Task Effort Clock_Summary
2922 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
2923 #+END_SRC
2924 Setup the estimate for effort values.
2925 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2926 ; global Effort estimate values
2927 ; global STYLE property values for completion
2928 (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")
2929 ("STYLE_ALL" . "habit"))))
2930 #+END_SRC
2931
2932 *** Tags
2933 Tags are mostly used for filtering inside the agenda.
2934 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2935 ; Tags with fast selection keys
2936 (setq org-tag-alist (quote ((:startgroup)
2937 ("@errand" . ?e)
2938 ("@office" . ?o)
2939 ("@home" . ?H)
2940 (:endgroup)
2941 ("PHONE" . ?p)
2942 ("WAITING" . ?w)
2943 ("HOLD" . ?h)
2944 ("PERSONAL" . ?P)
2945 ("WORK" . ?W)
2946 ("ORG" . ?O)
2947 ("PRIVATE" . ?N)
2948 ("crypt" . ?E)
2949 ("MARK" . ?M)
2950 ("NOTE" . ?n)
2951 ("CANCELLED" . ?c)
2952 ("FLAGGED" . ??))))
2953
2954 ; Allow setting single tags without the menu
2955 (setq org-fast-tag-selection-single-key (quote expert))
2956
2957 ; For tag searches ignore tasks with scheduled and deadline dates
2958 (setq org-agenda-tags-todo-honor-ignore-options t)
2959 #+END_SRC
2960
2961 *** Archiving
2962 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2963 (setq org-archive-mark-done nil)
2964 (setq org-archive-location "%s_archive::* Archived Tasks")
2965 #+END_SRC
2966
2967 *** org-babel
2968 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2969 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
2970 (setq org-plantuml-jar-path "~/java/plantuml.jar")
2971
2972 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
2973
2974 ; Make babel results blocks lowercase
2975 (setq org-babel-results-keyword "results")
2976
2977 (org-babel-do-load-languages
2978 (quote org-babel-load-languages)
2979 (quote ((emacs-lisp . t)
2980 (awk . t)
2981 (css . t)
2982 (makefile . t)
2983 (perl . t)
2984 (ruby . t)
2985 (dot . t)
2986 (ditaa . t)
2987 (R . t)
2988 (python . t)
2989 (ruby . t)
2990 (gnuplot . t)
2991 (clojure . t)
2992 (sh . t)
2993 (ledger . t)
2994 (org . t)
2995 (plantuml . t)
2996 (latex . t))))
2997
2998 ; Do not prompt to confirm evaluation
2999 ; This may be dangerous - make sure you understand the consequences
3000 ; of setting this -- see the docstring for details
3001 (setq org-confirm-babel-evaluate nil)
3002
3003 ; Use fundamental mode when editing plantuml blocks with C-c '
3004 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
3005 #+END_SRC
3006
3007 #+BEGIN_SRC emacs-lisp :tangle yes
3008 ;; Don't have images visible on startup, breaks on console
3009 (setq org-startup-with-inline-images nil)
3010 #+END_SRC
3011
3012 #+BEGIN_SRC emacs-lisp :tangle yes
3013 (add-to-list 'org-structure-template-alist
3014 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
3015 "<comment>\n?\n</comment>"))
3016 #+END_SRC
3017 **** ditaa, graphviz, etc
3018 Those are all nice tools. Look at
3019 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
3020 to them.
3021
3022 *** Publishing and exporting
3023
3024
3025 Org-mode can export to a variety of publishing formats including (but not limited to)
3026
3027 - ASCII
3028 (plain text - but not the original org-mode file)
3029 - HTML
3030 - LaTeX
3031 - Docbook
3032 which enables getting to lots of other formats like ODF, XML, etc
3033 - PDF
3034 via LaTeX or Docbook
3035 - iCal
3036
3037 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
3038
3039 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3040 ;; Explicitly load required exporters
3041 (require 'ox-html)
3042 (require 'ox-latex)
3043 (require 'ox-ascii)
3044 ;; FIXME, check the following two
3045 ;(require 'ox-icalendar)
3046 ;(require 'ox-odt)
3047
3048 ; experimenting with docbook exports - not finished
3049 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
3050 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
3051
3052 ;; define categories that should be excluded
3053 (setq org-export-exclude-category (list "google" "google"))
3054 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
3055
3056 ; define how the date strings look
3057 (setq org-export-date-timestamp-format "%Y-%m-%d")
3058 ; Inline images in HTML instead of producting links to the image
3059 (setq org-html-inline-images t)
3060 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
3061 (setq org-export-with-sub-superscripts nil)
3062
3063 (setq org-html-head-extra (concat
3064 "<link rel=\"stylesheet\" href=\"http://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
3065 ))
3066 (setq org-html-head-include-default-style nil)
3067 ; Do not generate internal css formatting for HTML exports
3068 (setq org-export-htmlize-output-type (quote css))
3069 ; Export with LaTeX fragments
3070 (setq org-export-with-LaTeX-fragments t)
3071 ; Increase default number of headings to export
3072 (setq org-export-headline-levels 6)
3073
3074
3075 (setq org-publish-project-alist
3076 '(
3077 ("config-notes"
3078 :base-directory "~/.emacs.d/"
3079 :base-extension "org"
3080 :exclude "elisp"
3081 :publishing-directory "/develop/www/emacs"
3082 :recursive t
3083 :publishing-function org-html-publish-to-html
3084 :headline-levels 4 ; Just the default for this project.
3085 :auto-preamble t
3086 :auto-sitemap t
3087 :makeindex t
3088 )
3089 ("config-static"
3090 :base-directory "~/.emacs.d/"
3091 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
3092 :publishing-directory "/develop/www/emacs"
3093 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
3094 :recursive t
3095 :publishing-function org-publish-attachment
3096 )
3097 ("inherit-org-info-js"
3098 :base-directory "/develop/vcs/org-info-js/"
3099 :recursive t
3100 :base-extension "js"
3101 :publishing-directory "/develop/www/"
3102 :publishing-function org-publish-attachment
3103 )
3104 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
3105 )
3106 )
3107 )
3108
3109 (setq org-export-with-timestamps nil)
3110 #+END_SRC
3111
3112 **** Latex export
3113
3114 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3115 (setq org-latex-to-pdf-process
3116 '("xelatex -interaction nonstopmode %f"
3117 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
3118 (setq org-export-latex-listings 'minted)
3119 (setq org-latex-listings t)
3120
3121 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
3122 ;; but adapted to use latexmk 4.20 or higher.
3123 (defun my-auto-tex-cmd ()
3124 "When exporting from .org with latex, automatically run latex,
3125 pdflatex, or xelatex as appropriate, using latexmk."
3126 (let ((texcmd)))
3127 ;; default command: oldstyle latex via dvi
3128 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
3129 ;; pdflatex -> .pdf
3130 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
3131 (setq texcmd "latexmk -pdf -quiet %f"))
3132 ;; xelatex -> .pdf
3133 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3134 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
3135 ;; LaTeX compilation command
3136 (setq org-latex-to-pdf-process (list texcmd)))
3137
3138 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
3139
3140 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
3141 (setq org-export-latex-packages-alist
3142 '(("" "graphicx" t)
3143 ("" "longtable" nil)
3144 ("" "float" nil)
3145 ("" "minted" nil)
3146 ))
3147
3148 (defun my-auto-tex-parameters ()
3149 "Automatically select the tex packages to include."
3150 ;; default packages for ordinary latex or pdflatex export
3151 (setq org-export-latex-default-packages-alist
3152 '(("AUTO" "inputenc" t)
3153 ("T1" "fontenc" t)
3154 ("" "fixltx2e" nil)
3155 ("" "wrapfig" nil)
3156 ("" "soul" t)
3157 ("" "textcomp" t)
3158 ("" "marvosym" t)
3159 ("" "wasysym" t)
3160 ("" "latexsym" t)
3161 ("" "amssymb" t)
3162 ("" "hyperref" nil)))
3163
3164 ;; Packages to include when xelatex is used
3165 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3166 (setq org-export-latex-default-packages-alist
3167 '(("" "fontspec" t)
3168 ("" "xunicode" t)
3169 ("" "url" t)
3170 ("" "rotating" t)
3171 ("german" "babel" t)
3172 ("babel" "csquotes" t)
3173 ("" "soul" t)
3174 ("xetex" "hyperref" nil)
3175 )))
3176
3177 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
3178 (setq org-export-latex-classes
3179 (cons '("scrartcl"
3180 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
3181 ("\\section{%s}" . "\\section*{%s}")
3182 ("\\subsection{%s}" . "\\subsection*{%s}")
3183 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
3184 ("\\paragraph{%s}" . "\\paragraph*{%s}")
3185 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
3186 org-export-latex-classes))))
3187
3188 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
3189 #+END_SRC
3190
3191 *** Prevent editing invisible text
3192 The following setting prevents accidentally editing hidden text when
3193 the point is inside a folded region. This can happen if you are in
3194 the body of a heading and globally fold the org-file with =S-TAB=
3195
3196 I find invisible edits (and undo's) hard to deal with so now I can't
3197 edit invisible text. =C-c C-r= (org-reveal) will display where the
3198 point is if it is buried in invisible text to allow editing again.
3199
3200 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3201 (setq org-catch-invisible-edits 'error)
3202 #+END_SRC
3203
3204 *** Whatever
3205 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3206 ;; disable the default org-mode stuck projects agenda view
3207 (setq org-stuck-projects (quote ("" nil nil "")))
3208
3209 ; force showing the next headline.
3210 (setq org-show-entry-below (quote ((default))))
3211
3212 (setq org-show-following-heading t)
3213 (setq org-show-hierarchy-above t)
3214 (setq org-show-siblings (quote ((default))))
3215
3216 (setq org-special-ctrl-a/e t)
3217 (setq org-special-ctrl-k t)
3218 (setq org-yank-adjusted-subtrees t)
3219
3220 (setq org-table-export-default-format "orgtbl-to-csv")
3221
3222 #+END_SRC
3223
3224 The following setting adds alphabetical lists like
3225 ,a. item one
3226 ,b. item two
3227
3228 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3229 (if (> emacs-major-version 23)
3230 (setq org-list-allow-alphabetical t)
3231 (setq org-alphabetical-lists t))
3232 #+END_SRC
3233
3234 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3235 (setq org-remove-highlights-with-change nil)
3236
3237 (setq org-list-demote-modify-bullet (quote (("+" . "-")
3238 ("*" . "-")
3239 ("1." . "-")
3240 ("1)" . "-"))))
3241
3242
3243
3244 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
3245
3246
3247 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
3248 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
3249
3250 #+END_SRC
3251
3252
3253 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3254 ;; Enable abbrev-mode
3255 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
3256 (setq org-startup-indented t)
3257 (setq org-startup-folded t)
3258 (setq org-cycle-separator-lines 0)
3259 #+END_SRC
3260
3261 I find extra blank lines in lists and headings a bit of a nuisance.
3262 To get a body after a list you need to include a blank line between
3263 the list entry and the body -- and indent the body appropriately.
3264 Most of my lists have no body detail so I like the look of collapsed
3265 lists with no blank lines better.
3266
3267 The following setting prevents creating blank lines before headings
3268 but allows list items to adapt to existing blank lines around the items:
3269 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3270 (setq org-blank-before-new-entry (quote ((heading)
3271 (plain-list-item . auto))))
3272 #+END_SRC
3273
3274 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3275 (setq org-reverse-note-order nil)
3276 (setq org-default-notes-file "~/notes.org")
3277 #+END_SRC
3278
3279 Enforce task blocking. Tasks can't go done when there is any subtask
3280 still open. Unless they have a property of =NOBLOCKING: t=
3281 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3282 (setq org-enforce-todo-checkbox-dependencies t)
3283 (setq org-enforce-todo-dependencies t)
3284 #+END_SRC
3285
3286 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3287 (setq org-fast-tag-selection-single-key (quote expert))
3288 (setq org-footnote-auto-adjust t)
3289 (setq org-hide-block-startup t)
3290 (setq org-icalendar-alarm-time 15)
3291 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
3292 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
3293 (setq org-icalendar-honor-noexport-tag t)
3294 (setq org-icalendar-include-bbdb-anniversaries nil)
3295 (setq org-icalendar-include-body 200)
3296 (setq org-icalendar-include-todo nil)
3297 (setq org-icalendar-store-UID t)
3298 (setq org-icalendar-timezone "Europe/Berlin")
3299 (setq org-insert-mode-line-in-empty-file t)
3300 (setq org-log-done (quote note))
3301 (setq org-log-into-drawer t)
3302 (setq org-log-state-notes-insert-after-drawers nil)
3303 (setq org-log-reschedule (quote time))
3304 (setq org-log-states-order-reversed t)
3305 (setq org-mobile-agendas (quote all))
3306 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
3307 (setq org-mobile-inbox-for-pull "~/org/refile.org")
3308 (setq org-remember-store-without-prompt t)
3309 (setq org-return-follows-link t)
3310 (setq org-reverse-note-order t)
3311
3312 ; regularly save our org-mode buffers
3313 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
3314
3315 (setq org-log-done t)
3316
3317 (setq org-enable-priority-commands t)
3318 (setq org-default-priority ?E)
3319 (setq org-lowest-priority ?E)
3320
3321
3322 #+END_SRC
3323
3324 Speed commands enable single-letter commands in Org-mode files when
3325 the point is at the beginning of a headline, or at the beginning of a
3326 code block.
3327
3328 See the `=org-speed-commands-default=' variable for a list of the keys
3329 and commands enabled at the beginning of headlines. All code blocks
3330 are available at the beginning of a code block, the following key
3331 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
3332 display a list of the code blocks commands and their related keys.
3333
3334 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3335 (setq org-use-speed-commands t)
3336 (setq org-speed-commands-user (quote (("0" . ignore)
3337 ("1" . ignore)
3338 ("2" . ignore)
3339 ("3" . ignore)
3340 ("4" . ignore)
3341 ("5" . ignore)
3342 ("6" . ignore)
3343 ("7" . ignore)
3344 ("8" . ignore)
3345 ("9" . ignore)
3346
3347 ("a" . ignore)
3348 ("d" . ignore)
3349 ("h" . bh/hide-other)
3350 ("i" progn
3351 (forward-char 1)
3352 (call-interactively 'org-insert-heading-respect-content))
3353 ("k" . org-kill-note-or-show-branches)
3354 ("l" . ignore)
3355 ("m" . ignore)
3356 ("q" . bh/show-org-agenda)
3357 ("r" . ignore)
3358 ("s" . org-save-all-org-buffers)
3359 ("w" . org-refile)
3360 ("x" . ignore)
3361 ("y" . ignore)
3362 ("z" . org-add-note)
3363
3364 ("A" . ignore)
3365 ("B" . ignore)
3366 ("E" . ignore)
3367 ("F" . bh/restrict-to-file-or-follow)
3368 ("G" . ignore)
3369 ("H" . ignore)
3370 ("J" . org-clock-goto)
3371 ("K" . ignore)
3372 ("L" . ignore)
3373 ("M" . ignore)
3374 ("N" . bh/narrow-to-org-subtree)
3375 ("P" . bh/narrow-to-org-project)
3376 ("Q" . ignore)
3377 ("R" . ignore)
3378 ("S" . ignore)
3379 ("T" . bh/org-todo)
3380 ("U" . bh/narrow-up-one-org-level)
3381 ("V" . ignore)
3382 ("W" . bh/widen)
3383 ("X" . ignore)
3384 ("Y" . ignore)
3385 ("Z" . ignore))))
3386
3387 (add-hook 'org-agenda-mode-hook
3388 (lambda ()
3389 (define-key org-agenda-mode-map "q" 'bury-buffer))
3390 'append)
3391
3392 (defvar bh/current-view-project nil)
3393 (add-hook 'org-agenda-mode-hook
3394 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
3395 'append)
3396 #+END_SRC
3397
3398 The following displays the contents of code blocks in Org-mode files
3399 using the major-mode of the code. It also changes the behavior of
3400 =TAB= to as if it were used in the appropriate major mode. This means
3401 that reading and editing code form inside of your Org-mode files is
3402 much more like reading and editing of code using its major mode.
3403
3404 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3405 (setq org-src-fontify-natively t)
3406 (setq org-src-tab-acts-natively t)
3407 #+END_SRC
3408
3409 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3410 (setq org-src-preserve-indentation nil)
3411 (setq org-edit-src-content-indentation 0)
3412 #+END_SRC
3413
3414
3415 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3416 (setq org-attach-directory "~/org/data/")
3417 #+END_SRC
3418 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3419 (setq org-agenda-sticky t)
3420 #+END_SRC
3421
3422 **** Checklist handling
3423 [2013-05-11 Sat 22:15]
3424
3425 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3426 (require 'org-checklist)
3427 #+END_SRC
3428
3429 ** perl / cperl
3430 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
3431 up here to be used.
3432 #+BEGIN_SRC emacs-lisp :tangle yes
3433 (use-package cperl-mode
3434 :commands cperl-mode
3435 :init
3436 (progn
3437 (defalias 'perl-mode 'cperl-mode)
3438 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
3439 (add-auto-mode 'pod-mode "\\.pod$")
3440 (add-auto-mode 'tt-mode "\\.tt$")
3441 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
3442 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
3443 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
3444 )
3445 :config
3446 (progn
3447 (setq cperl-invalid-face nil
3448 cperl-close-paren-offset -4
3449 cperl-continued-statement-offset 0
3450 cperl-indent-level 4
3451 cperl-indent-parens-as-block t
3452 cperl-hairy t
3453 cperl-electric-keywords t
3454 cperl-electric-lbrace-space t
3455 cperl-electric-parens nil
3456 cperl-highlight-variables-indiscriminately t
3457 cperl-imenu-addback t
3458 cperl-invalid-face (quote underline)
3459 cperl-lazy-help-time 5
3460 cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$"
3461 cperl-syntaxify-by-font-lock t
3462 cperl-use-syntax-table-text-property-for-tags t)
3463
3464 ;; And have cperl mode give ElDoc a useful string
3465 (defun my-cperl-eldoc-documentation-function ()
3466 "Return meaningful doc string for `eldoc-mode'."
3467 (car
3468 (let ((cperl-message-on-help-error nil))
3469 (cperl-get-help))))
3470 (add-hook 'cperl-mode-hook
3471 (lambda ()
3472 (set (make-local-variable 'eldoc-documentation-function)
3473 'my-cperl-eldoc-documentation-function)
3474 (eldoc-mode))))
3475 )
3476 #+END_SRC
3477 ** puppet
3478 [2014-05-22 Thu 00:05]
3479 #+BEGIN_SRC emacs-lisp :tangle yes
3480 (use-package puppet-mode
3481 :mode ("\\.pp\\'" . puppet-mode)
3482 :config
3483 (use-package puppet-ext
3484 :init
3485 (progn
3486 (bind-key "C-x ?" 'puppet-set-anchor puppet-mode-map)
3487 (bind-key "C-c C-r" 'puppet-create-require puppet-mode-map))))
3488 #+END_SRC
3489
3490 ** python
3491 Use elpy for the emacs python fun, but dont let it initialize all the
3492 various variables. Elpy author may like them, but I'm not him...
3493 #+BEGIN_SRC emacs-lisp :tangle yes
3494 (use-package elpy
3495 :defer t
3496 :mode ("\.py" . elpy-mode)
3497 :init
3498 (progn
3499 (safe-load (concat jj-elisp-dir "/elpy/elpy-autoloads.el"))
3500 )
3501 :config
3502 (progn
3503
3504 (use-package nose
3505 :ensure nose
3506 :commands (nosetests-all nosetests-module nosetests-one
3507 nosetests-failed nosetests-pdb-all
3508 nosetests-pdb-module nosetests-pdb-one)
3509 )
3510
3511 (use-package pyvenv
3512 :ensure pyvenv
3513 :commands (pyvenv-activate pyvenv-deactivate pyvenv-mode pyvenv-restart-python)
3514 )
3515
3516 (use-package idomenu
3517 :ensure idomenu
3518 :commands (idomenu)
3519 :defer t)
3520
3521 (use-package highlight-indentation
3522 :ensure t
3523 :commands (highlight-indentation-mode))
3524
3525 (use-package find-file-in-project
3526 :ensure t
3527 :commands (find-file-in-project ffip-project-files ffip ))
3528
3529 (use-package fuzzy
3530 :ensure t)
3531
3532 ;; Local variables in `python-mode'. This is not removed when Elpy
3533 ;; is disabled, which can cause some confusion.
3534 (add-hook 'python-mode-hook 'elpy-initialize-local-variables)
3535
3536 ;; Flymake support using flake8, including warning faces.
3537 (when (and (executable-find "flake8")
3538 (not (executable-find python-check-command)))
3539 (setq python-check-command "flake8"))
3540
3541 ;; `flymake-no-changes-timeout': The original value of 0.5 is too
3542 ;; short for Python code, as that will result in the current line to
3543 ;; be highlighted most of the time, and that's annoying. This value
3544 ;; might be on the long side, but at least it does not, in general,
3545 ;; interfere with normal interaction.
3546 (setq flymake-no-changes-timeout 60)
3547
3548 ;; `flymake-start-syntax-check-on-newline': This should be nil for
3549 ;; Python, as;; most lines with a colon at the end will mean the next
3550 ;; line is always highlighted as error, which is not helpful and
3551 ;; mostly annoying.
3552 (setq flymake-start-syntax-check-on-newline nil)
3553
3554 ;; `ac-auto-show-menu': Short timeout because the menu is great.
3555 (setq ac-auto-show-menu 0.4)
3556
3557 ;; `ac-quick-help-delay': I'd like to show the menu right with the
3558 ;; completions, but this value should be greater than
3559 ;; `ac-auto-show-menu' to show help for the first entry as well.
3560 (setq ac-quick-help-delay 0.5)
3561
3562 ;; `yas-trigger-key': TAB, as is the default, conflicts with the
3563 ;; autocompletion. We also need to tell yasnippet about the new
3564 ;; binding. This is a bad interface to set the trigger key. Stop
3565 ;; doing this.
3566 (let ((old (when (boundp 'yas-trigger-key)
3567 yas-trigger-key)))
3568 (setq yas-trigger-key "C-c C-i")
3569 (when (fboundp 'yas--trigger-key-reload)
3570 (yas--trigger-key-reload old)))
3571
3572 ;; yas-snippet-dirs can be a string for a single directory. Make
3573 ;; sure it's a list in that case so we can add our own entry.
3574 (when (not (listp yas-snippet-dirs))
3575 (setq yas-snippet-dirs (list yas-snippet-dirs)))
3576 (add-to-list 'yas-snippet-dirs
3577 (concat (file-name-directory (locate-library "elpy"))
3578 "snippets/")
3579 t)
3580
3581 ;; Now load yasnippets.
3582 (yas-reload-all)
3583 (elpy-enable t)
3584 (elpy-use-ipython)))
3585
3586 #+END_SRC
3587
3588 Below is old setup
3589 #+BEGIN_SRC emacs-lisp :tangle no
3590 (autoload 'python-mode "python-mode" "Python Mode." t)
3591 (add-auto-mode 'python-mode "\\.py\\'")
3592 (add-auto-mode 'python-mode "\\.py$")
3593 (add-auto-mode 'python-mode "SConstruct\\'")
3594 (add-auto-mode 'python-mode "SConscript\\'")
3595 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
3596
3597 (after 'python-mode
3598 (set-variable 'py-indent-offset 4)
3599 (set-variable 'py-smart-indentation nil)
3600 (set-variable 'indent-tabs-mode nil)
3601 (define-key python-mode-map "\C-m" 'newline-and-indent)
3602 (turn-on-eldoc-mode)
3603 (defun python-auto-fill-comments-only ()
3604 (auto-fill-mode 1)
3605 (set (make-local-variable 'fill-nobreak-predicate)
3606 (lambda ()
3607 (not (python-in-string/comment)))))
3608 (add-hook 'python-mode-hook
3609 (lambda ()
3610 (python-auto-fill-comments-only)))
3611 ;; pymacs
3612 (autoload 'pymacs-apply "pymacs")
3613 (autoload 'pymacs-call "pymacs")
3614 (autoload 'pymacs-eval "pymacs" nil t)
3615 (autoload 'pymacs-exec "pymacs" nil t)
3616 (autoload 'pymacs-load "pymacs" nil t))
3617 #+END_SRC
3618
3619 If an =ipython= executable is on the path, then assume that IPython is
3620 the preferred method python evaluation.
3621 #+BEGIN_SRC emacs-lisp :tangle no
3622 (when (executable-find "ipython")
3623 (require 'ipython)
3624 (setq org-babel-python-mode 'python-mode))
3625
3626 (setq python-shell-interpreter "ipython")
3627 (setq python-shell-interpreter-args "")
3628 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
3629 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
3630 (setq python-shell-completion-setup-code
3631 "from IPython.core.completerlib import module_completion")
3632 (setq python-shell-completion-module-string-code
3633 "';'.join(module_completion('''%s'''))\n")
3634 (setq python-shell-completion-string-code
3635 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
3636 #+END_SRC
3637 ** rainbow-delimiters
3638 [2013-04-09 Di 23:38]
3639 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
3640 which highlights parens, brackets, and braces according to their
3641 depth. Each successive level is highlighted a different color. This
3642 makes it easy to spot matching delimiters, orient yourself in the code,
3643 and tell which statements are at the same depth.
3644 #+BEGIN_SRC emacs-lisp :tangle yes
3645 (use-package rainbow-delimiters
3646 :ensure rainbow-delimiters
3647 :init
3648 (global-rainbow-delimiters-mode))
3649 #+END_SRC
3650 ** rainbow-mode
3651 #+BEGIN_SRC emacs-lisp :tangle yes
3652 (use-package rainbow-mode
3653 :ensure rainbow-mode
3654 :diminish rainbow-mode)
3655 #+END_SRC
3656
3657 ** re-builder
3658 Saner regex syntax
3659 #+BEGIN_SRC emacs-lisp :tangle yes
3660 (use-package re-builder
3661 :command re-builder
3662 :defer t
3663 :config
3664 (setq reb-re-syntax 'string))
3665 #+END_SRC
3666 ** recentf
3667 [2014-05-19 Mo 22:56]
3668 Recentf is a minor mode that builds a list of recently opened
3669 files. This list is is automatically saved across Emacs sessions.
3670 #+BEGIN_SRC emacs-lisp :tangle yes
3671 (use-package recentf
3672 :if (not noninteractive)
3673 :bind ("C-x C-r" . recentf-open-files)
3674 :init
3675 (progn
3676 (recentf-mode 1)
3677 (setq recentf-max-menu-items 25)
3678 (setq recentf-save-file (expand-file-name ".recentf" jj-cache-dir))
3679
3680 (defun recentf-add-dired-directory ()
3681 (if (and dired-directory
3682 (file-directory-p dired-directory)
3683 (not (string= "/" dired-directory)))
3684 (let ((last-idx (1- (length dired-directory))))
3685 (recentf-add-file
3686 (if (= ?/ (aref dired-directory last-idx))
3687 (substring dired-directory 0 last-idx)
3688 dired-directory)))))
3689
3690 (add-hook 'dired-mode-hook 'recentf-add-dired-directory)))
3691 #+END_SRC
3692 ** Region bindings mode
3693 [2013-05-01 Wed 22:51]
3694 This mode allows to have keybindings that are only alive when the
3695 region is active. Helpful for things that only do any useful action
3696 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
3697 #+BEGIN_SRC emacs-lisp :tangle yes
3698 (use-package region-bindings-mode
3699 :ensure region-bindings-mode
3700 :init
3701 (region-bindings-mode-enable))
3702 #+END_SRC
3703 ** ruby
3704 [2013-05-22 Wed 22:33]
3705 Programming in ruby...
3706
3707 *** Auto-modes
3708 #+BEGIN_SRC emacs-lisp :tangle yes
3709 (add-auto-mode 'ruby-mode
3710 "Rakefile\\'" "\\.rake\\'" "\.rxml\\'"
3711 "\\.rjs\\'" ".irbrc\\'" "\.builder\\'" "\\.ru\\'"
3712 "\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
3713 #+END_SRC
3714
3715 *** Config
3716 #+BEGIN_SRC emacs-lisp :tangle yes
3717 (use-package ruby-mode
3718 :mode ("\\.rb\\'" . ruby-mode)
3719 :interpreter ("ruby" . ruby-mode)
3720 :defer t
3721 :config
3722 (progn
3723 (use-package yari
3724 :init
3725 (progn
3726 (defvar yari-helm-source-ri-pages
3727 '((name . "RI documentation")
3728 (candidates . (lambda () (yari-ruby-obarray)))
3729 (action ("Show with Yari" . yari))
3730 (candidate-number-limit . 300)
3731 (requires-pattern . 2)
3732 "Source for completing RI documentation."))
3733
3734 (defun helm-yari (&optional rehash)
3735 (interactive (list current-prefix-arg))
3736 (when current-prefix-arg (yari-ruby-obarray rehash))
3737 (helm 'yari-helm-source-ri-pages (yari-symbol-at-point)))))
3738
3739 (defun my-ruby-smart-return ()
3740 (interactive)
3741 (when (memq (char-after) '(?\| ?\" ?\'))
3742 (forward-char))
3743 (call-interactively 'newline-and-indent))
3744
3745 (use-package ruby-hash-syntax
3746 :ensure ruby-hash-syntax)
3747
3748 (use-package inf-ruby
3749 :ensure inf-ruby
3750 :commands inf-ruby-minor-mode
3751 :init
3752 (progn
3753 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)
3754 (bind-key "<return>" 'my-ruby-smart-return ruby-mode-map)
3755 ;(bind-key "<tab>" 'indent-for-tab-command ruby-mode-map)
3756
3757
3758 (set (make-local-variable 'yas-fallback-behavior)
3759 '(apply ruby-indent-command . nil))
3760 (bind-key "<tab>" 'yas-expand-from-trigger-key ruby-mode-map)))
3761
3762 ;; Stupidly the non-bundled ruby-mode isn't a derived mode of
3763 ;; prog-mode: we run the latter's hooks anyway in that case.
3764 (add-hook 'ruby-mode-hook
3765 (lambda ()
3766 (unless (derived-mode-p 'prog-mode)
3767 (run-hooks 'prog-mode-hook))))
3768 ))
3769 #+END_SRC
3770 ** sessions :FIXME:
3771 [2013-05-22 Wed 22:40]
3772 Save and restore the desktop
3773 #+BEGIN_SRC emacs-lisp :tangle yes
3774 (setq desktop-path (list jj-cache-dir))
3775 (desktop-save-mode 1)
3776 (defadvice desktop-read (around trace-desktop-errors activate)
3777 (let ((debug-on-error t))
3778 ad-do-it))
3779
3780 ;;----------------------------------------------------------------------------
3781 ;; Restore histories and registers after saving
3782 ;;----------------------------------------------------------------------------
3783 (use-package session
3784 :if (not noninteractive)
3785 :load-path "site-lisp/session/lisp/"
3786 :init
3787 (progn
3788 (setq session-save-file (expand-file-name "session" jj-cache-dir))
3789 (setq desktop-globals-to-save
3790 (append '((extended-command-history . 30)
3791 (file-name-history . 100)
3792 (grep-history . 30)
3793 (compile-history . 30)
3794 (minibuffer-history . 50)
3795 (query-replace-history . 60)
3796 (read-expression-history . 60)
3797 (regexp-history . 60)
3798 (regexp-search-ring . 20)
3799 (search-ring . 20)
3800 (comint-input-ring . 50)
3801 (shell-command-history . 50)
3802 kill-ring
3803 desktop-missing-file-warning
3804 tags-file-name
3805 register-alist)))
3806
3807 (session-initialize)
3808
3809 (defun remove-session-use-package-from-settings ()
3810 (when (string= (file-name-nondirectory (buffer-file-name)) "settings.el")
3811 (save-excursion
3812 (goto-char (point-min))
3813 (when (re-search-forward "^ '(session-use-package " nil t)
3814 (delete-region (line-beginning-position)
3815 (1+ (line-end-position)))))))
3816
3817 (add-hook 'before-save-hook 'remove-session-use-package-from-settings)
3818
3819 ;; expanded folded secitons as required
3820 (defun le::maybe-reveal ()
3821 (when (and (or (memq major-mode '(org-mode outline-mode))
3822 (and (boundp 'outline-minor-mode)
3823 outline-minor-mode))
3824 (outline-invisible-p))
3825 (if (eq major-mode 'org-mode)
3826 (org-reveal)
3827 (show-subtree))))
3828
3829 (add-hook 'session-after-jump-to-last-change-hook
3830 'le::maybe-reveal)
3831
3832 (defun save-information ()
3833 (with-temp-message "Saving Emacs information..."
3834 (recentf-cleanup)
3835
3836 (loop for func in kill-emacs-hook
3837 unless (memq func '(exit-gnus-on-exit server-force-stop))
3838 do (funcall func))
3839
3840 (unless (or noninteractive
3841 (eq 'listen (process-status server-process)))
3842 (server-start))))
3843
3844 (run-with-idle-timer 300 t 'save-information)
3845
3846 (if window-system
3847 (add-hook 'after-init-hook 'session-initialize t))))
3848
3849 #+END_SRC
3850 *** savehist
3851 [2013-04-21 So 20:25]
3852 Save a bit of history
3853 #+BEGIN_SRC emacs-lisp tangle no
3854 (require 'savehist)
3855 (setq savehist-additional-variables
3856 '(search ring regexp-search-ring kill-ring compile-history))
3857 ;; save every minute
3858 (setq savehist-autosave-interval 60)
3859 (setq savehist-file (expand-file-name "savehist" jj-cache-dir))
3860 (savehist-mode +1)
3861 #+END_SRC
3862
3863 *** saveplace
3864 Store at which point I have been in files.
3865 #+BEGIN_SRC emacs-lisp :tangle yes
3866 (setq-default save-place t)
3867 (require 'saveplace)
3868 (setq save-place-file (expand-file-name "saved-places" jj-cache-dir))
3869 #+END_SRC
3870
3871 ** sh
3872 Settings for shell scripts
3873 #+BEGIN_SRC emacs-lisp :tangle yes
3874 (use-package sh-script
3875 :defer t
3876 :config
3877 (progn
3878 (defvar sh-script-initialized nil)
3879 (defun initialize-sh-script ()
3880 (unless sh-script-initialized
3881 (setq sh-script-initialized t)
3882 (setq sh-indent-comment t)
3883 (info-lookup-add-help :mode 'shell-script-mode
3884 :regexp ".*"
3885 :doc-spec
3886 '(("(bash)Index")))))
3887
3888 (add-hook 'shell-mode-hook 'initialize-sh-script)))
3889 #+END_SRC
3890 ** sh-toggle
3891 #+BEGIN_SRC emacs-lisp :tangle yes
3892 (use-package sh-toggle
3893 :bind ("C-. C-z" . shell-toggle))
3894 #+END_SRC
3895 ** timestamp
3896 By default, Emacs can update the time stamp for the following two
3897 formats if one exists in the first 8 lines of the file.
3898 - Time-stamp: <>
3899 - Time-stamp: " "
3900 #+BEGIN_SRC emacs-lisp :tangle yes
3901 (use-package time-stamp
3902 :commands time-stamp
3903 :init
3904 (progn
3905 (add-hook 'write-file-hooks 'time-stamp)
3906 (setq time-stamp-active t))
3907 :config
3908 (progn
3909 (setq time-stamp-format "%02H:%02M:%02S (%z) - %02d.%02m.%:y from %u (%U) on %s")
3910 (setq time-stamp-old-format-warn nil)
3911 (setq time-stamp-time-zone nil)))
3912 #+END_SRC
3913
3914 ** tiny-tools
3915 We configure only a bit of the tiny-tools to load when I should need
3916 them. I don't need much actually, but these things are nice to have.
3917
3918 #+BEGIN_SRC emacs-lisp :tangle yes
3919 (autoload 'turn-on-tinyperl-mode "tinyperl" "" t)
3920 (add-hook 'perl-mode-hook 'turn-on-tinyperl-mode)
3921 (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode)
3922
3923 (autoload 'tinycomment-indent-for-comment "tinycomment" "" t)
3924 (autoload 'tinyeat-forward-preserve "tinyeat" "" t)
3925 (autoload 'tinyeat-backward-preserve "tinyeat" "" t)
3926 (autoload 'tinyeat-kill-line-backward "tinyeat" "" t)
3927 #+END_SRC
3928 *** Keyboard changes for tiny-tools
3929 #+BEGIN_SRC emacs-lisp :tangle yes
3930 (bind-key "\M-;" 'tinycomment-indent-for-comment)
3931 (bind-key "ESC C-k" 'tinyeat-kill-line-backward)
3932 (bind-key "ESC d" 'tinyeat-forward-preserve)
3933 (bind-key "<M-backspace>" 'tinyeat-backward-preserve)
3934 (bind-key "<S-backspace>" 'tinyeat-delete-whole-word)
3935 #+END_SRC
3936 ** tramp
3937 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
3938 #+BEGIN_SRC emacs-lisp :tangle yes
3939 (use-package tramp
3940 :defer t
3941 :config
3942 (progn
3943 (setq tramp-persistency-file-name (expand-file-name "tramp" jj-cache-dir))
3944 (setq shell-prompt-pattern "^[^a-zA-Z].*[#$%>] *")
3945 (add-to-list 'tramp-default-method-alist '("\\`localhost\\'" "\\`root\\'" "su")
3946 )
3947 (setq tramp-debug-buffer nil)
3948 (setq tramp-default-method "sshx")
3949 (tramp-set-completion-function "ssh"
3950 '((tramp-parse-sconfig "/etc/ssh_config")
3951 (tramp-parse-sconfig "~/.ssh/config")))
3952 (setq tramp-verbose 5)
3953 ))
3954 #+END_SRC
3955
3956 ** transient mark
3957 For some reason I prefer this mode more than the way without. I want to
3958 see the marked region.
3959 #+BEGIN_SRC emacs-lisp :tangle yes
3960 (transient-mark-mode 1)
3961 #+END_SRC
3962 ** undo-tree
3963 [2013-04-21 So 11:07]
3964 Emacs undo is pretty powerful - but can also be confusing. There are
3965 tons of modes available to change it, even downgrade it to the very
3966 crappy ways one usually knows from other systems which lose
3967 information. undo-tree is different - it helps keeping you sane while
3968 keeping the full power of emacs undo/redo.
3969 #+BEGIN_SRC emacs-lisp :tangle yes
3970 (use-package undo-tree
3971 :ensure undo-tree
3972 :init
3973 (global-undo-tree-mode)
3974 :diminish undo-tree-mode)
3975 #+END_SRC
3976
3977 Additionally I would like to keep the region active should I undo
3978 while I have one.
3979
3980 #+BEGIN_SRC emacs-lisp :tangle yes
3981 ;; Keep region when undoing in region
3982 (defadvice undo-tree-undo (around keep-region activate)
3983 (if (use-region-p)
3984 (let ((m (set-marker (make-marker) (mark)))
3985 (p (set-marker (make-marker) (point))))
3986 ad-do-it
3987 (goto-char p)
3988 (set-mark m)
3989 (set-marker p nil)
3990 (set-marker m nil))
3991 ad-do-it))
3992 #+END_SRC
3993 ** uniquify
3994 Always have unique buffernames. See [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html][Uniquify - GNU Emacs Manual]]
3995 #+BEGIN_SRC emacs-lisp :tangle yes
3996 (use-package uniquify
3997 :init
3998 (progn
3999 (setq uniquify-buffer-name-style 'post-forward)
4000 (setq uniquify-after-kill-buffer-p t)
4001 (setq uniquify-ignore-buffers-re "^\\*")))
4002 #+END_SRC
4003
4004 ** url
4005 url contains code to parse and handle URLs - who would have thought? I
4006 set it to send Accept-language header and tell it to not send email,
4007 operating system or location info.
4008 #+BEGIN_SRC emacs-lisp :tangle yes
4009 (setq url-mime-language-string "de,en")
4010 (setq url-privacy-level (quote (email os lastloc)))
4011 #+END_SRC
4012 ** visual-regexp
4013 [2014-06-01 Sun 21:38]
4014 visual-regexp for Emacs is like replace-regexp, but with live visual
4015 feedback directly in the buffer
4016 #+BEGIN_SRC emacs-lisp :tangle yes
4017 (use-package visual-regexp
4018 :ensure visual-regexp
4019 :bind (("C-M-%" . vr/replace)
4020 ("M-%" . vr/query-replace)
4021 ("C-c m" . vr/mc-mark))
4022 :defer t)
4023 #+END_SRC
4024 ** volatile highlights
4025 [2013-04-21 So 20:31]
4026 VolatileHighlights highlights changes to the buffer caused by commands
4027 such as ‘undo’, ‘yank’/’yank-pop’, etc. The highlight disappears at the
4028 next command. The highlighting gives useful visual feedback for what
4029 your operation actually changed in the buffer.
4030 #+BEGIN_SRC emacs-lisp :tangle yes
4031 (use-package volatile-highlights
4032 :ensure volatile-highlights
4033 :init
4034 (volatile-highlights-mode t)
4035 :diminish volatile-highlights-mode)
4036 #+END_SRC
4037 ** writegood
4038 This highlights some /weaselwords/, a mode to /aid in finding common
4039 writing problems/...
4040 [2013-04-27 Sa 23:29]
4041 #+BEGIN_SRC emacs-lisp :tangle no
4042 (use-package writegood-mode
4043 :ensure writegood-mode
4044 :defer t
4045 :init
4046 (bind-key "C-c g" 'writegood-mode))
4047 #+END_SRC
4048 ** web-mode
4049 [2014-06-01 Sun 22:48]
4050 #+BEGIN_SRC emacs-lisp :tangle yes
4051 (use-package web-mode
4052 :ensure web-mode
4053 :mode (("\\.phtml\\'" . web-mode)
4054 ("\\.tpl\\.php\\'" . web-mode)
4055 ("\\.jsp\\'" . web-mode)
4056 ("\\.as[cp]x\\'" . web-mode)
4057 ("\\.erb\\'" . web-mode)
4058 ("\\.mustache\\'" . web-mode)
4059 ("\\.html\\'" . web-mode)
4060 ("\\.djhtml\\'" . web-mode))
4061 :init
4062 (progn
4063 (add-hook 'web-mode-hook
4064 (lambda ()
4065 (setq web-mode-markup-indent-offset 2)
4066 (setq web-mode-css-indent-offset 2)
4067 (setq web-mode-code-indent-offset 2)
4068 (setq web-mode-enable-css-colorization t)
4069 (setq web-mode-enable-comment-keywords t)
4070 (setq web-mode-enable-current-element-highlight t)))))
4071
4072 #+END_SRC
4073 ** yafolding
4074 Yet another folding extension for the Emacs editor. Unlike many
4075 others, this one works by just using the existing indentation of the
4076 file, so basically works in every halfway structured file.
4077 #+BEGIN_SRC emacs-lisp :tangle yes
4078 (use-package yafolding
4079 :bind (("C-#" . yafolding)
4080 ("C-c C-f" . yafolding-toggle-all-by-current-level))
4081 :commands (yafolding yafolding-toggle-all-by-current-level)
4082 )
4083 #+END_SRC
4084 ** yaml-mode
4085 [2013-04-28 So 01:13]
4086 YAML is a nice format for data, which is both, human and machine
4087 readable/editable without getting a big headache.
4088 #+BEGIN_SRC emacs-lisp :tangle yes
4089 (use-package yaml-mode
4090 :ensure yaml-mode
4091
4092 :mode ("\\.ya?ml\\'" . yaml-mode)
4093 :config
4094 (bind-key "C-m" 'newline-and-indent yaml-mode-map ))
4095 #+END_SRC
4096
4097 ** yasnippet
4098 [2013-04-27 Sa 23:16]
4099 Yasnippet is a template system. Type an abbreviation, expand it into
4100 whatever the snippet holds.
4101 #+BEGIN_SRC emacs-lisp :tangle yes
4102 (setq yas-snippet-dirs (expand-file-name "yasnippet/snippets" jj-elisp-dir))
4103 (use-package yasnippet
4104 :ensure yasnippet
4105 :init
4106 (progn
4107 (yas-global-mode 1)
4108 ;; Integrate hippie-expand with ya-snippet
4109 (add-to-list 'hippie-expand-try-functions-list
4110 'yas-hippie-try-expand)
4111 ))
4112 #+END_SRC
4113 * Thats it
4114 And thats it for this file, control passes "back" to [[file:../initjj.org][initjj.org/el]]
4115 which then may load more files.