b1a82f4990c8c9502b7d661f0bdcdcfd652cf9bb
[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 #+DATE: %Y-%m-%d
6 #+SETUPFILE: ~/.emacs.d/elisp/org-templates/level-0.org
7 #+LATEX_CMD: xelatex
8
9 * Notes for people looking at this using a webbrowser
10 My whole emacs config is done using [[http://orgmode.org/][org-mode]] files, with a little magic
11 in ~/.emacs.d/init.el to have it readable for emacs.
12
13 I publish them using the [[http://orgmode.org/manual/HTML-export.html#HTML-export][HTML export feature]] of org-mode, combined with
14 a javascript [[http://orgmode.org/worg/code/org-info-js/][called org-info.js]] which lets you navigate my config
15 similar to what org-mode allows you in Emacs.
16
17 Basic navigation is =n= for next, =p= for previous, =l= will give you
18 a direct link to the point you are at and the key =?= will show you a
19 help with all keyboard shortcuts. You might also want to try pressing
20 =m= followed by a series of =F=.
21
22 If you have Javascript disabled you only miss the nice navigation, you
23 will see the whole file at once.
24
25
26 * Copyright notice(s)
27 My config is made up of stuff I wrote myself - and lots of stuff I
28 copied from all around the net. I try to list all of the original
29 authors here, but this config is a living thing for more than a decade
30 now, so there are things where I just don't know anymore where it might
31 be from.
32
33 If you find something that you are the author off and I forgot to
34 mention you don't hesitate to tell me and I will fix that oversight.
35
36 ** My own stuff
37 ----------
38 #+BEGIN_QUOTE
39 Copyright © 200x-2012 Joerg Jaspert <joerg@ganneff.de>
40
41 My code in this document is free software: you can redistribute it
42 and/or modify it under the terms of the [[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html][GNU General Public License]]
43 as published by the Free Software Foundation, version 2.0.
44
45 My writing here is subject to the [[http://creativecommons.org/licenses/by-nc-sa/3.0/][CC —
46 Attribution-NonCommercial-ShareAlike 3.0 Unported — CC BY-NC-SA 3.0]]
47 license.
48 #+END_QUOTE
49 ----------
50
51 ** Sacha Chua
52 I copied various functions and snippets from [[http://sachachua.com/blog/category/emacs/][Sacha Chuas blog]] (worth a
53 read). Her copyright/license notice:
54
55 ----------
56 #+BEGIN_QUOTE
57 Copyright © 2001-2012 Sacha Chua (sacha@sachachua.com).
58
59 Please feel free to reuse content under a [[http://creativecommons.org/licenses/by-nc-sa/3.0/][Creative Commons —
60 Attribution-NonCommercial-ShareAlike Unported — CC BY-NC-SA]] license
61 unless otherwise noted.
62 #+END_QUOTE
63 ----------
64
65 Functions copied from her start with /sacha//.
66
67 ** Bernt Hansen
68 Much of my org-mode setup is copied from [[http://doc.norang.ca/org-mode.html][Bernt Hansens org-mode
69 page]]. His license statement:
70
71 ----------
72 #+BEGIN_QUOTE
73 Copyright (C) 2012 Bernt Hansen.
74
75 Permission is granted to copy, distribute and/or modify this document
76 under the terms of the GNU Free Documentation License, Version 1.3
77 or any later version published by the Free Software Foundation;
78 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
79
80 Code in this document is free software: you can redistribute it
81 and/or modify it under the terms of the GNU General Public
82 License as published by the Free Software Foundation, either
83 version 3 of the License, or (at your option) any later version.
84
85 This code is distributed in the hope that it will be useful,
86 but WITHOUT ANY WARRANTY; without even the implied warranty of
87 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88 GNU General Public License for more details.
89 #+END_QUOTE
90 ----------
91
92 Functions copied from him start with /bh//.
93
94 ** Roland Mas
95 I copied a few functions for my [[file:gnus.org][gnus]] setup from [[http://roland.entierement.nu/blog/2010/09/08/gnus-dovecot-offlineimap-search-a-howto.html][his blog]] that enable me to
96 use notmuch and gnus together. His license statement:
97
98 ----------
99 #+BEGIN_QUOTE
100 [[http://creativecommons.org/licenses/by-nc-sa/2.0/fr/][Creative Commons — Attribution - Pas d'Utilisation
101 Commerciale - Partage dans les Mêmes Conditions 2.0 France — CC BY-NC-SA
102 2.0]] Sauf indication contraire, le contenu de ce site est mis à
103 disposition sous un contrat Creative Commons.
104 #+END_QUOTE
105 ----------
106
107 In case you are as good in french as I am, that should be equal to:
108 ----------
109 #+BEGIN_QUOTE
110 Please feel free to reuse content under a [[http://creativecommons.org/licenses/by-nc-sa/2.0/][Creative Commons —
111 Attribution-NonCommercial-ShareAlike Unported — CC BY-NC-SA]] license
112 unless otherwise noted.
113 #+END_QUOTE
114 ----------
115
116 ** Emacs Prelude
117 #+BEGIN_QUOTE
118 Prelude is an enhanced Emacs 24 configuration that should make your
119 experience with Emacs both more pleasant and more powerful. Prelude
120 alters a lot of the default settings, bundles a plethora of additional
121 packages and adds its own core library to the mix. The final product
122 offers an easy to use Emacs configuration for Emacs newcomers and lots
123 of additional power for Emacs power users.
124 #+END_QUOTE
125
126 So much for their own advertisement, and while I agree it is a pretty
127 nice configuration, I only like parts of it. Especially as I am forced
128 to use older emacs too (prelude requires emacs24), and I also like to
129 do stuff on my own...
130
131 Anything copied from prelude should start with prelude-, and their
132 license statement is:
133
134 ----------
135 #+BEGIN_QUOTE
136 Copyright © 2011-2013 Bozhidar Batsov
137
138 Author: Bozhidar Batsov <bozhidar@batsov.com>
139 URL: https://github.com/bbatsov/prelude
140 This program is free software; you can redistribute it and/or
141 modify it under the terms of the GNU General Public License
142 as published by the Free Software Foundation; either version 3
143 of the License, or (at your option) any later version.
144 #+END_QUOTE
145 ----------
146
147 You should be able to find a full list of contributors at
148 [[https://github.com/bbatsov/prelude/graphs/contributors][their github]] pages.
149
150
151 * Initial preparation
152 To have my config here actually work, =emacs= needs a little help. For
153 some reason it can't just read an =org-mode= based config on its own, tsk.
154
155 Which means that the emacs initfile needs to have the magic. My init
156 file is =~/.emacs.d/init.el=. I try to keep it as small as possible, yet
157 it does have some entries.
158
159 As I commented inside that file, I won't repeat stuff here, just read it
160 below.
161
162 #+INCLUDE: "~/.emacs.d/init.el" src emacs-lisp
163 #+INCLUDE: "~/.emacs.d/initjj.org"
164
165
166
167 * Basic config
168 ** General functions
169 :PROPERTIES:
170 :ID: b6e6cf73-9802-4a7b-bd65-fdb6f9745319
171 :END:
172 The following functions are used throughout my config, and so I load
173 them first.
174
175 safe-load does not break emacs initialization, should a file be
176 unreadable while emacs boots up.
177 #+BEGIN_SRC emacs-lisp
178 (defvar safe-load-error-list ""
179 "*List of files that reported errors when loaded via safe-load")
180
181 (defun safe-load (file &optional noerror nomessage nosuffix)
182 "Load a file. If error on load, report back, wait for
183 a key stroke then continue on"
184 (interactive "f")
185 (condition-case nil (load file noerror nomessage nosuffix)
186 (error
187 (progn
188 (setq safe-load-error-list (concat safe-load-error-list " " file))
189 (message "****** [Return to continue] Error loading %s" safe-load-error-list )
190 (sleep-for 1)
191 nil))))
192
193 (defun safe-load-check ()
194 "Check for any previous safe-load loading errors. (safe-load.el)"
195 (interactive)
196 (if (string-equal safe-load-error-list "") ()
197 (message (concat "****** error loading: " safe-load-error-list))))
198 #+END_SRC
199
200 match-paren will either jump to the "other" paren or simply insert %
201 #+BEGIN_SRC emacs-lisp
202 (defun match-paren (arg)
203 "Go to the matching parenthesis if on parenthesis otherwise insert %."
204 (interactive "p")
205 (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
206 ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
207 (t (self-insert-command (or arg 1)))))
208 #+END_SRC
209
210 I have some stuff put away in my local dir. I don't want to load it all
211 at startup time, so it is using the autoload feature. For that to work
212 load the loaddefs, so autoload knows where to grab stuff
213 #+BEGIN_SRC emacs-lisp
214 (load-file (concat jj-elisp-dir "/tiny/loaddefs.el"))
215 (load-file (concat jj-elisp-local-dir "/loaddefs.el"))
216 #+END_SRC
217
218
219 Always ensure to have a scratch buffer around.
220 #+BEGIN_SRC emacs-lisp
221 (save-excursion
222 (set-buffer (get-buffer-create "*scratch*"))
223 (lisp-interaction-mode)
224 (make-local-variable 'kill-buffer-query-functions)
225 (add-hook 'kill-buffer-query-functions 'kill-scratch-buffer))
226 #+END_SRC
227
228 Helpers for the config
229 #+BEGIN_SRC emacs-lisp
230 (require 'use-package)
231 (require 'bind-key)
232 #+END_SRC
233
234 ** Path settings
235 *** Load path
236 We need to define the load-path. As I have lots of things I add
237 locally, its getting a few entries. I only leave out org-mode here, as
238 that is already done in =init.el=.
239
240 I also disliked the repeated /add-to-list/ lines, so I now just have
241 one variable and go over that in a loop.
242 #+BEGIN_SRC emacs-lisp
243 (defvar jj-elisp-subdirs '(local gnus icicle org/contrib tiny mo-git-blame cedet
244 cedet/eieio ecb jdee/lisp sunrise multiple-cursors
245 auto-complete yasnippet magit)
246 "List of subdirectories in jj-elisp-dir to add to load-path")
247
248 (let (dirval)
249 (dolist (dirval jj-elisp-subdirs)
250 (let ((name (expand-file-name (symbol-name dirval) jj-elisp-dir)))
251 (when (file-exists-p name)
252 (add-to-list 'load-path name)))))
253 ;; For older emacsen we need an extra directory, which should be at
254 ;; THE END of the load path
255 (when (< emacs-major-version 24)
256 (add-to-list 'load-path (expand-file-name "emacs23" jj-elisp-dir) t))
257
258 #+END_SRC
259
260 *** Info path
261 Help emacs to find the info files
262 #+BEGIN_SRC emacs-lisp
263 (setq Info-directory-list '("~/emacs/info"
264 "/usr/local/share/info/"
265 "/usr/local/info/"
266 "/usr/local/gnu/info/"
267 "/usr/local/gnu/lib/info/"
268 "/usr/local/gnu/lib/emacs/info/"
269 "/usr/local/emacs/info/"
270 "/usr/local/lib/info/"
271 "/usr/local/lib/emacs/info/"
272 "/usr/share/info/emacs-23"
273 "/usr/share/info/"
274 "/usr/share/info/"))
275 (setq Info-default-directory-list
276 (cons "~/emacs/info" Info-default-directory-list))
277 #+END_SRC
278
279 ** Interface related
280 *** General stuff
281 :PROPERTIES:
282 :ID: 0a1560d9-7e55-47ab-be52-b3a8b8eea4aa
283 :END:
284 I dislike the startup message
285 #+BEGIN_SRC emacs-lisp
286 (setq inhibit-splash-screen t)
287 (setq inhibit-startup-message t)
288 #+END_SRC
289
290 Usually I want the lines to break at 72 characters.
291 #+BEGIN_SRC emacs-lisp
292 (if (> emacs-major-version 22)
293 (setq fill-column 72)
294 (setq default-fill-column 72))
295 #+END_SRC
296
297 And it is nice to have a final newline in files.
298 #+BEGIN_SRC emacs-lisp
299 (setq require-final-newline t)
300 #+END_SRC
301
302 After I typed 300 characters or took a break for more than a minute it
303 would be nice of emacs to save whatever I am on in one of its auto-save
304 backups. See [[info:emacs#Auto%20Save%20Control][info:emacs#Auto Save Control]] for more details.
305 #+BEGIN_SRC emacs-lisp
306 (setq auto-save-interval 300)
307 (setq auto-save-timeout 60)
308 #+END_SRC
309
310 Set my full name and my default mail address - for whatever wants to use
311 it later. Also, I am using gnus.
312 #+BEGIN_SRC emacs-lisp
313 (setq user-full-name "Joerg Jaspert")
314 (setq user-mail-address "joerg@ganneff.de")
315 (setq mail-user-agent (quote gnus-user-agent))
316 #+END_SRC
317
318 My default mail server. Well, simply a localhost, I have a forwarder that
319 puts mail off the right way, no need for emacs to have any further
320 knowledge here.
321 #+BEGIN_SRC emacs-lisp
322 (setq smtpmail-default-smtp-server "localhost")
323 (setq smtpmail-smtp-server "localhost")
324 #+END_SRC
325
326 Enable automatic handling of compressed files.
327 #+BEGIN_SRC emacs-lisp
328 (auto-compression-mode 1)
329 #+END_SRC
330
331 Emacs forbids a certain set of commands, as they can be very confusing
332 for new users. Enable them.
333 #+BEGIN_SRC emacs-lisp
334 (put 'narrow-to-region 'disabled nil)
335 (put 'narrow-to-page 'disabled nil)
336 (put 'narrow-to-defun 'disabled nil)
337 (put 'upcase-region 'disabled nil)
338 (put 'downcase-region 'disabled nil)
339 #+END_SRC
340
341 *** Look / Theme
342 I've tried various different fonts and while I like the Terminus font
343 most for my shells, in Emacs Inconsolata clearly wins.
344 #+BEGIN_SRC emacs-lisp
345 (if (> emacs-major-version 22)
346 (set-frame-font "Inconsolata-14")
347 (set-default-font "Inconsolata-14"))
348 #+END_SRC
349
350 I always use dark backgrounds, so tell Emacs about it. No need to
351 guess around.
352 #+BEGIN_SRC emacs-lisp
353 (setq-default frame-background-mode 'dark)
354 #+END_SRC
355
356 And I always liked dark backgrounds with colors setup for them. So I
357 switched through multiple themes doing it in emacs too, but never
358 entirely liked it. Until I found solarized, which is now not only my
359 emacs theme, but also for most of my other software too, especially my
360 shell. Consistent look is great.
361 #+BEGIN_SRC emacs-lisp
362 (if (boundp 'custom-theme-load-path)
363 (progn
364 (defun jj-init-theme ()
365 (interactive)
366 (if (eq jj-color-style 'dark )(load-theme 'solarized-dark t)
367 (load-theme 'solarized-light t))
368 (set-face-attribute 'org-date nil :underline nil)
369 )
370 (add-to-list 'custom-theme-load-path jj-theme-dir)
371 (add-hook 'after-init-hook 'jj-init-theme)
372 )
373 (message "Emacs version too old, using non-solarize theme")
374 (defvar custom-theme-load-path jj-theme-dir)
375 (require 'naquadah-theme))
376 #+END_SRC
377
378 Make the fringe (gutter) smaller, the argument is a width in pixels (the default is 8)
379 #+BEGIN_SRC emacs-lisp
380 (if (fboundp 'fringe-mode)
381 (fringe-mode 4))
382 #+END_SRC
383
384 *** Cursor changes
385 [2013-04-21 So 20:54]
386 I do not want my cursor to blink.
387 #+BEGIN_SRC emacs-lisp
388 (blink-cursor-mode -1)
389 #+END_SRC
390 *** Menu, Tool and Scrollbar
391 I don't want to see the menu-bar, tool-bar or scrollbar.
392 #+BEGIN_SRC emacs-lisp
393 (when window-system
394 (menu-bar-mode -1)
395 (tool-bar-mode -1)
396 (set-scroll-bar-mode nil))
397 #+END_SRC
398 **** When using emacs in daemon mode
399 Emacs has a very nice mode where it detaches itself and runs as daemon -
400 and you can just open /frames/ (windows) from it by using [[http://www.emacswiki.org/emacs/EmacsClient][Emacs
401 Client]]. It's fast, it's nice, it's convinient.
402
403 Except that Emacs behaves stupid when you do that and ignores your
404 menu/tool/scrollbar settings. Sucks.
405
406 For them to work even then, we have to do two things.
407 1. We have to set the frame alist. We simple set both,
408 =initial-frame-alist= and =default-frame-alist= to the same value here.
409 #+BEGIN_SRC emacs-lisp
410 (setq initial-frame-alist '(
411 (horizontal-scroll-bars . nil)
412 (vertical-scroll-bars . nil)
413 (menu-bar-lines . 0)
414 ))
415 (setq default-frame-alist (copy-alist initial-frame-alist))
416 #+END_SRC
417 2. We have to disable the toolbar using the customize interface, so you
418 can find that in the [[id:0102208d-fdf6-4928-9e40-7e341bd3aa3a][Customized variables]] section.
419
420 *** Hilight current line in buffer
421 As it says, it does a hilight of the current line.
422 #+BEGIN_SRC emacs-lisp
423 (global-hl-line-mode +1)
424 #+END_SRC
425 *** Allow recursive minibuffers
426 This allows (additional) minibuffer commands while in the minibuffer.
427 #+BEGIN_SRC emacs-lisp
428 (setq enable-recursive-minibuffers 't)
429 #+END_SRC
430
431 *** Modeline related changes
432 I want to see line and column numbers, so turn them on.
433 Size indication lets me know how far I am in a buffer.
434
435 And modeline-posn is great. It will hilight the column number in the
436 modeline in red as soon as you are over the defined limit.
437
438 #+BEGIN_SRC emacs-lisp
439 (line-number-mode 1)
440 (column-number-mode 1)
441 (size-indication-mode 1)
442 (display-time-mode 1)
443 (setq display-time-day-and-date nil)
444 (setq display-time-24hr-format t)
445 (setq modelinepos-column-limit 72)
446
447 (require 'modeline-posn)
448 (set-face-foreground 'modelinepos-column-warning "grey20")
449 (set-face-background 'modelinepos-column-warning "red")
450 #+END_SRC
451 **** diminish
452 [2013-04-22 Mon 11:27]
453 The modeline is easily cluttered up with stuff I don't really need to
454 see. So lets hide those. There are two ways, one of them uses diminish
455 to get entirely rid of some modes, the other is a function taken from
456 "Mastering Emacs" which replaces the modes text with an own (set of)
457 character(s).
458 #+BEGIN_SRC emacs-lisp
459 (require 'diminish)
460 (diminish 'auto-fill-function)
461 (defvar mode-line-cleaner-alist
462 `((auto-complete-mode . " α")
463 (yas-minor-mode . " y")
464 (paredit-mode . " π")
465 (eldoc-mode . "")
466 (abbrev-mode . "")
467 ;; Major modes
468 (lisp-interaction-mode . "λ")
469 (hi-lock-mode . "")
470 (python-mode . "Py")
471 (emacs-lisp-mode . "EL")
472 (org-mode . "Ω")
473 (org-indent-mode . "")
474 (sh-mode . " Σ")
475 (nxhtml-mode . "nx"))
476
477 "Alist for `clean-mode-line'.
478
479 When you add a new element to the alist, keep in mind that you
480 must pass the correct minor/major mode symbol and a string you
481 want to use in the modeline *in lieu of* the original.
482
483 Want some symbols? Go:
484
485 ;ςερτζθιοπασδφγηξκλυχψωβνμ
486 :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
487 @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
488 ☃⌕☥
489 ")
490
491 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
492
493 #+END_SRC
494 Unfortunately icicles breaks this with the way it adds/removes itself,
495 so take it our for now...
496
497 *** Default mode
498 Back when I started with text-mode. But nowadays I want default mode to
499 be org-mode - it is just so much better to use. And does sensible things
500 with many README files out there, and various other "crap" you get to
501 read in emacs.
502 #+BEGIN_SRC emacs-lisp
503 (if (> emacs-major-version 22)
504 (setq major-mode 'org-mode)
505 (setq default-major-mode 'org-mode))
506 (setq initial-major-mode 'org-mode)
507 #+END_SRC
508
509 *** Shell
510 [2013-04-23 Tue 16:43]
511 Shell. zsh in my case.
512 #+BEGIN_SRC emacs-lisp
513 (setq shell-file-name "zsh")
514 (setq shell-command-switch "-c")
515 (setq explicit-shell-file-name shell-file-name)
516 (setenv "SHELL" shell-file-name)
517 (setq explicit-sh-args '("-login" "-i"))
518 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
519 (setq comint-scroll-to-bottom-on-input t) ; always insert at the bottom
520 (setq comint-scroll-to-bottom-on-output t) ; always add output at the bottom
521 (setq comint-scroll-show-maximum-output t) ; scroll to show max possible output
522 (setq comint-completion-autolist t) ; show completion list when ambiguous
523 (setq comint-input-ignoredups t) ; no duplicates in command history
524 (setq comint-completion-addsuffix t) ; insert space/slash after file completion
525 #+END_SRC
526
527 *** Emacs shell
528 Basic settings for emacs integrated shell
529 #+BEGIN_SRC emacs-lisp
530 (setq eshell-cmpl-cycle-completions nil
531 eshell-save-history-on-exit t
532 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
533 (eval-after-load 'esh-opt
534 '(progn
535 (require 'em-cmpl)
536 (require 'em-prompt)
537 (require 'em-term)
538 ;; TODO: for some reason requiring this here breaks it, but
539 ;; requiring it after an eshell session is started works fine.
540 ;; (require 'eshell-vc)
541 (setenv "PAGER" "cat")
542 ; (set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
543 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
544 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
545 (add-hook 'eshell-preoutput-filter-functions
546 'ansi-color-filter-apply)
547 (add-to-list 'eshell-visual-commands "ssh")
548 (add-to-list 'eshell-visual-commands "tail")
549 (add-to-list 'eshell-command-completions-alist
550 '("gunzip" "gz\\'"))
551 (add-to-list 'eshell-command-completions-alist
552 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))))
553
554 #+END_SRC
555
556 *** Isearch related
557 Incremental search is great, but annoyingly you need to type whatever
558 you want. If you want to search for just the next (or previous)
559 occurence of what is at your cursor position use the following.
560 *C-x* will insert the current word while *M-up* and *M-down* will just
561 jump to the next/previous occurence of it.
562 #+BEGIN_SRC emacs-lisp
563 (define-key isearch-mode-map (kbd "C-x") 'sacha/isearch-yank-current-word)
564 (global-set-key '[M-up] 'sacha/search-word-backward)
565 (global-set-key '[M-down] 'sacha/search-word-forward)
566 #+END_SRC
567
568 *** Frame configuration
569 I want to see the buffername and its size, not the host I am on in my
570 frame title.
571 #+BEGIN_SRC emacs-lisp
572 (setq frame-title-format "%b (%i)")
573 #+END_SRC
574
575 *** Protect some buffers
576 I don't want some buffers to be killed, **scratch** for example.
577 In the past I had a long function that just recreated them, but the
578 =keep-buffers= package is easier.
579 #+BEGIN_SRC emacs-lisp
580 (require 'keep-buffers)
581 (keep-buffers-mode 1)
582 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
583 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
584 (push '("\\`*Group" . nil) keep-buffers-protected-alist)
585 #+END_SRC
586
587 *** yes-or-no-p
588 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
589 lazy.
590 #+BEGIN_SRC emacs-lisp
591 (defalias 'yes-or-no-p 'y-or-n-p)
592 #+END_SRC
593
594 *** Language/i18n stuff
595 In this day and age, UTF-8 is the way to go.
596 #+BEGIN_SRC emacs-lisp
597 (set-language-environment 'utf-8)
598 (set-default-coding-systems 'utf-8)
599 (set-terminal-coding-system 'utf-8)
600 (set-keyboard-coding-system 'utf-8)
601 (set-clipboard-coding-system 'utf-8)
602 (prefer-coding-system 'utf-8)
603 #+END_SRC
604
605 *** Hilight matching parentheses
606 While I do have the nifty shortcut to jump to the other parentheses,
607 hilighting them makes it obvious where they are.
608 #+BEGIN_SRC emacs-lisp
609 (require 'paren)
610 (setq show-paren-style 'parenthesis)
611 (show-paren-mode +1)
612 #+END_SRC
613 *** Kill other buffers
614 While many editors allow you to close "all the other files, not the one
615 you are in", emacs doesn't have this... Except, now it will.
616 #+BEGIN_SRC emacs-lisp
617 (global-set-key (kbd "C-c k") 'prelude-kill-other-buffers)
618 #+END_SRC
619 *** Scrolling
620 Default scrolling behaviour in emacs is a bit annoying, who wants to
621 jump half-windows?
622 #+BEGIN_SRC emacs-lisp
623 (setq scroll-margin 0)
624 (setq scroll-conservatively 100000)
625 (setq scroll-up-aggressively 0.0)
626 (setq scroll-down-aggressively 0.0)
627 (setq scroll-preserve-screen-position t)
628 #+END_SRC
629
630 *** Copy/Paste with X
631 [2013-04-09 Di 23:31]
632 The default how emacs handles cutting/pasting with the primary selection
633 changed in emacs24. I am used to the old way, so get it back.
634 #+BEGIN_SRC emacs-lisp
635 (setq x-select-enable-primary t)
636 (setq x-select-enable-clipboard t ;; copy-paste should work ...
637 interprogram-paste-function ;; ...with...
638 'x-cut-buffer-or-selection-value) ;; ...other X clients
639
640 #+END_SRC
641
642 *** Global keyboard changes not directly related to a mode
643 Disable /suspend_frame/ function, I dislike it.
644 #+BEGIN_SRC emacs-lisp
645 (global-unset-key [(control z)])
646 (global-unset-key [(control x) (control z)])
647 #+END_SRC
648
649 Default of *C-k* is to kill from the point to the end of line. If
650 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
651 set, including newline. But to kill the entire line, one still needs a
652 *C-a* in front of it. So I change it, by defining a function to do just this for
653 me. Lazyness++.
654 #+BEGIN_SRC emacs-lisp
655 (defun kill-entire-line ()
656 "Kill this entire line (including newline), regardless of where point is within the line."
657 (interactive)
658 (beginning-of-line)
659 (kill-line)
660 (back-to-indentation))
661
662 (global-unset-key [(control k)])
663 (global-set-key [(control k)] 'kill-entire-line)
664 (global-set-key [remap kill-whole-line] 'kill-entire-line)
665 #+END_SRC
666
667 And the same is true when I'm in org-mode, which has an own kill function...
668 (the keybinding happens later, after org-mode is loaded fully)
669 #+BEGIN_SRC emacs-lisp
670 (defun jj-org-kill-line (&optional arg)
671 "Kill the entire line, regardless of where point is within the line, org-mode-version"
672 (interactive "P")
673 (beginning-of-line)
674 (org-kill-line arg)
675 (back-to-indentation)
676 )
677 #+END_SRC
678
679 I really hate tabs, so I don't want any indentation to try using them.
680 And in case a project really needs them, I can change it just for that
681 file/project, but luckily none of those I work in is as broken.
682 #+BEGIN_SRC emacs-lisp
683 (setq-default indent-tabs-mode nil)
684 #+END_SRC
685
686 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
687 #+BEGIN_SRC emacs-lisp
688 (global-set-key "\M-5" 'match-paren)
689 #+END_SRC
690
691 Instead of the default "mark-defun" I want a more readline-like setting.
692 #+begin_src emacs-lisp
693 (global-set-key (kbd "C-M-h") 'backward-kill-word)
694 #+end_src
695
696 Align whatever with a regexp.
697 #+begin_src emacs-lisp
698 (global-set-key (kbd "C-x \\") 'align-regexp)
699 #+end_src
700
701 Font size changes
702 #+begin_src emacs-lisp
703 (global-set-key (kbd "C-+") 'text-scale-increase)
704 (global-set-key (kbd "C--") 'text-scale-decrease)
705 #+end_src
706
707 Regexes are too useful, so use the regex search by default.
708 #+begin_src emacs-lisp
709 (global-set-key (kbd "C-s") 'isearch-forward-regexp)
710 (global-set-key (kbd "\C-r") 'isearch-backward-regexp)
711 (global-set-key (kbd "C-M-s") 'isearch-forward)
712 (global-set-key (kbd "C-M-r") 'isearch-backward)
713 #+end_src
714
715 Rgrep is infinitely useful in multi-file projects.
716 #+begin_src emacs-lisp
717 (define-key global-map "\C-x\C-g" 'rgrep)
718 #+end_src
719
720 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
721 AKA transpose lines.
722 #+BEGIN_SRC emacs-lisp
723 (global-set-key [(meta shift up)] 'move-line-up)
724 (global-set-key [(meta shift down)] 'move-line-down)
725 #+END_SRC
726
727 "Pull" lines up, join them
728 #+BEGIN_SRC emacs-lisp
729 (global-set-key (kbd "M-j")
730 (lambda ()
731 (interactive)
732 (join-line -1)))
733 #+END_SRC
734
735 When I press Enter I almost always want to go to the right indentation on the next line.
736 #+BEGIN_SRC emacs-lisp
737 (global-set-key (kbd "RET") 'newline-and-indent)
738 #+END_SRC
739
740 Easier undo, and i don't need suspend-frame
741 #+BEGIN_SRC emacs-lisp
742 (global-set-key (kbd "C-z") 'undo)
743 #+END_SRC
744
745 Window switching, go backwards. (C-x o goes to the next window)
746 #+BEGIN_SRC emacs-lisp
747 (global-set-key (kbd "C-x O") (lambda ()
748 (interactive)
749 (other-window -1)))
750 #+END_SRC
751
752 Edit file as root
753 #+BEGIN_SRC emacs-lisp
754 (global-set-key (kbd "C-x C-r") 'prelude-sudo-edit)
755 #+END_SRC
756
757 M-space is bound to just-one-space, which is great for programming. What
758 it does is remove all spaces around the cursor, except for one. But to
759 be really useful, it also should include newlines. It doesn’t do this by
760 default. Rather, you have to call it with a negative argument. Sure
761 not, bad Emacs.
762 #+BEGIN_SRC emacs-lisp
763 (global-set-key (kbd "M-SPC") 'just-one-space-with-newline)
764 #+END_SRC
765
766 Count which commands I use how often.
767 #+BEGIN_SRC emacs-lisp
768 (defvar keyfreq-file
769 (expand-file-name "keyfreq" jj-cache-dir)
770 "Keyfreq cache file")
771 (defvar keyfreq-file-lock
772 (expand-file-name "keyfreq.lock" jj-cache-dir)
773 "Keyfreq cache file")
774 (require 'keyfreq)
775 (keyfreq-mode 1)
776 (keyfreq-autosave-mode 1)
777 #+END_SRC
778
779 **** ace-jump-mode
780 [2013-04-28 So 11:26]
781 #+BEGIN_SRC emacs-lisp
782 (autoload 'ace-jump-mode "ace-jump-mode" "Emacs quick move minor mode" t)
783 (define-key global-map (kbd "H-SPC") 'ace-jump-mode)
784 ;; enable a more powerful jump back function from ace jump mode
785 (autoload 'ace-jump-mode-pop-mark "ace-jump-mode" "Ace jump back :-)" t)
786 (eval-after-load "ace-jump-mode" '(ace-jump-mode-enable-mark-sync))
787 (define-key global-map (kbd "H-c SPC") 'ace-jump-mode-pop-mark)
788 #+END_SRC
789 **** Overwrite mode
790 Usually you can press the *Ins*ert key, to get into overwrite mode. I
791 don't like that, have broken much with it and so just forbid it by
792 disabling that.
793 #+BEGIN_SRC emacs-lisp
794 (global-unset-key [insert])
795 (global-unset-key [kp-insert])
796 #+END_SRC
797
798 ** Miscellaneous stuff
799 Emacs should keep backup copies of files I edit, but I do not want them
800 to clutter up the filesystem everywhere. So I put them into one defined
801 place, backup-directory, which even contains my username (for systems
802 where =temporary-file-directory= is not inside my home).
803 #+BEGIN_SRC emacs-lisp
804 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
805 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
806
807 (setq version-control t) ;; Use version numbers for backups
808 (setq kept-new-versions 10) ;; Number of newest versions to keep
809 (setq kept-old-versions 2) ;; Number of oldest versions to keep
810 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
811
812 (add-hook 'before-save-hook 'force-backup-of-buffer)
813
814 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
815 (setq backup-by-copying t)
816 (setq make-backup-files t)
817
818 (setq backup-enable-predicate
819 (lambda (name)
820 (and (normal-backup-enable-predicate name)
821 (not
822 (let ((method (file-remote-p name 'method)))
823 (when (stringp method)
824 (member method '("su" "sudo"))))))))
825
826 #+END_SRC
827
828 Weeks start on Monday, not sunday.
829 #+BEGIN_SRC emacs-lisp
830 (setq calendar-week-start-day 1)
831 #+END_SRC
832
833 Searches and matches should ignore case.
834 #+BEGIN_SRC emacs-lisp
835 (setq-default case-fold-search t)
836 #+END_SRC
837
838 Which buffers to get rid off at midnight.
839 #+BEGIN_SRC emacs-lisp
840 (setq clean-buffer-list-kill-buffer-names (quote ("*Help*" "*Apropos*"
841 "*Man " "*Buffer List*"
842 "*Compile-Log*"
843 "*info*" "*vc*"
844 "*vc-diff*" "*diff*"
845 "*Customize"
846 "*tramp/" "*debug "
847 "*magit" "*Calendar")))
848 #+END_SRC
849
850 Don't display a cursor in non-selected windows.
851 #+BEGIN_SRC emacs-lisp
852 (setq-default cursor-in-non-selected-windows nil)
853 #+END_SRC
854
855 What should be displayed in the mode-line for files with those types
856 of line endings.
857 #+BEGIN_SRC emacs-lisp
858 (setq eol-mnemonic-dos "(DOS)")
859 (setq eol-mnemonic-mac "(Mac)")
860 #+END_SRC
861
862 Much larger threshold for garbage collection prevents it to run too often.
863 #+BEGIN_SRC emacs-lisp
864 (setq gc-cons-threshold 48000000)
865 #+END_SRC
866
867 #+BEGIN_SRC emacs-lisp
868 (setq max-lisp-eval-depth 1000)
869 (setq max-specpdl-size 3000)
870 #+END_SRC
871
872 Unfill paragraph
873 From https://raw.github.com/qdot/conf_emacs/master/emacs_conf.org
874 #+BEGIN_SRC emacs-lisp
875 (defun unfill-paragraph ()
876 "Takes a multi-line paragraph and makes it into a single line of text."
877 (interactive)
878 (let ((fill-column (point-max)))
879 (fill-paragraph nil)))
880 #+END_SRC
881
882 #+BEGIN_SRC emacs-lisp
883 (setq-default indicate-empty-lines t)
884 #+END_SRC
885 *** Browser
886 #+BEGIN_SRC emacs-lisp
887 (setq browse-url-browser-function (quote browse-url-generic))
888 (setq browse-url-generic-program "/usr/bin/x-www-browser")
889 #+END_SRC
890
891 *** When saving a script - make it executable
892 #+BEGIN_SRC emacs-lisp
893 (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
894 #+END_SRC
895
896 *** Emacs Server
897 #+BEGIN_SRC emacs-lisp
898 (server-start)
899 #+END_SRC
900
901 ** Customized variables
902 [2013-05-02 Thu 22:14]
903 The following contains a set of variables i may reasonably want to
904 change on other systems - which don't affect the init file loading
905 process. So I *can* use the customization interface for it...
906 #+BEGIN_SRC emacs-lisp
907 (defgroup ganneff nil
908 "Modify ganneffs settings"
909 :group 'environment)
910
911 (defgroup ganneff-org-mode nil
912 "Ganneffs org-mode settings"
913 :tag "Ganneffs org-mode settings"
914 :group 'ganneff
915 :link '(custom-group-link "ganneff"))
916
917 (defcustom bh/organization-task-id "d0db0d3c-f22e-42ff-a654-69524ff7cc91"
918 "ID of the organization task."
919 :tag "Organization Task ID"
920 :type 'string
921 :group 'ganneff-org-mode)
922
923 (defcustom org-my-archive-expiry-days 2
924 "The number of days after which a completed task should be auto-archived.
925 This can be 0 for immediate, or a floating point value."
926 :tag "Archive expiry days"
927 :type 'float
928 :group 'ganneff-org-mode)
929 #+END_SRC
930
931
932 * Customized variables
933 :PROPERTIES:
934 :ID: 0102208d-fdf6-4928-9e40-7e341bd3aa3a
935 :END:
936 Of course I want to be able to use the customize interface, and some
937 things can only be set via it (or so they say). I usually prefer to put
938 things I keep for a long while into statements somewhere else, not just
939 custom-set here, but we need it anyways.
940
941 #+BEGIN_SRC emacs-lisp
942 (setq custom-file jj-custom-file)
943 (safe-load custom-file)
944 #+END_SRC
945
946 The source of this is:
947 #+INCLUDE: "~/.emacs.d/config/customized.el" src emacs-lisp
948
949
950 * Extra modes and their configuration
951 ** mode alists
952 For some file endings we need to tell emacs what mode we want for them.
953 I only list modes here where I don't have any other special
954 configuration.
955
956 - Some extras for ruby, used with ruby on rails for example
957 #+BEGIN_SRC emacs-lisp
958 (add-to-list 'auto-mode-alist '("\\.rxml$" . ruby-mode))
959 (add-to-list 'auto-mode-alist '("\\.rjs$" . ruby-mode))
960 (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
961 (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
962 (add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
963 #+END_SRC
964
965 - Markdown syntax
966 #+BEGIN_SRC emacs-lisp
967 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
968 #+END_SRC
969
970 - diff
971 #+BEGIN_SRC emacs-lisp
972 (add-to-list 'auto-mode-alist '("COMMIT_EDITMSG$" . diff-mode))
973 #+END_SRC
974
975 - perl
976 #+BEGIN_SRC emacs-lisp
977 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
978 (add-to-list 'auto-mode-alist '("\\.pod$" . pod-mode))
979 (add-to-list 'auto-mode-alist '("\\.tt$" . tt-mode))
980 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
981 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
982 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
983 #+END_SRC
984
985 - python
986 #+BEGIN_SRC emacs-lisp
987 (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
988 (add-to-list 'auto-mode-alist '("\\.py$" . python-mode))
989 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
990 #+END_SRC
991
992 ** Region bindings mode
993 [2013-05-01 Wed 22:51]
994 This mode allows to have keybindings that are only alive when the
995 region is active. Helpful for things that only do any useful action
996 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
997 #+BEGIN_SRC emacs-lisp
998 (require 'region-bindings-mode)
999 (region-bindings-mode-enable)
1000 #+END_SRC
1001 ** tramp
1002 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
1003 #+BEGIN_SRC emacs-lisp
1004 (require 'tramp)
1005 (setq tramp-default-method "ssh")
1006 (setq tramp-persistency-file-name (expand-file-name "tramp" jj-cache-dir))
1007 (setq shell-prompt-pattern "^[^a-zA-Z].*[#$%>] *")
1008 (add-to-list 'tramp-default-method-alist
1009 '("\\`localhost\\'" "\\`root\\'" "su")
1010 )
1011 (setq tramp-debug-buffer nil)
1012 (setq tramp-default-method "sshx")
1013 (setq tramp-verbose 5)
1014 #+END_SRC
1015
1016 ** tiny-tools
1017 We configure only a bit of the tiny-tools to load when I should need
1018 them. I don't need much actually, but these things are nice to have.
1019
1020 #+BEGIN_SRC emacs-lisp
1021 (autoload 'turn-on-tinyperl-mode "tinyperl" "" t)
1022 (add-hook 'perl-mode-hook 'turn-on-tinyperl-mode)
1023 (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode)
1024
1025 (autoload 'tinycomment-indent-for-comment "tinycomment" "" t)
1026 (autoload 'tinyeat-forward-preserve "tinyeat" "" t)
1027 (autoload 'tinyeat-backward-preserve "tinyeat" "" t)
1028 (autoload 'tinyeat-delete-paragraph "tinyeat" "" t)
1029 (autoload 'tinyeat-kill-line "tinyeat" "" t)
1030 (autoload 'tinyeat-zap-line "tinyeat" "" t)
1031 (autoload 'tinyeat-kill-line-backward "tinyeat" "" t)
1032 (autoload 'tinyeat-kill-buffer-lines-point-max "tinyeat" "" t)
1033 (autoload 'tinyeat-kill-buffer-lines-point-min "tinyeat" "" t)
1034 #+END_SRC
1035 *** Keyboard changes for tiny-tools
1036 #+BEGIN_SRC emacs-lisp
1037 (global-set-key "\M-;" 'tinycomment-indent-for-comment)
1038
1039 (global-set-key (kbd "ESC C-k") 'tinyeat-kill-line-backward)
1040 (global-set-key (kbd "ESC d") 'tinyeat-forward-preserve)
1041 (global-set-key (kbd "ESC z") 'tinyeat-kill-buffer-lines-main)
1042 (global-set-key (kbd "<M-backspace>") 'tinyeat-backward-preserve)
1043 (global-set-key (kbd "<C-delete>") 'tinyeat-forward-preserve)
1044 (global-set-key (kbd "<S-backspace>") 'tinyeat-delete-whole-word)
1045 #+END_SRC
1046
1047 ** dired & co
1048 I like dired and work a lot with it, but it tends to leave lots of
1049 windows around.
1050 dired-single to the rescue.
1051 #+BEGIN_SRC emacs-lisp
1052 (autoload 'dired-single-buffer "dired-single" "" t)
1053 (autoload 'dired-single-buffer-mouse "dired-single" "" t)
1054 (autoload 'dired-single-magic-buffer "dired-single" "" t)
1055 (autoload 'dired-single-toggle-buffer-name "dired-single" "" t)
1056 #+END_SRC
1057
1058 We want some extra key bindings loaded. In case we haven't loaded dired
1059 yet, there won't be a keymap to add to, so add our setup function to the
1060 load hook only. Otherwise just bind the keys.
1061 #+BEGIN_SRC emacs-lisp
1062 (if (boundp 'dired-mode-map)
1063 ;; we're good to go; just add our bindings
1064 (my-dired-init)
1065 ;; it's not loaded yet, so add our bindings to the load-hook
1066 (add-hook 'dired-load-hook 'my-dired-init))
1067 #+END_SRC
1068
1069 A few settings
1070 #+BEGIN_SRC emacs-lisp
1071 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
1072 (setq dired-dwim-target t)
1073 (setq dired-listing-switches "-alh")
1074 (setq dired-recursive-copies (quote top))
1075 (setq dired-recursive-deletes (quote top))
1076 #+END_SRC
1077
1078 wdired
1079 #+BEGIN_SRC emacs-lisp
1080 (setq wdired-allow-to-change-permissions t)
1081 #+END_SRC
1082 ** filladapt
1083 [2013-05-02 Thu 00:04]
1084 #+BEGIN_SRC emacs-lisp
1085 (require 'filladapt)
1086 (eval-after-load "filladapt" '(diminish 'filladapt-mode))
1087 (setq-default filladapt-mode t)
1088 #+END_SRC
1089 ** ffap
1090 [2013-05-03 Fri 16:09]
1091 Replace default find-file with find-file-at-point, which tries to
1092 guess the default file/URL from text around the point.
1093 #+BEGIN_SRC emacs-lisp
1094 (ffap-bindings)
1095 #+END_SRC
1096 ** icicles
1097 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles][“In case you never heard of it, Icicles is to ‘TAB’ completion what
1098 ‘TAB’ completion is to typing things manually every time.”]]
1099 #+BEGIN_SRC emacs-lisp
1100 (require 'icicles)
1101 (icy-mode 1)
1102 #+END_SRC
1103
1104 And while I like icicles, I don't want it to interfere with my
1105 org-mode stuff.
1106 #+BEGIN_SRC emacs-lisp
1107
1108 #+END_SRC
1109 ** uniquify
1110 Always have unique buffernames. See [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html][Uniquify - GNU Emacs Manual]]
1111 #+BEGIN_SRC emacs-lisp
1112 (require 'uniquify)
1113 (setq uniquify-buffer-name-style 'post-forward)
1114 (setq uniquify-after-kill-buffer-p t)
1115 (setq uniquify-ignore-buffers-re "^\\*")
1116 #+END_SRC
1117
1118 ** abbrev
1119 A defined abbrev is a word which expands, if you insert it, into some
1120 different text. Abbrevs are defined by the user to expand in specific
1121 ways.
1122 #+BEGIN_SRC emacs-lisp
1123 (setq save-abbrevs 'silently)
1124 (setq abbrev-file-name (expand-file-name "abbrev_defs" jj-cache-dir))
1125 (if (file-exists-p abbrev-file-name)
1126 (quietly-read-abbrev-file))
1127 (abbrev-mode 1)
1128 #+END_SRC
1129
1130 ** font-lock
1131 Obviously emacs can do syntax hilighting. For more things than you ever
1132 heard about.
1133 And I want to have it everywhere.
1134 #+BEGIN_SRC emacs-lisp
1135 (require 'font-lock)
1136 (global-font-lock-mode 1)
1137 (setq font-lock-maximum-decoration t)
1138 #+END_SRC
1139 ** miniedit
1140 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
1141 #+BEGIN_SRC emacs-lisp
1142 (require 'miniedit)
1143 (miniedit-install)
1144 #+END_SRC
1145
1146 ** timestamp
1147 By default, Emacs can update the time stamp for the following two
1148 formats if one exists in the first 8 lines of the file.
1149 - Time-stamp: <>
1150 - Time-stamp: " "
1151 #+BEGIN_SRC emacs-lisp
1152 (require 'time-stamp)
1153 (setq time-stamp-active t)
1154 (setq time-stamp-format "%02H:%02M:%02S (%z) - %02d.%02m.%:y from %u (%U) on %s")
1155 (setq time-stamp-old-format-warn nil)
1156 (setq time-stamp-time-zone nil)
1157 (add-hook 'write-file-hooks 'time-stamp)
1158 #+END_SRC
1159
1160 ** cperl
1161 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
1162 up here to be used.
1163 #+BEGIN_SRC emacs-lisp
1164 (autoload 'cperl-mode "cperl-mode" )
1165 (defalias 'perl-mode 'cperl-mode)
1166 (setq cperl-hairy t)
1167 (setq cperl-electric-keywords t)
1168 (setq cperl-electric-lbrace-space t)
1169 (setq cperl-electric-parens nil)
1170 (setq cperl-highlight-variables-indiscriminately t)
1171 (setq cperl-imenu-addback t)
1172 (setq cperl-invalid-face (quote underline))
1173 (setq cperl-lazy-help-time 5)
1174 (setq cperl-mode-hook (quote (turn-on-tinyperl-mode)))
1175 (setq cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$")
1176 (setq cperl-syntaxify-by-font-lock t)
1177 (setq cperl-use-syntax-table-text-property-for-tags t)
1178 #+END_SRC
1179
1180 And have cperl mode give ElDoc a useful string
1181 #+BEGIN_SRC emacs-lisp
1182 (defun my-cperl-eldoc-documentation-function ()
1183 "Return meaningful doc string for `eldoc-mode'."
1184 (car
1185 (let ((cperl-message-on-help-error nil))
1186 (cperl-get-help))))
1187 (add-hook 'cperl-mode-hook
1188 (lambda ()
1189 (set (make-local-variable 'eldoc-documentation-function)
1190 'my-cperl-eldoc-documentation-function)
1191 (eldoc-mode)))
1192 #+END_SRC
1193
1194 ** python
1195 #+BEGIN_SRC emacs-lisp
1196 (autoload 'python-mode "python-mode" "Python Mode." t)
1197 (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
1198 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
1199 (setq interpreter-mode-alist
1200 (cons '("python" . python-mode)
1201 interpreter-mode-alist)
1202 python-mode-hook
1203 '(lambda () (progn
1204 (set-variable 'py-indent-offset 4)
1205 (set-variable 'py-smart-indentation nil)
1206 (set-variable 'indent-tabs-mode nil)
1207 (define-key python-mode-map "\C-m" 'newline-and-indent)
1208 (turn-on-eldoc-mode)
1209 )))
1210 (defun python-auto-fill-comments-only ()
1211 (auto-fill-mode 1)
1212 (set (make-local-variable 'fill-nobreak-predicate)
1213 (lambda ()
1214 (not (python-in-string/comment)))))
1215 (add-hook 'python-mode-hook
1216 (lambda ()
1217 (python-auto-fill-comments-only)))
1218 ;; pymacs
1219 (autoload 'pymacs-apply "pymacs")
1220 (autoload 'pymacs-call "pymacs")
1221 (autoload 'pymacs-eval "pymacs" nil t)
1222 (autoload 'pymacs-exec "pymacs" nil t)
1223 (autoload 'pymacs-load "pymacs" nil t)
1224
1225 #+END_SRC
1226
1227 If an =ipython= executable is on the path, then assume that IPython is
1228 the preferred method python evaluation.
1229 #+BEGIN_SRC emacs-lisp
1230 (when (executable-find "ipython")
1231 (require 'ipython)
1232 (setq org-babel-python-mode 'python-mode))
1233
1234 (setq python-shell-interpreter "ipython")
1235 (setq python-shell-interpreter-args "")
1236 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
1237 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
1238 (setq python-shell-completion-setup-code
1239 "from IPython.core.completerlib import module_completion")
1240 (setq python-shell-completion-module-string-code
1241 "';'.join(module_completion('''%s'''))\n")
1242 (setq python-shell-completion-string-code
1243 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
1244 #+END_SRC
1245
1246 ** sh
1247 I prefer comments to be indented too
1248 #+BEGIN_SRC emacs-lisp
1249 (setq sh-indent-comment t)
1250 #+END_SRC
1251
1252 ** auto-revert
1253 When files change outside emacs for whatever reason I want emacs to deal
1254 with it. Not to have to revert buffers myself
1255 #+BEGIN_SRC emacs-lisp
1256 (require 'autorevert)
1257 (setq global-auto-revert-mode t)
1258 (global-auto-revert-mode)
1259 #+END_SRC
1260
1261 ** linum (line number)
1262 Various modes should have line numbers in front of each line.
1263
1264 But then there are some where it would just be deadly - like org-mode,
1265 gnus, so we have a list of modes where we don't want to see it.
1266 #+BEGIN_SRC emacs-lisp
1267 (require 'linum)
1268 (setq linum-format "%3d ")
1269 (setq linum-mode-inhibit-modes-list '(org-mode
1270 eshell-mode
1271 shell-mode
1272 gnus-group-mode
1273 gnus-summary-mode
1274 gnus-article-mode))
1275
1276 (defadvice linum-on (around linum-on-inhibit-for-modes)
1277 "Stop the load of linum-mode for some major modes."
1278 (unless (member major-mode linum-mode-inhibit-modes-list)
1279 ad-do-it))
1280
1281 (ad-activate 'linum-on)
1282 (global-linum-mode 1)
1283 #+END_SRC
1284
1285 ** css
1286 #+BEGIN_SRC emacs-lisp
1287 (autoload 'css-mode "css-mode")
1288 (setq auto-mode-alist (cons '("\\.css\\'" . css-mode) auto-mode-alist))
1289 #+END_SRC
1290
1291 ** html-helper
1292 Instead of default /html-mode/ I use /html-helper-mode/.
1293 #+BEGIN_SRC emacs-lisp
1294 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
1295 (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
1296 (setq auto-mode-alist (cons '("\\.asp$" . html-helper-mode) auto-mode-alist))
1297 (setq auto-mode-alist (cons '("\\.phtml$" . html-helper-mode) auto-mode-alist))
1298 (defalias 'html-mode 'html-helper-mode)
1299 #+END_SRC
1300
1301 ** auctex
1302 #+BEGIN_SRC emacs-lisp
1303 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
1304 (setq TeX-auto-save t)
1305 (setq TeX-parse-self t)
1306 (setq TeX-PDF-mode t)
1307 #+END_SRC
1308
1309 ** Debian related
1310 #+BEGIN_SRC emacs-lisp
1311 (require 'dpkg-dev-el-loaddefs nil 'noerror)
1312 (require 'debian-el-loaddefs nil 'noerror)
1313
1314 (setq debian-changelog-full-name "Joerg Jaspert")
1315 (setq debian-changelog-mailing-address "joerg@debian.org")
1316 #+END_SRC
1317
1318 ** org :FIXME:
1319 *** General settings
1320 [2013-04-28 So 17:06]
1321 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
1322 it is quite extensive. Nevertheless, it starts out small, loading it.
1323 #+BEGIN_SRC emacs-lisp
1324 (require 'org)
1325 #+END_SRC
1326
1327 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
1328 that we need org-protocol.
1329 #+BEGIN_SRC emacs-lisp
1330 (require 'org-protocol)
1331 #+END_SRC
1332
1333 *** Global keybindings.
1334 [2013-04-28 So 17:12]
1335 Start off by defining a series of keybindings. We also remove C-c [
1336 #+BEGIN_SRC emacs-lisp
1337 ;; Disable C-c [ and C-c ] in org-mode
1338 (add-hook 'org-mode-hook
1339 (lambda ()
1340 ;; Undefine C-c [ and C-c ] since this breaks my
1341 ;; org-agenda files when directories are included. It
1342 ;; expands the files in the directories individually
1343 (org-defkey org-mode-map "\C-c[" 'undefined)
1344 (org-defkey org-mode-map "\C-c]" 'undefined))
1345 'append)
1346
1347 (global-set-key "\C-cl" 'org-store-link)
1348 (global-set-key "\C-ca" 'org-agenda)
1349 (global-set-key "\C-cb" 'org-iswitchb)
1350 (define-key mode-specific-map [?a] 'org-agenda)
1351
1352
1353 ;; Custom Key Bindings
1354 (global-set-key (kbd "<f12>") 'org-agenda)
1355 (global-set-key (kbd "<f5>") 'bh/org-todo)
1356 (global-set-key (kbd "<S-f5>") 'bh/widen)
1357 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
1358 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
1359 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
1360 (global-set-key (kbd "<f9> c") 'calendar)
1361 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
1362 (global-set-key (kbd "<f9> h") 'bh/hide-other)
1363 (global-set-key (kbd "<f9> n") 'org-narrow-to-subtree)
1364 (global-set-key (kbd "<f9> w") 'widen)
1365 (global-set-key (kbd "<f9> u") 'bh/narrow-up-one-level)
1366
1367 (global-set-key (kbd "<f9> I") 'bh/punch-in)
1368 (global-set-key (kbd "<f9> O") 'bh/punch-out)
1369
1370 (global-set-key (kbd "<f9> r") 'boxquote-region)
1371 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
1372
1373 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
1374 (global-set-key (kbd "<f9> T") 'tabify)
1375 (global-set-key (kbd "<f9> U") 'untabify)
1376
1377 (global-set-key (kbd "<f9> v") 'visible-mode)
1378 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
1379 (global-set-key (kbd "C-<f9>") 'previous-buffer)
1380 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
1381 (global-set-key (kbd "C-x n r") 'narrow-to-region)
1382 (global-set-key (kbd "C-<f10>") 'next-buffer)
1383 (global-set-key (kbd "<f11>") 'org-clock-goto)
1384 (global-set-key (kbd "C-<f11>") 'org-clock-in)
1385 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
1386 (global-set-key (kbd "C-M-r") 'org-capture)
1387 (global-set-key (kbd "C-c r") 'org-capture)
1388
1389 (define-key org-mode-map [(control k)] 'jj-org-kill-line)
1390
1391
1392 ;; Enable abbrev-mode
1393 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
1394 (setq org-startup-indented t)
1395 (setq org-cycle-separator-lines 2)
1396
1397 (setq org-reverse-note-order nil)
1398
1399 (setq org-agenda-log-mode-items (quote (closed clock state)))
1400 (if (> emacs-major-version 23)
1401 (setq org-agenda-span 7)
1402 (setq org-agenda-ndays 7))
1403
1404 (setq org-agenda-show-all-dates t)
1405 (setq org-agenda-start-on-weekday nil)
1406 (setq org-deadline-warning-days 14)
1407 (setq org-default-notes-file "~/notes.org")
1408 (setq org-enforce-todo-checkbox-dependencies t)
1409 (setq org-enforce-todo-dependencies t)
1410 (setq org-fast-tag-selection-single-key (quote expert))
1411 (setq org-footnote-auto-adjust t)
1412 (setq org-hide-block-startup t)
1413 (setq org-icalendar-alarm-time 15)
1414 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
1415 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
1416 (setq org-icalendar-honor-noexport-tag t)
1417 (setq org-icalendar-include-bbdb-anniversaries nil)
1418 (setq org-icalendar-include-body 200)
1419 (setq org-icalendar-include-todo nil)
1420 (setq org-icalendar-store-UID t)
1421 (setq org-icalendar-timezone "Europe/Berlin")
1422 (setq org-insert-mode-line-in-empty-file t)
1423 (setq org-log-done (quote note))
1424 (setq org-log-into-drawer t)
1425 (setq org-log-reschedule (quote time))
1426 (setq org-log-states-order-reversed t)
1427 (setq org-mobile-agendas (quote all))
1428 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
1429 (setq org-mobile-inbox-for-pull "~/org/refile.org")
1430 (setq org-remember-store-without-prompt t)
1431 (setq org-return-follows-link t)
1432 (setq org-reverse-note-order t)
1433 (setq org-todo-keywords (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)") (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
1434
1435 ; regularly save our org-mode buffers
1436 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
1437
1438 (setq org-log-done t)
1439 (setq org-agenda-files (quote ("~/org/"
1440 "~/org/debian"
1441 "~/org/debconf"
1442 "~/org/spi"
1443 "~/org/nsb"
1444 )))
1445 (setq org-default-notes-file "~/org/notes.org")
1446 ;;*** disable priority handling
1447 (setq org-enable-priority-commands nil)
1448 (setq org-use-fast-todo-selection t)
1449 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1450
1451 #+END_SRC
1452
1453 Speed commands enable single-letter commands in Org-mode files when
1454 the point is at the beginning of a headline, or at the beginning of a
1455 code block.
1456
1457 See the `=org-speed-commands-default=' variable for a list of the keys
1458 and commands enabled at the beginning of headlines. All code blocks
1459 are available at the beginning of a code block, the following key
1460 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
1461 display a list of the code blocks commands and their related keys.
1462
1463 #+BEGIN_SRC emacs-lisp
1464 (setq org-use-speed-commands t)
1465 (setq org-speed-commands-user (quote (("0" . ignore)
1466 ("1" . ignore)
1467 ("2" . ignore)
1468 ("3" . ignore)
1469 ("4" . ignore)
1470 ("5" . ignore)
1471 ("6" . ignore)
1472 ("7" . ignore)
1473 ("8" . ignore)
1474 ("9" . ignore)
1475
1476 ("a" . ignore)
1477 ("d" . ignore)
1478 ("h" . bh/hide-other)
1479 ("i" progn
1480 (forward-char 1)
1481 (call-interactively 'org-insert-heading-respect-content))
1482 ("k" . org-kill-note-or-show-branches)
1483 ("l" . ignore)
1484 ("m" . ignore)
1485 ("q" . bh/show-org-agenda)
1486 ("r" . ignore)
1487 ("s" . org-save-all-org-buffers)
1488 ("w" . org-refile)
1489 ("x" . ignore)
1490 ("y" . ignore)
1491 ("z" . org-add-note)
1492
1493 ("A" . ignore)
1494 ("B" . ignore)
1495 ("E" . ignore)
1496 ("F" . bh/restrict-to-file-or-follow)
1497 ("G" . ignore)
1498 ("H" . ignore)
1499 ("J" . org-clock-goto)
1500 ("K" . ignore)
1501 ("L" . ignore)
1502 ("M" . ignore)
1503 ("N" . bh/narrow-to-subtree)
1504 ("P" . bh/narrow-to-project)
1505 ("Q" . ignore)
1506 ("R" . ignore)
1507 ("S" . ignore)
1508 ("T" . bh/org-todo)
1509 ("U" . bh/narrow-up-one-level)
1510 ("V" . ignore)
1511 ("W" . bh/widen)
1512 ("X" . ignore)
1513 ("Y" . ignore)
1514 ("Z" . ignore))))
1515
1516 (add-hook 'org-agenda-mode-hook
1517 (lambda ()
1518 (define-key org-agenda-mode-map "q" 'bury-buffer))
1519 'append)
1520
1521 (setq org-todo-keyword-faces
1522 (quote (("TODO" :foreground "red" :weight bold)
1523 ("NEXT" :foreground "light blue" :weight bold)
1524 ("DONE" :foreground "forest green" :weight bold)
1525 ("WAITING" :foreground "orange" :weight bold)
1526 ("HOLD" :foreground "orange" :weight bold)
1527 ("DELEGATED" :foreground "yellow" :weight bold)
1528 ("CANCELLED" :foreground "forest green" :weight bold)
1529 ("PHONE" :foreground "forest green" :weight bold))))
1530
1531 (setq org-todo-state-tags-triggers
1532 (quote (("CANCELLED" ("CANCELLED" . t))
1533 ("WAITING" ("WAITING" . t))
1534 ("HOLD" ("WAITING" . t) ("HOLD" . t))
1535 (done ("WAITING") ("HOLD"))
1536 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1537 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1538 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1539
1540 ; Tags with fast selection keys
1541 (setq org-tag-alist (quote ((:startgroup)
1542 ("@errand" . ?e)
1543 ("@office" . ?o)
1544 ("@home" . ?H)
1545 (:endgroup)
1546 ("PHONE" . ?p)
1547 ("WAITING" . ?w)
1548 ("HOLD" . ?h)
1549 ("PERSONAL" . ?P)
1550 ("WORK" . ?W)
1551 ("ORG" . ?O)
1552 ("PRIVATE" . ?N)
1553 ("crypt" . ?E)
1554 ("MARK" . ?M)
1555 ("NOTE" . ?n)
1556 ("CANCELLED" . ?c)
1557 ("FLAGGED" . ??))))
1558
1559 ; Allow setting single tags without the menu
1560 (setq org-fast-tag-selection-single-key (quote expert))
1561
1562 ; Overwrite the current window with the agenda
1563 (setq org-agenda-window-setup 'current-window)
1564 #+END_SRC
1565
1566 The following displays the contents of code blocks in Org-mode files
1567 using the major-mode of the code. It also changes the behavior of
1568 =TAB= to as if it were used in the appropriate major mode. This means
1569 that reading and editing code form inside of your Org-mode files is
1570 much more like reading and editing of code using its major mode.
1571
1572 #+BEGIN_SRC emacs-lisp
1573 (setq org-src-fontify-natively t)
1574 (setq org-src-tab-acts-natively t)
1575
1576 ; For tag searches ignore tasks with scheduled and deadline dates
1577 (setq org-agenda-tags-todo-honor-ignore-options t)
1578
1579 ;;** org capture replaces remember mode
1580 (setq org-directory "~/org")
1581 (setq org-default-notes-file "~/org/refile.org")
1582
1583 ;; I use C-M-r to start capture mode
1584 (global-set-key (kbd "C-M-r") 'org-capture)
1585 ;; I use C-c r to start capture mode when using SSH from my Android phone
1586 (global-set-key (kbd "C-c r") 'org-capture)
1587
1588 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
1589 ;; see http://orgmode.org/manual/Template-elements.html
1590 (setq org-capture-templates
1591 (quote (("t" "todo" entry (file "~/org/refile.org")
1592 "* TODO %?\nAdded: %U\n"
1593 :clock-in t :clock-resume t)
1594 ("l" "linktodo" entry (file "~/org/refile.org")
1595 "* TODO %?\nAdded: %U\n%a\n"
1596 :clock-in t :clock-resume t)
1597 ("r" "respond" entry (file "~/org/refile.org")
1598 "* TODO Respond to %:from on %:subject\nAdded: %U\n%a\n"
1599 :clock-in t :clock-resume t :immediate-finish t)
1600 ("n" "note" entry (file "~/org/refile.org")
1601 "* %? :NOTE:\nAdded: %U\n%a\n"
1602 :clock-in t :clock-resume t)
1603 ("d" "Delegated" entry (file "~/org/refile.org")
1604 "* DELEGATED %?\nAdded: %U\n%a\n"
1605 :clock-in t :clock-resume t)
1606 ("j" "Journal" entry (file+datetree "~/org/diary.org")
1607 "* %?\nAdded: %U\n"
1608 :clock-in t :clock-resume t)
1609 ("w" "org-protocol" entry (file "~/org/refile.org")
1610 "* TODO Review %c\nAdded: %U\n"
1611 :immediate-finish t)
1612 ("p" "Phone call" entry (file "~/org/refile.org")
1613 "* PHONE %? :PHONE:\nAdded: %U"
1614 :clock-in t :clock-resume t)
1615 ("f" "Firewall request" entry (file+headline "~/org/nsb/dlh.org" "Firewall")
1616 "* TODO Firewall Reuqest, RT: %?\nAdded: %U"
1617 :clock-in t :clock-resume t)
1618 ("i" "Ticket" entry (file+headline "~/org/nsb/dlh.org" "RT Ticket")
1619 "* TODO , RT: %?\nAdded: %U"
1620 :clock-in t :clock-resume t)
1621 ("x" "Bookmark link" entry (file "~/org/refile.org")
1622 "* Bookmark: %c\n%i\nAdded: %U\n"
1623 :immediate-finish t)
1624 ("h" "Habit" entry (file "~/org/refile.org")
1625 "* NEXT %?\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\nAdded: %U\nSCHEDULED: %t .+1d/3d\n")
1626 )))
1627
1628 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1629 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1630 (org-agenda-files :maxlevel . 9))))
1631
1632 ; Use full outline paths for refile targets - we file directly with IDO
1633 (setq org-refile-use-outline-path t)
1634
1635 ; Targets complete directly with IDO
1636 (setq org-outline-path-complete-in-steps nil)
1637
1638 ; Allow refile to create parent tasks with confirmation
1639 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1640
1641 ; Use IDO for both buffer and file completion and ido-everywhere to t
1642 (setq org-completion-use-ido t)
1643 (setq org-completion-use-iswitchb nil)
1644
1645 ;;;; Refile settings
1646 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1647
1648 ;; Do not dim blocked tasks
1649 (setq org-agenda-dim-blocked-tasks nil)
1650 ;; Compact the block agenda view
1651 (setq org-agenda-compact-blocks t)
1652
1653
1654 ;; disable the default org-mode stuck projects agenda view
1655 (setq org-stuck-projects (quote ("" nil nil "")))
1656
1657 ; force showing the next headline.
1658 (setq org-show-entry-below (quote ((default))))
1659
1660 (setq org-show-following-heading t)
1661 (setq org-show-hierarchy-above t)
1662 (setq org-show-siblings (quote ((default))))
1663
1664 (setq org-special-ctrl-a/e 'reversed)
1665 (setq org-special-ctrl-k t)
1666 (setq org-yank-adjusted-subtrees t)
1667
1668
1669 ;; Always hilight the current agenda line
1670 (add-hook 'org-agenda-mode-hook
1671 '(lambda () (hl-line-mode 1))
1672 'append)
1673
1674 ;; Keep tasks with dates on the global todo lists
1675 (setq org-agenda-todo-ignore-with-date nil)
1676
1677 ;; Keep tasks with deadlines on the global todo lists
1678 (setq org-agenda-todo-ignore-deadlines nil)
1679
1680 ;; Keep tasks with scheduled dates on the global todo lists
1681 (setq org-agenda-todo-ignore-scheduled nil)
1682
1683 ;; Keep tasks with timestamps on the global todo lists
1684 (setq org-agenda-todo-ignore-timestamp nil)
1685
1686 ;; Remove completed deadline tasks from the agenda view
1687 (setq org-agenda-skip-deadline-if-done t)
1688
1689 ;; Remove completed scheduled tasks from the agenda view
1690 (setq org-agenda-skip-scheduled-if-done t)
1691
1692 ;; Remove completed items from search results
1693 (setq org-agenda-skip-timestamp-if-done t)
1694
1695 ;; Include agenda archive files when searching for things
1696 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
1697
1698 ;; Show all future entries for repeating tasks
1699 (setq org-agenda-repeating-timestamp-show-all t)
1700
1701 ;; Show all agenda dates - even if they are empty
1702 (setq org-agenda-show-all-dates t)
1703
1704 ;; Sorting order for tasks on the agenda
1705 (setq org-agenda-sorting-strategy
1706 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
1707 (todo category-up priority-down effort-up)
1708 (tags category-up priority-down effort-up)
1709 (search category-up))))
1710
1711 ;; Start the weekly agenda on Monday
1712 (setq org-agenda-start-on-weekday 1)
1713
1714 ;; Enable display of the time grid so we can see the marker for the current time
1715 (setq org-agenda-time-grid (quote ((daily today remove-match)
1716 #("----------------" 0 16 (org-heading t))
1717 (0800 1000 1200 1400 1500 1700 1900 2100))))
1718
1719 ;; Display tags farther right
1720 (setq org-agenda-tags-column -102)
1721
1722 ; position the habit graph on the agenda to the right of the default
1723 (setq org-habit-graph-column 50)
1724
1725 ; turn habits back on
1726 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
1727
1728 ;;
1729 ;; Agenda sorting functions
1730 ;;
1731 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
1732
1733
1734 (setq org-deadline-warning-days 30)
1735
1736 (setq org-table-export-default-format "orgtbl-to-csv")
1737
1738 ;; Custom agenda command definitions
1739 (setq org-agenda-custom-commands
1740 (quote (("N" "Notes" tags "NOTE"
1741 ((org-agenda-overriding-header "Notes")
1742 (org-tags-match-list-sublevels t)))
1743 ("h" "Habits" tags-todo "STYLE=\"habit\""
1744 ((org-agenda-overriding-header "Habits")
1745 (org-agenda-sorting-strategy
1746 '(todo-state-down effort-up category-keep))))
1747 (" " "Agenda"
1748 ((agenda "" nil)
1749 (tags "REFILE"
1750 ((org-agenda-overriding-header "Tasks to Refile")
1751 (org-tags-match-list-sublevels nil)))
1752 (tags-todo "-HOLD-CANCELLED/!"
1753 ((org-agenda-overriding-header "Projects")
1754 (org-agenda-skip-function 'bh/skip-non-projects)
1755 (org-agenda-sorting-strategy
1756 '(category-keep))))
1757 (tags-todo "-CANCELLED/!"
1758 ((org-agenda-overriding-header "Stuck Projects")
1759 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
1760 (tags-todo "-WAITING-CANCELLED/!NEXT"
1761 ((org-agenda-overriding-header "Next Tasks")
1762 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1763 (org-agenda-todo-ignore-scheduled t)
1764 (org-agenda-todo-ignore-deadlines t)
1765 (org-agenda-todo-ignore-with-date t)
1766 (org-tags-match-list-sublevels t)
1767 (org-agenda-sorting-strategy
1768 '(todo-state-down effort-up category-keep))))
1769 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
1770 ((org-agenda-overriding-header "Tasks")
1771 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
1772 (org-agenda-todo-ignore-scheduled t)
1773 (org-agenda-todo-ignore-deadlines t)
1774 (org-agenda-todo-ignore-with-date t)
1775 (org-agenda-sorting-strategy
1776 '(category-keep))))
1777 (tags-todo "-CANCELLED/!WAITING|HOLD"
1778 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1779 (org-tags-match-list-sublevels nil)
1780 (org-agenda-todo-ignore-scheduled 'future)
1781 (org-agenda-todo-ignore-deadlines 'future)))
1782 (tags "-REFILE/"
1783 ((org-agenda-overriding-header "Tasks to Archive")
1784 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1785 (org-tags-match-list-sublevels nil))))
1786 nil)
1787 ("r" "Tasks to Refile" tags "REFILE"
1788 ((org-agenda-overriding-header "Tasks to Refile")
1789 (org-tags-match-list-sublevels nil)))
1790 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
1791 ((org-agenda-overriding-header "Stuck Projects")
1792 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
1793 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
1794 ((org-agenda-overriding-header "Next Tasks")
1795 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1796 (org-agenda-todo-ignore-scheduled t)
1797 (org-agenda-todo-ignore-deadlines t)
1798 (org-agenda-todo-ignore-with-date t)
1799 (org-tags-match-list-sublevels t)
1800 (org-agenda-sorting-strategy
1801 '(todo-state-down effort-up category-keep))))
1802 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
1803 ((org-agenda-overriding-header "Tasks")
1804 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
1805 (org-agenda-sorting-strategy
1806 '(category-keep))))
1807 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
1808 ((org-agenda-overriding-header "Projects")
1809 (org-agenda-skip-function 'bh/skip-non-projects)
1810 (org-agenda-sorting-strategy
1811 '(category-keep))))
1812 ("w" "Waiting Tasks" tags-todo "-CANCELLED/!WAITING|HOLD"
1813 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
1814 (org-tags-match-list-sublevels nil))
1815 ("A" "Tasks to Archive" tags "-REFILE/"
1816 ((org-agenda-overriding-header "Tasks to Archive")
1817 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1818 (org-tags-match-list-sublevels nil))))))
1819
1820 (setq org-archive-mark-done nil)
1821 (setq org-archive-location "%s_archive::* Archived Tasks")
1822
1823 (setq org-startup-folded 'content)
1824
1825 (global-set-key (kbd "<f9> p") 'bh/phone-call)
1826
1827 (setq org-remove-highlights-with-change nil)
1828
1829 (setq org-list-demote-modify-bullet (quote (("+" . "-")
1830 ("*" . "-")
1831 ("1." . "-")
1832 ("1)" . "-"))))
1833
1834 (setq org-agenda-persistent-filter t)
1835
1836
1837 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1838 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
1839
1840 (add-hook 'org-agenda-mode-hook
1841 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
1842 'append)
1843
1844 (add-hook 'org-agenda-mode-hook
1845 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
1846 'append)
1847
1848 (add-hook 'org-agenda-mode-hook
1849 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
1850 'append)
1851
1852 (add-hook 'org-agenda-mode-hook
1853 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
1854 'append)
1855
1856 (add-hook 'org-agenda-mode-hook
1857 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
1858 'append)
1859
1860 ; Rebuild the reminders everytime the agenda is displayed
1861 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
1862
1863 ; This is at the end of my .emacs - so appointments are set up when Emacs starts
1864 (if (file-exists-p "~/org/refile.org")
1865 (bh/org-agenda-to-appt))
1866
1867
1868 ; Activate appointments so we get notifications
1869 (appt-activate t)
1870
1871 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
1872 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
1873
1874
1875 ;;
1876 ;; Resume clocking task when emacs is restarted
1877 (org-clock-persistence-insinuate)
1878 ;;
1879 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
1880 (setq org-clock-history-length 36)
1881 ;; Resume clocking task on clock-in if the clock is open
1882 (setq org-clock-in-resume t)
1883 ;; Change tasks to NEXT when clocking in
1884 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1885 ;; Separate drawers for clocking and logs
1886 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1887 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1888 (setq org-clock-into-drawer t)
1889 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1890 (setq org-clock-out-remove-zero-time-clocks t)
1891 ;; Clock out when moving task to a done state
1892 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
1893 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1894 (setq org-clock-persist t)
1895 ;; Do not prompt to resume an active clock
1896 (setq org-clock-persist-query-resume nil)
1897 ;; Enable auto clock resolution for finding open clocks
1898 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1899 ;; Include current clocking task in clock reports
1900 (setq org-clock-report-include-clocking-task t)
1901
1902 ; use discrete minute intervals (no rounding) increments
1903 (setq org-time-stamp-rounding-minutes (quote (1 1)))
1904
1905 (setq bh/keep-clock-running nil)
1906
1907 (setq org-agenda-clock-consistency-checks
1908 (quote (:max-duration "4:00"
1909 :min-duration 0
1910 :max-gap 0
1911 :gap-ok-around ("4:00"))))
1912
1913 ;; Agenda clock report parameters
1914 (setq org-agenda-clockreport-parameter-plist
1915 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
1916
1917 ; Set default column view headings: Task Effort Clock_Summary
1918 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
1919
1920 ; global Effort estimate values
1921 ; global STYLE property values for completion
1922 (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")
1923 ("STYLE_ALL" . "habit"))))
1924
1925 ;; Agenda log mode items to display (closed and state changes by default)
1926 (setq org-agenda-log-mode-items (quote (state)))
1927
1928 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1929
1930 ;;; define categories that should be excluded
1931 (setq org-export-exclude-category (list "google" "google"))
1932 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1933 #+END_SRC
1934
1935 #+BEGIN_SRC emacs-lisp
1936 (setq org-publish-project-alist
1937 '(
1938 ("config-notes"
1939 :base-directory "~/.emacs.d/config/"
1940 :base-extension "org"
1941 :publishing-directory "/develop/www/emacs"
1942 :recursive t
1943 :publishing-function org-publish-org-to-html
1944 :headline-levels 4 ; Just the default for this project.
1945 :auto-preamble t
1946 )
1947 ("config-static"
1948 :base-directory "~/.emacs.d/config/"
1949 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
1950 :publishing-directory "/develop/www/emacs"
1951 :recursive t
1952 :publishing-function org-publish-attachment
1953 )
1954 ("inherit-org-info-js"
1955 :base-directory "/develop/vcs/org-info-js/"
1956 :recursive t
1957 :base-extension "js"
1958 :publishing-directory "/develop/www/"
1959 :publishing-function org-publish-attachment
1960 )
1961 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
1962 )
1963 )
1964 )
1965 #+END_SRC
1966 #+BEGIN_SRC emacs-lisp
1967 (setq org-latex-to-pdf-process
1968 '("xelatex -interaction nonstopmode %f"
1969 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
1970 #+END_SRC
1971 #+BEGIN_SRC emacs-lisp
1972 (require 'org-latex)
1973 (setq org-export-latex-listings 'minted)
1974
1975 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1976 ;; but adapted to use latexmk 4.20 or higher.
1977 (defun my-auto-tex-cmd ()
1978 "When exporting from .org with latex, automatically run latex,
1979 pdflatex, or xelatex as appropriate, using latexmk."
1980 (let ((texcmd)))
1981 ;; default command: oldstyle latex via dvi
1982 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
1983 ;; pdflatex -> .pdf
1984 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
1985 (setq texcmd "latexmk -pdf -quiet %f"))
1986 ;; xelatex -> .pdf
1987 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
1988 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
1989 ;; LaTeX compilation command
1990 (setq org-latex-to-pdf-process (list texcmd)))
1991
1992 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
1993
1994 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
1995 (setq org-export-latex-packages-alist
1996 '(("" "graphicx" t)
1997 ("" "longtable" nil)
1998 ("" "float" nil)
1999 ("" "minted" nil)
2000 ))
2001
2002 (defun my-auto-tex-parameters ()
2003 "Automatically select the tex packages to include."
2004 ;; default packages for ordinary latex or pdflatex export
2005 (setq org-export-latex-default-packages-alist
2006 '(("AUTO" "inputenc" t)
2007 ("T1" "fontenc" t)
2008 ("" "fixltx2e" nil)
2009 ("" "wrapfig" nil)
2010 ("" "soul" t)
2011 ("" "textcomp" t)
2012 ("" "marvosym" t)
2013 ("" "wasysym" t)
2014 ("" "latexsym" t)
2015 ("" "amssymb" t)
2016 ("" "hyperref" nil)))
2017
2018 ;; Packages to include when xelatex is used
2019 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
2020 (setq org-export-latex-default-packages-alist
2021 '(("" "fontspec" t)
2022 ("" "xunicode" t)
2023 ("" "url" t)
2024 ("" "rotating" t)
2025 ("german" "babel" t)
2026 ("babel" "csquotes" t)
2027 ("" "soul" t)
2028 ("xetex" "hyperref" nil)
2029 )))
2030
2031 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
2032 (setq org-export-latex-classes
2033 (cons '("scrartcl"
2034 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
2035 ("\\section{%s}" . "\\section*{%s}")
2036 ("\\subsection{%s}" . "\\subsection*{%s}")
2037 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2038 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2039 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
2040 org-export-latex-classes))))
2041
2042 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
2043 #+END_SRC
2044 #+BEGIN_SRC emacs-lisp
2045 (setq org-attach-directory "~/org/data/")
2046 #+END_SRC
2047 #+BEGIN_SRC emacs-lisp
2048 (setq org-agenda-sticky t)
2049 #+END_SRC
2050 ** transient mark
2051 For some reason I prefer this mode more than the way without. I want to
2052 see the marked region.
2053 #+BEGIN_SRC emacs-lisp
2054 (transient-mark-mode 1)
2055 #+END_SRC
2056 ** cua
2057 I know that this lets it look "more like windows", but I don't much care
2058 about its paste/copy/cut keybindings, the really nice part is the great
2059 support for rectangular regions, which I started to use a lot since I
2060 know this mode. The normal keybindings for those are just to useless.
2061 #+BEGIN_SRC emacs-lisp
2062 (cua-mode t)
2063 (setq cua-enable-cua-keys (quote shift))
2064 #+END_SRC
2065
2066 Luckily cua-mode easily supports this, with the following line I just
2067 get the CUA selection and rectangle stuff, not the keybindings. Yes,
2068 even though the above =cua-enable-cua-keys= setting would only enable
2069 them if the selection is done when the region was marked with a shifted
2070 movement keys.
2071 #+BEGIN_SRC emacs-lisp
2072 (cua-selection-mode t)
2073 #+END_SRC
2074
2075 ** mo-git-blame
2076 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2077 Emacs]].
2078
2079 #+BEGIN_SRC emacs-lisp
2080 (autoload 'mo-git-blame-file "mo-git-blame" nil t)
2081 (autoload 'mo-git-blame-current "mo-git-blame" nil t)
2082 #+END_SRC
2083
2084 ** mingus
2085 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2086
2087 I want to access it from anywhere using =F6=.
2088 #+BEGIN_SRC emacs-lisp
2089 (autoload 'mingus "mingus-stays-home" nil t)
2090 (global-set-key (kbd "<f6>") 'mingus)
2091 (setq mingus-dired-add-keys t)
2092 (setq mingus-mode-always-modeline nil)
2093 (setq mingus-mode-line-show-elapsed-percentage nil)
2094 (setq mingus-mode-line-show-volume nil)
2095 (setq mingus-mpd-config-file "/etc/mpd.conf")
2096 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2097 (setq mingus-mpd-root "/share/music/")
2098 #+END_SRC
2099
2100 ** saveplace
2101 Store at which point I have been in files.
2102 #+BEGIN_SRC emacs-lisp
2103 (setq-default save-place t)
2104 (require 'saveplace)
2105 (setq save-place-file (expand-file-name "saved-places" jj-cache-dir))
2106 #+END_SRC
2107 ** savehist
2108 [2013-04-21 So 20:25]
2109 Save a bit of history
2110 #+BEGIN_SRC emacs-lisp
2111 (require 'savehist)
2112 (setq savehist-additional-variables
2113 '(search ring regexp-search-ring kill-ring compile-history))
2114 ;; save every minute
2115 (setq savehist-autosave-interval 60)
2116 (setq savehist-file (expand-file-name "savehist" jj-cache-dir))
2117 (savehist-mode +1)
2118 #+END_SRC
2119
2120 ** easypg
2121 EasyPG is a GnuPG interface for Emacs.
2122 #+BEGIN_SRC emacs-lisp
2123 (require 'epa-file)
2124 (epa-file-enable)
2125 #+END_SRC
2126
2127 I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
2128 #+BEGIN_SRC emacs-lisp
2129 (defadvice epg--start (around advice-epg-disable-agent disable)
2130 "Don't allow epg--start to use gpg-agent in plain text
2131 terminals."
2132 (if (display-graphic-p)
2133 ad-do-it
2134 (let ((agent (getenv "GPG_AGENT_INFO")))
2135 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
2136 ad-do-it
2137 (setenv "GPG_AGENT_INFO" agent))))
2138 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
2139 (ad-activate 'epg--start)
2140 #+END_SRC
2141 ** message
2142 #+BEGIN_SRC emacs-lisp
2143 (require 'message)
2144 (setq message-kill-buffer-on-exit t)
2145 #+END_SRC
2146 ** gnus
2147 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
2148 what I want every emacs to know.
2149
2150 #+BEGIN_SRC emacs-lisp
2151 ;;*** Keyboardmacros
2152 (global-unset-key "\M-n")
2153 (global-set-key "\M-n" 'gnus) ; Start gnus with M-n
2154 #+END_SRC
2155
2156 ** url
2157 url contains code to parse and handle URLs - who would have thought? I
2158 set it to send Accept-language header and tell it to not send email,
2159 operating system or location info.
2160 #+BEGIN_SRC emacs-lisp
2161 (setq url-mime-language-string "de,en")
2162 (setq url-privacy-level (quote (email os lastloc)))
2163 #+END_SRC
2164 ** hippie-exp
2165 Crazy way of completion. It looks at the word before point and then
2166 tries to expand it in various ways.
2167 #+BEGIN_SRC emacs-lisp
2168 (require 'hippie-exp)
2169 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
2170 try-expand-dabbrev-all-buffers
2171 try-expand-dabbrev-from-kill
2172 try-complete-file-name-partially
2173 try-complete-file-name
2174 try-expand-all-abbrevs try-expand-list
2175 try-expand-line
2176 try-complete-lisp-symbol-partially
2177 try-complete-lisp-symbol))
2178 (global-set-key (kbd "M-/") 'hippie-expand)
2179 #+END_SRC
2180 ** yasnippet
2181 [2013-04-27 Sa 23:16]
2182 Yasnippet is a template system. Type an abbreviation, expand it into
2183 whatever the snippet holds.
2184 #+BEGIN_SRC emacs-lisp
2185 (setq yas-snippet-dirs (expand-file-name "yasnippet/snippets" jj-elisp-dir))
2186 (require 'yasnippet)
2187 (yas-global-mode 1)
2188
2189 ;; Integrate hippie-expand with ya-snippet
2190 (add-to-list 'hippie-expand-try-functions-list
2191 'yas-hippie-try-expand)
2192 #+END_SRC
2193 ** elpa
2194 The Emacs Lisp Package Archive (may) contain(s) some things I
2195 want. Even though I usually only use it to get the package, then when I
2196 like it move it into my own space. My elpa subdir stays empty.
2197 #+BEGIN_SRC emacs-lisp
2198 (when (> emacs-major-version 23)
2199 (require 'package)
2200 (setq package-user-dir (expand-file-name "elpa" jj-cache-dir))
2201 (package-initialize)
2202 (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
2203 (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
2204 )
2205 #+END_SRC
2206 ** multiple cursors
2207 [2013-04-08 Mon 23:57]
2208 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2209 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2210 #+BEGIN_SRC emacs-lisp
2211 (require 'multiple-cursors)
2212 (define-key region-bindings-mode-map "a" 'mc/mark-all-like-this)
2213
2214 (define-key region-bindings-mode-map "p" 'mc/mark-previous-like-this)
2215 (define-key region-bindings-mode-map "n" 'mc/mark-next-like-this)
2216 (define-key region-bindings-mode-map "l" 'mc/edit-lines)
2217 (define-key region-bindings-mode-map "m" 'mc/mark-more-like-this-extended)
2218 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))
2219 #+END_SRC
2220 ** rainbow-delimiters
2221 [2013-04-09 Di 23:38]
2222 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
2223 which highlights parens, brackets, and braces according to their
2224 depth. Each successive level is highlighted a different color. This
2225 makes it easy to spot matching delimiters, orient yourself in the code,
2226 and tell which statements are at the same depth.
2227 #+BEGIN_SRC emacs-lisp
2228 (when (require 'rainbow-delimiters nil 'noerror)
2229 (global-rainbow-delimiters-mode))
2230 #+END_SRC
2231 ** undo-tree
2232 [2013-04-21 So 11:07]
2233 Emacs undo is pretty powerful - but can also be confusing. There are
2234 tons of modes available to change it, even downgrade it to the very
2235 crappy ways one usually knows from other systems which lose
2236 information. undo-tree is different - it helps keeping you sane while
2237 keeping the full power of emacs undo/redo.
2238 #+BEGIN_SRC emacs-lisp
2239 (require 'undo-tree)
2240 (global-undo-tree-mode)
2241 (diminish 'undo-tree-mode)
2242 #+END_SRC
2243
2244 Additionally I would like to keep the region active should I undo
2245 while I have one.
2246
2247 #+BEGIN_SRC emacs-lisp
2248 ;; Keep region when undoing in region
2249 (defadvice undo-tree-undo (around keep-region activate)
2250 (if (use-region-p)
2251 (let ((m (set-marker (make-marker) (mark)))
2252 (p (set-marker (make-marker) (point))))
2253 ad-do-it
2254 (goto-char p)
2255 (set-mark m)
2256 (set-marker p nil)
2257 (set-marker m nil))
2258 ad-do-it))
2259 #+END_SRC
2260 ** windmove
2261 [2013-04-21 So 20:27]
2262 Use shift + arrow keys to switch between visible buffers
2263 #+BEGIN_SRC emacs-lisp
2264 (require 'windmove)
2265 (windmove-default-keybindings 'hyper)
2266 (setq windmove-wrap-around t)
2267 #+END_SRC
2268 ** volatile highlights
2269 [2013-04-21 So 20:31]
2270 VolatileHighlights highlights changes to the buffer caused by commands
2271 such as ‘undo’, ‘yank’/’yank-pop’, etc. The highlight disappears at the
2272 next command. The highlighting gives useful visual feedback for what
2273 your operation actually changed in the buffer.
2274 #+BEGIN_SRC emacs-lisp
2275 (require 'volatile-highlights)
2276 (volatile-highlights-mode t)
2277 (diminish 'volatile-highlights-mode)
2278 #+END_SRC
2279 ** ediff
2280 [2013-04-21 So 20:36]
2281 ediff - don't start another frame
2282 #+BEGIN_SRC elisp
2283 (require 'ediff)
2284 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
2285 #+END_SRC
2286 ** re-builder
2287 Saner regex syntax
2288 #+BEGIN_SRC emacs-lisp
2289 (require 're-builder)
2290 (setq reb-re-syntax 'string)
2291 #+END_SRC
2292
2293 [2013-04-21 So 20:39]
2294
2295 ** magit
2296 [2013-04-21 So 20:48]
2297 magit is a mode for interacting with git.
2298 #+BEGIN_SRC emacs-lisp
2299 (require 'magitload)
2300 (require 'magit-svn)
2301 (global-set-key (kbd "C-x g") 'magit-status)
2302 (setq magit-commit-signoff t)
2303 #+END_SRC
2304
2305 ** lisp editing stuff
2306 [2013-04-21 So 21:00]
2307 I'm not doing much of it, except for my emacs and gnus configs, but
2308 then I like it nice too...
2309 #+BEGIN_SRC emacs-lisp
2310 (define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
2311 (require 'paredit)
2312 (setq lisp-coding-hook 'lisp-coding-defaults)
2313 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2314
2315 (eval-after-load "paredit"
2316 '(diminish 'paredit-mode " π"))
2317
2318 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2319 (add-hook 'emacs-lisp-mode-hook (lambda ()
2320 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2321
2322 (define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
2323
2324 (eval-after-load "elisp-slime-nav"
2325 '(diminish 'elisp-slime-nav-mode))
2326 (eval-after-load "rainbow-mode"
2327 '(diminish 'rainbow-mode))
2328 (eval-after-load "eldoc"
2329 '(diminish 'eldoc-mode))
2330 #+END_SRC
2331
2332 ** writegood
2333 This highlights some /weaselwords/, a mode to /aid in finding common
2334 writing problems/...
2335 [2013-04-27 Sa 23:29]
2336 #+BEGIN_SRC emacs-lisp
2337 (require 'writegood-mode)
2338 (global-set-key "\C-cg" 'writegood-mode)
2339 #+END_SRC
2340 ** auto-complete mode
2341 [2013-04-27 Sa 16:33]
2342 And aren't we all lazy? I definitely am, and I like my emacs doing as
2343 much possible work for me as it can.
2344 So here, auto-complete-mode, which lets emacs do this, based on what I
2345 already had typed.
2346 #+BEGIN_SRC emacs-lisp
2347 (require 'auto-complete)
2348 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
2349 (setq ac-dwim t)
2350 (setq ac-auto-start t)
2351
2352 ;; custom keybindings to use tab, enter and up and down arrows
2353 (define-key ac-complete-mode-map "\t" 'ac-expand)
2354 (define-key ac-complete-mode-map "\r" 'ac-complete)
2355 (define-key ac-complete-mode-map "\M-n" 'ac-next)
2356 (define-key ac-complete-mode-map "\M-p" 'ac-previous)
2357 (define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
2358
2359 (require 'ac-dabbrev)
2360 (setq ac-sources (list ac-source-dabbrev))
2361
2362 (setq auto-completion-syntax-alist (quote (global accept . word))) ;; Use space and punctuation to accept the current the most likely completion.
2363 (setq auto-completion-min-chars (quote (global . 2))) ;; Avoid completion for short trivial words.
2364 (setq completion-use-dynamic t)
2365
2366 (add-hook 'latex-mode-hook 'auto-complete-mode)
2367 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
2368 (add-hook 'prog-mode-hook 'auto-complete-mode)
2369 (add-hook 'org-mode-hook 'auto-complete-mode)
2370 #+END_SRC
2371 ** yaml-mode
2372 [2013-04-28 So 01:13]
2373 YAML is a nice format for data, which is both, human and machine
2374 readable/editable without getting a big headache.
2375 #+BEGIN_SRC emacs-lisp
2376 (require 'yaml-mode)
2377 (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
2378 (add-hook 'yaml-mode-hook
2379 '(lambda ()
2380 (define-key yaml-mode-map "\C-m" 'newline-and-indent)))
2381 #+END_SRC
2382
2383 ** flycheck
2384 [2013-04-28 So 22:21]
2385 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
2386 As the one time I tried Flymake i wasn't happy, thats easy to
2387 understand for me.
2388 #+BEGIN_SRC emacs-lisp
2389 (when (> emacs-major-version 23)
2390 (require 'flycheck)
2391 (add-hook 'after-init-hook #'global-flycheck-mode))
2392 #+END_SRC