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