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