Loads
[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 yes
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 ** avy-mode
592 [2013-04-28 So 11:26]
593 avy is a GNU Emacs package for jumping to visible text using a char-based decision tree.
594 #+BEGIN_SRC emacs-lisp
595 (use-package avy
596 :ensure avy
597 :commands (avy-goto-char avy-goto-char-2 avy-goto-line avy-goto-word-1 avy-goto-word-0 avy-isearch avy-goto-subword-0 avy-goto-subword-1 avy-copy-line avy-copy-region avy-move-line)
598 :bind (("H-SPC" . avy-goto-char-2)
599 ("M-g g" . avy-goto-line)
600 )
601 :init
602 (progn
603 (setq avy-all-windows 'all-frames)
604 (setq avi-keys '(?a ?s ?d ?e ?f ?h ?j ?k ?l ?n ?m ?v ?r ?u) )
605 )
606 :config
607 (progn
608 (bind-key "C-y" 'avy-isearch isearch-mode-map)
609 )
610 )
611 #+END_SRC
612 ** ace-window
613 [2013-04-21 So 20:27]
614 Use H-w to switch windows
615 #+BEGIN_SRC emacs-lisp
616 (use-package ace-window
617 :ensure ace-window
618 :commands ace-window
619 :bind ("H-w" . ace-window)
620 :config
621 (progn
622 (setq aw-keys '(?a ?s ?d ?f ?j ?k ?l))
623 ))
624 #+END_SRC
625 ** aggressive-indent
626 [2014-10-27 Mon 13:08]
627 electric-indent-mode is enough to keep your code nicely aligned when
628 all you do is type. However, once you start shifting blocks around,
629 transposing lines, or slurping and barfing sexps, indentation is bound
630 to go wrong.
631
632 aggressive-indent-mode is a minor mode that keeps your code always
633 indented. It reindents after every command, making it more reliable
634 than electric-indent-mode.
635 #+BEGIN_SRC emacs-lisp
636 (use-package aggressive-indent
637 :ensure aggressive-indent
638 :commands (aggressive-indent-mode global-aggressive-indent-mode)
639 :config
640 (progn
641 (global-aggressive-indent-mode 0)
642 (setq aggressive-indent-comments-too 0)
643 (add-to-list 'aggressive-indent-excluded-modes 'html-mode)
644 ))
645 #+END_SRC
646 ** anzu
647 [2014-06-01 Sun 23:02]
648 Provides a minor mode which displays current match and total matches
649 information in the mode-line in various search modes.
650 #+BEGIN_SRC emacs-lisp
651 (use-package anzu
652 :ensure anzu
653 :diminish anzu-mode
654 :defer t
655 :idle
656 (progn
657 (global-anzu-mode 1))
658 :config
659 (progn
660 (setq anzu-search-threshold 1000)
661 (set-face-attribute 'anzu-mode-line nil :foreground "yellow" :weight 'bold)))
662 #+END_SRC
663 ** ascii
664 [2014-05-21 Wed 00:33]
665 #+BEGIN_SRC emacs-lisp
666 (use-package ascii
667 :commands (ascii-on ascii-toggle ascii-display)
668 :bind (("C-c e A" . ascii-toggle))
669 :init
670 (progn
671 (defun ascii-toggle ()
672 (interactive)
673 (defvar ascii-display nil)
674 (if ascii-display
675 (ascii-off)
676 (ascii-on)))
677
678 (bind-key "C-c e A" 'ascii-toggle)))
679 #+END_SRC
680 ** auctex
681 #+BEGIN_SRC emacs-lisp
682 (setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
683 (setq TeX-auto-save t)
684 (setq TeX-parse-self t)
685 (setq TeX-PDF-mode t)
686 #+END_SRC
687 ** auto-complete mode
688 [2013-04-27 Sa 16:33]
689 And aren't we all lazy? I definitely am, and I like my emacs doing as
690 much possible work for me as it can.
691 So here, auto-complete-mode, which lets emacs do this, based on what I
692 already had typed.
693 #+BEGIN_SRC emacs-lisp
694 (use-package auto-complete-config
695 :ensure auto-complete
696 :idle
697 (ac-config-default)
698 :config
699 (progn
700 ;; hook AC into completion-at-point
701 (defun sanityinc/auto-complete-at-point ()
702 (when (and (not (minibufferp))
703 (fboundp 'auto-complete-mode)
704 auto-complete-mode)
705 (auto-complete)))
706 (defun set-auto-complete-as-completion-at-point-function ()
707 (add-to-list 'completion-at-point-functions 'sanityinc/auto-complete-at-point))
708 ;; Exclude very large buffers from dabbrev
709 (defun sanityinc/dabbrev-friend-buffer (other-buffer)
710 (< (buffer-size other-buffer) (* 1 1024 1024)))
711
712 (use-package pos-tip
713 :ensure t)
714
715 ;; custom keybindings to use tab, enter and up and down arrows
716 (bind-key "\t" 'ac-expand ac-complete-mode-map)
717 (bind-key "\r" 'ac-complete ac-complete-mode-map)
718 (bind-key "M-n" 'ac-next ac-complete-mode-map)
719 (bind-key "M-p" 'ac-previous ac-complete-mode-map)
720 (bind-key "C-s" 'ac-isearch ac-completing-map)
721 (bind-key "M-TAB" 'auto-complete ac-mode-map)
722
723 (setq ac-comphist-file (expand-file-name "ac-comphist.dat" jj-cache-dir))
724 (setq ac-use-comphist t)
725 (setq ac-expand-on-auto-complete nil)
726 (setq ac-dwim t)
727 (setq ac-auto-start 3)
728 (setq ac-delay 0.3)
729 (setq ac-menu-height 15)
730 (setq ac-quick-help-delay 0.5)
731 (setq ac-use-fuzzy t)
732
733 (ac-flyspell-workaround)
734
735 ;; use 't when auto-complete is disabled
736 (setq tab-always-indent 'complete)
737 (add-to-list 'completion-styles 'initials t)
738
739 ;; Use space and punctuation to accept the current the most likely completion.
740 (setq auto-completion-syntax-alist (quote (global accept . word)))
741 ;; Avoid completion for short trivial words.
742 (setq auto-completion-min-chars (quote (global . 3)))
743 (setq completion-use-dynamic t)
744
745 (add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
746
747 ;; Exclude very large buffers from dabbrev
748 (setq dabbrev-friend-buffer-function 'sanityinc/dabbrev-friend-buffer)
749
750 (use-package ac-dabbrev
751 :ensure t)
752
753 (set-default 'ac-sources
754 '(ac-source-imenu
755 ac-source-dictionary
756 ac-source-words-in-buffer
757 ac-source-words-in-same-mode-buffers
758 ; ac-source-words-in-all-buffer
759 ac-source-dabbrev))
760
761 (dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
762 sass-mode yaml-mode csv-mode espresso-mode haskell-mode
763 html-mode nxml-mode sh-mode smarty-mode clojure-mode
764 lisp-mode textile-mode markdown-mode tuareg-mode python-mode
765 js3-mode css-mode less-css-mode sql-mode ielm-mode))
766 (add-to-list 'ac-modes mode))
767
768 (add-hook 'latex-mode-hook 'auto-complete-mode)
769 (add-hook 'LaTeX-mode-hook 'auto-complete-mode)
770 (add-hook 'prog-mode-hook 'auto-complete-mode)
771 (add-hook 'org-mode-hook 'auto-complete-mode)))
772
773 #+END_SRC
774
775 ** auto-revert
776 When files change outside emacs for whatever reason I want emacs to deal
777 with it. Not to have to revert buffers myself
778 #+BEGIN_SRC emacs-lisp
779 (use-package autorevert
780 :commands auto-revert-mode
781 :diminish auto-revert-mode
782 :idle
783 (progn
784 (setq global-auto-revert-mode t)
785 (setq global-auto-revert-non-file-buffers t)
786 (global-auto-revert-mode)))
787 #+END_SRC
788
789 ** backups
790 Emacs should keep backup copies of files I edit, but I do not want them
791 to clutter up the filesystem everywhere. So I put them into one defined
792 place, backup-directory, which even contains my username (for systems
793 where =temporary-file-directory= is not inside my home).
794 #+BEGIN_SRC emacs-lisp
795 (use-package backups-mode
796 :load-path "elisp/backups-mode"
797 :bind (("\C-cv" . save-version)
798 ("\C-cb" . list-backups)
799 ("\C-ck" . kill-buffer-prompt)
800 ("\C-cw" . backup-walker-start))
801 :init
802 (progn
803 (setq backup-directory jj-backup-directory)
804 ;(setq tramp-backup-directory (concat jj-backup-directory "/tramp"))
805 ;(if (not (file-exists-p tramp-backup-directory))
806 ; (make-directory tramp-backup-directory))
807 ;(setq tramp-backup-directory-alist `((".*" . ,tramp-backup-directory)))
808 (setq backup-directory-alist `(("." . ,jj-backup-directory)))
809 (setq auto-save-list-file-prefix (concat jj-backup-directory ".auto-saves-"))
810 (setq auto-save-file-name-transforms `((".*" ,jj-backup-directory t)))
811
812 (setq version-control t) ;; Use version numbers for backups
813 (setq kept-new-versions 10) ;; Number of newest versions to keep
814 (setq kept-old-versions 2) ;; Number of oldest versions to keep
815 (setq delete-old-versions t) ;; Ask to delete excess backup versions?
816 (setq backup-by-copying t)
817 (setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
818 (setq make-backup-files t)
819
820 (defadvice kill-buffer (around kill-buffer)
821 "Always save before killing a file buffer"
822 (when (and (buffer-modified-p)
823 (buffer-file-name)
824 (file-exists-p (buffer-file-name)))
825 (save-buffer))
826 ad-do-it)
827 (ad-activate 'kill-buffer)
828
829 (defadvice save-buffers-kill-emacs (around save-buffers-kill-emacs)
830 "Always save before killing emacs"
831 (save-some-buffers t)
832 ad-do-it)
833 (ad-activate 'save-buffers-kill-emacs)
834
835 (defun kill-buffer-prompt ()
836 "Allows one to kill a buffer without saving it.
837 This is necessary since once you start backups-mode all file based buffers
838 are saved automatically when they are killed"
839 (interactive)
840 (if (and (buffer-modified-p) (buffer-file-name) (file-exists-p (buffer-file-name)) (y-or-n-p "Save buffer?"))
841 (save-buffer)
842 (set-buffer-modified-p nil))
843 (kill-buffer))
844
845 (setq backup-enable-predicate
846 (lambda (name)
847 (and (normal-backup-enable-predicate name)
848 (not
849 (let ((method (file-remote-p name 'method)))
850 (when (stringp method)
851 (member method '("su" "sudo"))))))))))
852
853 #+END_SRC
854 ** browse-kill-ring
855 [2014-12-11 Thu 11:31]
856 #+BEGIN_SRC emacs-lisp
857 (use-package browse-kill-ring
858 :commands (browse-kill-ring browse-kill-ring-mode)
859 :bind ("M-y" . browse-kill-ring)
860 )
861 #+END_SRC
862 ** calendar
863 [2014-06-10 Tue 22:20]
864 #+BEGIN_SRC emacs-lisp
865 (use-package cal
866 :commands (cal/insert)
867 :bind ("C-c c" . cal/insert)
868 :config
869 (progn
870 ; Weeks start on Monday, not sunday.
871 (setq calendar-week-start-day 1)
872
873 ; Display ISO week numbers in Calendar Mode
874 (copy-face font-lock-constant-face 'calendar-iso-week-face)
875 (set-face-attribute 'calendar-iso-week-face nil :height 0.7)
876 (setq calendar-intermonth-text
877 '(propertize
878 (format "%2d"
879 (car
880 (calendar-iso-from-absolute
881 (calendar-absolute-from-gregorian (list month day year)))))
882 'font-lock-face 'calendar-iso-week-face))
883 (copy-face 'default 'calendar-iso-week-header-face)
884 (set-face-attribute 'calendar-iso-week-header-face nil :height 0.7)
885 (setq calendar-intermonth-header
886 (propertize "Wk" ; or e.g. "KW" in Germany
887 'font-lock-face 'calendar-iso-week-header-face))))
888
889 #+END_SRC
890
891 ** crontab-mode
892 [2013-05-21 Tue 23:18]
893 #+BEGIN_SRC emacs-lisp
894 (use-package crontab-mode
895 :ensure crontab-mode
896 :commands crontab-mode
897 :mode ("\\.?cron\\(tab\\)?\\'" . crontab-mode))
898 #+END_SRC
899
900 ** css
901 web-mode takes over, see [[*web-mode][web-mode]]
902 #+BEGIN_SRC emacs-lisp :tangle no
903 (use-package css-mode
904 :mode ("\\.css\\'" . css-mode)
905 :defer t
906 :config
907 (progn
908 ;;; CSS flymake
909 (use-package flymake-css
910 :ensure flymake-css
911 :config
912 (progn
913 (defun maybe-flymake-css-load ()
914 "Activate flymake-css as necessary, but not in derived modes."
915 (when (eq major-mode 'css-mode)
916 (flymake-css-load)))
917 (add-hook 'css-mode-hook 'maybe-flymake-css-load)))
918 ;;; Auto-complete CSS keywords
919 (eval-after-load 'auto-complete
920 '(progn
921 (dolist (hook '(css-mode-hook sass-mode-hook scss-mode-hook))
922 (add-hook hook 'ac-css-mode-setup))))))
923 #+END_SRC
924
925 ** cua
926 I know that this lets it look "more like windows", but I don't much care
927 about its paste/copy/cut keybindings, the really nice part is the great
928 support for rectangular regions, which I started to use a lot since I
929 know this mode. The normal keybindings for those are just to useless.
930 #+BEGIN_SRC emacs-lisp
931 (cua-mode t)
932 (setq cua-enable-cua-keys (quote shift))
933 #+END_SRC
934
935 Luckily cua-mode easily supports this, with the following line I just
936 get the CUA selection and rectangle stuff, not the keybindings. Yes,
937 even though the above =cua-enable-cua-keys= setting would only enable
938 them if the selection is done when the region was marked with a shifted
939 movement keys.
940 #+BEGIN_SRC emacs-lisp
941 (cua-selection-mode t)
942 #+END_SRC
943
944 ** Debian related
945 #+BEGIN_SRC emacs-lisp
946 (require 'dpkg-dev-el-loaddefs nil 'noerror)
947 (require 'debian-el-loaddefs nil 'noerror)
948
949 (setq debian-changelog-full-name "Joerg Jaspert")
950 (setq debian-changelog-mailing-address "joerg@debian.org")
951 #+END_SRC
952
953 ** diff-mode
954 #+BEGIN_SRC emacs-lisp
955 (use-package diff-mode
956 :commands diff-mode
957 :mode (("\\.diff" . diff-mode))
958 :config
959 (use-package diff-mode-))
960 #+END_SRC
961
962 ** dired & co
963 #+BEGIN_SRC emacs-lisp
964 (use-package dired
965 :commands (dired dired-other-window dired-other-frame dired-noselect
966 dired-mode dired-jump)
967 :defines (dired-omit-regexp-orig)
968 :init
969 (progn
970 (setq diredp-hide-details-initially-flag nil))
971 :config
972 (progn
973 (setq dired-auto-revert-buffer (quote dired-directory-changed-p))
974 (setq dired-dwim-target t)
975 (setq dired-listing-switches "-alh")
976 (setq dired-listing-switches "-alXh --group-directories-first")
977 (setq dired-recursive-copies (quote top))
978 (setq dired-recursive-deletes (quote top))
979 (setq dired-guess-shell-alist-user
980 '(("\\.pdf\\'" "mupdf")
981 ("\\.\\(?:djvu\\|eps\\)\\'" "evince")
982 ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "eog")
983 ("\\.\\(?:xcf\\)\\'" "gimp")
984 ("\\.csv\\'" "libreoffice")
985 ("\\.tex\\'" "pdflatex" "latex")
986 ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|ogv\\)\\(?:\\.part\\)?\\'" "vlc")
987 ("\\.html?\\'" "conkeror")))
988
989 (bind-key "F" 'find-name-dired dired-mode-map)
990
991 (use-package dired+
992 :ensure dired+)
993
994 (use-package dired-x)
995
996 (use-package dired-single
997 :ensure dired-single
998 :init
999 (progn
1000 (bind-key "<return>" 'dired-single-buffer dired-mode-map)
1001 (bind-key "<mouse-1>" 'dired-single-buffer-mouse dired-mode-map)
1002 (bind-key "^"
1003 (function
1004 (lambda nil (interactive) (dired-single-buffer ".."))) dired-mode-map )))
1005
1006 (use-package wdired
1007 :ensure wdired
1008 :init
1009 (progn
1010 (setq wdired-allow-to-change-permissions t)
1011 (bind-key "r" 'wdired-change-to-wdired-mode dired-mode-map)))
1012
1013 (use-package gnus-dired
1014 :commands (gnus-dired-attach gnus-dired-mode)
1015 :init
1016 (progn
1017 ;;(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
1018 (bind-key "a" 'gnus-dired-attach dired-mode-map)))
1019
1020 (use-package runner
1021 :ensure runner)
1022
1023 (defvar mark-files-cache (make-hash-table :test #'equal))
1024
1025 (defun mark-similar-versions (name)
1026 (let ((pat name))
1027 (if (string-match "^\\(.+?\\)-[0-9._-]+$" pat)
1028 (setq pat (match-string 1 pat)))
1029 (or (gethash pat mark-files-cache)
1030 (ignore (puthash pat t mark-files-cache)))))
1031
1032 (defun dired-mark-similar-version ()
1033 (interactive)
1034 (setq mark-files-cache (make-hash-table :test #'equal))
1035 (dired-mark-sexp '(mark-similar-versions name)))
1036
1037 (defun dired-package-initialize ()
1038 (unless (featurep 'runner)
1039 (bind-key "M-!" 'async-shell-command dired-mode-map)
1040 (unbind-key "M-s f" dired-mode-map)
1041
1042 (defadvice dired-omit-startup (after diminish-dired-omit activate)
1043 "Make sure to remove \"Omit\" from the modeline."
1044 (diminish 'dired-omit-mode) dired-mode-map)
1045
1046 ;; Omit files that Git would ignore
1047 (defun dired-omit-regexp ()
1048 (let ((file (expand-file-name ".git"))
1049 parent-dir)
1050 (while (and (not (file-exists-p file))
1051 (progn
1052 (setq parent-dir
1053 (file-name-directory
1054 (directory-file-name
1055 (file-name-directory file))))
1056 ;; Give up if we are already at the root dir.
1057 (not (string= (file-name-directory file)
1058 parent-dir))))
1059 ;; Move up to the parent dir and try again.
1060 (setq file (expand-file-name ".git" parent-dir)))
1061 ;; If we found a change log in a parent, use that.
1062 (if (file-exists-p file)
1063 (let ((regexp (funcall dired-omit-regexp-orig))
1064 (omitted-files
1065 (shell-command-to-string "git clean -d -x -n")))
1066 (if (= 0 (length omitted-files))
1067 regexp
1068 (concat
1069 regexp
1070 (if (> (length regexp) 0)
1071 "\\|" "")
1072 "\\("
1073 (mapconcat
1074 #'(lambda (str)
1075 (concat
1076 "^"
1077 (regexp-quote
1078 (substring str 13
1079 (if (= ?/ (aref str (1- (length str))))
1080 (1- (length str))
1081 nil)))
1082 "$"))
1083 (split-string omitted-files "\n" t)
1084 "\\|")
1085 "\\)")))
1086 (funcall dired-omit-regexp-orig))))))
1087
1088 (add-hook 'dired-mode-hook 'dired-package-initialize)
1089
1090 (defun dired-double-jump (first-dir second-dir)
1091 (interactive
1092 (list (read-directory-name "First directory: "
1093 (expand-file-name "~")
1094 nil nil "/Downloads/")
1095 (read-directory-name "Second directory: "
1096 (expand-file-name "~")
1097 nil nil "/")))
1098 (dired first-dir)
1099 (dired-other-window second-dir))
1100 (bind-key "C-c J" 'dired-double-jump)
1101
1102 (defun dired-back-to-top ()
1103 (interactive)
1104 (goto-char (point-min))
1105 (dired-next-line 4))
1106
1107 (define-key dired-mode-map
1108 (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
1109
1110 (defun dired-jump-to-bottom ()
1111 (interactive)
1112 (goto-char (point-max))
1113 (dired-next-line -1))
1114
1115 (define-key dired-mode-map
1116 (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)))
1117
1118 #+END_SRC
1119 ** discover-my-major
1120 [2014-06-01 Sun 23:32]
1121 Discover key bindings and their meaning for the current Emacs major mode.
1122 #+BEGIN_SRC emacs-lisp
1123 (use-package discover-my-major
1124 :ensure discover-my-major
1125 :commands discover-my-major
1126 :bind ("C-h C-m" . discover-my-major))
1127 #+END_SRC
1128 ** easypg
1129 EasyPG is a GnuPG interface for Emacs.
1130 Bookmark: [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1131 #+BEGIN_SRC emacs-lisp
1132 (use-package epa-file
1133 :config
1134 (progn
1135 (epa-file-enable)
1136 ;; I took the following from [[http://www.emacswiki.org/emacs/EasyPG][EmacsWiki: Easy PG]]
1137 (defadvice epg--start (around advice-epg-disable-agent disable)
1138 "Don't allow epg--start to use gpg-agent in plain text
1139 terminals . "
1140 (if (display-graphic-p)
1141 ad-do-it
1142 (let ((agent (getenv "GPG_AGENT_INFO")))
1143 (setenv "GPG_AGENT_INFO" nil) ; give us a usable text password prompt
1144 ad-do-it
1145 (setenv "GPG_AGENT_INFO" agent))))
1146 (ad-enable-advice 'epg--start 'around 'advice-epg-disable-agent)
1147 (ad-activate 'epg--start)
1148 ))
1149 #+END_SRC
1150 ** ediff
1151 [2013-04-21 So 20:36]
1152 ediff - don't start another frame
1153 #+BEGIN_SRC emacs-lisp
1154 (use-package ediff
1155 :pre-init
1156 (progn
1157 (defvar ctl-period-equals-map)
1158 (define-prefix-command 'ctl-period-equals-map)
1159 (bind-key "C-. =" 'ctl-period-equals-map)
1160 (bind-key "C-. = c" 'compare-windows)) ; not an ediff command, but it fits
1161
1162 :bind (("C-. = b" . ediff-buffers)
1163 ("C-. = B" . ediff-buffers3)
1164 ("C-. = =" . ediff-files)
1165 ("C-. = f" . ediff-files)
1166 ("C-. = F" . ediff-files3)
1167 ("C-. = r" . ediff-revision)
1168 ("C-. = p" . ediff-patch-file)
1169 ("C-. = P" . ediff-patch-buffer)
1170 ("C-. = l" . ediff-regions-linewise)
1171 ("C-. = w" . ediff-regions-wordwise))
1172 :config (progn
1173 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1174 (setq ediff-split-window-function 'split-window-horizontally)
1175 )
1176 )
1177 #+END_SRC
1178 ** emms
1179
1180 EMMS is the Emacs Multimedia System.
1181 #+BEGIN_SRC emacs-lisp :tangle no
1182 (require 'emms-source-file)
1183 (require 'emms-source-playlist)
1184 (require 'emms-info)
1185 (require 'emms-cache)
1186 (require 'emms-playlist-mode)
1187 (require 'emms-playing-time)
1188 (require 'emms-player-mpd)
1189 (require 'emms-playlist-sort)
1190 (require 'emms-mark)
1191 (require 'emms-browser)
1192 (require 'emms-lyrics)
1193 (require 'emms-last-played)
1194 (require 'emms-score)
1195 (require 'emms-tag-editor)
1196 (require 'emms-history)
1197 (require 'emms-i18n)
1198
1199 (setq emms-playlist-default-major-mode 'emms-playlist-mode)
1200 (add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
1201 (emms-playing-time 1)
1202 (emms-lyrics 1)
1203 (add-hook 'emms-player-started-hook 'emms-last-played-update-current)
1204 ;(add-hook 'emms-player-started-hook 'emms-player-mpd-sync-from-emms)
1205 (emms-score 1)
1206 (when (fboundp 'emms-cache) ; work around compiler warning
1207 (emms-cache 1))
1208 (setq emms-score-default-score 3)
1209
1210 (defun emms-mpd-init ()
1211 "Connect Emms to mpd."
1212 (interactive)
1213 (emms-player-mpd-connect))
1214
1215 ;; players
1216 (require 'emms-player-mpd)
1217 (setq emms-player-mpd-server-name "localhost")
1218 (setq emms-player-mpd-server-port "6600")
1219 (add-to-list 'emms-info-functions 'emms-info-mpd)
1220 (add-to-list 'emms-player-list 'emms-player-mpd)
1221 (setq emms-volume-change-function 'emms-volume-mpd-change)
1222 (setq emms-player-mpd-sync-playlist t)
1223
1224 (setq emms-source-file-default-directory "/var/lib/mpd/music")
1225 (setq emms-player-mpd-music-directory "/var/lib/mpd/music")
1226 (setq emms-info-auto-update t)
1227 (setq emms-lyrics-scroll-p t)
1228 (setq emms-lyrics-display-on-minibuffer t)
1229 (setq emms-lyrics-display-on-modeline nil)
1230 (setq emms-lyrics-dir "~/.emacs.d/var/lyrics")
1231
1232 (setq emms-last-played-format-alist
1233 '(((emms-last-played-seconds-today) . "%H:%M")
1234 (604800 . "%a %H:%M") ; this week
1235 ((emms-last-played-seconds-month) . "%d.%m.%Y")
1236 ((emms-last-played-seconds-year) . "%d.%m.%Y")
1237 (t . "Never played")))
1238
1239 ;; Playlist format
1240 (defun my-describe (track)
1241 (let* ((empty "...")
1242 (name (emms-track-name track))
1243 (type (emms-track-type track))
1244 (short-name (file-name-nondirectory name))
1245 (play-count (or (emms-track-get track 'play-count) 0))
1246 (last-played (or (emms-track-get track 'last-played) '(0 0 0)))
1247 (artist (or (emms-track-get track 'info-artist) empty))
1248 (year (emms-track-get track 'info-year))
1249 (playing-time (or (emms-track-get track 'info-playing-time) 0))
1250 (min (/ playing-time 60))
1251 (sec (% playing-time 60))
1252 (album (or (emms-track-get track 'info-album) empty))
1253 (tracknumber (emms-track-get track 'info-tracknumber))
1254 (short-name (file-name-sans-extension
1255 (file-name-nondirectory name)))
1256 (title (or (emms-track-get track 'info-title) short-name))
1257 (rating (emms-score-get-score name))
1258 (rate-char ?☭)
1259 )
1260 (format "%12s %20s (%.4s) [%-20s] - %2s. %-30s | %2d %s"
1261 (emms-last-played-format-date last-played)
1262 artist
1263 year
1264 album
1265 (if (and tracknumber ; tracknumber
1266 (not (zerop (string-to-number tracknumber))))
1267 (format "%02d" (string-to-number tracknumber))
1268 "")
1269 title
1270 play-count
1271 (make-string rating rate-char)))
1272 )
1273
1274 (setq emms-track-description-function 'my-describe)
1275
1276 ;; (global-set-key (kbd "C-<f9> t") 'emms-play-directory-tree)
1277 ;; (global-set-key (kbd "H-<f9> e") 'emms-play-file)
1278 (global-set-key (kbd "H-<f9> <f9>") 'emms-mpd-init)
1279 (global-set-key (kbd "H-<f9> d") 'emms-play-dired)
1280 (global-set-key (kbd "H-<f9> x") 'emms-start)
1281 (global-set-key (kbd "H-<f9> v") 'emms-stop)
1282 (global-set-key (kbd "H-<f9> n") 'emms-next)
1283 (global-set-key (kbd "H-<f9> p") 'emms-previous)
1284 (global-set-key (kbd "H-<f9> o") 'emms-show)
1285 (global-set-key (kbd "H-<f9> h") 'emms-shuffle)
1286 (global-set-key (kbd "H-<f9> SPC") 'emms-pause)
1287 (global-set-key (kbd "H-<f9> a") 'emms-add-directory-tree)
1288 (global-set-key (kbd "H-<f9> b") 'emms-smart-browse)
1289 (global-set-key (kbd "H-<f9> l") 'emms-playlist-mode-go)
1290
1291 (global-set-key (kbd "H-<f9> r") 'emms-toggle-repeat-track)
1292 (global-set-key (kbd "H-<f9> R") 'emms-toggle-repeat-playlist)
1293 (global-set-key (kbd "H-<f9> m") 'emms-lyrics-toggle-display-on-minibuffer)
1294 (global-set-key (kbd "H-<f9> M") 'emms-lyrics-toggle-display-on-modeline)
1295
1296 (global-set-key (kbd "H-<f9> <left>") (lambda () (interactive) (emms-seek -10)))
1297 (global-set-key (kbd "H-<f9> <right>") (lambda () (interactive) (emms-seek +10)))
1298 (global-set-key (kbd "H-<f9> <down>") (lambda () (interactive) (emms-seek -60)))
1299 (global-set-key (kbd "H-<f9> <up>") (lambda () (interactive) (emms-seek +60)))
1300
1301 (global-set-key (kbd "H-<f9> s u") 'emms-score-up-playing)
1302 (global-set-key (kbd "H-<f9> s d") 'emms-score-down-playing)
1303 (global-set-key (kbd "H-<f9> s o") 'emms-score-show-playing)
1304 (global-set-key (kbd "H-<f9> s s") 'emms-score-set-playing)
1305
1306 (define-key emms-playlist-mode-map "u" 'emms-score-up-playing)
1307 (define-key emms-playlist-mode-map "d" 'emms-score-down-playing)
1308 (define-key emms-playlist-mode-map "o" 'emms-score-show-playing)
1309 (define-key emms-playlist-mode-map "s" 'emms-score-set-playing)
1310 (define-key emms-playlist-mode-map "r" 'emms-mpd-init)
1311 (define-key emms-playlist-mode-map "N" 'emms-playlist-new)
1312
1313 (define-key emms-playlist-mode-map "x" 'emms-start)
1314 (define-key emms-playlist-mode-map "v" 'emms-stop)
1315 (define-key emms-playlist-mode-map "n" 'emms-next)
1316 (define-key emms-playlist-mode-map "p" 'emms-previous)
1317
1318 (setq emms-playlist-buffer-name "*EMMS Playlist*"
1319 emms-playlist-mode-open-playlists t)
1320
1321 ;; Faces
1322 (if (window-system)
1323 ((lambda ()
1324 (set-face-attribute
1325 'emms-browser-artist-face nil
1326 :family "Arno Pro")
1327 )
1328 ))
1329
1330 (setq emms-player-mpd-supported-regexp
1331 (or (emms-player-mpd-get-supported-regexp)
1332 (concat "\\`http://\\|"
1333 (emms-player-simple-regexp
1334 "m3u" "ogg" "flac" "mp3" "wav" "mod" "au" "aiff"))))
1335 (emms-player-set emms-player-mpd 'regex emms-player-mpd-supported-regexp)
1336
1337 #+END_SRC
1338 ** Emacs shell
1339 Basic settings for emacs integrated shell
1340 #+BEGIN_SRC emacs-lisp :tangle no
1341 (use-package eshell
1342 :defer t
1343 :commands eshell
1344 :init
1345 (progn
1346 (defun eshell-initialize ()
1347 (defun eshell-spawn-external-command (beg end)
1348 "Parse and expand any history references in current input."
1349 (save-excursion
1350 (goto-char end)
1351 (when (looking-back "&!" beg)
1352 (delete-region (match-beginning 0) (match-end 0))
1353 (goto-char beg)
1354 (insert "spawn "))))
1355 (add-hook 'eshell-expand-input-functions 'eshell-spawn-external-command)
1356 (eval-after-load "em-unix"
1357 '(progn
1358 (unintern 'eshell/su)
1359 (unintern 'eshell/sudo))))
1360 (add-hook 'eshell-first-time-mode-hook 'eshell-initialize)
1361 )
1362 :config
1363 (progn
1364 (defalias 'emacs 'find-file)
1365 (defalias 'ec 'find-file)
1366 (defalias 'e 'find-file)
1367
1368 (use-package f
1369 :ensure f)
1370 (use-package 'em-cmpl)
1371 (use-package 'em-prompt)
1372 (use-package 'em-term)
1373
1374 (setq eshell-cmpl-cycle-completions nil
1375 eshell-save-history-on-exit t
1376 eshell-buffer-maximum-lines 20000
1377 eshell-history-size 350
1378 eshell-buffer-shorthand t
1379 eshell-highlight-prompt t
1380 eshell-plain-echo-behavior t
1381 eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
1382
1383 (setenv "PAGER" "cat")
1384 (setq eshell-visual-commands
1385 '("less" "tmux" "htop" "top" "bash" "zsh" "tail"))
1386 (setq eshell-visual-subcommands
1387 '(("git" "log" "l" "diff" "show")))
1388
1389 (add-to-list 'eshell-command-completions-alist
1390 '("gunzip" "gz\\'"))
1391 (add-to-list 'eshell-command-completions-alist
1392 '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
1393
1394 (when (not (functionp 'eshell/rgrep))
1395 (defun eshell/rgrep (&rest args)
1396 "Use Emacs grep facility instead of calling external grep."
1397 (eshell-grep "rgrep" args t)))
1398
1399 ;(set-face-attribute 'eshell-prompt nil :foreground "turquoise1")
1400 (add-hook 'eshell-mode-hook ;; for some reason this needs to be a hook
1401 '(lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol)))
1402 (add-hook 'eshell-preoutput-filter-functions
1403 'ansi-color-filter-apply)
1404 ;; Prompt with a bit of help from http://www.emacswiki.org/emacs/EshellPrompt
1405
1406 (defmacro with-face (str &rest properties)
1407 `(propertize ,str 'face (list ,@properties)))
1408
1409 (defun eshell/abbr-pwd ()
1410 (let ((home (getenv "HOME"))
1411 (path (eshell/pwd)))
1412 (cond
1413 ((string-equal home path) "~")
1414 ((f-ancestor-of? home path) (concat "~/" (f-relative path home)))
1415 (path))))
1416
1417 (defun eshell/my-prompt ()
1418 (let ((header-bg "#161616"))
1419 (concat
1420 (with-face user-login-name :foreground "cyan")
1421 (with-face (concat "@" hostname) :foreground "white")
1422 " "
1423 (with-face (eshell/abbr-pwd) :foreground "#009900")
1424 (if (= (user-uid) 0)
1425 (with-face "#" :foreground "red")
1426 (with-face "$" :foreground "#69b7f0"))
1427 " ")))
1428
1429 (use-package eshell-prompt-extras
1430 :ensure t
1431 :init
1432 (progn
1433 (setq eshell-highlight-prompt nil
1434 ;; epe-git-dirty-char "Ϟ"
1435 epe-git-dirty-char "*"
1436 eshell-prompt-function 'epe-theme-dakrone)))
1437
1438 (defun eshell/magit ()
1439 "Function to open magit-status for the current directory"
1440 (interactive)
1441 (magit-status default-directory)
1442 nil)
1443
1444 (setq eshell-prompt-function 'eshell/my-prompt)
1445 (setq eshell-highlight-prompt nil)
1446 (setq eshell-prompt-regexp "^[^#$\n]+[#$] ")))
1447
1448 #+END_SRC
1449
1450 *** Isearch related
1451 Incremental search is great, but annoyingly you need to type whatever
1452 you want. If you want to search for just the next (or previous)
1453 occurence of what is at your cursor position use the following.
1454 *C-x* will insert the current word while *M-up* and *M-down* will just
1455 jump to the next/previous occurence of it.
1456 #+BEGIN_SRC emacs-lisp
1457 (bind-key "C-x" 'sacha/isearch-yank-current-word isearch-mode-map)
1458 (bind-key* "<M-up>" 'sacha/search-word-backward)
1459 (bind-key* "<M-down>" 'sacha/search-word-forward)
1460 #+END_SRC
1461
1462 *** Frame configuration
1463 I want to see the buffername and its size, not the host I am on in my
1464 frame title.
1465 #+BEGIN_SRC emacs-lisp
1466 (setq frame-title-format "%b (%i)")
1467 #+END_SRC
1468
1469 *** Protect some buffers
1470 I don't want some buffers to be killed, **scratch** for example.
1471 In the past I had a long function that just recreated them, but the
1472 =keep-buffers= package is easier.
1473 #+BEGIN_SRC emacs-lisp
1474 (use-package keep-buffers
1475 :init
1476 (progn
1477 (keep-buffers-mode 1)
1478 (push '("\\`*scratch" . erase) keep-buffers-protected-alist)
1479 (push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
1480 ))
1481 #+END_SRC
1482
1483 *** yes-or-no-p
1484 Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
1485 lazy.
1486 #+BEGIN_SRC emacs-lisp
1487 (defalias 'yes-or-no-p 'y-or-n-p)
1488 #+END_SRC
1489
1490 *** Language/i18n stuff
1491 In this day and age, UTF-8 is the way to go.
1492 #+BEGIN_SRC emacs-lisp
1493 (set-language-environment 'utf-8)
1494 (set-default-coding-systems 'utf-8)
1495 (set-terminal-coding-system 'utf-8)
1496 (set-keyboard-coding-system 'utf-8)
1497 (set-clipboard-coding-system 'utf-8)
1498 (prefer-coding-system 'utf-8)
1499 (set-charset-priority 'unicode)
1500 (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
1501 (when (display-graphic-p)
1502 (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
1503 #+END_SRC
1504
1505 *** Hilight matching parentheses
1506 While I do have the nifty shortcut to jump to the other parentheses,
1507 hilighting them makes it obvious where they are.
1508 #+BEGIN_SRC emacs-lisp
1509 (use-package mic-paren
1510 :init
1511 (paren-activate))
1512 #+END_SRC
1513 *** Kill other buffers
1514 While many editors allow you to close "all the other files, not the one
1515 you are in", emacs doesn't have this... Except, now it will.
1516 (Update 30.05.2014: Not used ever, deactivated)
1517 #+BEGIN_SRC emacs-lisp :tangle no
1518 (bind-key "C-c k" 'prelude-kill-other-buffers)
1519 #+END_SRC
1520 *** Scrolling
1521 Default scrolling behaviour in emacs is a bit annoying, who wants to
1522 jump half-windows?
1523 #+BEGIN_SRC emacs-lisp
1524 (setq scroll-margin 0)
1525 (setq scroll-conservatively 100000)
1526 (setq scroll-up-aggressively 0.0)
1527 (setq scroll-down-aggressively 0.0)
1528 (setq scroll-preserve-screen-position t)
1529 #+END_SRC
1530
1531 *** Copy/Paste with X
1532 [2013-04-09 Di 23:31]
1533 The default how emacs handles cutting/pasting with the primary selection
1534 changed in emacs24. I am used to the old way, so get it back.
1535 #+BEGIN_SRC emacs-lisp
1536 (setq select-enable-primary t)
1537 (setq select-enable-clipboard nil)
1538 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
1539 (setq mouse-drag-copy-region t)
1540 #+END_SRC
1541 *** Global keyboard changes not directly related to a mode
1542 Disable /suspend_frame/ function, I dislike it.
1543 #+BEGIN_SRC emacs-lisp
1544 (unbind-key "C-z")
1545 (unbind-key "C-x C-z")
1546 #+END_SRC
1547
1548 http://endlessparentheses.com/kill-entire-line-with-prefix-argument.html?source=rss
1549 #+BEGIN_SRC emacs-lisp
1550 (defmacro bol-with-prefix (function)
1551 "Define a new function which calls FUNCTION.
1552 Except it moves to beginning of line before calling FUNCTION when
1553 called with a prefix argument. The FUNCTION still receives the
1554 prefix argument."
1555 (let ((name (intern (format "endless/%s-BOL" function))))
1556 `(progn
1557 (defun ,name (p)
1558 ,(format
1559 "Call `%s', but move to BOL when called with a prefix argument."
1560 function)
1561 (interactive "P")
1562 (when p
1563 (forward-line 0))
1564 (call-interactively ',function))
1565 ',name)))
1566
1567 (global-set-key [remap paredit-kill] (bol-with-prefix paredit-kill))
1568 (global-set-key [remap org-kill-line] (bol-with-prefix org-kill-line))
1569 (global-set-key [remap kill-line] (bol-with-prefix kill-line))
1570 #+END_SRC
1571
1572 Default of *C-k* is to kill from the point to the end of line. If
1573 'kill-whole-line' (see [[id:0a1560d9-7e55-47ab-be52-b3a8b8eea4aa][the kill-whole-line part in "General stuff"]]) is
1574 set, including newline. But to kill the entire line, one still needs a
1575 *C-a* in front of it. So I change it, by defining a function to do just this for
1576 me. Lazyness++.
1577 #+BEGIN_SRC emacs-lisp :tangle no
1578 (defun kill-entire-line ()
1579 "Kill this entire line (including newline), regardless of where point is within the line."
1580 (interactive)
1581 (beginning-of-line)
1582 (kill-line)
1583 (back-to-indentation))
1584
1585 (bind-key* "C-k" 'kill-entire-line)
1586 (global-set-key [remap kill-whole-line] 'kill-entire-line)
1587 #+END_SRC
1588
1589 And the same is true when I'm in org-mode, which has an own kill function...
1590 (the keybinding happens later, after org-mode is loaded fully)
1591 #+BEGIN_SRC emacs-lisp :tangle no
1592 (defun jj-org-kill-line (&optional arg)
1593 "Kill the entire line, regardless of where point is within the line, org-mode-version"
1594 (interactive "P")
1595 (beginning-of-line)
1596 (org-kill-line arg)
1597 (back-to-indentation)
1598 )
1599 #+END_SRC
1600
1601 I really hate tabs, so I don't want any indentation to try using them.
1602 And in case a project really needs them, I can change it just for that
1603 file/project, but luckily none of those I work in is as broken.
1604 #+BEGIN_SRC emacs-lisp
1605 (setq-default indent-tabs-mode nil)
1606 #+END_SRC
1607
1608 Make the % key jump to the matching {}[]() if on another, like vi, see [[id:b6e6cf73-9802-4a7b-bd65-fdb6f9745319][the function]]
1609 #+BEGIN_SRC emacs-lisp
1610 (bind-key* "M-5" 'match-paren)
1611 #+END_SRC
1612
1613 Instead of the default "mark-defun" I want a more readline-like setting.
1614 #+BEGIN_SRC emacs-lisp
1615 (bind-key "C-M-h" 'backward-kill-word)
1616 #+END_SRC
1617
1618 Align whatever with a regexp.
1619 #+BEGIN_SRC emacs-lisp
1620 (bind-key "C-x \\" 'align-regexp)
1621 #+END_SRC
1622
1623 Font size changes
1624 #+BEGIN_SRC emacs-lisp
1625 (bind-key "C-+" 'text-scale-increase)
1626 (bind-key "C--" 'text-scale-decrease)
1627 #+END_SRC
1628
1629 Regexes are too useful, so use the regex search by default.
1630 #+begin_src emacs-lisp
1631 (bind-key "C-s" 'isearch-forward-regexp)
1632 (bind-key "C-r" 'isearch-backward-regexp)
1633 (bind-key "C-M-s" 'isearch-forward)
1634 (bind-key "C-M-r" 'isearch-backward)
1635 #+end_src
1636
1637 Rgrep is infinitely useful in multi-file projects.
1638 #+begin_src emacs-lisp
1639 (bind-key "C-x C-g" 'rgrep)
1640 #+end_src
1641
1642 Easy way to move a line up - or down. Simpler than dealing with C-x C-t
1643 AKA transpose lines.
1644 #+BEGIN_SRC emacs-lisp
1645 (bind-key "<M-S-up>" 'move-line-up)
1646 (bind-key "<M-S-down>" 'move-line-down)
1647 #+END_SRC
1648
1649 "Pull" lines up, join them
1650 #+BEGIN_SRC emacs-lisp
1651 (defun join-line-or-lines-in-region ()
1652 "Join this line or the lines in the selected region.
1653 Joins single lines in reverse order to the default, ie. pulls the next one up."
1654 (interactive)
1655 (cond ((region-active-p)
1656 (let ((min (line-number-at-pos (region-beginning))))
1657 (goto-char (region-end))
1658 (while (> (line-number-at-pos) min)
1659 (join-line ))))
1660 (t (let ((current-prefix-arg '(4)))
1661 (call-interactively 'join-line)))))
1662 (bind-key "M-j" 'join-line-or-lines-in-region)
1663 #+END_SRC
1664
1665 When I press Enter I almost always want to go to the right indentation on the next line.
1666 #+BEGIN_SRC emacs-lisp
1667 (bind-key "RET" 'newline-and-indent)
1668 #+END_SRC
1669
1670 Easier undo, and i don't need suspend-frame
1671 #+BEGIN_SRC emacs-lisp
1672 (bind-key "C-z" 'undo)
1673 #+END_SRC
1674
1675 Window switching, go backwards. (C-x o goes to the next window)
1676 #+BEGIN_SRC emacs-lisp
1677 (bind-key "C-x O" (lambda ()
1678 (interactive)
1679 (other-window -1)))
1680 #+END_SRC
1681
1682 Edit file as root
1683 #+BEGIN_SRC emacs-lisp
1684 (bind-key "C-x C-r" 'prelude-sudo-edit)
1685 #+END_SRC
1686
1687 M-space is bound to just-one-space, which is great for programming. What
1688 it does is remove all spaces around the cursor, except for one. But to
1689 be really useful, it also should include newlines. It doesn’t do this by
1690 default. Rather, you have to call it with a negative argument. Sure
1691 not, bad Emacs.
1692 #+BEGIN_SRC emacs-lisp
1693 (bind-key "M-SPC" 'just-one-space-with-newline)
1694 #+END_SRC
1695
1696 Count which commands I use how often.
1697 #+BEGIN_SRC emacs-lisp
1698 (use-package keyfreq
1699 :ensure keyfreq
1700 :init
1701 (progn
1702 (setq keyfreq-file (expand-file-name "keyfreq" jj-cache-dir))
1703 (setq keyfreq-file-lock (expand-file-name "keyfreq.lock" jj-cache-dir))
1704 (keyfreq-mode 1)
1705 (keyfreq-autosave-mode 1)))
1706 #+END_SRC
1707
1708 Duplicate current line
1709 #+BEGIN_SRC emacs-lisp
1710 (defun duplicate-line ()
1711 "Insert a copy of the current line after the current line."
1712 (interactive)
1713 (save-excursion
1714 (let ((line-text (buffer-substring-no-properties
1715 (line-beginning-position)
1716 (line-end-position))))
1717 (move-end-of-line 1)
1718 (newline)
1719 (insert line-text))))
1720
1721 (bind-key "C-c p" 'duplicate-line)
1722 #+END_SRC
1723
1724 Smarter move to the beginning of the line. That is, it first moves to
1725 the beginning of the line - and on second keypress it goes to the
1726 first character on line.
1727 #+BEGIN_SRC emacs-lisp
1728 (defun smarter-move-beginning-of-line (arg)
1729 "Move point back to indentation of beginning of line.
1730
1731 Move point to the first non-whitespace character on this line.
1732 If point is already there, move to the beginning of the line.
1733 Effectively toggle between the first non-whitespace character and
1734 the beginning of the line.
1735
1736 If ARG is not nil or 1, move forward ARG - 1 lines first. If
1737 point reaches the beginning or end of the buffer, stop there."
1738 (interactive "^p")
1739 (setq arg (or arg 1))
1740
1741 ;; Move lines first
1742 (when (/= arg 1)
1743 (let ((line-move-visual nil))
1744 (forward-line (1- arg))))
1745
1746 (let ((orig-point (point)))
1747 (back-to-indentation)
1748 (when (= orig-point (point))
1749 (move-beginning-of-line 1))))
1750
1751 ;; remap C-a to `smarter-move-beginning-of-line'
1752 (global-set-key [remap move-beginning-of-line]
1753 'smarter-move-beginning-of-line)
1754
1755 #+END_SRC
1756
1757 Easily copy characters from the previous nonblank line, starting just
1758 above point. With a prefix argument, only copy ARG characters (never
1759 past EOL), no argument copies rest of line.
1760 #+BEGIN_SRC emacs-lisp
1761 (require 'misc)
1762 (bind-key "H-y" 'copy-from-above-command)
1763 #+END_SRC
1764
1765 Open a new X Terminal pointing to the directory of the current
1766 buffers path.
1767 #+BEGIN_SRC emacs-lisp
1768 (bind-key "H-t" 'jj-open-shell)
1769 #+END_SRC
1770
1771 Align code
1772 #+BEGIN_SRC emacs-lisp
1773 (bind-key "H-a" 'align-code)
1774 #+END_SRC
1775
1776 Insert date
1777 #+BEGIN_SRC emacs-lisp
1778 (bind-key "C-c d" 'insert-date)
1779 #+END_SRC
1780
1781 Another key for indenting
1782 #+BEGIN_SRC emacs-lisp
1783 (bind-key "H-i" 'indent-region)
1784 #+END_SRC
1785
1786 Clean all whitespace stuff
1787 #+BEGIN_SRC emacs-lisp
1788 (bind-key "H-w" 'whitespace-cleanup)
1789 #+END_SRC
1790
1791 Comment/Uncomment
1792 #+BEGIN_SRC emacs-lisp
1793 (bind-key "H-c" 'comment-dwim)
1794 #+END_SRC
1795
1796 Show keystrokes in progress
1797 #+BEGIN_SRC emacs-lisp
1798 (setq echo-keystrokes 0.1)
1799 #+END_SRC
1800 **** Overwrite mode
1801 Usually you can press the *Ins*ert key, to get into overwrite mode. I
1802 don't like that, have broken much with it and so just forbid it by
1803 disabling that.
1804 #+BEGIN_SRC emacs-lisp
1805 (unbind-key "<insert>")
1806 (unbind-key "<kp-insert>")
1807 #+END_SRC
1808
1809 *** Easily navigate sillyCased words
1810 #+BEGIN_SRC emacs-lisp
1811 (global-subword-mode 1)
1812 #+END_SRC
1813 *** Delete file of current buffer, then kill buffer
1814 [2014-06-14 Sat 23:03]
1815 #+BEGIN_SRC emacs-lisp
1816 (defun delete-current-buffer-file ()
1817 "Removes file connected to current buffer and kills buffer."
1818 (interactive)
1819 (let ((filename (buffer-file-name))
1820 (buffer (current-buffer))
1821 (name (buffer-name)))
1822 (if (not (and filename (file-exists-p filename)))
1823 (ido-kill-buffer)
1824 (when (yes-or-no-p "Are you sure you want to remove this file? ")
1825 (delete-file filename)
1826 (kill-buffer buffer)
1827 (message "File '%s' successfully removed" filename)))))
1828
1829 (global-set-key (kbd "C-x C-k") 'delete-current-buffer-file)
1830 #+END_SRC
1831 *** Rename file of current buffer
1832 [2014-06-14 Sat 23:04]
1833 #+BEGIN_SRC emacs-lisp
1834 (defun rename-current-buffer-file ()
1835 "Renames current buffer and file it is visiting."
1836 (interactive)
1837 (let ((name (buffer-name))
1838 (filename (buffer-file-name)))
1839 (if (not (and filename (file-exists-p filename)))
1840 (error "Buffer '%s' is not visiting a file!" name)
1841 (let ((new-name (read-file-name "New name: " filename)))
1842 (if (get-buffer new-name)
1843 (error "A buffer named '%s' already exists!" new-name)
1844 (rename-file filename new-name 1)
1845 (rename-buffer new-name)
1846 (set-visited-file-name new-name)
1847 (set-buffer-modified-p nil)
1848 (message "File '%s' successfully renamed to '%s'"
1849 name (file-name-nondirectory new-name)))))))
1850
1851 (global-set-key (kbd "C-x C-S-r") 'rename-current-buffer-file)
1852 #+END_SRC
1853 *** Quickly find emacs lisp sources
1854 [2014-06-22 Sun 23:05]
1855 #+BEGIN_SRC emacs-lisp
1856 (bind-key "C-l" 'find-library 'help-command)
1857 (bind-key "C-f" 'find-function 'help-command)
1858 (bind-key "C-k" 'find-function-on-key 'help-command)
1859 (bind-key "C-v" 'find-variable 'help-command)
1860 #+END_SRC
1861 *** Adjust occur
1862 [2015-01-26 Mon 16:01]
1863 #+BEGIN_SRC emacs-lisp
1864 (bind-key "M-s o" 'occur-dwim)
1865 #+END_SRC
1866
1867 ** ethan-wspace
1868 [2014-06-01 Sun 15:00]
1869 Proper whitespace handling
1870 #+BEGIN_SRC emacs-lisp :tangle no
1871 (use-package ethan-wspace
1872 :ensure ethan-wspace
1873 :diminish (ethan-wspace-mode . "ew")
1874 :init
1875 (global-ethan-wspace-mode 1))
1876 #+END_SRC
1877
1878 ** expand-region
1879 [2014-06-01 Sun 15:16]
1880 #+BEGIN_SRC emacs-lisp
1881 (use-package expand-region
1882 :ensure expand-region
1883 :bind ("C-M-+" . er/expand-region)
1884 :commands er/expand-region)
1885 #+END_SRC
1886 ** filladapt
1887 [2013-05-02 Thu 00:04]
1888 Filladapt by KyleJones enhances Emacs’ fill functions by guessing a
1889 fill prefix, such as a comment sequence in program code, and handling
1890 bullet points like “1.” or “*”.
1891 #+BEGIN_SRC emacs-lisp
1892 (use-package filladapt
1893 :diminish filladapt-mode
1894 :idle
1895 (setq-default filladapt-mode t))
1896 #+END_SRC
1897 ** flycheck
1898 [2013-04-28 So 22:21]
1899 Flycheck is a on-the-fly syntax checking tool, supposedly better than Flymake.
1900 As the one time I tried Flymake i wasn't happy, thats easy to
1901 understand for me.
1902 #+BEGIN_SRC emacs-lisp
1903 (use-package flycheck
1904 :ensure flycheck
1905 :diminish flycheck-mode
1906 :bind (("M-n" . next-error)
1907 ("M-p" . previous-error))
1908 :idle
1909 (progn
1910 (add-hook 'find-file-hook
1911 (lambda ()
1912 (when (not (equal 'emacs-lisp-mode major-mode))
1913 (flycheck-mode)))))
1914 :config
1915 (progn
1916 (use-package flycheck-color-mode-line
1917 :ensure flycheck-color-mode-line)
1918 (setq flycheck-highlighting-mode nil)
1919 (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
1920 ))
1921 #+END_SRC
1922 ** font-lock
1923 Obviously emacs can do syntax hilighting. For more things than you ever
1924 heard about.
1925 And I want to have it everywhere.
1926 #+BEGIN_SRC emacs-lisp
1927 (use-package font-lock
1928 :init
1929 (progn
1930 (global-font-lock-mode 1)
1931 (setq font-lock-maximum-decoration t)))
1932 #+END_SRC
1933 ** git commit mode
1934 #+BEGIN_SRC emacs-lisp :tangle no
1935 (use-package git-commit
1936 :commands git-commit
1937 :mode ("COMMIT_EDITMSG" . git-commit-mode))
1938 #+END_SRC
1939
1940 ** git rebase mode
1941 #+BEGIN_SRC emacs-lisp :tangle no
1942 (use-package git-rebase
1943 :commands git-rebase
1944 :mode ("git-rebase-todo" . git-rebase-mode))
1945 #+END_SRC
1946 ** git-gutter+
1947 [2014-05-21 Wed 22:56]
1948 #+BEGIN_SRC emacs-lisp
1949 (use-package git-gutter+
1950 :ensure git-gutter+
1951 :diminish git-gutter+-mode
1952 :bind (("C-x n" . git-gutter+-next-hunk)
1953 ("C-x p" . git-gutter+-previous-hunk)
1954 ("C-x v =" . git-gutter+-show-hunk)
1955 ("C-x r" . git-gutter+-revert-hunks)
1956 ("C-x s" . git-gutter+-stage-hunks)
1957 ("C-x c" . git-gutter+-commit)
1958 )
1959 :idle
1960 (progn
1961 (setq git-gutter+-disabled-modes '(org-mode))
1962 (global-git-gutter+-mode 1))
1963 :config
1964 (progn
1965 (use-package git-gutter-fringe+
1966 :ensure git-gutter-fringe+
1967 :config
1968 (progn
1969 (setq git-gutter-fr+-side 'right-fringe)
1970 ;(git-gutter-fr+-minimal)
1971 ))))
1972
1973 #+END_SRC
1974 ** git-messenger
1975 [2015-02-22 Sun 14:00]
1976 Provides function that popup commit message at current line. This is
1977 useful when you want to know why this line was changed.
1978 #+BEGIN_SRC emacs-lisp
1979 (use-package git-messenger
1980 :ensure git-messenger
1981 :commands (git-messenger:popup-message)
1982 :bind (("C-x v p" . git-messenger:popup-message))
1983 :config
1984 (progn
1985 (bind-key "m" 'git-messenger:copy-message git-messenger-map)
1986 (add-hook 'git-messenger:popup-buffer-hook 'magit-commit-mode)
1987 (setq git-messenger:show-detail t)))
1988 #+END_SRC
1989 ** git timemachine
1990 [2014-07-23 Mi 12:57]
1991 Browse historic versions of a file with p (previous) and n (next).
1992 #+BEGIN_SRC emacs-lisp
1993 (use-package git-timemachine
1994 :ensure git-timemachine
1995 :commands git-timemachine)
1996 #+END_SRC
1997 ** gnus
1998 Most of my gnus config is in an own file, [[file:gnus.org][gnus.org]], here I only have
1999 what I want every emacs to know.
2000 #+BEGIN_SRC emacs-lisp
2001 (bind-key "C-c g" 'gnus) ; Start gnus with M-n
2002 (after 'gnus
2003 (jj-init-theme)
2004 )
2005 #+END_SRC
2006 ** golden ratio
2007 [2015-02-20 Fri 16:27]
2008 When working with many windows at the same time, each window has a
2009 size that is not convenient for editing.
2010
2011 golden-ratio helps on this issue by resizing automatically the windows
2012 you are working on to the size specified in the "Golden Ratio". The
2013 window that has the main focus will have the perfect size for editing,
2014 while the ones that are not being actively edited will be re-sized to
2015 a smaller size that doesn't get in the way, but at the same time will
2016 be readable enough to know it's content.
2017 #+BEGIN_SRC emacs-lisp
2018 (use-package golden-ratio
2019 :ensure golden-ratio
2020 :diminish golden-ratio-mode
2021 :init
2022 (progn
2023 (golden-ratio-mode 1)
2024 (setq golden-ratio-exclude-buffer-names '("*LV*" "*guide-key*"))
2025 (setq golden-ratio-exclude-modes '("calendar-mode" "gnus-summary-mode"
2026 "gnus-article-mode" "calc-mode" "calc-trail-mode"
2027 "bbdb-mode"))
2028 ))
2029 #+END_SRC
2030 ** goto last change
2031 [2015-02-22 Sun 13:28]
2032 Move point through buffer-undo-list positions.
2033 #+BEGIN_SRC emacs-lisp
2034 (use-package goto-last-change
2035 :commands (goto-last-change)
2036 :bind (("M-g l" . goto-last-change))
2037 )
2038 #+END_SRC
2039 ** guide-key
2040 [2014-06-11 Wed 22:27]
2041 guide-key.el displays the available key bindings automatically and
2042 dynamically.
2043
2044 For whatever reason I like this more than icicles <backtab> completion
2045 for this.
2046 #+BEGIN_SRC emacs-lisp
2047 (use-package guide-key
2048 :ensure guide-key
2049 :diminish guide-key-mode
2050 :init
2051 (progn
2052 (setq guide-key/guide-key-sequence '("C-x" "C-c" "M-g" "M-s"))
2053 (guide-key-mode 1)
2054 (setq guide-key/recursive-key-sequence-flag t)
2055 (setq guide-key/popup-window-position 'bottom)
2056 (setq guide-key/idle-delay 0.5)))
2057
2058 #+END_SRC
2059
2060 ** highlight mode
2061 [2014-05-21 Wed 23:51]
2062 #+BEGIN_SRC emacs-lisp
2063 (use-package hi-lock
2064 :bind (("M-o l" . highlight-lines-matching-regexp)
2065 ("M-o r" . highlight-regexp)
2066 ("M-o w" . highlight-phrase)))
2067
2068 (use-package hilit-chg
2069 :bind ("M-o C" . highlight-changes-mode))
2070
2071 #+END_SRC
2072 ** hippie-exp
2073 Crazy way of completion. It looks at the word before point and then
2074 tries to expand it in various ways.
2075 #+BEGIN_SRC emacs-lisp
2076 (use-package hippie-exp
2077 :bind ("M-/" . hippie-expand)
2078 :commands hippie-expand
2079 :config
2080 (progn
2081 (setq hippie-expand-try-functions-list '(try-expand-dabbrev
2082 try-expand-dabbrev-all-buffers
2083 try-expand-dabbrev-from-kill
2084 try-complete-file-name-partially
2085 try-complete-file-name
2086 try-expand-all-abbrevs try-expand-list
2087 try-expand-line
2088 try-complete-lisp-symbol-partially
2089 try-complete-lisp-symbol))))
2090 #+END_SRC
2091 ** html-helper
2092 Replaced by web-mode [[*web-mode][web-mode]]
2093 #+BEGIN_SRC emacs-lisp :tangle no
2094 (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
2095 (add-auto-mode 'html-helper-mode "\\.html$")
2096 (add-auto-mode 'html-helper-mode "\\.asp$")
2097 (add-auto-mode 'html-helper-mode "\\.phtml$")
2098 (add-auto-mode 'html-helper-mode "\\.(jsp|tmpl)\\'")
2099 (defalias 'html-mode 'html-helper-mode)
2100 #+END_SRC
2101 ** hydra
2102 [2015-01-26 Mon 15:50]
2103 This is a package for GNU Emacs that can be used to tie related
2104 commands into a family of short bindings with a common prefix - a
2105 Hydra.
2106
2107 Once you summon the Hydra through the prefixed binding (the body + any
2108 one head), all heads can be called in succession with only a short
2109 extension.
2110
2111 The Hydra is vanquished once Hercules, any binding that isn't the
2112 Hydra's head, arrives. Note that Hercules, besides vanquishing the
2113 Hydra, will still serve his orignal purpose, calling his proper
2114 command. This makes the Hydra very seamless, it's like a minor mode
2115 that disables itself auto-magically.
2116 #+BEGIN_SRC emacs-lisp
2117 (use-package hydra
2118 :ensure hydra
2119 :init
2120 (progn
2121 (setq hydra-is-helpful t)
2122 (setq hydra-lv t)
2123
2124 (defhydra hydra-zoom (:color red)
2125 "zoom"
2126 ("g" text-scale-increase "in")
2127 ("l" text-scale-decrease "out")
2128 ("q" nil "quit"))
2129 (bind-key "<F2>" 'hydra-zoom/toggle)
2130
2131 (defhydra hydra-error (:color red)
2132 "goto-error"
2133 ("h" first-error "first")
2134 ("j" next-error "next")
2135 ("k" previous-error "prev")
2136 ("v" recenter-top-bottom "recenter")
2137 ("q" nil "quit"))
2138 (bind-key "M-g e" 'hydra-error/body)
2139
2140 (defhydra hydra-gnus (:color red)
2141 "gnus functions"
2142 ("m" gnus-uu-mark-thread "mark thread")
2143 ("d" gnus-summary-delete-article "delete article(s)")
2144 ("r" gnus-summary-mark-as-read-forward "mark read")
2145 ("n" gnus-summary-next-thread "next thread")
2146 ("p" gnus-summary-prev-thread "previous thread")
2147 ("g" gnus-summary-next-group "next group")
2148 ("l" gnus-recenter "recenter")
2149 ("x" gnus-summary-limit-to-unread "unread")
2150 ("q" nil "quit"))
2151 (bind-key "C-c h" 'hydra-gnus/body)
2152
2153 (defhydra hydra-launcher (:color blue)
2154 "Launch"
2155 ("h" man "man")
2156 ("r" (browse-url "http://www.reddit.com/r/emacs/") "reddit")
2157 ("w" (browse-url "http://www.emacswiki.org/") "emacswiki")
2158 ("s" shell "shell")
2159 ("q" nil "cancel"))
2160 (bind-key "C-c r" 'hydra-launcher/body)
2161
2162 ; whitespace mode gets loaded late, so variable may not be there yet. Workaround...
2163 (defvar whitespace-mode nil)
2164 (defhydra hydra-toggle (:color pink)
2165 "
2166 _a_ abbrev-mode: % 4`abbrev-mode^^^^ _f_ auto-fill-mode: %`auto-fill-function
2167 _c_ auto-complete-mode: % 4`auto-complete-mode _r_ auto-revert-mode: %`auto-revert-mode
2168 _d_ debug-on-error: % 4`debug-on-error^ _t_ truncate-lines: %`truncate-lines
2169 _w_ whitespace-mode: % 4`whitespace-mode _g_ golden-ratio-mode: %`golden-ratio-mode
2170 _l_ linum-mode: % 4`linum-mode _k_ linum relative: %`linum-format
2171
2172 "
2173 ("a" abbrev-mode nil)
2174 ("c" auto-complete-mode nil)
2175 ("i" aggressive-indent-mode nil)
2176 ("d" toggle-debug-on-error nil)
2177 ("f" auto-fill-mode nil)
2178 ("g" golden-ratio-mode nil)
2179 ("t" toggle-truncate-lines nil)
2180 ("w" whitespace-mode nil)
2181 ("r" auto-revert-mode nil)
2182 ("l" linum-mode nil)
2183 ("k" linum-relative-toggle nil)
2184 ("q" nil "cancel"))
2185 (bind-key "C-c C-v" 'hydra-toggle/body)
2186 ))
2187
2188
2189 #+END_SRC
2190 ** ibuffer
2191 [2014-05-21 Wed 23:54]
2192 #+BEGIN_SRC emacs-lisp
2193 (use-package ibuffer
2194 :defer t
2195 :bind (("C-h h" . ibuffer)
2196 ("C-x C-b" . ibuffer)
2197 ("<XF86WebCam>" . ibuffer)
2198 )
2199 :commands (ibuffer)
2200 :defines (ibuffer-filtering-alist
2201 ibuffer-filter-groups ibuffer-compile-formats ibuffer-git-column-length
2202 ibuffer-show-empty-filter-groups ibuffer-saved-filter-groups)
2203 :config
2204 (progn
2205 (defvar my-ibufffer-separator " • ")
2206 (setq ibuffer-filter-group-name-face 'variable-pitch
2207 ibuffer-use-header-line t
2208 ibuffer-old-time 12)
2209 (unbind-key "M-o" ibuffer-mode-map)
2210 (bind-key "s" 'isearch-forward-regexp ibuffer-mode-map)
2211 (bind-key "." 'ibuffer-invert-sorting ibuffer-mode-map)
2212
2213 (use-package f
2214 :ensure f)
2215
2216 (use-package ibuffer-vc
2217 :ensure t
2218 :commands
2219 (ibuffer-vc-set-filter-groups-by-vc-root
2220 ibuffer-vc-generate-filter-groups-by-vc-root))
2221
2222 (use-package ibuffer-tramp
2223 :ensure t
2224 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
2225 ibuffer-tramp-set-filter-groups-by-tramp-connection))
2226 ;; Switching to ibuffer puts the cursor on the most recent buffer
2227 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
2228 "Open ibuffer with cursor pointed to most recent buffer name"
2229 (let ((recent-buffer-name (buffer-name)))
2230 ad-do-it
2231 (ibuffer-update nil t)
2232 (unless (string= recent-buffer-name "*Ibuffer*")
2233 (ibuffer-jump-to-buffer recent-buffer-name))))
2234
2235 (defun ibuffer-magit-status ()
2236 (interactive)
2237 (--when-let (get-buffer "*Ibuffer*")
2238 (with-current-buffer it
2239 (let* ((selected-buffer (ibuffer-current-buffer))
2240 (buffer-path (with-current-buffer
2241 selected-buffer
2242 (or (buffer-file-name)
2243 list-buffers-directory
2244 default-directory)))
2245 (default-directory
2246 (if (file-regular-p buffer-path)
2247 (file-name-directory buffer-path)
2248 buffer-path)))
2249 (magit-status default-directory)))))
2250 (bind-key "i" 'ibuffer-magit-status ibuffer-mode-map)
2251 (bind-key "G" 'ibuffer-magit-status ibuffer-mode-map)
2252
2253 (setq ibuffer-directory-abbrev-alist
2254 (-uniq
2255 (-flatten
2256 (--map
2257 (list
2258 (cons (f-slash (f-expand (cdr it))) my-ibufffer-separator)
2259 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
2260 '(
2261 ("dak" . "/develop/dak/")
2262 ("org" . "~/org/")
2263 ("config" . "~/.emacs.d/config/")
2264 ("tmp" . "~/tmp/")
2265 ("systmp" . "/tmp/")
2266 ("puppet" . "~/git/puppet")
2267 ("git" . "~/git/")
2268 )))))
2269
2270 (use-package ibuffer-git
2271 :ensure t)
2272 (use-package ibuffer-vc
2273 :ensure t)
2274
2275 (define-ibuffer-column size-h
2276 (:name "Size" :inline t)
2277 (cond
2278 ((> (buffer-size) 1000)
2279 (format "%7.1fk" (/ (buffer-size) 1000.0)))
2280 ((> (buffer-size) 1000000)
2281 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
2282 (t
2283 (format "%8d" (buffer-size)))))
2284
2285 (use-package ibuf-ext)
2286 (define-ibuffer-filter filename2
2287 "Toggle current view to buffers with filename matching QUALIFIER."
2288 (:description "filename2"
2289 :reader (read-from-minibuffer "Filter by filename (regexp): "))
2290 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
2291 (ibuffer-awhen (with-current-buffer buf
2292 (or buffer-file-name
2293 default-directory))
2294 (string-match qualifier it)))
2295
2296 (defvar ibuffer-magit-filter-groups nil)
2297 (defun ibuffer-magit-define-filter-groups ()
2298 (when (and (not ibuffer-magit-filter-groups)
2299 (boundp 'magit-repo-dirs))
2300 (setq ibuffer-magit-filter-groups
2301 (--map (list
2302 (concat "git:: "
2303 (file-name-nondirectory (directory-file-name it)))
2304 `(filename2 . ,it))
2305 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
2306
2307 (defun ibuffer-set-filter-groups-by-root ()
2308 (interactive)
2309 ;; (ibuffer-projectile-define-filter-groups)
2310 ;; (ibuffer-magit-define-filter-groups)
2311 (setq ibuffer-filter-groups
2312 (-concat
2313 ;; ibuffer-projectile-filter-groups
2314 ibuffer-magit-filter-groups
2315
2316 '(("MORE"
2317 (or (mode . magit-log-edit-mode)
2318 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2319 (name . "^\\*Pymacs\\*$")
2320 (name . "^\\*helm.*\\*")
2321 (name . "^\\*Compile-log\\*$")
2322 (name . "^\\*Ido Completions\\*$")
2323 (name . "^\\*magit-\\(process\\)\\*$")
2324 (name . "^ "))))
2325 '(("EMACS"
2326 (or
2327 (name . "^\\*scratch")
2328 (name . "^\\*Messages")
2329 (name . "^\\*Help")
2330 )))
2331 (ibuffer-vc-generate-filter-groups-by-vc-root)
2332 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
2333
2334 (defun toggle-ibuffer-filter-groups ()
2335 "DOCSTRING"
2336 (interactive)
2337 (let ((ibuf (get-buffer "*Ibuffer*")))
2338 (when ibuf
2339 (with-current-buffer ibuf
2340 (let ((selected-buffer (ibuffer-current-buffer)))
2341 (if (not ibuffer-filter-groups)
2342 (ibuffer-set-filter-groups-by-root)
2343 (setq ibuffer-filter-groups nil))
2344 (pop-to-buffer ibuf)
2345 (ibuffer-update nil t)
2346 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
2347
2348 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
2349
2350 (defun ibuffer-back-to-top ()
2351 (interactive)
2352 (beginning-of-buffer)
2353 (next-line 3))
2354
2355 (defun ibuffer-jump-to-bottom ()
2356 (interactive)
2357 (end-of-buffer)
2358 (beginning-of-line)
2359 (next-line -2))
2360
2361 (define-key ibuffer-mode-map
2362 (vector 'remap 'end-of-buffer) 'ibuffer-jump-to-bottom)
2363 (define-key ibuffer-mode-map
2364 (vector 'remap 'beginning-of-buffer) 'ibuffer-back-to-top)
2365
2366 (setq ibuffer-default-sorting-mode 'recency
2367 ibuffer-eliding-string "…"
2368 ibuffer-compile-formats t
2369 ibuffer-git-column-length 6
2370 ibuffer-show-empty-filter-groups nil
2371 ibuffer-default-directory "~/"
2372 )
2373
2374 (setq ibuffer-formats '((mark vc-status-mini
2375 " "
2376 (git-status 8 8 :left)
2377 " "
2378 read-only modified
2379 " "
2380 (name 18 18 :left :elide)
2381 " "
2382 (size-h 9 -1 :right)
2383 " "
2384 (mode 16 16 :left :elide)
2385 " " filename-and-process)
2386 (mark " "
2387 (git-status 8 8 :left)
2388 " "
2389 (name 16 -1)
2390 " " filename)
2391 ))
2392
2393 (setq ibuffer-saved-filter-groups
2394 (quote (("flat")
2395 ("default"
2396 ("dired" (mode . dired-mode))
2397 ("perl" (mode . cperl-mode))
2398 ("puppet" (or
2399 (mode . puppet-mode)
2400 (mode . yaml-mode)))
2401 ("ruby" (mode . ruby-mode))
2402 ("emacs" (or
2403 (name . "^\\*scratch\\*$")
2404 (name . "^\\*Compile-log\\*$")
2405 (name . "^\\*Completions\\*$")
2406 (name . "^\\*Messages\\*$")
2407 (name . "^\\*Backtrace\\*$")
2408 (name . "^\\*Packages*\\*$")
2409 (name . "^\\*Help*\\*$")
2410 ))
2411 ("gnus" (or
2412 (mode . message-mode)
2413 (mode . bbdb-mode)
2414 (mode . mail-mode)
2415 (mode . gnus-group-mode)
2416 (mode . gnus-summary-mode)
2417 (mode . gnus-article-mode)
2418 (name . "^\\.bbdb$")
2419 (name . "^\\.newsrc-dribble")))
2420 ("org" (or
2421 (filename . ".*/org/.*")
2422 (mode . org-agenda-mode)
2423 (name . "^diary$")))
2424 ("other" (or
2425 (mode . magit-log-edit-mode)
2426 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
2427 ("categorized"
2428 ;; -------------------------------------------------
2429 ;; programming languages #1
2430 ("code" (or
2431 (mode . emacs-lisp-mode)
2432 (mode . python-mode)
2433 (mode . ruby-mode)
2434 (mode . coffee-mode)
2435 (mode . js-mode)
2436 (mode . js2-mode)
2437 (mode . actionscript-mode)
2438 (mode . java-mode)
2439 (mode . sh-mode)
2440 (mode . haskell-mode)
2441 (mode . html-mode)
2442 (mode . web-mode)
2443 (mode . haml-mode)
2444 (mode . nxml-mode)
2445 (mode . css-mode)))
2446 ;; -------------------------------------------------
2447 ;; configuration/data files
2448 ("conf" (or
2449 (mode . json-mode)
2450 (mode . yaml-mode)
2451 (mode . conf-mode)))
2452 ;; -------------------------------------------------
2453 ;; text/notetaking/org
2454 ("org agenda" (mode . org-agenda-mode))
2455 ("org" (or
2456 (mode . org-mode)
2457 (name . "^\\*Calendar\\*$")
2458 (name . "^diary$")))
2459 ("text misc" (or
2460 (mode . text-mode)
2461 (mode . rst-mode)
2462 (mode . markdown-mode)))
2463 ;; -------------------------------------------------
2464 ;; media
2465 ("media" (or
2466 (mode . image-mode)))
2467 ;; -------------------------------------------------
2468 ;; misc
2469 ("w3m" (mode . w3m-mode))
2470 ("scm" (or
2471 (mode . magit-status-mode)
2472 (mode . magit-log-mode)
2473 (mode . vc-annotate-mode)))
2474 ("dired" (mode . dired-mode))
2475 ("help" (or
2476 (mode . Info-mode)
2477 (mode . help-mode)
2478 (mode . Man-mode)
2479 (name . "^\\*Personal Keybindings\\*$")))
2480 ;; -------------------------------------------------
2481 ;; *buffer* buffers
2482 ("MORE" (or (mode . magit-log-edit-mode)
2483 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2484 (name . "^\\*Pymacs\\*$")
2485 (name . "^\\*Compile-log\\*$")
2486 (name . "^\\*Completions\\*$")
2487 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
2488 (name . "^ ")))
2489 ("*buffer*" (name . "\\*.*\\*"))))))
2490
2491 (add-hook 'ibuffer-mode-hook
2492 (lambda ()
2493 (ibuffer-auto-mode 1)
2494 (ibuffer-switch-to-saved-filter-groups "default")))
2495
2496 ;; Unless you turn this variable on you will be prompted every time
2497 ;; you want to delete a buffer, even unmodified ones, which is way
2498 ;; too cautious for most people. You’ll still be prompted for
2499 ;; confirmation when deleting modified buffers after the option has
2500 ;; been turned off.
2501 (setq ibuffer-expert t)
2502
2503 ))
2504 #+END_SRC
2505 ** icicles
2506 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
2507 ‘TAB’ completion is to typing things manually every time.”]]
2508 #+BEGIN_SRC emacs-lisp
2509 (use-package icicles
2510 :load-path "elisp/icicle/"
2511 :init
2512 (icy-mode 1))
2513 #+END_SRC
2514 ** icomplete
2515 Incremental mini-buffer completion preview: Type in the minibuffer,
2516 list of matching commands is echoed
2517 #+BEGIN_SRC emacs-lisp
2518 (icomplete-mode 99)
2519 #+END_SRC
2520 ** iedit
2521 [2014-05-26 Mon 22:49]
2522 #+BEGIN_SRC emacs-lisp
2523 (use-package iedit
2524 :ensure iedit
2525 :commands (iedit-mode)
2526 :defer t
2527 :bind (("C-;" . iedit-mode)
2528 ("C-," . iedit-mode-toggle-on-function))
2529 )
2530
2531 #+END_SRC
2532 ** info stuff
2533 [2014-05-20 Tue 23:35]
2534 #+BEGIN_SRC emacs-lisp
2535 (use-package info
2536 :bind ("C-h C-i" . info-lookup-symbol)
2537 :commands info-lookup-symbol
2538 :config
2539 (progn
2540 ;; (defadvice info-setup (after load-info+ activate)
2541 ;; (use-package info+))
2542
2543 (defadvice Info-exit (after remove-info-window activate)
2544 "When info mode is quit, remove the window."
2545 (if (> (length (window-list)) 1)
2546 (delete-window)))))
2547
2548 (use-package info-look
2549 :commands info-lookup-add-help)
2550 #+END_SRC
2551 ** linum (line number)
2552 Various modes should have line numbers in front of each line.
2553
2554 But then there are some where it would just be deadly - like org-mode,
2555 gnus, so we have a list of modes where we don't want to see it.
2556 #+BEGIN_SRC emacs-lisp
2557 (use-package linum
2558 :diminish linum-mode
2559 :config
2560 (progn
2561 (setq linum-format "%3d ")
2562 (setq linum-mode-inhibit-modes-list '(org-mode
2563 eshell-mode
2564 shell-mode
2565 gnus-group-mode
2566 gnus-summary-mode
2567 gnus-article-mode))
2568
2569 (defadvice linum-on (around linum-on-inhibit-for-modes)
2570 "Stop the load of linum-mode for some major modes."
2571 (unless (member major-mode linum-mode-inhibit-modes-list)
2572 ad-do-it))
2573
2574 (ad-activate 'linum-on)
2575
2576 (use-package linum-relative
2577 :ensure linum-relative
2578 :init
2579 (progn
2580 (setq linum-format 'dynamic)
2581 )))
2582 :init
2583 (global-linum-mode 1))
2584 #+END_SRC
2585
2586 ** lisp editing stuff
2587
2588 [2013-04-21 So 21:00]
2589 I'm not doing much of it, except for my emacs and gnus configs, but
2590 then I like it nice too...
2591 #+BEGIN_SRC emacs-lisp
2592 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
2593
2594 (defun remove-elc-on-save ()
2595 "If you're saving an elisp file, likely the .elc is no longer valid."
2596 (make-local-variable 'after-save-hook)
2597 (add-hook 'after-save-hook
2598 (lambda ()
2599 (if (file-exists-p (concat buffer-file-name "c"))
2600 (delete-file (concat buffer-file-name "c"))))))
2601
2602 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
2603 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
2604
2605 (use-package paredit
2606 :ensure paredit
2607 :diminish paredit-mode " π")
2608
2609 (setq lisp-coding-hook 'lisp-coding-defaults)
2610 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2611
2612 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2613 (add-hook 'emacs-lisp-mode-hook (lambda ()
2614 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2615
2616 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
2617
2618 (after "elisp-slime-nav"
2619 '(diminish 'elisp-slime-nav-mode))
2620 (after "rainbow-mode"
2621 '(diminish 'rainbow-mode))
2622 (after "eldoc"
2623 '(diminish 'eldoc-mode))
2624 #+END_SRC
2625 ** magit
2626 [2013-04-21 So 20:48]
2627 magit is a mode for interacting with git.
2628 #+BEGIN_SRC emacs-lisp
2629 (use-package magit
2630 :ensure magit
2631 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
2632 magit-git-repo-p magit-list-repos)
2633 :defer t
2634 :bind (("C-x g" . magit-status)
2635 ("C-x G" . magit-status-with-prefix))
2636 :init
2637 (progn
2638 (setq magit-commit-signoff t
2639 magit-repo-dirs '("~/git"
2640 "/develop/vcs/"
2641 "/develop/Debian/"
2642 )
2643 magit-repo-dirs-depth 4
2644 magit-log-auto-more t)
2645
2646 (use-package magit-blame
2647 :commands magit-blame-mode
2648 :defer t)
2649
2650 ; (use-package magit-svn
2651 ; :ensure magit-svn
2652 ; :commands (magit-svn-mode
2653 ; turn-on-magit-svn)
2654 ; :defer t)
2655
2656 (add-hook 'magit-mode-hook 'hl-line-mode)
2657 (defun magit-status-with-prefix ()
2658 (interactive)
2659 (let ((current-prefix-arg '(4)))
2660 (call-interactively 'magit-status)))
2661 )
2662 :config
2663 (progn
2664 (setenv "GIT_PAGER" "")
2665
2666 (unbind-key "M-h" magit-mode-map)
2667 (unbind-key "M-s" magit-mode-map)
2668
2669 ; (use-package magit-find-file
2670 ; :ensure magit-find-file
2671 ; :commands (magit-find-file-completing-read)
2672 ; :defer t
2673 ; :init
2674 ; (progn
2675 ; (bind-key "C-x C-f" 'magit-find-file-completing-read magit-mode-map)))
2676
2677 (add-hook 'magit-log-edit-mode-hook
2678 #'(lambda ()
2679 (set-fill-column 72)
2680 (flyspell-mode)))
2681
2682 (defadvice magit-status (around magit-fullscreen activate)
2683 (window-configuration-to-register :magit-fullscreen)
2684 ad-do-it
2685 (delete-other-windows))
2686
2687 (defun magit-quit-session ()
2688 "Restores the previous window configuration and kills the magit buffer"
2689 (interactive)
2690 (kill-buffer)
2691 (jump-to-register :magit-fullscreen))
2692
2693 (bind-key "q" 'magit-quit-session magit-status-mode-map)
2694
2695 (defun magit-rebase-unpushed (commit &optional args)
2696 "Start an interactive rebase sequence over all unpushed commits."
2697 (interactive (list (magit-get-tracked-branch)
2698 (magit-rebase-arguments)))
2699 (if (setq commit (magit-rebase-interactive-assert commit))
2700 (magit-run-git-sequencer "rebase" "-i" commit args)
2701 (magit-log-select
2702 `(lambda (commit)
2703 (magit-rebase-interactive (concat commit "^") (list ,@args))))))
2704
2705 (magit-define-popup-action 'magit-rebase-popup ?l "Rebase unpushed" 'magit-rebase-unpushed)
2706 ))
2707 #+END_SRC
2708 ** markdown-mode
2709 [2014-05-20 Tue 23:04]
2710 #+BEGIN_SRC emacs-lisp
2711 (use-package markdown-mode
2712 :mode (("\\.md\\'" . markdown-mode)
2713 ("\\.mdwn\\'" . markdown-mode))
2714 :defer t)
2715 #+END_SRC
2716 ** message
2717 #+BEGIN_SRC emacs-lisp
2718 (use-package message
2719 :idle
2720 (progn
2721 (setq message-kill-buffer-on-exit t)))
2722 #+END_SRC
2723 ** mingus
2724 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2725
2726 I want to access it from anywhere using =F6=.
2727 #+BEGIN_SRC emacs-lisp
2728 (use-package mingus-stays-home
2729 :bind ( "<f6>" . mingus)
2730 :defer t
2731 :config
2732 (progn
2733 (setq mingus-dired-add-keys t)
2734 (setq mingus-mode-always-modeline nil)
2735 (setq mingus-mode-line-show-elapsed-percentage nil)
2736 (setq mingus-mode-line-show-volume nil)
2737 (setq mingus-mpd-config-file "/etc/mpd.conf")
2738 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2739 (setq mingus-mpd-root "/share/music/")))
2740 #+END_SRC
2741
2742 ** miniedit
2743 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
2744 #+BEGIN_SRC emacs-lisp
2745 (use-package miniedit
2746 :ensure miniedit
2747 :commands miniedit
2748 :config
2749 (progn
2750 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
2751 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
2752 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
2753 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
2754 ))
2755 #+END_SRC
2756
2757 ** mmm-mode
2758 [2013-05-21 Tue 23:39]
2759 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
2760 coexist in one buffer.
2761 #+BEGIN_SRC emacs-lisp :tangle no
2762 (use-package mmm-auto
2763 :ensure mmm-mode
2764 :init
2765 (progn
2766 (setq mmm-global-mode 'buffers-with-submode-classes)
2767 (setq mmm-submode-decoration-level 2)
2768 (eval-after-load 'mmm-vars
2769 '(progn
2770 (mmm-add-group
2771 'html-css
2772 '((css-cdata
2773 :submode css-mode
2774 :face mmm-code-submode-face
2775 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
2776 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
2777 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2778 @ "\n" _ "\n" @ "</script>" @)))
2779 (css
2780 :submode css-mode
2781 :face mmm-code-submode-face
2782 :front "<style[^>]*>[ \t]*\n?"
2783 :back "[ \t]*</style>"
2784 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2785 @ "\n" _ "\n" @ "</style>" @)))
2786 (css-inline
2787 :submode css-mode
2788 :face mmm-code-submode-face
2789 :front "style=\""
2790 :back "\"")))
2791 (dolist (mode (list 'html-mode 'nxml-mode))
2792 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
2793 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
2794 ))))
2795 #+END_SRC
2796
2797 ** mo-git-blame
2798 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2799 Emacs]].
2800 #+BEGIN_SRC emacs-lisp
2801 (use-package mo-git-blame
2802 :ensure mo-git-blame
2803 :commands (mo-git-blame-current
2804 mo-git-blame-file)
2805 :config
2806 (progn
2807 (setq mo-git-blame-blame-window-width 25)))
2808 #+END_SRC
2809
2810 ** multiple cursors
2811 [2013-04-08 Mon 23:57]
2812 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2813 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2814 #+BEGIN_SRC emacs-lisp
2815 (use-package multiple-cursors
2816 :ensure multiple-cursors
2817 :defer t
2818 :commands (mc/remove-fake-cursors
2819 mc/create-fake-cursor-at-point
2820 mc/pop-state-from-overlay
2821 mc/maybe-multiple-cursors-mode)
2822 :defines (multiple-cursors-mode
2823 mc--read-char
2824 mc--read-quoted-char
2825 rectangular-region-mode)
2826 :bind (("C-S-c C-S-c" . mc/edit-lines)
2827 ("C->" . mc/mark-next-like-this)
2828 ("C-<" . mc/mark-previous-like-this)
2829 ("C-c C-<" . mc/mark-all-like-this)
2830 ("C-c i" . mc/insert-numbers))
2831 :config
2832 (progn
2833 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
2834 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
2835 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
2836 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
2837 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
2838 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
2839 #+END_SRC
2840 ** neotree
2841 [2014-08-27 Wed 17:15]
2842 A emacs tree plugin
2843 #+BEGIN_SRC emacs-lisp
2844 (use-package neotree
2845 :ensure neotree
2846 :defer t
2847 :bind (("<f8>" . neotree-toggle))
2848 :commands (neotree-find
2849 neotree-toggle
2850 neotree)
2851 :idle
2852 (progn
2853 (setq neo-smart-open t))
2854 :config
2855 (progn
2856 (bind-key "^" 'neotree-select-up-node neotree-mode-map)))
2857 #+END_SRC
2858 ** nxml
2859 [2013-05-22 Wed 22:02]
2860 nxml-mode is a major mode for editing XML.
2861 #+BEGIN_SRC emacs-lisp
2862 (add-auto-mode
2863 'nxml-mode
2864 (concat "\\."
2865 (regexp-opt
2866 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2867 "gpx" "tcx"))
2868 "\\'"))
2869 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2870 (fset 'xml-mode 'nxml-mode)
2871 (setq nxml-slash-auto-complete-flag t)
2872
2873 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2874 (defun pp-xml-region (begin end)
2875 "Pretty format XML markup in region. The function inserts
2876 linebreaks to separate tags that have nothing but whitespace
2877 between them. It then indents the markup by using nxml's
2878 indentation rules."
2879 (interactive "r")
2880 (save-excursion
2881 (nxml-mode)
2882 (goto-char begin)
2883 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2884 (backward-char) (insert "\n"))
2885 (indent-region begin end)))
2886
2887 ;;----------------------------------------------------------------------------
2888 ;; Integration with tidy for html + xml
2889 ;;----------------------------------------------------------------------------
2890 ;; tidy is autoloaded
2891 (eval-after-load 'tidy
2892 '(progn
2893 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2894 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2895 ))
2896
2897 #+END_SRC
2898 ** org :FIXME:
2899 *** General settings
2900 [2013-04-28 So 17:06]
2901
2902 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
2903 it is quite extensive. Nevertheless, it starts out small, loading it.
2904 #+BEGIN_SRC emacs-lisp
2905 (require 'org)
2906 #+END_SRC
2907
2908 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
2909 that we need org-protocol.
2910 #+BEGIN_SRC emacs-lisp
2911 (require 'org-protocol)
2912 #+END_SRC
2913
2914 *** Agenda
2915
2916 My current =org-agenda-files= variable only includes a set of
2917 directories.
2918 #+BEGIN_SRC emacs-lisp
2919 (setq org-agenda-files (quote ("~/org/"
2920 "~/org/debian"
2921 "~/org/debconf"
2922 "~/org/spi"
2923 "~/org/nsb"
2924 )))
2925 (setq org-default-notes-file "~/org/notes.org")
2926 #+END_SRC
2927 =org-mode= manages the =org-agenda-files= variable automatically using
2928 =C-c [= and =C-c ]= to add and remove files respectively. However,
2929 this replaces my directory list with a list of explicit filenames
2930 instead and is not what I want. If this occurs then adding a new org
2931 file to any of the above directories will not contribute to my agenda
2932 and I will probably miss something important.
2933
2934 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
2935 prevent messing up my list of directories in the =org-agenda-files=
2936 variable. I just add and remove directories manually here. Changing
2937 the list of directories in =org-agenda-files= happens very rarely
2938 since new files in existing directories are automatically picked up.
2939
2940 #+BEGIN_SRC emacs-lisp
2941 ;; Keep tasks with dates on the global todo lists
2942 (setq org-agenda-todo-ignore-with-date nil)
2943
2944 ;; Keep tasks with deadlines on the global todo lists
2945 (setq org-agenda-todo-ignore-deadlines nil)
2946
2947 ;; Keep tasks with scheduled dates on the global todo lists
2948 (setq org-agenda-todo-ignore-scheduled nil)
2949
2950 ;; Keep tasks with timestamps on the global todo lists
2951 (setq org-agenda-todo-ignore-timestamp nil)
2952
2953 ;; Remove completed deadline tasks from the agenda view
2954 (setq org-agenda-skip-deadline-if-done t)
2955
2956 ;; Remove completed scheduled tasks from the agenda view
2957 (setq org-agenda-skip-scheduled-if-done t)
2958
2959 ;; Remove completed items from search results
2960 (setq org-agenda-skip-timestamp-if-done t)
2961
2962 ;; Include agenda archive files when searching for things
2963 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
2964
2965 ;; Show all future entries for repeating tasks
2966 (setq org-agenda-repeating-timestamp-show-all t)
2967
2968 ;; Show all agenda dates - even if they are empty
2969 (setq org-agenda-show-all-dates t)
2970
2971 ;; Sorting order for tasks on the agenda
2972 (setq org-agenda-sorting-strategy
2973 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
2974 (todo category-up priority-down effort-up)
2975 (tags category-up priority-down effort-up)
2976 (search category-up))))
2977
2978 ;; Start the weekly agenda on Monday
2979 (setq org-agenda-start-on-weekday 1)
2980
2981 ;; Enable display of the time grid so we can see the marker for the current time
2982 (setq org-agenda-time-grid (quote ((daily today remove-match)
2983 #("----------------" 0 16 (org-heading t))
2984 (0800 1000 1200 1400 1500 1700 1900 2100))))
2985
2986 ;; Display tags farther right
2987 (setq org-agenda-tags-column -102)
2988
2989 ; position the habit graph on the agenda to the right of the default
2990 (setq org-habit-graph-column 50)
2991
2992 ; turn habits back on
2993 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
2994
2995 ;;
2996 ;; Agenda sorting functions
2997 ;;
2998 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
2999
3000
3001 (setq org-deadline-warning-days 30)
3002
3003 ;; Always hilight the current agenda line
3004 (add-hook 'org-agenda-mode-hook
3005 '(lambda () (hl-line-mode 1))
3006 'append)
3007 #+END_SRC
3008
3009 #+BEGIN_SRC emacs-lisp
3010 (setq org-agenda-persistent-filter t)
3011 (add-hook 'org-agenda-mode-hook
3012 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
3013 'append)
3014
3015 (add-hook 'org-agenda-mode-hook
3016 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
3017 'append)
3018
3019 (add-hook 'org-agenda-mode-hook
3020 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
3021 'append)
3022
3023 (add-hook 'org-agenda-mode-hook
3024 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
3025 'append)
3026
3027 (add-hook 'org-agenda-mode-hook
3028 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
3029 'append)
3030
3031 ; Rebuild the reminders everytime the agenda is displayed
3032 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
3033
3034 ;(if (file-exists-p "~/org/refile.org")
3035 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
3036
3037 ; Activate appointments so we get notifications
3038 (appt-activate t)
3039
3040 (setq org-agenda-log-mode-items (quote (closed clock state)))
3041 (if (> emacs-major-version 23)
3042 (setq org-agenda-span 3)
3043 (setq org-agenda-ndays 3))
3044
3045 (setq org-agenda-show-all-dates t)
3046 (setq org-agenda-start-on-weekday nil)
3047 (setq org-deadline-warning-days 14)
3048
3049 #+END_SRC
3050 *** Global keybindings.
3051 Start off by defining a series of keybindings.
3052
3053 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
3054 setup manually, not by org-mode. Also turn off =C-c ;=, which
3055 comments headlines - a function never used.
3056 #+BEGIN_SRC emacs-lisp
3057 (add-hook 'org-mode-hook
3058 (lambda ()
3059 (org-defkey org-mode-map "\C-c[" 'undefined)
3060 (org-defkey org-mode-map "\C-c]" 'undefined)
3061 (org-defkey org-mode-map "\C-c;" 'undefined))
3062 'append)
3063 #+END_SRC
3064
3065 And now a largish set of keybindings...
3066 #+BEGIN_SRC emacs-lisp
3067 (bind-key "C-c l" 'org-store-link)
3068 (bind-key "C-c a" 'org-agenda)
3069 ;(bind-key "C-c b" 'org-iswitchb)
3070 (define-key mode-specific-map [?a] 'org-agenda)
3071
3072 (bind-key "<f12>" 'org-agenda)
3073 (bind-key "<f5>" 'bh/org-todo)
3074 (bind-key "<S-f5>" 'bh/widen)
3075 (bind-key "<f7>" 'bh/set-truncate-lines)
3076 ;(bind-key "<f8>" 'org-cycle-agenda-files)
3077
3078 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
3079 (bind-key "<f9> b" 'bbdb)
3080 (bind-key "<f9> c" 'calendar)
3081 (bind-key "<f9> f" 'boxquote-insert-file)
3082 (bind-key "<f9> h" 'bh/hide-other)
3083 (bind-key "<f9> n" 'org-narrow-to-subtree)
3084 (bind-key "<f9> w" 'widen)
3085 (bind-key "<f9> u" 'bh/narrow-up-one-level)
3086 (bind-key "<f9> I" 'bh/punch-in)
3087 (bind-key "<f9> O" 'bh/punch-out)
3088 (bind-key "<f9> H" 'jj/punch-in-hw)
3089 (bind-key "<f9> W" 'jj/punch-out-hw)
3090 (bind-key "<f9> o" 'bh/make-org-scratch)
3091 (bind-key "<f9> p" 'bh/phone-call)
3092 (bind-key "<f9> r" 'boxquote-region)
3093 (bind-key "<f9> s" 'bh/switch-to-scratch)
3094 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
3095 (bind-key "<f9> T" 'tabify)
3096 (bind-key "<f9> U" 'untabify)
3097 (bind-key "<f9> v" 'visible-mode)
3098 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
3099 (bind-key "C-<f9>" 'previous-buffer)
3100 (bind-key "C-<f10>" 'next-buffer)
3101 (bind-key "M-<f9>" 'org-toggle-inline-images)
3102 ;(bind-key "C-x n r" 'narrow-to-region)
3103 (bind-key "<f11>" 'org-clock-goto)
3104 (bind-key "C-<f11>" 'org-clock-in)
3105 (bind-key "C-M-r" 'org-capture)
3106 (bind-key "C-c r" 'org-capture)
3107 (bind-key "C-S-<f12>" 'bh/save-then-publish)
3108 ;(bind-key "C-k" 'jj-org-kill-line org-mode-map)
3109
3110 #+END_SRC
3111
3112 *** Tasks, States, Todo fun
3113
3114 First we define the global todo keywords.
3115 #+BEGIN_SRC emacs-lisp
3116 (setq org-todo-keywords
3117 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
3118 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
3119
3120 (setq org-todo-keyword-faces
3121 (quote (("TODO" :foreground "red" :weight bold)
3122 ("NEXT" :foreground "light blue" :weight bold)
3123 ("DONE" :foreground "forest green" :weight bold)
3124 ("WAITING" :foreground "orange" :weight bold)
3125 ("HOLD" :foreground "orange" :weight bold)
3126 ("DELEGATED" :foreground "yellow" :weight bold)
3127 ("CANCELLED" :foreground "dark green" :weight bold)
3128 ("PHONE" :foreground "dark green" :weight bold))))
3129 #+END_SRC
3130
3131 **** Fast Todo Selection
3132 Fast todo selection allows changing from any task todo state to any
3133 other state directly by selecting the appropriate key from the fast
3134 todo selection key menu.
3135 #+BEGIN_SRC emacs-lisp
3136 (setq org-use-fast-todo-selection t)
3137 #+END_SRC
3138 Changing a task state is done with =C-c C-t KEY=
3139
3140 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
3141
3142 The setting
3143 #+BEGIN_SRC emacs-lisp
3144 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
3145 #+END_SRC
3146 allows changing todo states with S-left and S-right skipping all of
3147 the normal processing when entering or leaving a todo state. This
3148 cycles through the todo states but skips setting timestamps and
3149 entering notes which is very convenient when all you want to do is fix
3150 up the status of an entry.
3151
3152 **** Todo State Triggers
3153 I have a few triggers that automatically assign tags to tasks based on
3154 state changes. If a task moves to =CANCELLED= state then it gets a
3155 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
3156 =CANCELLED= tag. These are used for filtering tasks in agenda views
3157 which I'll talk about later.
3158
3159 The triggers break down to the following rules:
3160
3161 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
3162 - Moving a task to =WAITING= adds a =WAITING= tag
3163 - Moving a task to =HOLD= adds a =WAITING= tag
3164 - Moving a task to a done state removes a =WAITING= tag
3165 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
3166 - Moving a task to =NEXT= removes a =WAITING= tag
3167 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
3168
3169 The tags are used to filter tasks in the agenda views conveniently.
3170 #+BEGIN_SRC emacs-lisp
3171 (setq org-todo-state-tags-triggers
3172 (quote (("CANCELLED" ("CANCELLED" . t))
3173 ("WAITING" ("WAITING" . t))
3174 ("HOLD" ("WAITING" . t) ("HOLD" . t))
3175 (done ("WAITING") ("HOLD"))
3176 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
3177 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
3178 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
3179 #+END_SRC
3180
3181 *** Capturing new tasks
3182 Org capture replaces the old remember mode.
3183 #+BEGIN_SRC emacs-lisp
3184 (setq org-directory "~/org")
3185 (setq org-default-notes-file "~/org/refile.org")
3186
3187 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
3188 ;; see http://orgmode.org/manual/Template-elements.html
3189 (setq org-capture-templates
3190 (quote (("t" "todo" entry (file "~/org/refile.org")
3191 "* TODO %?\nAdded: %U\n"
3192 :clock-in t :clock-resume t)
3193 ("l" "linktodo" entry (file "~/org/refile.org")
3194 "* TODO %?\nAdded: %U\n%a\n"
3195 :clock-in t :clock-resume t)
3196 ("r" "respond" entry (file "~/org/refile.org")
3197 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
3198 :clock-in t :clock-resume t :immediate-finish t)
3199 ("n" "note" entry (file "~/org/refile.org")
3200 "* %? :NOTE:\nAdded: %U\n%a\n"
3201 :clock-in t :clock-resume t)
3202 ("d" "Delegated" entry (file "~/org/refile.org")
3203 "* DELEGATED %?\nAdded: %U\n%a\n"
3204 :clock-in t :clock-resume t)
3205 ("j" "Journal" entry (file+datetree "~/org/diary.org")
3206 "* %?\nAdded: %U\n"
3207 :clock-in t :clock-resume t)
3208 ("w" "org-protocol" entry (file "~/org/refile.org")
3209 "* TODO Review %c\nAdded: %U\n"
3210 :immediate-finish t)
3211 ("p" "Phone call" entry (file "~/org/refile.org")
3212 "* PHONE %? :PHONE:\nAdded: %U"
3213 :clock-in t :clock-resume t)
3214 ("x" "Bookmark link" entry (file "~/org/refile.org")
3215 "* Bookmark: %c\n%i\nAdded: %U\n"
3216 :immediate-finish t)
3217 ("h" "Habit" entry (file "~/org/refile.org")
3218 "* 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")
3219 )))
3220 #+END_SRC
3221
3222 Capture mode now handles automatically clocking in and out of a
3223 capture task. This all works out of the box now without special hooks.
3224 When I start a capture mode task the task is clocked in as specified
3225 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
3226 resumes on the original clocking task.
3227
3228 The quick clocking in and out of capture mode tasks (often it takes
3229 less than a minute to capture some new task details) can leave
3230 empty clock drawers in my tasks which aren't really useful.
3231 The following prevents this.
3232 #+BEGIN_SRC emacs-lisp
3233 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
3234 #+END_SRC
3235
3236 *** Refiling
3237 All my newly captured entries end up in =refile.org= and want to be
3238 moved over to the right place. The following is the setup for it.
3239 #+BEGIN_SRC emacs-lisp
3240 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
3241 (setq org-refile-targets (quote ((nil :maxlevel . 9)
3242 (org-agenda-files :maxlevel . 9))))
3243
3244 ; Use full outline paths for refile targets - we file directly with IDO
3245 (setq org-refile-use-outline-path t)
3246
3247 ; Targets complete directly with IDO
3248 (setq org-outline-path-complete-in-steps nil)
3249
3250 ; Allow refile to create parent tasks with confirmation
3251 (setq org-refile-allow-creating-parent-nodes (quote confirm))
3252
3253 ; Use IDO for both buffer and file completion and ido-everywhere to t
3254 (setq org-completion-use-ido t)
3255 (setq org-completion-use-iswitchb nil)
3256 :; Use IDO for both buffer and file completion and ido-everywhere to t
3257 ;(setq ido-everywhere t)
3258 ;(setq ido-max-directory-size 100000)
3259 ;(ido-mode (quote both))
3260 ; Use the current window when visiting files and buffers with ido
3261 (setq ido-default-file-method 'selected-window)
3262 (setq ido-default-buffer-method 'selected-window)
3263
3264 ;;;; Refile settings
3265 (setq org-refile-target-verify-function 'bh/verify-refile-target)
3266 #+END_SRC
3267
3268 *** Custom agenda
3269 Agenda view is the central place for org-mode interaction...
3270 #+BEGIN_SRC emacs-lisp
3271 ;; Do not dim blocked tasks
3272 (setq org-agenda-dim-blocked-tasks nil)
3273 ;; Compact the block agenda view
3274 (setq org-agenda-compact-blocks t)
3275
3276 ;; Custom agenda command definitions
3277 (setq org-agenda-custom-commands
3278 (quote (("N" "Notes" tags "NOTE"
3279 ((org-agenda-overriding-header "Notes")
3280 (org-tags-match-list-sublevels t)))
3281 ("h" "Habits" tags-todo "STYLE=\"habit\""
3282 ((org-agenda-overriding-header "Habits")
3283 (org-agenda-sorting-strategy
3284 '(todo-state-down effort-up category-keep))))
3285 (" " "Agenda"
3286 ((agenda "" nil)
3287 (tags "REFILE"
3288 ((org-agenda-overriding-header "Tasks to Refile")
3289 (org-tags-match-list-sublevels nil)))
3290 (tags-todo "-HOLD-CANCELLED/!"
3291 ((org-agenda-overriding-header "Projects")
3292 (org-agenda-skip-function 'bh/skip-non-projects)
3293 (org-agenda-sorting-strategy
3294 '(category-keep))))
3295 (tags-todo "-CANCELLED/!"
3296 ((org-agenda-overriding-header "Stuck Projects")
3297 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3298 (tags-todo "-WAITING-CANCELLED/!NEXT"
3299 ((org-agenda-overriding-header "Next Tasks")
3300 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3301 (org-agenda-todo-ignore-scheduled t)
3302 (org-agenda-todo-ignore-deadlines t)
3303 (org-agenda-todo-ignore-with-date t)
3304 (org-tags-match-list-sublevels t)
3305 (org-agenda-sorting-strategy
3306 '(todo-state-down effort-up category-keep))))
3307 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3308 ((org-agenda-overriding-header "Tasks")
3309 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3310 (org-agenda-todo-ignore-scheduled t)
3311 (org-agenda-todo-ignore-deadlines t)
3312 (org-agenda-todo-ignore-with-date t)
3313 (org-agenda-sorting-strategy
3314 '(category-keep))))
3315 (tags-todo "-CANCELLED+WAITING/!"
3316 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
3317 (org-agenda-skip-function 'bh/skip-stuck-projects)
3318 (org-tags-match-list-sublevels nil)
3319 (org-agenda-todo-ignore-scheduled 'future)
3320 (org-agenda-todo-ignore-deadlines 'future)))
3321 (tags "-REFILE/"
3322 ((org-agenda-overriding-header "Tasks to Archive")
3323 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3324 (org-tags-match-list-sublevels nil))))
3325 nil)
3326 ("r" "Tasks to Refile" tags "REFILE"
3327 ((org-agenda-overriding-header "Tasks to Refile")
3328 (org-tags-match-list-sublevels nil)))
3329 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
3330 ((org-agenda-overriding-header "Stuck Projects")
3331 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3332 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
3333 ((org-agenda-overriding-header "Next Tasks")
3334 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3335 (org-agenda-todo-ignore-scheduled t)
3336 (org-agenda-todo-ignore-deadlines t)
3337 (org-agenda-todo-ignore-with-date t)
3338 (org-tags-match-list-sublevels t)
3339 (org-agenda-sorting-strategy
3340 '(todo-state-down effort-up category-keep))))
3341 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3342 ((org-agenda-overriding-header "Tasks")
3343 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3344 (org-agenda-sorting-strategy
3345 '(category-keep))))
3346 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
3347 ((org-agenda-overriding-header "Projects")
3348 (org-agenda-skip-function 'bh/skip-non-projects)
3349 (org-agenda-sorting-strategy
3350 '(category-keep))))
3351 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
3352 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
3353 (org-tags-match-list-sublevels nil))
3354 ("A" "Tasks to Archive" tags "-REFILE/"
3355 ((org-agenda-overriding-header "Tasks to Archive")
3356 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3357 (org-tags-match-list-sublevels nil))))))
3358
3359 ; Overwrite the current window with the agenda
3360 (setq org-agenda-window-setup 'current-window)
3361
3362 #+END_SRC
3363
3364 *** Time
3365 #+BEGIN_SRC emacs-lisp
3366 ;;
3367 ;; Resume clocking task when emacs is restarted
3368 (org-clock-persistence-insinuate)
3369 ;;
3370 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
3371 (setq org-clock-history-length 36)
3372 ;; Resume clocking task on clock-in if the clock is open
3373 (setq org-clock-in-resume t)
3374 ;; Change tasks to NEXT when clocking in
3375 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
3376 ;; Separate drawers for clocking and logs
3377 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
3378 ;; Save clock data and state changes and notes in the LOGBOOK drawer
3379 (setq org-clock-into-drawer t)
3380 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
3381 (setq org-clock-out-remove-zero-time-clocks t)
3382 ;; Clock out when moving task to a done state
3383 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
3384 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
3385 (setq org-clock-persist t)
3386 ;; Do not prompt to resume an active clock
3387 (setq org-clock-persist-query-resume nil)
3388 ;; Enable auto clock resolution for finding open clocks
3389 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
3390 ;; Include current clocking task in clock reports
3391 (setq org-clock-report-include-clocking-task t)
3392
3393 ; use discrete minute intervals (no rounding) increments
3394 (setq org-time-stamp-rounding-minutes (quote (1 1)))
3395
3396 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
3397
3398 (setq bh/keep-clock-running nil)
3399
3400 (setq org-agenda-clock-consistency-checks
3401 (quote (:max-duration "4:00"
3402 :min-duration 0
3403 :max-gap 0
3404 :gap-ok-around ("4:00"))))
3405
3406 #+END_SRC
3407
3408 **** Setting a default clock task
3409 Per default the =** Organization= task in my tasks.org file receives
3410 misc clock time. This is the task I clock in on when I punch in at the
3411 start of my work day with =F9-I=. Punching-in anywhere clocks in this
3412 Organization task as the default task.
3413
3414 If I want to change the default clocking task I just visit the
3415 new task in any org buffer and clock it in with =C-u C-u C-c C-x
3416 C-i=. Now this new task that collects miscellaneous clock
3417 minutes when the clock would normally stop.
3418
3419 You can quickly clock in the default clocking task with =C-u C-c
3420 C-x C-i d=. Another option is to repeatedly clock out so the
3421 clock moves up the project tree until you clock out the
3422 top-level task and the clock moves to the default task.
3423
3424 **** Reporting
3425 #+BEGIN_SRC emacs-lisp
3426 ;; Agenda clock report parameters
3427 (setq org-agenda-clockreport-parameter-plist
3428 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
3429
3430 ;; Agenda log mode items to display (closed and state changes by default)
3431 (setq org-agenda-log-mode-items (quote (closed state)))
3432 #+END_SRC
3433 **** Task estimates, column view
3434 Setup column view globally with the following headlines
3435 #+BEGIN_SRC emacs-lisp
3436 ; Set default column view headings: Task Effort Clock_Summary
3437 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
3438 #+END_SRC
3439 Setup the estimate for effort values.
3440 #+BEGIN_SRC emacs-lisp
3441 ; global Effort estimate values
3442 ; global STYLE property values for completion
3443 (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")
3444 ("STYLE_ALL" . "habit"))))
3445 #+END_SRC
3446
3447 *** Tags
3448 Tags are mostly used for filtering inside the agenda.
3449 #+BEGIN_SRC emacs-lisp
3450 ; Tags with fast selection keys
3451 (setq org-tag-alist (quote ((:startgroup)
3452 ("@errand" . ?e)
3453 ("@office" . ?o)
3454 ("@home" . ?H)
3455 (:endgroup)
3456 ("PHONE" . ?p)
3457 ("WAITING" . ?w)
3458 ("HOLD" . ?h)
3459 ("PERSONAL" . ?P)
3460 ("WORK" . ?W)
3461 ("ORG" . ?O)
3462 ("PRIVATE" . ?N)
3463 ("crypt" . ?E)
3464 ("MARK" . ?M)
3465 ("NOTE" . ?n)
3466 ("CANCELLED" . ?c)
3467 ("FLAGGED" . ??))))
3468
3469 ; Allow setting single tags without the menu
3470 (setq org-fast-tag-selection-single-key (quote expert))
3471
3472 ; For tag searches ignore tasks with scheduled and deadline dates
3473 (setq org-agenda-tags-todo-honor-ignore-options t)
3474 #+END_SRC
3475
3476 *** Archiving
3477 #+BEGIN_SRC emacs-lisp
3478 (setq org-archive-mark-done nil)
3479 (setq org-archive-location "%s_archive::* Archived Tasks")
3480 #+END_SRC
3481
3482 *** org-babel
3483 #+BEGIN_SRC emacs-lisp
3484 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
3485 (setq org-plantuml-jar-path "~/java/plantuml.jar")
3486
3487 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
3488
3489 ; Make babel results blocks lowercase
3490 (setq org-babel-results-keyword "results")
3491
3492 (org-babel-do-load-languages
3493 (quote org-babel-load-languages)
3494 (quote ((emacs-lisp . t)
3495 (awk . t)
3496 (css . t)
3497 (makefile . t)
3498 (perl . t)
3499 (ruby . t)
3500 (dot . t)
3501 (ditaa . t)
3502 (R . t)
3503 (python . t)
3504 (ruby . t)
3505 (gnuplot . t)
3506 (clojure . t)
3507 (sh . t)
3508 (ledger . t)
3509 (org . t)
3510 (plantuml . t)
3511 (latex . t))))
3512
3513 ; Do not prompt to confirm evaluation
3514 ; This may be dangerous - make sure you understand the consequences
3515 ; of setting this -- see the docstring for details
3516 (setq org-confirm-babel-evaluate nil)
3517
3518 ; Use fundamental mode when editing plantuml blocks with C-c '
3519 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
3520 #+END_SRC
3521
3522 #+BEGIN_SRC emacs-lisp
3523 ;; Don't have images visible on startup, breaks on console
3524 (setq org-startup-with-inline-images nil)
3525 #+END_SRC
3526
3527 #+BEGIN_SRC emacs-lisp
3528 (add-to-list 'org-structure-template-alist
3529 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
3530 "<comment>\n?\n</comment>"))
3531 #+END_SRC
3532 **** ditaa, graphviz, etc
3533 Those are all nice tools. Look at
3534 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
3535 to them.
3536
3537 *** Publishing and exporting
3538
3539
3540 Org-mode can export to a variety of publishing formats including (but not limited to)
3541
3542 - ASCII
3543 (plain text - but not the original org-mode file)
3544 - HTML
3545 - LaTeX
3546 - Docbook
3547 which enables getting to lots of other formats like ODF, XML, etc
3548 - PDF
3549 via LaTeX or Docbook
3550 - iCal
3551
3552 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
3553
3554 #+BEGIN_SRC emacs-lisp
3555 ;; Explicitly load required exporters
3556 (require 'ox-html)
3557 (require 'ox-latex)
3558 (require 'ox-ascii)
3559 ;; FIXME, check the following two
3560 ;(require 'ox-icalendar)
3561 ;(require 'ox-odt)
3562
3563 ; experimenting with docbook exports - not finished
3564 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
3565 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
3566
3567 ;; define categories that should be excluded
3568 (setq org-export-exclude-category (list "google" "google"))
3569 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
3570
3571 ; define how the date strings look
3572 (setq org-export-date-timestamp-format "%Y-%m-%d")
3573 ; Inline images in HTML instead of producting links to the image
3574 (setq org-html-inline-images t)
3575 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
3576 (setq org-export-with-sub-superscripts nil)
3577
3578 (setq org-html-head-extra (concat
3579 "<link rel=\"stylesheet\" href=\"https://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
3580 ))
3581 (setq org-html-head-include-default-style nil)
3582 ; Do not generate internal css formatting for HTML exports
3583 (setq org-export-htmlize-output-type (quote css))
3584 ; Export with LaTeX fragments
3585 (setq org-export-with-LaTeX-fragments t)
3586 ; Increase default number of headings to export
3587 (setq org-export-headline-levels 6)
3588
3589
3590 (setq org-publish-project-alist
3591 '(
3592 ("config-notes"
3593 :base-directory "~/.emacs.d/"
3594 :base-extension "org"
3595 :exclude "elisp"
3596 :publishing-directory "/develop/www/emacs"
3597 :recursive t
3598 :publishing-function org-html-publish-to-html
3599 :headline-levels 4 ; Just the default for this project.
3600 :auto-preamble t
3601 :auto-sitemap t
3602 :makeindex t
3603 )
3604 ("config-static"
3605 :base-directory "~/.emacs.d/"
3606 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
3607 :publishing-directory "/develop/www/emacs"
3608 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
3609 :recursive t
3610 :publishing-function org-publish-attachment
3611 )
3612 ("inherit-org-info-js"
3613 :base-directory "/develop/vcs/org-info-js/"
3614 :recursive t
3615 :base-extension "js"
3616 :publishing-directory "/develop/www/"
3617 :publishing-function org-publish-attachment
3618 )
3619 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
3620 )
3621 )
3622 )
3623
3624 (setq org-export-with-timestamps nil)
3625 #+END_SRC
3626
3627 **** Latex export
3628
3629 #+BEGIN_SRC emacs-lisp
3630 (setq org-latex-to-pdf-process
3631 '("xelatex -interaction nonstopmode %f"
3632 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
3633 (setq org-export-latex-listings 'minted)
3634 (setq org-latex-listings t)
3635
3636 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
3637 ;; but adapted to use latexmk 4.20 or higher.
3638 (defun my-auto-tex-cmd ()
3639 "When exporting from .org with latex, automatically run latex,
3640 pdflatex, or xelatex as appropriate, using latexmk."
3641 (let ((texcmd)))
3642 ;; default command: oldstyle latex via dvi
3643 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
3644 ;; pdflatex -> .pdf
3645 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
3646 (setq texcmd "latexmk -pdf -quiet %f"))
3647 ;; xelatex -> .pdf
3648 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3649 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
3650 ;; LaTeX compilation command
3651 (setq org-latex-to-pdf-process (list texcmd)))
3652
3653 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
3654
3655 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
3656 (setq org-export-latex-packages-alist
3657 '(("" "graphicx" t)
3658 ("" "longtable" nil)
3659 ("" "float" nil)
3660 ("" "minted" nil)
3661 ))
3662
3663 (defun my-auto-tex-parameters ()
3664 "Automatically select the tex packages to include."
3665 ;; default packages for ordinary latex or pdflatex export
3666 (setq org-export-latex-default-packages-alist
3667 '(("AUTO" "inputenc" t)
3668 ("T1" "fontenc" t)
3669 ("" "fixltx2e" nil)
3670 ("" "wrapfig" nil)
3671 ("" "soul" t)
3672 ("" "textcomp" t)
3673 ("" "marvosym" t)
3674 ("" "wasysym" t)
3675 ("" "latexsym" t)
3676 ("" "amssymb" t)
3677 ("" "hyperref" nil)))
3678
3679 ;; Packages to include when xelatex is used
3680 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3681 (setq org-export-latex-default-packages-alist
3682 '(("" "fontspec" t)
3683 ("" "xunicode" t)
3684 ("" "url" t)
3685 ("" "rotating" t)
3686 ("german" "babel" t)
3687 ("babel" "csquotes" t)
3688 ("" "soul" t)
3689 ("xetex" "hyperref" nil)
3690 )))
3691
3692 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
3693 (setq org-export-latex-classes
3694 (cons '("scrartcl"
3695 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
3696 ("\\section{%s}" . "\\section*{%s}")
3697 ("\\subsection{%s}" . "\\subsection*{%s}")
3698 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
3699 ("\\paragraph{%s}" . "\\paragraph*{%s}")
3700 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
3701 org-export-latex-classes))))
3702
3703 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
3704 #+END_SRC
3705
3706 *** Prevent editing invisible text
3707 The following setting prevents accidentally editing hidden text when
3708 the point is inside a folded region. This can happen if you are in
3709 the body of a heading and globally fold the org-file with =S-TAB=
3710
3711 I find invisible edits (and undo's) hard to deal with so now I can't
3712 edit invisible text. =C-c C-r= (org-reveal) will display where the
3713 point is if it is buried in invisible text to allow editing again.
3714
3715 #+BEGIN_SRC emacs-lisp
3716 (setq org-catch-invisible-edits 'error)
3717 #+END_SRC
3718
3719 *** Whatever
3720 #+BEGIN_SRC emacs-lisp
3721 ;; disable the default org-mode stuck projects agenda view
3722 (setq org-stuck-projects (quote ("" nil nil "")))
3723
3724 ; force showing the next headline.
3725 (setq org-show-entry-below (quote ((default))))
3726
3727 (setq org-show-following-heading t)
3728 (setq org-show-hierarchy-above t)
3729 (setq org-show-siblings (quote ((default))))
3730
3731 (setq org-special-ctrl-a/e t)
3732 (setq org-special-ctrl-k t)
3733 (setq org-yank-adjusted-subtrees t)
3734
3735 (setq org-table-export-default-format "orgtbl-to-csv")
3736
3737 #+END_SRC
3738
3739 The following setting adds alphabetical lists like
3740 ,a. item one
3741 ,b. item two
3742
3743 #+BEGIN_SRC emacs-lisp
3744 (if (> emacs-major-version 23)
3745 (setq org-list-allow-alphabetical t)
3746 (setq org-alphabetical-lists t))
3747 #+END_SRC
3748
3749 #+BEGIN_SRC emacs-lisp
3750 (setq org-remove-highlights-with-change nil)
3751
3752 (setq org-list-demote-modify-bullet (quote (("+" . "-")
3753 ("*" . "-")
3754 ("1." . "-")
3755 ("1)" . "-"))))
3756
3757
3758
3759 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
3760
3761
3762 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
3763 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
3764
3765 #+END_SRC
3766
3767
3768 #+BEGIN_SRC emacs-lisp
3769 ;; Enable abbrev-mode
3770 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
3771 (setq org-startup-indented t)
3772 (setq org-startup-folded t)
3773 (setq org-cycle-separator-lines 0)
3774 #+END_SRC
3775
3776 I find extra blank lines in lists and headings a bit of a nuisance.
3777 To get a body after a list you need to include a blank line between
3778 the list entry and the body -- and indent the body appropriately.
3779 Most of my lists have no body detail so I like the look of collapsed
3780 lists with no blank lines better.
3781
3782 The following setting prevents creating blank lines before headings
3783 but allows list items to adapt to existing blank lines around the items:
3784 #+BEGIN_SRC emacs-lisp
3785 (setq org-blank-before-new-entry (quote ((heading)
3786 (plain-list-item . auto))))
3787 #+END_SRC
3788
3789 #+BEGIN_SRC emacs-lisp
3790 (setq org-reverse-note-order nil)
3791 (setq org-default-notes-file "~/notes.org")
3792 #+END_SRC
3793
3794 Enforce task blocking. Tasks can't go done when there is any subtask
3795 still open. Unless they have a property of =NOBLOCKING: t=
3796 #+BEGIN_SRC emacs-lisp
3797 (setq org-enforce-todo-checkbox-dependencies t)
3798 (setq org-enforce-todo-dependencies t)
3799 #+END_SRC
3800
3801 #+BEGIN_SRC emacs-lisp
3802 (setq org-fast-tag-selection-single-key (quote expert))
3803 (setq org-footnote-auto-adjust t)
3804 (setq org-hide-block-startup t)
3805 (setq org-icalendar-alarm-time 15)
3806 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
3807 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
3808 (setq org-icalendar-honor-noexport-tag t)
3809 (setq org-icalendar-include-bbdb-anniversaries nil)
3810 (setq org-icalendar-include-body 200)
3811 (setq org-icalendar-include-todo nil)
3812 (setq org-icalendar-store-UID t)
3813 (setq org-icalendar-timezone "Europe/Berlin")
3814 (setq org-insert-mode-line-in-empty-file t)
3815 (setq org-log-done (quote note))
3816 (setq org-log-into-drawer t)
3817 (setq org-log-state-notes-insert-after-drawers nil)
3818 (setq org-log-reschedule (quote time))
3819 (setq org-log-states-order-reversed t)
3820 (setq org-mobile-agendas (quote all))
3821 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
3822 (setq org-mobile-inbox-for-pull "~/org/refile.org")
3823 (setq org-remember-store-without-prompt t)
3824 (setq org-return-follows-link t)
3825 (setq org-reverse-note-order t)
3826
3827 ; regularly save our org-mode buffers
3828 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
3829
3830 (setq org-log-done t)
3831
3832 (setq org-enable-priority-commands t)
3833 (setq org-default-priority ?E)
3834 (setq org-lowest-priority ?E)
3835
3836
3837 #+END_SRC
3838
3839 Speed commands enable single-letter commands in Org-mode files when
3840 the point is at the beginning of a headline, or at the beginning of a
3841 code block.
3842
3843 See the `=org-speed-commands-default=' variable for a list of the keys
3844 and commands enabled at the beginning of headlines. All code blocks
3845 are available at the beginning of a code block, the following key
3846 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
3847 display a list of the code blocks commands and their related keys.
3848
3849 #+BEGIN_SRC emacs-lisp
3850 (setq org-use-speed-commands nil)
3851 (setq org-speed-commands-user (quote (("0" . ignore)
3852 ("1" . ignore)
3853 ("2" . ignore)
3854 ("3" . ignore)
3855 ("4" . ignore)
3856 ("5" . ignore)
3857 ("6" . ignore)
3858 ("7" . ignore)
3859 ("8" . ignore)
3860 ("9" . ignore)
3861
3862 ("a" . ignore)
3863 ("d" . ignore)
3864 ("h" . bh/hide-other)
3865 ("i" progn
3866 (forward-char 1)
3867 (call-interactively 'org-insert-heading-respect-content))
3868 ("k" . org-kill-note-or-show-branches)
3869 ("l" . ignore)
3870 ("m" . ignore)
3871 ("q" . bh/show-org-agenda)
3872 ("r" . ignore)
3873 ("s" . org-save-all-org-buffers)
3874 ("w" . org-refile)
3875 ("x" . ignore)
3876 ("y" . ignore)
3877 ("z" . org-add-note)
3878
3879 ("A" . ignore)
3880 ("B" . ignore)
3881 ("E" . ignore)
3882 ("F" . bh/restrict-to-file-or-follow)
3883 ("G" . ignore)
3884 ("H" . ignore)
3885 ("J" . org-clock-goto)
3886 ("K" . ignore)
3887 ("L" . ignore)
3888 ("M" . ignore)
3889 ("N" . bh/narrow-to-org-subtree)
3890 ("P" . bh/narrow-to-org-project)
3891 ("Q" . ignore)
3892 ("R" . ignore)
3893 ("S" . ignore)
3894 ("T" . bh/org-todo)
3895 ("U" . bh/narrow-up-one-org-level)
3896 ("V" . ignore)
3897 ("W" . bh/widen)
3898 ("X" . ignore)
3899 ("Y" . ignore)
3900 ("Z" . ignore))))
3901
3902 (add-hook 'org-agenda-mode-hook
3903 (lambda ()
3904 (define-key org-agenda-mode-map "q" 'bury-buffer))
3905 'append)
3906
3907 (defvar bh/current-view-project nil)
3908 (add-hook 'org-agenda-mode-hook
3909 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
3910 'append)
3911 #+END_SRC
3912
3913
3914 The following displays the contents of code blocks in Org-mode files
3915 using the major-mode of the code. It also changes the behavior of
3916 =TAB= to as if it were used in the appropriate major mode. This means
3917 that reading and editing code form inside of your Org-mode files is
3918 much more like reading and editing of code using its major mode.
3919
3920 #+BEGIN_SRC emacs-lisp
3921 (setq org-src-fontify-natively t)
3922 (setq org-src-tab-acts-natively t)
3923 #+END_SRC
3924
3925 #+BEGIN_SRC emacs-lisp
3926 (setq org-src-preserve-indentation nil)
3927 (setq org-edit-src-content-indentation 0)
3928 #+END_SRC
3929
3930
3931 #+BEGIN_SRC emacs-lisp
3932 (setq org-attach-directory "~/org/data/")
3933 #+END_SRC
3934 #+BEGIN_SRC emacs-lisp
3935 (setq org-agenda-sticky t)
3936 #+END_SRC
3937
3938 **** Checklist handling
3939 [2013-05-11 Sat 22:15]
3940
3941 #+BEGIN_SRC emacs-lisp
3942 ;(require 'org-checklist)
3943 #+END_SRC
3944
3945 ** perl / cperl
3946 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
3947 up here to be used.
3948 #+BEGIN_SRC emacs-lisp
3949 (use-package cperl-mode
3950 :commands cperl-mode
3951 :idle
3952 (progn
3953 (defalias 'perl-mode 'cperl-mode)
3954 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
3955 (add-auto-mode 'pod-mode "\\.pod$")
3956 (add-auto-mode 'tt-mode "\\.tt$")
3957 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
3958 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
3959 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
3960 )
3961 :config
3962 (progn
3963 (setq cperl-invalid-face nil
3964 cperl-close-paren-offset -4
3965 cperl-continued-statement-offset 0
3966 cperl-indent-level 4
3967 cperl-indent-parens-as-block t
3968 cperl-hairy t
3969 cperl-electric-keywords t
3970 cperl-electric-lbrace-space t
3971 cperl-electric-parens nil
3972 cperl-highlight-variables-indiscriminately t
3973 cperl-imenu-addback t
3974 cperl-invalid-face (quote underline)
3975 cperl-lazy-help-time 5
3976 cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$"
3977 cperl-syntaxify-by-font-lock t
3978 cperl-use-syntax-table-text-property-for-tags t)
3979
3980 ;; And have cperl mode give ElDoc a useful string
3981 (defun my-cperl-eldoc-documentation-function ()
3982 "Return meaningful doc string for `eldoc-mode'."
3983 (car
3984 (let ((cperl-message-on-help-error nil))
3985 (cperl-get-help))))
3986 (add-hook 'cperl-mode-hook
3987 (lambda ()
3988 (set (make-local-variable 'eldoc-documentation-function)
3989 'my-cperl-eldoc-documentation-function)
3990 (eldoc-mode))))
3991 )
3992 #+END_SRC
3993 ** puppet
3994 [2014-05-22 Thu 00:05]
3995 #+BEGIN_SRC emacs-lisp
3996 (use-package puppet-mode
3997 :mode ("\\.pp\\'" . puppet-mode)
3998 :commands puppet-mode
3999 :idle
4000 (progn
4001 (defun my-puppet-mode-hook ()
4002 (setq require-final-newline nil))
4003 (add-hook 'puppet-mode-hook 'my-puppet-mode-hook))
4004 :config
4005 (progn
4006 (use-package puppet-ext
4007 :init
4008 (progn
4009 (bind-key "C-x ?" 'puppet-set-anchor puppet-mode-map)
4010 (bind-key "C-c C-r" 'puppet-create-require puppet-mode-map)))))
4011 #+END_SRC
4012
4013 ** python
4014 Use elpy for the emacs python fun, but dont let it initialize all the
4015 various variables. Elpy author may like them, but I'm not him...
4016 #+BEGIN_SRC emacs-lisp
4017 (use-package elpy
4018 :defer t
4019 :mode ("\.py" . python-mode)
4020 :init
4021 (progn
4022 (safe-load (concat jj-elisp-dir "/elpy/elpy-autoloads.el"))
4023 )
4024 :config
4025 (progn
4026
4027 (use-package nose
4028 :ensure nose
4029 :commands (nosetests-all nosetests-module nosetests-one
4030 nosetests-failed nosetests-pdb-all
4031 nosetests-pdb-module nosetests-pdb-one)
4032 )
4033
4034 (use-package pyvenv
4035 :ensure pyvenv
4036 :commands (pyvenv-activate pyvenv-deactivate pyvenv-mode pyvenv-restart-python)
4037 )
4038
4039 (use-package idomenu
4040 :ensure idomenu
4041 :commands (idomenu)
4042 :defer t)
4043
4044 (use-package highlight-indentation
4045 :ensure t
4046 :commands (highlight-indentation-mode))
4047
4048 (use-package find-file-in-project
4049 :ensure t
4050 :commands (find-file-in-project ffip-project-files ffip ))
4051
4052 (use-package fuzzy
4053 :ensure t)
4054
4055 ;; Local variables in `python-mode'. This is not removed when Elpy
4056 ;; is disabled, which can cause some confusion.
4057 (add-hook 'python-mode-hook 'elpy-initialize-local-variables)
4058
4059 (defun my-python-mode-hook ()
4060 (setq require-final-newline nil)
4061 (setq mode-require-final-newline))
4062 (add-hook 'python-mode-hook 'my-python-mode-hook)
4063
4064 ;; Flymake support using flake8, including warning faces.
4065 (when (and (executable-find "flake8")
4066 (not (executable-find python-check-command)))
4067 (setq python-check-command "flake8"))
4068
4069 ;; `flymake-no-changes-timeout': The original value of 0.5 is too
4070 ;; short for Python code, as that will result in the current line to
4071 ;; be highlighted most of the time, and that's annoying. This value
4072 ;; might be on the long side, but at least it does not, in general,
4073 ;; interfere with normal interaction.
4074 (setq flymake-no-changes-timeout 60)
4075
4076 ;; `flymake-start-syntax-check-on-newline': This should be nil for
4077 ;; Python, as;; most lines with a colon at the end will mean the next
4078 ;; line is always highlighted as error, which is not helpful and
4079 ;; mostly annoying.
4080 (setq flymake-start-syntax-check-on-newline nil)
4081
4082 ;; `ac-auto-show-menu': Short timeout because the menu is great.
4083 (setq ac-auto-show-menu 0.4)
4084
4085 ;; `ac-quick-help-delay': I'd like to show the menu right with the
4086 ;; completions, but this value should be greater than
4087 ;; `ac-auto-show-menu' to show help for the first entry as well.
4088 (setq ac-quick-help-delay 0.5)
4089
4090 ;; `yas-trigger-key': TAB, as is the default, conflicts with the
4091 ;; autocompletion. We also need to tell yasnippet about the new
4092 ;; binding. This is a bad interface to set the trigger key. Stop
4093 ;; doing this.
4094 (let ((old (when (boundp 'yas-trigger-key)
4095 yas-trigger-key)))
4096 (setq yas-trigger-key "C-c C-i")
4097 (when (fboundp 'yas--trigger-key-reload)
4098 (yas--trigger-key-reload old)))
4099
4100 ;; yas-snippet-dirs can be a string for a single directory. Make
4101 ;; sure it's a list in that case so we can add our own entry.
4102 (when (not (listp yas-snippet-dirs))
4103 (setq yas-snippet-dirs (list yas-snippet-dirs)))
4104 (add-to-list 'yas-snippet-dirs
4105 (concat (file-name-directory (locate-library "elpy"))
4106 "snippets/")
4107 t)
4108
4109 ;; Now load yasnippets.
4110 (yas-reload-all)
4111 (elpy-enable t)
4112 (elpy-use-ipython)))
4113
4114 #+END_SRC
4115
4116 Below is old setup
4117 #+BEGIN_SRC emacs-lisp :tangle no
4118 (autoload 'python-mode "python-mode" "Python Mode." t)
4119 (add-auto-mode 'python-mode "\\.py\\'")
4120 (add-auto-mode 'python-mode "\\.py$")
4121 (add-auto-mode 'python-mode "SConstruct\\'")
4122 (add-auto-mode 'python-mode "SConscript\\'")
4123 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
4124
4125 (after 'python-mode
4126 (set-variable 'py-indent-offset 4)
4127 (set-variable 'py-smart-indentation nil)
4128 (set-variable 'indent-tabs-mode nil)
4129 (define-key python-mode-map "\C-m" 'newline-and-indent)
4130 (turn-on-eldoc-mode)
4131 (defun python-auto-fill-comments-only ()
4132 (auto-fill-mode 1)
4133 (set (make-local-variable 'fill-nobreak-predicate)
4134 (lambda ()
4135 (not (python-in-string/comment)))))
4136 (add-hook 'python-mode-hook
4137 (lambda ()
4138 (python-auto-fill-comments-only)))
4139 ;; pymacs
4140 (autoload 'pymacs-apply "pymacs")
4141 (autoload 'pymacs-call "pymacs")
4142 (autoload 'pymacs-eval "pymacs" nil t)
4143 (autoload 'pymacs-exec "pymacs" nil t)
4144 (autoload 'pymacs-load "pymacs" nil t))
4145 #+END_SRC
4146
4147 If an =ipython= executable is on the path, then assume that IPython is
4148 the preferred method python evaluation.
4149 #+BEGIN_SRC emacs-lisp :tangle no
4150 (when (executable-find "ipython")
4151 (require 'ipython)
4152 (setq org-babel-python-mode 'python-mode))
4153
4154 (setq python-shell-interpreter "ipython")
4155 (setq python-shell-interpreter-args "")
4156 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
4157 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
4158 (setq python-shell-completion-setup-code
4159 "from IPython.core.completerlib import module_completion")
4160 (setq python-shell-completion-module-string-code
4161 "';'.join(module_completion('''%s'''))\n")
4162 (setq python-shell-completion-string-code
4163 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
4164 #+END_SRC
4165 ** rainbow-delimiters
4166 [2013-04-09 Di 23:38]
4167 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
4168 which highlights parens, brackets, and braces according to their
4169 depth. Each successive level is highlighted a different color. This
4170 makes it easy to spot matching delimiters, orient yourself in the code,
4171 and tell which statements are at the same depth.
4172 #+BEGIN_SRC emacs-lisp
4173 (use-package rainbow-delimiters
4174 :ensure rainbow-delimiters
4175 :commands rainbow-delimiters-mode
4176 :init
4177 (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
4178 #+END_SRC
4179 ** rainbow-mode
4180 #+BEGIN_SRC emacs-lisp
4181 (use-package rainbow-mode
4182 :ensure rainbow-mode
4183 :defer t
4184 :diminish rainbow-mode)
4185 #+END_SRC
4186
4187 ** re-builder
4188 Saner regex syntax
4189 #+BEGIN_SRC emacs-lisp
4190 (use-package re-builder
4191 :commands re-builder
4192 :defer t
4193 :config
4194 (setq reb-re-syntax 'string))
4195 #+END_SRC
4196 ** recentf
4197 [2014-05-19 Mo 22:56]
4198 Recentf is a minor mode that builds a list of recently opened
4199 files. This list is is automatically saved across Emacs sessions.
4200 #+BEGIN_SRC emacs-lisp
4201 (use-package recentf
4202 :if (not noninteractive)
4203 :bind ("C-x C-r" . recentf-open-files)