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