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