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