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