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