fd30e428c63be9f7f12b77c66a4299c8d17f930c
[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 ("q" nil "quit"))
2120 (bind-key "C-c h" 'hydra-gnus/body)
2121
2122 (defhydra hydra-launcher (:color blue)
2123 "Launch"
2124 ("h" man "man")
2125 ("r" (browse-url "http://www.reddit.com/r/emacs/") "reddit")
2126 ("w" (browse-url "http://www.emacswiki.org/") "emacswiki")
2127 ("s" shell "shell")
2128 ("q" nil "cancel"))
2129 (bind-key "C-c r" 'hydra-launcher/body)
2130
2131 ; whitespace mode gets loaded late, so variable may not be there yet. Workaround...
2132 (defvar whitespace-mode nil)
2133 (defhydra hydra-toggle (:color pink)
2134 "
2135 _a_ abbrev-mode: % 4`abbrev-mode^^^^ _f_ auto-fill-mode: %`auto-fill-function
2136 _c_ auto-complete-mode: % 4`auto-complete-mode _r_ auto-revert-mode: %`auto-revert-mode
2137 _d_ debug-on-error: % 4`debug-on-error^ _t_ truncate-lines: %`truncate-lines
2138 _w_ whitespace-mode: % 4`whitespace-mode _g_ golden-ratio-mode: %`golden-ratio-mode
2139 _l_ linum-mode: % 4`linum-mode _k_ linum relative: %`linum-format
2140
2141 "
2142 ("a" abbrev-mode nil)
2143 ("c" auto-complete-mode nil)
2144 ("i" aggressive-indent-mode nil)
2145 ("d" toggle-debug-on-error nil)
2146 ("f" auto-fill-mode nil)
2147 ("g" golden-ratio-mode nil)
2148 ("t" toggle-truncate-lines nil)
2149 ("w" whitespace-mode nil)
2150 ("r" auto-revert-mode nil)
2151 ("l" linum-mode nil)
2152 ("k" linum-relative-toggle nil)
2153 ("q" nil "cancel"))
2154 (bind-key "C-c C-v" 'hydra-toggle/body)
2155 ))
2156
2157
2158 #+END_SRC
2159 ** ibuffer
2160 [2014-05-21 Wed 23:54]
2161 #+BEGIN_SRC emacs-lisp :tangle yes
2162 (use-package ibuffer
2163 :defer t
2164 :bind (("C-h h" . ibuffer)
2165 ("C-x C-b" . ibuffer)
2166 ("<XF86WebCam>" . ibuffer)
2167 )
2168 :commands (ibuffer)
2169 :defines (ibuffer-filtering-alist
2170 ibuffer-filter-groups ibuffer-compile-formats ibuffer-git-column-length
2171 ibuffer-show-empty-filter-groups ibuffer-saved-filter-groups)
2172 :config
2173 (progn
2174 (defvar my-ibufffer-separator " • ")
2175 (setq ibuffer-filter-group-name-face 'variable-pitch
2176 ibuffer-use-header-line t
2177 ibuffer-old-time 12)
2178 (unbind-key "M-o" ibuffer-mode-map)
2179 (bind-key "s" 'isearch-forward-regexp ibuffer-mode-map)
2180 (bind-key "." 'ibuffer-invert-sorting ibuffer-mode-map)
2181
2182 (use-package f
2183 :ensure f)
2184
2185 (use-package ibuffer-vc
2186 :ensure t
2187 :commands
2188 (ibuffer-vc-set-filter-groups-by-vc-root
2189 ibuffer-vc-generate-filter-groups-by-vc-root))
2190
2191 (use-package ibuffer-tramp
2192 :ensure t
2193 :commands (ibuffer-tramp-generate-filter-groups-by-tramp-connection
2194 ibuffer-tramp-set-filter-groups-by-tramp-connection))
2195 ;; Switching to ibuffer puts the cursor on the most recent buffer
2196 (defadvice ibuffer (around ibuffer-point-to-most-recent activate)
2197 "Open ibuffer with cursor pointed to most recent buffer name"
2198 (let ((recent-buffer-name (buffer-name)))
2199 ad-do-it
2200 (ibuffer-update nil t)
2201 (unless (string= recent-buffer-name "*Ibuffer*")
2202 (ibuffer-jump-to-buffer recent-buffer-name))))
2203
2204 (defun ibuffer-magit-status ()
2205 (interactive)
2206 (--when-let (get-buffer "*Ibuffer*")
2207 (with-current-buffer it
2208 (let* ((selected-buffer (ibuffer-current-buffer))
2209 (buffer-path (with-current-buffer
2210 selected-buffer
2211 (or (buffer-file-name)
2212 list-buffers-directory
2213 default-directory)))
2214 (default-directory
2215 (if (file-regular-p buffer-path)
2216 (file-name-directory buffer-path)
2217 buffer-path)))
2218 (magit-status default-directory)))))
2219 (bind-key "i" 'ibuffer-magit-status ibuffer-mode-map)
2220 (bind-key "G" 'ibuffer-magit-status ibuffer-mode-map)
2221
2222 (setq ibuffer-directory-abbrev-alist
2223 (-uniq
2224 (-flatten
2225 (--map
2226 (list
2227 (cons (f-slash (f-expand (cdr it))) my-ibufffer-separator)
2228 (cons (f-slash (f-canonical (cdr it))) (concat (car it) my-ibufffer-separator)))
2229 '(
2230 ("dak" . "/develop/dak/")
2231 ("org" . "~/org/")
2232 ("config" . "~/.emacs.d/config/")
2233 ("tmp" . "~/tmp/")
2234 ("systmp" . "/tmp/")
2235 ("puppet" . "~/git/puppet")
2236 ("git" . "~/git/")
2237 )))))
2238
2239 (use-package ibuffer-git
2240 :ensure t)
2241 (use-package ibuffer-vc
2242 :ensure t)
2243
2244 (define-ibuffer-column size-h
2245 (:name "Size" :inline t)
2246 (cond
2247 ((> (buffer-size) 1000)
2248 (format "%7.1fk" (/ (buffer-size) 1000.0)))
2249 ((> (buffer-size) 1000000)
2250 (format "%7.1fM" (/ (buffer-size) 1000000.0)))
2251 (t
2252 (format "%8d" (buffer-size)))))
2253
2254 (use-package ibuf-ext)
2255 (define-ibuffer-filter filename2
2256 "Toggle current view to buffers with filename matching QUALIFIER."
2257 (:description "filename2"
2258 :reader (read-from-minibuffer "Filter by filename (regexp): "))
2259 ;; (ibuffer-awhen (buffer-local-value 'buffer-file-name buf)
2260 (ibuffer-awhen (with-current-buffer buf
2261 (or buffer-file-name
2262 default-directory))
2263 (string-match qualifier it)))
2264
2265 (defvar ibuffer-magit-filter-groups nil)
2266 (defun ibuffer-magit-define-filter-groups ()
2267 (when (and (not ibuffer-magit-filter-groups)
2268 (boundp 'magit-repo-dirs))
2269 (setq ibuffer-magit-filter-groups
2270 (--map (list
2271 (concat "git:: "
2272 (file-name-nondirectory (directory-file-name it)))
2273 `(filename2 . ,it))
2274 (mapcar 'cdr (magit-list-repos magit-repo-dirs))))))
2275
2276 (defun ibuffer-set-filter-groups-by-root ()
2277 (interactive)
2278 ;; (ibuffer-projectile-define-filter-groups)
2279 ;; (ibuffer-magit-define-filter-groups)
2280 (setq ibuffer-filter-groups
2281 (-concat
2282 ;; ibuffer-projectile-filter-groups
2283 ibuffer-magit-filter-groups
2284
2285 '(("MORE"
2286 (or (mode . magit-log-edit-mode)
2287 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2288 (name . "^\\*Pymacs\\*$")
2289 (name . "^\\*helm.*\\*")
2290 (name . "^\\*Compile-log\\*$")
2291 (name . "^\\*Ido Completions\\*$")
2292 (name . "^\\*magit-\\(process\\)\\*$")
2293 (name . "^ "))))
2294 '(("EMACS"
2295 (or
2296 (name . "^\\*scratch")
2297 (name . "^\\*Messages")
2298 (name . "^\\*Help")
2299 )))
2300 (ibuffer-vc-generate-filter-groups-by-vc-root)
2301 (ibuffer-tramp-generate-filter-groups-by-tramp-connection))))
2302
2303 (defun toggle-ibuffer-filter-groups ()
2304 "DOCSTRING"
2305 (interactive)
2306 (let ((ibuf (get-buffer "*Ibuffer*")))
2307 (when ibuf
2308 (with-current-buffer ibuf
2309 (let ((selected-buffer (ibuffer-current-buffer)))
2310 (if (not ibuffer-filter-groups)
2311 (ibuffer-set-filter-groups-by-root)
2312 (setq ibuffer-filter-groups nil))
2313 (pop-to-buffer ibuf)
2314 (ibuffer-update nil t)
2315 (ibuffer-jump-to-buffer (buffer-name selected-buffer )))))))
2316
2317 (bind-key "h" 'toggle-ibuffer-filter-groups ibuffer-mode-map)
2318
2319 (defun ibuffer-back-to-top ()
2320 (interactive)
2321 (beginning-of-buffer)
2322 (next-line 3))
2323
2324 (defun ibuffer-jump-to-bottom ()
2325 (interactive)
2326 (end-of-buffer)
2327 (beginning-of-line)
2328 (next-line -2))
2329
2330 (define-key ibuffer-mode-map
2331 (vector 'remap 'end-of-buffer) 'ibuffer-jump-to-bottom)
2332 (define-key ibuffer-mode-map
2333 (vector 'remap 'beginning-of-buffer) 'ibuffer-back-to-top)
2334
2335 (setq ibuffer-default-sorting-mode 'recency
2336 ibuffer-eliding-string "…"
2337 ibuffer-compile-formats t
2338 ibuffer-git-column-length 6
2339 ibuffer-show-empty-filter-groups nil
2340 ibuffer-default-directory "~/"
2341 )
2342
2343 (setq ibuffer-formats '((mark vc-status-mini
2344 " "
2345 (git-status 8 8 :left)
2346 " "
2347 read-only modified
2348 " "
2349 (name 18 18 :left :elide)
2350 " "
2351 (size-h 9 -1 :right)
2352 " "
2353 (mode 16 16 :left :elide)
2354 " " filename-and-process)
2355 (mark " "
2356 (git-status 8 8 :left)
2357 " "
2358 (name 16 -1)
2359 " " filename)
2360 ))
2361
2362 (setq ibuffer-saved-filter-groups
2363 (quote (("flat")
2364 ("default"
2365 ("dired" (mode . dired-mode))
2366 ("perl" (mode . cperl-mode))
2367 ("puppet" (or
2368 (mode . puppet-mode)
2369 (mode . yaml-mode)))
2370 ("ruby" (mode . ruby-mode))
2371 ("emacs" (or
2372 (name . "^\\*scratch\\*$")
2373 (name . "^\\*Compile-log\\*$")
2374 (name . "^\\*Completions\\*$")
2375 (name . "^\\*Messages\\*$")
2376 (name . "^\\*Backtrace\\*$")
2377 (name . "^\\*Packages*\\*$")
2378 (name . "^\\*Help*\\*$")
2379 ))
2380 ("gnus" (or
2381 (mode . message-mode)
2382 (mode . bbdb-mode)
2383 (mode . mail-mode)
2384 (mode . gnus-group-mode)
2385 (mode . gnus-summary-mode)
2386 (mode . gnus-article-mode)
2387 (name . "^\\.bbdb$")
2388 (name . "^\\.newsrc-dribble")))
2389 ("org" (or
2390 (filename . ".*/org/.*")
2391 (mode . org-agenda-mode)
2392 (name . "^diary$")))
2393 ("other" (or
2394 (mode . magit-log-edit-mode)
2395 (name . "^\\*magit-\\(process\\|commit\\)\\*$"))))
2396 ("categorized"
2397 ;; -------------------------------------------------
2398 ;; programming languages #1
2399 ("code" (or
2400 (mode . emacs-lisp-mode)
2401 (mode . python-mode)
2402 (mode . ruby-mode)
2403 (mode . coffee-mode)
2404 (mode . js-mode)
2405 (mode . js2-mode)
2406 (mode . actionscript-mode)
2407 (mode . java-mode)
2408 (mode . sh-mode)
2409 (mode . haskell-mode)
2410 (mode . html-mode)
2411 (mode . web-mode)
2412 (mode . haml-mode)
2413 (mode . nxml-mode)
2414 (mode . css-mode)))
2415 ;; -------------------------------------------------
2416 ;; configuration/data files
2417 ("conf" (or
2418 (mode . json-mode)
2419 (mode . yaml-mode)
2420 (mode . conf-mode)))
2421 ;; -------------------------------------------------
2422 ;; text/notetaking/org
2423 ("org agenda" (mode . org-agenda-mode))
2424 ("org" (or
2425 (mode . org-mode)
2426 (name . "^\\*Calendar\\*$")
2427 (name . "^diary$")))
2428 ("text misc" (or
2429 (mode . text-mode)
2430 (mode . rst-mode)
2431 (mode . markdown-mode)))
2432 ;; -------------------------------------------------
2433 ;; media
2434 ("media" (or
2435 (mode . image-mode)))
2436 ;; -------------------------------------------------
2437 ;; misc
2438 ("w3m" (mode . w3m-mode))
2439 ("scm" (or
2440 (mode . magit-status-mode)
2441 (mode . magit-log-mode)
2442 (mode . vc-annotate-mode)))
2443 ("dired" (mode . dired-mode))
2444 ("help" (or
2445 (mode . Info-mode)
2446 (mode . help-mode)
2447 (mode . Man-mode)
2448 (name . "^\\*Personal Keybindings\\*$")))
2449 ;; -------------------------------------------------
2450 ;; *buffer* buffers
2451 ("MORE" (or (mode . magit-log-edit-mode)
2452 (name . "^\\*\\(traad-server\\|httpd\\|epc con.*\\|tramp/.*\\|Completions\\)\\*$")
2453 (name . "^\\*Pymacs\\*$")
2454 (name . "^\\*Compile-log\\*$")
2455 (name . "^\\*Completions\\*$")
2456 (name . "^\\*magit-\\(process\\|commit\\)\\*$")
2457 (name . "^ ")))
2458 ("*buffer*" (name . "\\*.*\\*"))))))
2459
2460 (add-hook 'ibuffer-mode-hook
2461 (lambda ()
2462 (ibuffer-auto-mode 1)
2463 (ibuffer-switch-to-saved-filter-groups "default")))
2464
2465 ;; Unless you turn this variable on you will be prompted every time
2466 ;; you want to delete a buffer, even unmodified ones, which is way
2467 ;; too cautious for most people. You’ll still be prompted for
2468 ;; confirmation when deleting modified buffers after the option has
2469 ;; been turned off.
2470 (setq ibuffer-expert t)
2471
2472 ))
2473 #+END_SRC
2474 ** icicles
2475 [[http://article.gmane.org/gmane.emacs.orgmode/4574/match%3Dicicles]["In case you never heard of it, Icicles is to ‘TAB’ completion what
2476 ‘TAB’ completion is to typing things manually every time.”]]
2477 #+BEGIN_SRC emacs-lisp :tangle yes
2478 (use-package icicles
2479 :load-path "elisp/icicle/"
2480 :init
2481 (icy-mode 1))
2482 #+END_SRC
2483 ** icomplete
2484 Incremental mini-buffer completion preview: Type in the minibuffer,
2485 list of matching commands is echoed
2486 #+BEGIN_SRC emacs-lisp :tangle yes
2487 (icomplete-mode 99)
2488 #+END_SRC
2489 ** iedit
2490 [2014-05-26 Mon 22:49]
2491 #+BEGIN_SRC emacs-lisp :tangle yes
2492 (use-package iedit
2493 :ensure iedit
2494 :commands (iedit-mode)
2495 :defer t
2496 :bind (("C-;" . iedit-mode)
2497 ("C-," . iedit-mode-toggle-on-function))
2498 )
2499
2500 #+END_SRC
2501 ** info stuff
2502 [2014-05-20 Tue 23:35]
2503 #+BEGIN_SRC emacs-lisp :tangle yes
2504 (use-package info
2505 :bind ("C-h C-i" . info-lookup-symbol)
2506 :commands info-lookup-symbol
2507 :config
2508 (progn
2509 ;; (defadvice info-setup (after load-info+ activate)
2510 ;; (use-package info+))
2511
2512 (defadvice Info-exit (after remove-info-window activate)
2513 "When info mode is quit, remove the window."
2514 (if (> (length (window-list)) 1)
2515 (delete-window)))))
2516
2517 (use-package info-look
2518 :commands info-lookup-add-help)
2519 #+END_SRC
2520 ** linum (line number)
2521 Various modes should have line numbers in front of each line.
2522
2523 But then there are some where it would just be deadly - like org-mode,
2524 gnus, so we have a list of modes where we don't want to see it.
2525 #+BEGIN_SRC emacs-lisp :tangle yes
2526 (use-package linum
2527 :diminish linum-mode
2528 :config
2529 (progn
2530 (setq linum-format "%3d ")
2531 (setq linum-mode-inhibit-modes-list '(org-mode
2532 eshell-mode
2533 shell-mode
2534 gnus-group-mode
2535 gnus-summary-mode
2536 gnus-article-mode))
2537
2538 (defadvice linum-on (around linum-on-inhibit-for-modes)
2539 "Stop the load of linum-mode for some major modes."
2540 (unless (member major-mode linum-mode-inhibit-modes-list)
2541 ad-do-it))
2542
2543 (ad-activate 'linum-on)
2544
2545 (use-package linum-relative
2546 :ensure linum-relative
2547 :init
2548 (progn
2549 (setq linum-format 'dynamic)
2550 )))
2551 :init
2552 (global-linum-mode 1))
2553 #+END_SRC
2554
2555 ** lisp editing stuff
2556
2557 [2013-04-21 So 21:00]
2558 I'm not doing much of it, except for my emacs and gnus configs, but
2559 then I like it nice too...
2560 #+BEGIN_SRC emacs-lisp :tangle yes
2561 (bind-key "TAB" 'lisp-complete-symbol read-expression-map)
2562
2563 (defun remove-elc-on-save ()
2564 "If you're saving an elisp file, likely the .elc is no longer valid."
2565 (make-local-variable 'after-save-hook)
2566 (add-hook 'after-save-hook
2567 (lambda ()
2568 (if (file-exists-p (concat buffer-file-name "c"))
2569 (delete-file (concat buffer-file-name "c"))))))
2570
2571 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
2572 (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
2573
2574 (use-package paredit
2575 :ensure paredit
2576 :diminish paredit-mode " π")
2577
2578 (setq lisp-coding-hook 'lisp-coding-defaults)
2579 (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
2580
2581 (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
2582 (add-hook 'emacs-lisp-mode-hook (lambda ()
2583 (run-hooks 'prelude-emacs-lisp-mode-hook)))
2584
2585 (bind-key "M-." 'find-function-at-point emacs-lisp-mode-map)
2586
2587 (after "elisp-slime-nav"
2588 '(diminish 'elisp-slime-nav-mode))
2589 (after "rainbow-mode"
2590 '(diminish 'rainbow-mode))
2591 (after "eldoc"
2592 '(diminish 'eldoc-mode))
2593 #+END_SRC
2594 ** magit
2595 [2013-04-21 So 20:48]
2596 magit is a mode for interacting with git.
2597 #+BEGIN_SRC emacs-lisp :tangle yes
2598 (use-package magit
2599 :ensure magit
2600 :commands (magit-log magit-run-gitk magit-run-git-gui magit-status
2601 magit-git-repo-p magit-list-repos)
2602 :defer t
2603 :bind (("C-x g" . magit-status)
2604 ("C-x G" . magit-status-with-prefix))
2605 :init
2606 (progn
2607 (setq magit-commit-signoff t
2608 magit-repo-dirs '("~/git"
2609 "/develop/vcs/"
2610 "/develop/Debian/"
2611 )
2612 magit-repo-dirs-depth 4
2613 magit-log-auto-more t)
2614
2615 (use-package magit-blame
2616 :commands magit-blame-mode
2617 :defer t)
2618
2619 (use-package magit-svn
2620 :ensure magit-svn
2621 :commands (magit-svn-mode
2622 turn-on-magit-svn)
2623 :defer t)
2624
2625 (add-hook 'magit-mode-hook 'hl-line-mode)
2626 (defun magit-status-with-prefix ()
2627 (interactive)
2628 (let ((current-prefix-arg '(4)))
2629 (call-interactively 'magit-status)))
2630 )
2631 :config
2632 (progn
2633 (setenv "GIT_PAGER" "")
2634
2635 (unbind-key "M-h" magit-mode-map)
2636 (unbind-key "M-s" magit-mode-map)
2637
2638 (use-package magit-find-file
2639 :ensure magit-find-file
2640 :commands (magit-find-file-completing-read)
2641 :defer t
2642 :init
2643 (progn
2644 (bind-key "C-x C-f" 'magit-find-file-completing-read magit-mode-map)))
2645
2646 (add-hook 'magit-log-edit-mode-hook
2647 #'(lambda ()
2648 (set-fill-column 72)
2649 (flyspell-mode)))
2650
2651 (defadvice magit-status (around magit-fullscreen activate)
2652 (window-configuration-to-register :magit-fullscreen)
2653 ad-do-it
2654 (delete-other-windows))
2655
2656 (defun magit-quit-session ()
2657 "Restores the previous window configuration and kills the magit buffer"
2658 (interactive)
2659 (kill-buffer)
2660 (jump-to-register :magit-fullscreen))
2661
2662 (bind-key "q" 'magit-quit-session magit-status-mode-map)
2663 ))
2664 #+END_SRC
2665 ** markdown-mode
2666 [2014-05-20 Tue 23:04]
2667 #+BEGIN_SRC emacs-lisp :tangle yes
2668 (use-package markdown-mode
2669 :mode (("\\.md\\'" . markdown-mode)
2670 ("\\.mdwn\\'" . markdown-mode))
2671 :defer t)
2672 #+END_SRC
2673 ** message
2674 #+BEGIN_SRC emacs-lisp :tangle yes
2675 (use-package message
2676 :idle
2677 (progn
2678 (setq message-kill-buffer-on-exit t)))
2679 #+END_SRC
2680 ** mingus
2681 [[https://github.com/pft/mingus][Mingus]] is a nice interface to mpd, the Music Player Daemon.
2682
2683 I want to access it from anywhere using =F6=.
2684 #+BEGIN_SRC emacs-lisp :tangle yes
2685 (use-package mingus-stays-home
2686 :bind ( "<f6>" . mingus)
2687 :defer t
2688 :config
2689 (progn
2690 (setq mingus-dired-add-keys t)
2691 (setq mingus-mode-always-modeline nil)
2692 (setq mingus-mode-line-show-elapsed-percentage nil)
2693 (setq mingus-mode-line-show-volume nil)
2694 (setq mingus-mpd-config-file "/etc/mpd.conf")
2695 (setq mingus-mpd-playlist-dir "/var/lib/mpd/playlists")
2696 (setq mingus-mpd-root "/share/music/")))
2697 #+END_SRC
2698
2699 ** miniedit
2700 Edit minibuffer in a full (text-mode) buffer by pressing *M-C-e*.
2701 #+BEGIN_SRC emacs-lisp :tangle yes
2702 (use-package miniedit
2703 :ensure miniedit
2704 :commands miniedit
2705 :config
2706 (progn
2707 (bind-key "M-C-e" 'miniedit minibuffer-local-map)
2708 (bind-key "M-C-e" 'miniedit minibuffer-local-ns-map)
2709 (bind-key "M-C-e" 'miniedit minibuffer-local-completion-map)
2710 (bind-key "M-C-e" 'miniedit minibuffer-local-must-match-map)
2711 ))
2712 #+END_SRC
2713
2714
2715 ** mmm-mode
2716 [2013-05-21 Tue 23:39]
2717 MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to
2718 coexist in one buffer.
2719 #+BEGIN_SRC emacs-lisp :tangle no
2720 (use-package mmm-auto
2721 :ensure mmm-mode
2722 :init
2723 (progn
2724 (setq mmm-global-mode 'buffers-with-submode-classes)
2725 (setq mmm-submode-decoration-level 2)
2726 (eval-after-load 'mmm-vars
2727 '(progn
2728 (mmm-add-group
2729 'html-css
2730 '((css-cdata
2731 :submode css-mode
2732 :face mmm-code-submode-face
2733 :front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
2734 :back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
2735 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2736 @ "\n" _ "\n" @ "</script>" @)))
2737 (css
2738 :submode css-mode
2739 :face mmm-code-submode-face
2740 :front "<style[^>]*>[ \t]*\n?"
2741 :back "[ \t]*</style>"
2742 :insert ((?j js-tag nil @ "<style type=\"text/css\">"
2743 @ "\n" _ "\n" @ "</style>" @)))
2744 (css-inline
2745 :submode css-mode
2746 :face mmm-code-submode-face
2747 :front "style=\""
2748 :back "\"")))
2749 (dolist (mode (list 'html-mode 'nxml-mode))
2750 (mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css))
2751 (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
2752 ))))
2753 #+END_SRC
2754
2755 ** mo-git-blame
2756 This is [[https://github.com/mbunkus/mo-git-blame][mo-git-blame -- An interactive, iterative 'git blame' mode for
2757 Emacs]].
2758 #+BEGIN_SRC emacs-lisp :tangle yes
2759 (use-package mo-git-blame
2760 :ensure mo-git-blame
2761 :commands (mo-git-blame-current
2762 mo-git-blame-file)
2763 :config
2764 (progn
2765 (setq mo-git-blame-blame-window-width 25)))
2766 #+END_SRC
2767
2768 ** multiple cursors
2769 [2013-04-08 Mon 23:57]
2770 Use multiple cursors mode. See [[http://emacsrocks.com/e13.html][Emacs Rocks! multiple cursors]] and
2771 [[https://github.com/emacsmirror/multiple-cursors][emacsmirror/multiple-cursors · GitHub]]
2772 #+BEGIN_SRC emacs-lisp :tangle yes
2773 (use-package multiple-cursors
2774 :ensure multiple-cursors
2775 :defer t
2776 :commands (mc/remove-fake-cursors
2777 mc/create-fake-cursor-at-point
2778 mc/pop-state-from-overlay
2779 mc/maybe-multiple-cursors-mode)
2780 :defines (multiple-cursors-mode
2781 mc--read-char
2782 mc--read-quoted-char
2783 rectangular-region-mode)
2784 :bind (("C-S-c C-S-c" . mc/edit-lines)
2785 ("C->" . mc/mark-next-like-this)
2786 ("C-<" . mc/mark-previous-like-this)
2787 ("C-c C-<" . mc/mark-all-like-this)
2788 ("C-c i" . mc/insert-numbers))
2789 :config
2790 (progn
2791 (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
2792 (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
2793 (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
2794 (bind-key "l" 'mc/edit-lines region-bindings-mode-map)
2795 (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
2796 (setq mc/list-file (expand-file-name "mc-cache.el" jj-cache-dir))))
2797 #+END_SRC
2798 ** neotree
2799 [2014-08-27 Wed 17:15]
2800 A emacs tree plugin
2801 #+BEGIN_SRC emacs-lisp :tangle yes
2802 (use-package neotree
2803 :ensure neotree
2804 :defer t
2805 :bind (("<f8>" . neotree-toggle))
2806 :commands (neotree-find
2807 neotree-toggle
2808 neotree)
2809 :idle
2810 (progn
2811 (setq neo-smart-open t))
2812 :config
2813 (progn
2814 (bind-key "^" 'neotree-select-up-node neotree-mode-map)))
2815 #+END_SRC
2816 ** nxml
2817 [2013-05-22 Wed 22:02]
2818 nxml-mode is a major mode for editing XML.
2819 #+BEGIN_SRC emacs-lisp :tangle yes
2820 (add-auto-mode
2821 'nxml-mode
2822 (concat "\\."
2823 (regexp-opt
2824 '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss"
2825 "gpx" "tcx"))
2826 "\\'"))
2827 (setq magic-mode-alist (cons '("<\\?xml " . nxml-mode) magic-mode-alist))
2828 (fset 'xml-mode 'nxml-mode)
2829 (setq nxml-slash-auto-complete-flag t)
2830
2831 ;; See: http://sinewalker.wordpress.com/2008/06/26/pretty-printing-xml-with-emacs-nxml-mode/
2832 (defun pp-xml-region (begin end)
2833 "Pretty format XML markup in region. The function inserts
2834 linebreaks to separate tags that have nothing but whitespace
2835 between them. It then indents the markup by using nxml's
2836 indentation rules."
2837 (interactive "r")
2838 (save-excursion
2839 (nxml-mode)
2840 (goto-char begin)
2841 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
2842 (backward-char) (insert "\n"))
2843 (indent-region begin end)))
2844
2845 ;;----------------------------------------------------------------------------
2846 ;; Integration with tidy for html + xml
2847 ;;----------------------------------------------------------------------------
2848 ;; tidy is autoloaded
2849 (eval-after-load 'tidy
2850 '(progn
2851 (add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))
2852 (add-hook 'html-mode-hook (lambda () (tidy-build-menu html-mode-map)))
2853 ))
2854
2855 #+END_SRC
2856 ** org :FIXME:
2857 *** General settings
2858 [2013-04-28 So 17:06]
2859
2860 I use org-mode a lot and, having my config for this based on [[*Bernt%20Hansen][the config of Bernt Hansen]],
2861 it is quite extensive. Nevertheless, it starts out small, loading it.
2862 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2863 (require 'org)
2864 #+END_SRC
2865
2866 My browsers (Conkeror, Iceweasel) can store links in org-mode. For
2867 that we need org-protocol.
2868 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2869 (require 'org-protocol)
2870 #+END_SRC
2871
2872 *** Agenda
2873
2874 My current =org-agenda-files= variable only includes a set of
2875 directories.
2876 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2877 (setq org-agenda-files (quote ("~/org/"
2878 "~/org/debian"
2879 "~/org/debconf"
2880 "~/org/spi"
2881 "~/org/nsb"
2882 )))
2883 (setq org-default-notes-file "~/org/notes.org")
2884 #+END_SRC
2885 =org-mode= manages the =org-agenda-files= variable automatically using
2886 =C-c [= and =C-c ]= to add and remove files respectively. However,
2887 this replaces my directory list with a list of explicit filenames
2888 instead and is not what I want. If this occurs then adding a new org
2889 file to any of the above directories will not contribute to my agenda
2890 and I will probably miss something important.
2891
2892 I have disabled the =C-c [= and =C-c ]= keys in =org-mode-hook= to
2893 prevent messing up my list of directories in the =org-agenda-files=
2894 variable. I just add and remove directories manually here. Changing
2895 the list of directories in =org-agenda-files= happens very rarely
2896 since new files in existing directories are automatically picked up.
2897
2898 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2899 ;; Keep tasks with dates on the global todo lists
2900 (setq org-agenda-todo-ignore-with-date nil)
2901
2902 ;; Keep tasks with deadlines on the global todo lists
2903 (setq org-agenda-todo-ignore-deadlines nil)
2904
2905 ;; Keep tasks with scheduled dates on the global todo lists
2906 (setq org-agenda-todo-ignore-scheduled nil)
2907
2908 ;; Keep tasks with timestamps on the global todo lists
2909 (setq org-agenda-todo-ignore-timestamp nil)
2910
2911 ;; Remove completed deadline tasks from the agenda view
2912 (setq org-agenda-skip-deadline-if-done t)
2913
2914 ;; Remove completed scheduled tasks from the agenda view
2915 (setq org-agenda-skip-scheduled-if-done t)
2916
2917 ;; Remove completed items from search results
2918 (setq org-agenda-skip-timestamp-if-done t)
2919
2920 ;; Include agenda archive files when searching for things
2921 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
2922
2923 ;; Show all future entries for repeating tasks
2924 (setq org-agenda-repeating-timestamp-show-all t)
2925
2926 ;; Show all agenda dates - even if they are empty
2927 (setq org-agenda-show-all-dates t)
2928
2929 ;; Sorting order for tasks on the agenda
2930 (setq org-agenda-sorting-strategy
2931 (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
2932 (todo category-up priority-down effort-up)
2933 (tags category-up priority-down effort-up)
2934 (search category-up))))
2935
2936 ;; Start the weekly agenda on Monday
2937 (setq org-agenda-start-on-weekday 1)
2938
2939 ;; Enable display of the time grid so we can see the marker for the current time
2940 (setq org-agenda-time-grid (quote ((daily today remove-match)
2941 #("----------------" 0 16 (org-heading t))
2942 (0800 1000 1200 1400 1500 1700 1900 2100))))
2943
2944 ;; Display tags farther right
2945 (setq org-agenda-tags-column -102)
2946
2947 ; position the habit graph on the agenda to the right of the default
2948 (setq org-habit-graph-column 50)
2949
2950 ; turn habits back on
2951 (run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
2952
2953 ;;
2954 ;; Agenda sorting functions
2955 ;;
2956 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
2957
2958
2959 (setq org-deadline-warning-days 30)
2960
2961 ;; Always hilight the current agenda line
2962 (add-hook 'org-agenda-mode-hook
2963 '(lambda () (hl-line-mode 1))
2964 'append)
2965 #+END_SRC
2966
2967 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
2968 (setq org-agenda-persistent-filter t)
2969 (add-hook 'org-agenda-mode-hook
2970 '(lambda () (org-defkey org-agenda-mode-map "W" 'bh/widen))
2971 'append)
2972
2973 (add-hook 'org-agenda-mode-hook
2974 '(lambda () (org-defkey org-agenda-mode-map "F" 'bh/restrict-to-file-or-follow))
2975 'append)
2976
2977 (add-hook 'org-agenda-mode-hook
2978 '(lambda () (org-defkey org-agenda-mode-map "N" 'bh/narrow-to-subtree))
2979 'append)
2980
2981 (add-hook 'org-agenda-mode-hook
2982 '(lambda () (org-defkey org-agenda-mode-map "U" 'bh/narrow-up-one-level))
2983 'append)
2984
2985 (add-hook 'org-agenda-mode-hook
2986 '(lambda () (org-defkey org-agenda-mode-map "P" 'bh/narrow-to-project))
2987 'append)
2988
2989 ; Rebuild the reminders everytime the agenda is displayed
2990 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
2991
2992 ;(if (file-exists-p "~/org/refile.org")
2993 ; (add-hook 'after-init-hook 'bh/org-agenda-to-appt))
2994
2995 ; Activate appointments so we get notifications
2996 (appt-activate t)
2997
2998 (setq org-agenda-log-mode-items (quote (closed clock state)))
2999 (if (> emacs-major-version 23)
3000 (setq org-agenda-span 3)
3001 (setq org-agenda-ndays 3))
3002
3003 (setq org-agenda-show-all-dates t)
3004 (setq org-agenda-start-on-weekday nil)
3005 (setq org-deadline-warning-days 14)
3006
3007 #+END_SRC
3008 *** Global keybindings.
3009 Start off by defining a series of keybindings.
3010
3011 Well, first we remove =C-c [= and =C-c ]=, as all agenda directories are
3012 setup manually, not by org-mode. Also turn off =C-c ;=, which
3013 comments headlines - a function never used.
3014 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3015 (add-hook 'org-mode-hook
3016 (lambda ()
3017 (org-defkey org-mode-map "\C-c[" 'undefined)
3018 (org-defkey org-mode-map "\C-c]" 'undefined)
3019 (org-defkey org-mode-map "\C-c;" 'undefined))
3020 'append)
3021 #+END_SRC
3022
3023 And now a largish set of keybindings...
3024 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3025 (bind-key "C-c l" 'org-store-link)
3026 (bind-key "C-c a" 'org-agenda)
3027 ;(bind-key "C-c b" 'org-iswitchb)
3028 (define-key mode-specific-map [?a] 'org-agenda)
3029
3030 (bind-key "<f12>" 'org-agenda)
3031 (bind-key "<f5>" 'bh/org-todo)
3032 (bind-key "<S-f5>" 'bh/widen)
3033 (bind-key "<f7>" 'bh/set-truncate-lines)
3034 ;(bind-key "<f8>" 'org-cycle-agenda-files)
3035
3036 (bind-key "<f9> <f9>" 'bh/show-org-agenda)
3037 (bind-key "<f9> b" 'bbdb)
3038 (bind-key "<f9> c" 'calendar)
3039 (bind-key "<f9> f" 'boxquote-insert-file)
3040 (bind-key "<f9> h" 'bh/hide-other)
3041 (bind-key "<f9> n" 'org-narrow-to-subtree)
3042 (bind-key "<f9> w" 'widen)
3043 (bind-key "<f9> u" 'bh/narrow-up-one-level)
3044 (bind-key "<f9> I" 'bh/punch-in)
3045 (bind-key "<f9> O" 'bh/punch-out)
3046 (bind-key "<f9> H" 'jj/punch-in-hw)
3047 (bind-key "<f9> W" 'jj/punch-out-hw)
3048 (bind-key "<f9> o" 'bh/make-org-scratch)
3049 (bind-key "<f9> p" 'bh/phone-call)
3050 (bind-key "<f9> r" 'boxquote-region)
3051 (bind-key "<f9> s" 'bh/switch-to-scratch)
3052 (bind-key "<f9> t" 'bh/insert-inactive-timestamp)
3053 (bind-key "<f9> T" 'tabify)
3054 (bind-key "<f9> U" 'untabify)
3055 (bind-key "<f9> v" 'visible-mode)
3056 (bind-key "<f9> SPC" 'bh/clock-in-last-task)
3057 (bind-key "C-<f9>" 'previous-buffer)
3058 (bind-key "C-<f10>" 'next-buffer)
3059 (bind-key "M-<f9>" 'org-toggle-inline-images)
3060 ;(bind-key "C-x n r" 'narrow-to-region)
3061 (bind-key "<f11>" 'org-clock-goto)
3062 (bind-key "C-<f11>" 'org-clock-in)
3063 (bind-key "C-M-r" 'org-capture)
3064 (bind-key "C-c r" 'org-capture)
3065 (bind-key "C-S-<f12>" 'bh/save-then-publish)
3066 ;(bind-key "C-k" 'jj-org-kill-line org-mode-map)
3067
3068 #+END_SRC
3069
3070 *** Tasks, States, Todo fun
3071
3072 First we define the global todo keywords.
3073 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3074 (setq org-todo-keywords
3075 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d@/!)")
3076 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "DELEGATED(g@/!)" "|" "CANCELLED(c@/!)" "PHONE"))))
3077
3078 (setq org-todo-keyword-faces
3079 (quote (("TODO" :foreground "red" :weight bold)
3080 ("NEXT" :foreground "light blue" :weight bold)
3081 ("DONE" :foreground "forest green" :weight bold)
3082 ("WAITING" :foreground "orange" :weight bold)
3083 ("HOLD" :foreground "orange" :weight bold)
3084 ("DELEGATED" :foreground "yellow" :weight bold)
3085 ("CANCELLED" :foreground "dark green" :weight bold)
3086 ("PHONE" :foreground "dark green" :weight bold))))
3087 #+END_SRC
3088
3089 **** Fast Todo Selection
3090 Fast todo selection allows changing from any task todo state to any
3091 other state directly by selecting the appropriate key from the fast
3092 todo selection key menu.
3093 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3094 (setq org-use-fast-todo-selection t)
3095 #+END_SRC
3096 Changing a task state is done with =C-c C-t KEY=
3097
3098 where =KEY= is the appropriate fast todo state selection key as defined in =org-todo-keywords=.
3099
3100 The setting
3101 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3102 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
3103 #+END_SRC
3104 allows changing todo states with S-left and S-right skipping all of
3105 the normal processing when entering or leaving a todo state. This
3106 cycles through the todo states but skips setting timestamps and
3107 entering notes which is very convenient when all you want to do is fix
3108 up the status of an entry.
3109
3110 **** Todo State Triggers
3111 I have a few triggers that automatically assign tags to tasks based on
3112 state changes. If a task moves to =CANCELLED= state then it gets a
3113 =CANCELLED= tag. Moving a =CANCELLED= task back to =TODO= removes the
3114 =CANCELLED= tag. These are used for filtering tasks in agenda views
3115 which I'll talk about later.
3116
3117 The triggers break down to the following rules:
3118
3119 - Moving a task to =CANCELLED= adds a =CANCELLED= tag
3120 - Moving a task to =WAITING= adds a =WAITING= tag
3121 - Moving a task to =HOLD= adds a =WAITING= tag
3122 - Moving a task to a done state removes a =WAITING= tag
3123 - Moving a task to =TODO= removes =WAITING= and =CANCELLED= tags
3124 - Moving a task to =NEXT= removes a =WAITING= tag
3125 - Moving a task to =DONE= removes =WAITING= and =CANCELLED= tags
3126
3127 The tags are used to filter tasks in the agenda views conveniently.
3128 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3129 (setq org-todo-state-tags-triggers
3130 (quote (("CANCELLED" ("CANCELLED" . t))
3131 ("WAITING" ("WAITING" . t))
3132 ("HOLD" ("WAITING" . t) ("HOLD" . t))
3133 (done ("WAITING") ("HOLD"))
3134 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
3135 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
3136 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
3137 #+END_SRC
3138
3139 *** Capturing new tasks
3140 Org capture replaces the old remember mode.
3141 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3142 (setq org-directory "~/org")
3143 (setq org-default-notes-file "~/org/refile.org")
3144
3145 ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
3146 ;; see http://orgmode.org/manual/Template-elements.html
3147 (setq org-capture-templates
3148 (quote (("t" "todo" entry (file "~/org/refile.org")
3149 "* TODO %?\nAdded: %U\n"
3150 :clock-in t :clock-resume t)
3151 ("l" "linktodo" entry (file "~/org/refile.org")
3152 "* TODO %?\nAdded: %U\n%a\n"
3153 :clock-in t :clock-resume t)
3154 ("r" "respond" entry (file "~/org/refile.org")
3155 "* TODO Respond to %:from on %:subject\nSCHEDULED: %t\nAdded: %U\n%a\n"
3156 :clock-in t :clock-resume t :immediate-finish t)
3157 ("n" "note" entry (file "~/org/refile.org")
3158 "* %? :NOTE:\nAdded: %U\n%a\n"
3159 :clock-in t :clock-resume t)
3160 ("d" "Delegated" entry (file "~/org/refile.org")
3161 "* DELEGATED %?\nAdded: %U\n%a\n"
3162 :clock-in t :clock-resume t)
3163 ("j" "Journal" entry (file+datetree "~/org/diary.org")
3164 "* %?\nAdded: %U\n"
3165 :clock-in t :clock-resume t)
3166 ("w" "org-protocol" entry (file "~/org/refile.org")
3167 "* TODO Review %c\nAdded: %U\n"
3168 :immediate-finish t)
3169 ("p" "Phone call" entry (file "~/org/refile.org")
3170 "* PHONE %? :PHONE:\nAdded: %U"
3171 :clock-in t :clock-resume t)
3172 ("x" "Bookmark link" entry (file "~/org/refile.org")
3173 "* Bookmark: %c\n%i\nAdded: %U\n"
3174 :immediate-finish t)
3175 ("h" "Habit" entry (file "~/org/refile.org")
3176 "* 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")
3177 )))
3178 #+END_SRC
3179
3180 Capture mode now handles automatically clocking in and out of a
3181 capture task. This all works out of the box now without special hooks.
3182 When I start a capture mode task the task is clocked in as specified
3183 by =:clock-in t= and when the task is filed with =C-c C-c= the clock
3184 resumes on the original clocking task.
3185
3186 The quick clocking in and out of capture mode tasks (often it takes
3187 less than a minute to capture some new task details) can leave
3188 empty clock drawers in my tasks which aren't really useful.
3189 The following prevents this.
3190 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3191 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
3192 #+END_SRC
3193
3194 *** Refiling
3195 All my newly captured entries end up in =refile.org= and want to be
3196 moved over to the right place. The following is the setup for it.
3197 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3198 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
3199 (setq org-refile-targets (quote ((nil :maxlevel . 9)
3200 (org-agenda-files :maxlevel . 9))))
3201
3202 ; Use full outline paths for refile targets - we file directly with IDO
3203 (setq org-refile-use-outline-path t)
3204
3205 ; Targets complete directly with IDO
3206 (setq org-outline-path-complete-in-steps nil)
3207
3208 ; Allow refile to create parent tasks with confirmation
3209 (setq org-refile-allow-creating-parent-nodes (quote confirm))
3210
3211 ; Use IDO for both buffer and file completion and ido-everywhere to t
3212 (setq org-completion-use-ido t)
3213 (setq org-completion-use-iswitchb nil)
3214 :; Use IDO for both buffer and file completion and ido-everywhere to t
3215 ;(setq ido-everywhere t)
3216 ;(setq ido-max-directory-size 100000)
3217 ;(ido-mode (quote both))
3218 ; Use the current window when visiting files and buffers with ido
3219 (setq ido-default-file-method 'selected-window)
3220 (setq ido-default-buffer-method 'selected-window)
3221
3222 ;;;; Refile settings
3223 (setq org-refile-target-verify-function 'bh/verify-refile-target)
3224 #+END_SRC
3225
3226 *** Custom agenda
3227 Agenda view is the central place for org-mode interaction...
3228 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3229 ;; Do not dim blocked tasks
3230 (setq org-agenda-dim-blocked-tasks nil)
3231 ;; Compact the block agenda view
3232 (setq org-agenda-compact-blocks t)
3233
3234 ;; Custom agenda command definitions
3235 (setq org-agenda-custom-commands
3236 (quote (("N" "Notes" tags "NOTE"
3237 ((org-agenda-overriding-header "Notes")
3238 (org-tags-match-list-sublevels t)))
3239 ("h" "Habits" tags-todo "STYLE=\"habit\""
3240 ((org-agenda-overriding-header "Habits")
3241 (org-agenda-sorting-strategy
3242 '(todo-state-down effort-up category-keep))))
3243 (" " "Agenda"
3244 ((agenda "" nil)
3245 (tags "REFILE"
3246 ((org-agenda-overriding-header "Tasks to Refile")
3247 (org-tags-match-list-sublevels nil)))
3248 (tags-todo "-HOLD-CANCELLED/!"
3249 ((org-agenda-overriding-header "Projects")
3250 (org-agenda-skip-function 'bh/skip-non-projects)
3251 (org-agenda-sorting-strategy
3252 '(category-keep))))
3253 (tags-todo "-CANCELLED/!"
3254 ((org-agenda-overriding-header "Stuck Projects")
3255 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3256 (tags-todo "-WAITING-CANCELLED/!NEXT"
3257 ((org-agenda-overriding-header "Next Tasks")
3258 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3259 (org-agenda-todo-ignore-scheduled t)
3260 (org-agenda-todo-ignore-deadlines t)
3261 (org-agenda-todo-ignore-with-date t)
3262 (org-tags-match-list-sublevels t)
3263 (org-agenda-sorting-strategy
3264 '(todo-state-down effort-up category-keep))))
3265 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3266 ((org-agenda-overriding-header "Tasks")
3267 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3268 (org-agenda-todo-ignore-scheduled t)
3269 (org-agenda-todo-ignore-deadlines t)
3270 (org-agenda-todo-ignore-with-date t)
3271 (org-agenda-sorting-strategy
3272 '(category-keep))))
3273 (tags-todo "-CANCELLED+WAITING/!"
3274 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
3275 (org-agenda-skip-function 'bh/skip-stuck-projects)
3276 (org-tags-match-list-sublevels nil)
3277 (org-agenda-todo-ignore-scheduled 'future)
3278 (org-agenda-todo-ignore-deadlines 'future)))
3279 (tags "-REFILE/"
3280 ((org-agenda-overriding-header "Tasks to Archive")
3281 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3282 (org-tags-match-list-sublevels nil))))
3283 nil)
3284 ("r" "Tasks to Refile" tags "REFILE"
3285 ((org-agenda-overriding-header "Tasks to Refile")
3286 (org-tags-match-list-sublevels nil)))
3287 ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
3288 ((org-agenda-overriding-header "Stuck Projects")
3289 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
3290 ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
3291 ((org-agenda-overriding-header "Next Tasks")
3292 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
3293 (org-agenda-todo-ignore-scheduled t)
3294 (org-agenda-todo-ignore-deadlines t)
3295 (org-agenda-todo-ignore-with-date t)
3296 (org-tags-match-list-sublevels t)
3297 (org-agenda-sorting-strategy
3298 '(todo-state-down effort-up category-keep))))
3299 ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
3300 ((org-agenda-overriding-header "Tasks")
3301 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
3302 (org-agenda-sorting-strategy
3303 '(category-keep))))
3304 ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
3305 ((org-agenda-overriding-header "Projects")
3306 (org-agenda-skip-function 'bh/skip-non-projects)
3307 (org-agenda-sorting-strategy
3308 '(category-keep))))
3309 ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
3310 ((org-agenda-overriding-header "Waiting and Postponed tasks"))
3311 (org-tags-match-list-sublevels nil))
3312 ("A" "Tasks to Archive" tags "-REFILE/"
3313 ((org-agenda-overriding-header "Tasks to Archive")
3314 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
3315 (org-tags-match-list-sublevels nil))))))
3316
3317 ; Overwrite the current window with the agenda
3318 (setq org-agenda-window-setup 'current-window)
3319
3320 #+END_SRC
3321
3322 *** Time
3323 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3324 ;;
3325 ;; Resume clocking task when emacs is restarted
3326 (org-clock-persistence-insinuate)
3327 ;;
3328 ;; Show lot sof clocking history so it's easy to pick items off the C-F11 list
3329 (setq org-clock-history-length 36)
3330 ;; Resume clocking task on clock-in if the clock is open
3331 (setq org-clock-in-resume t)
3332 ;; Change tasks to NEXT when clocking in
3333 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
3334 ;; Separate drawers for clocking and logs
3335 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
3336 ;; Save clock data and state changes and notes in the LOGBOOK drawer
3337 (setq org-clock-into-drawer t)
3338 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
3339 (setq org-clock-out-remove-zero-time-clocks t)
3340 ;; Clock out when moving task to a done state
3341 (setq org-clock-out-when-done (quote ("DONE" "WAITING" "DELEGATED" "CANCELLED")))
3342 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
3343 (setq org-clock-persist t)
3344 ;; Do not prompt to resume an active clock
3345 (setq org-clock-persist-query-resume nil)
3346 ;; Enable auto clock resolution for finding open clocks
3347 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
3348 ;; Include current clocking task in clock reports
3349 (setq org-clock-report-include-clocking-task t)
3350
3351 ; use discrete minute intervals (no rounding) increments
3352 (setq org-time-stamp-rounding-minutes (quote (1 1)))
3353
3354 (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
3355
3356 (setq bh/keep-clock-running nil)
3357
3358 (setq org-agenda-clock-consistency-checks
3359 (quote (:max-duration "4:00"
3360 :min-duration 0
3361 :max-gap 0
3362 :gap-ok-around ("4:00"))))
3363
3364 #+END_SRC
3365
3366 **** Setting a default clock task
3367 Per default the =** Organization= task in my tasks.org file receives
3368 misc clock time. This is the task I clock in on when I punch in at the
3369 start of my work day with =F9-I=. Punching-in anywhere clocks in this
3370 Organization task as the default task.
3371
3372 If I want to change the default clocking task I just visit the
3373 new task in any org buffer and clock it in with =C-u C-u C-c C-x
3374 C-i=. Now this new task that collects miscellaneous clock
3375 minutes when the clock would normally stop.
3376
3377 You can quickly clock in the default clocking task with =C-u C-c
3378 C-x C-i d=. Another option is to repeatedly clock out so the
3379 clock moves up the project tree until you clock out the
3380 top-level task and the clock moves to the default task.
3381
3382 **** Reporting
3383 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3384 ;; Agenda clock report parameters
3385 (setq org-agenda-clockreport-parameter-plist
3386 (quote (:link t :maxlevel 5 :fileskip0 t :compact t :narrow 80)))
3387
3388 ;; Agenda log mode items to display (closed and state changes by default)
3389 (setq org-agenda-log-mode-items (quote (closed state)))
3390 #+END_SRC
3391 **** Task estimates, column view
3392 Setup column view globally with the following headlines
3393 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3394 ; Set default column view headings: Task Effort Clock_Summary
3395 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
3396 #+END_SRC
3397 Setup the estimate for effort values.
3398 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3399 ; global Effort estimate values
3400 ; global STYLE property values for completion
3401 (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")
3402 ("STYLE_ALL" . "habit"))))
3403 #+END_SRC
3404
3405 *** Tags
3406 Tags are mostly used for filtering inside the agenda.
3407 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3408 ; Tags with fast selection keys
3409 (setq org-tag-alist (quote ((:startgroup)
3410 ("@errand" . ?e)
3411 ("@office" . ?o)
3412 ("@home" . ?H)
3413 (:endgroup)
3414 ("PHONE" . ?p)
3415 ("WAITING" . ?w)
3416 ("HOLD" . ?h)
3417 ("PERSONAL" . ?P)
3418 ("WORK" . ?W)
3419 ("ORG" . ?O)
3420 ("PRIVATE" . ?N)
3421 ("crypt" . ?E)
3422 ("MARK" . ?M)
3423 ("NOTE" . ?n)
3424 ("CANCELLED" . ?c)
3425 ("FLAGGED" . ??))))
3426
3427 ; Allow setting single tags without the menu
3428 (setq org-fast-tag-selection-single-key (quote expert))
3429
3430 ; For tag searches ignore tasks with scheduled and deadline dates
3431 (setq org-agenda-tags-todo-honor-ignore-options t)
3432 #+END_SRC
3433
3434 *** Archiving
3435 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3436 (setq org-archive-mark-done nil)
3437 (setq org-archive-location "%s_archive::* Archived Tasks")
3438 #+END_SRC
3439
3440 *** org-babel
3441 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3442 (setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
3443 (setq org-plantuml-jar-path "~/java/plantuml.jar")
3444
3445 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
3446
3447 ; Make babel results blocks lowercase
3448 (setq org-babel-results-keyword "results")
3449
3450 (org-babel-do-load-languages
3451 (quote org-babel-load-languages)
3452 (quote ((emacs-lisp . t)
3453 (awk . t)
3454 (css . t)
3455 (makefile . t)
3456 (perl . t)
3457 (ruby . t)
3458 (dot . t)
3459 (ditaa . t)
3460 (R . t)
3461 (python . t)
3462 (ruby . t)
3463 (gnuplot . t)
3464 (clojure . t)
3465 (sh . t)
3466 (ledger . t)
3467 (org . t)
3468 (plantuml . t)
3469 (latex . t))))
3470
3471 ; Do not prompt to confirm evaluation
3472 ; This may be dangerous - make sure you understand the consequences
3473 ; of setting this -- see the docstring for details
3474 (setq org-confirm-babel-evaluate nil)
3475
3476 ; Use fundamental mode when editing plantuml blocks with C-c '
3477 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
3478 #+END_SRC
3479
3480 #+BEGIN_SRC emacs-lisp :tangle yes
3481 ;; Don't have images visible on startup, breaks on console
3482 (setq org-startup-with-inline-images nil)
3483 #+END_SRC
3484
3485 #+BEGIN_SRC emacs-lisp :tangle yes
3486 (add-to-list 'org-structure-template-alist
3487 '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
3488 "<comment>\n?\n</comment>"))
3489 #+END_SRC
3490 **** ditaa, graphviz, etc
3491 Those are all nice tools. Look at
3492 http://doc.norang.ca/org-mode.html#playingwithditaa for a nice intro
3493 to them.
3494
3495 *** Publishing and exporting
3496
3497
3498 Org-mode can export to a variety of publishing formats including (but not limited to)
3499
3500 - ASCII
3501 (plain text - but not the original org-mode file)
3502 - HTML
3503 - LaTeX
3504 - Docbook
3505 which enables getting to lots of other formats like ODF, XML, etc
3506 - PDF
3507 via LaTeX or Docbook
3508 - iCal
3509
3510 A new exporter created by Nicolas Goaziou was introduced in org 8.0.
3511
3512 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3513 ;; Explicitly load required exporters
3514 (require 'ox-html)
3515 (require 'ox-latex)
3516 (require 'ox-ascii)
3517 ;; FIXME, check the following two
3518 ;(require 'ox-icalendar)
3519 ;(require 'ox-odt)
3520
3521 ; experimenting with docbook exports - not finished
3522 (setq org-export-docbook-xsl-fo-proc-command "fop %s %s")
3523 (setq org-export-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
3524
3525 ;; define categories that should be excluded
3526 (setq org-export-exclude-category (list "google" "google"))
3527 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
3528
3529 ; define how the date strings look
3530 (setq org-export-date-timestamp-format "%Y-%m-%d")
3531 ; Inline images in HTML instead of producting links to the image
3532 (setq org-html-inline-images t)
3533 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
3534 (setq org-export-with-sub-superscripts nil)
3535
3536 (setq org-html-head-extra (concat
3537 "<link rel=\"stylesheet\" href=\"http://ganneff.de/stylesheet.css\" type=\"text/css\" />\n"
3538 ))
3539 (setq org-html-head-include-default-style nil)
3540 ; Do not generate internal css formatting for HTML exports
3541 (setq org-export-htmlize-output-type (quote css))
3542 ; Export with LaTeX fragments
3543 (setq org-export-with-LaTeX-fragments t)
3544 ; Increase default number of headings to export
3545 (setq org-export-headline-levels 6)
3546
3547
3548 (setq org-publish-project-alist
3549 '(
3550 ("config-notes"
3551 :base-directory "~/.emacs.d/"
3552 :base-extension "org"
3553 :exclude "elisp"
3554 :publishing-directory "/develop/www/emacs"
3555 :recursive t
3556 :publishing-function org-html-publish-to-html
3557 :headline-levels 4 ; Just the default for this project.
3558 :auto-preamble t
3559 :auto-sitemap t
3560 :makeindex t
3561 )
3562 ("config-static"
3563 :base-directory "~/.emacs.d/"
3564 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
3565 :publishing-directory "/develop/www/emacs"
3566 :exclude "elisp\\|elpa\\|elpa.off\\|auto-save-list\\|cache\\|eshell\\|image-dired\\|themes\\|url"
3567 :recursive t
3568 :publishing-function org-publish-attachment
3569 )
3570 ("inherit-org-info-js"
3571 :base-directory "/develop/vcs/org-info-js/"
3572 :recursive t
3573 :base-extension "js"
3574 :publishing-directory "/develop/www/"
3575 :publishing-function org-publish-attachment
3576 )
3577 ("config" :components ("inherit-org-info-js" "config-notes" "config-static")
3578 )
3579 )
3580 )
3581
3582 (setq org-export-with-timestamps nil)
3583 #+END_SRC
3584
3585 **** Latex export
3586
3587 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3588 (setq org-latex-to-pdf-process
3589 '("xelatex -interaction nonstopmode %f"
3590 "xelatex -interaction nonstopmode %f")) ;; for multiple passes
3591 (setq org-export-latex-listings 'minted)
3592 (setq org-latex-listings t)
3593
3594 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
3595 ;; but adapted to use latexmk 4.20 or higher.
3596 (defun my-auto-tex-cmd ()
3597 "When exporting from .org with latex, automatically run latex,
3598 pdflatex, or xelatex as appropriate, using latexmk."
3599 (let ((texcmd)))
3600 ;; default command: oldstyle latex via dvi
3601 (setq texcmd "latexmk -dvi -pdfps -quiet %f")
3602 ;; pdflatex -> .pdf
3603 (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
3604 (setq texcmd "latexmk -pdf -quiet %f"))
3605 ;; xelatex -> .pdf
3606 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3607 (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
3608 ;; LaTeX compilation command
3609 (setq org-latex-to-pdf-process (list texcmd)))
3610
3611 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
3612
3613 ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
3614 (setq org-export-latex-packages-alist
3615 '(("" "graphicx" t)
3616 ("" "longtable" nil)
3617 ("" "float" nil)
3618 ("" "minted" nil)
3619 ))
3620
3621 (defun my-auto-tex-parameters ()
3622 "Automatically select the tex packages to include."
3623 ;; default packages for ordinary latex or pdflatex export
3624 (setq org-export-latex-default-packages-alist
3625 '(("AUTO" "inputenc" t)
3626 ("T1" "fontenc" t)
3627 ("" "fixltx2e" nil)
3628 ("" "wrapfig" nil)
3629 ("" "soul" t)
3630 ("" "textcomp" t)
3631 ("" "marvosym" t)
3632 ("" "wasysym" t)
3633 ("" "latexsym" t)
3634 ("" "amssymb" t)
3635 ("" "hyperref" nil)))
3636
3637 ;; Packages to include when xelatex is used
3638 (if (string-match "LATEX_CMD: xelatex" (buffer-string))
3639 (setq org-export-latex-default-packages-alist
3640 '(("" "fontspec" t)
3641 ("" "xunicode" t)
3642 ("" "url" t)
3643 ("" "rotating" t)
3644 ("german" "babel" t)
3645 ("babel" "csquotes" t)
3646 ("" "soul" t)
3647 ("xetex" "hyperref" nil)
3648 )))
3649
3650 (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
3651 (setq org-export-latex-classes
3652 (cons '("scrartcl"
3653 "\\documentclass[11pt,DIV=13,oneside]{scrartcl}"
3654 ("\\section{%s}" . "\\section*{%s}")
3655 ("\\subsection{%s}" . "\\subsection*{%s}")
3656 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
3657 ("\\paragraph{%s}" . "\\paragraph*{%s}")
3658 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
3659 org-export-latex-classes))))
3660
3661 (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
3662 #+END_SRC
3663
3664 *** Prevent editing invisible text
3665 The following setting prevents accidentally editing hidden text when
3666 the point is inside a folded region. This can happen if you are in
3667 the body of a heading and globally fold the org-file with =S-TAB=
3668
3669 I find invisible edits (and undo's) hard to deal with so now I can't
3670 edit invisible text. =C-c C-r= (org-reveal) will display where the
3671 point is if it is buried in invisible text to allow editing again.
3672
3673 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3674 (setq org-catch-invisible-edits 'error)
3675 #+END_SRC
3676
3677 *** Whatever
3678 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3679 ;; disable the default org-mode stuck projects agenda view
3680 (setq org-stuck-projects (quote ("" nil nil "")))
3681
3682 ; force showing the next headline.
3683 (setq org-show-entry-below (quote ((default))))
3684
3685 (setq org-show-following-heading t)
3686 (setq org-show-hierarchy-above t)
3687 (setq org-show-siblings (quote ((default))))
3688
3689 (setq org-special-ctrl-a/e t)
3690 (setq org-special-ctrl-k t)
3691 (setq org-yank-adjusted-subtrees t)
3692
3693 (setq org-table-export-default-format "orgtbl-to-csv")
3694
3695 #+END_SRC
3696
3697 The following setting adds alphabetical lists like
3698 ,a. item one
3699 ,b. item two
3700
3701 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3702 (if (> emacs-major-version 23)
3703 (setq org-list-allow-alphabetical t)
3704 (setq org-alphabetical-lists t))
3705 #+END_SRC
3706
3707 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3708 (setq org-remove-highlights-with-change nil)
3709
3710 (setq org-list-demote-modify-bullet (quote (("+" . "-")
3711 ("*" . "-")
3712 ("1." . "-")
3713 ("1)" . "-"))))
3714
3715
3716
3717 (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp 'append)
3718
3719
3720 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
3721 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
3722
3723 #+END_SRC
3724
3725
3726 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3727 ;; Enable abbrev-mode
3728 (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
3729 (setq org-startup-indented t)
3730 (setq org-startup-folded t)
3731 (setq org-cycle-separator-lines 0)
3732 #+END_SRC
3733
3734 I find extra blank lines in lists and headings a bit of a nuisance.
3735 To get a body after a list you need to include a blank line between
3736 the list entry and the body -- and indent the body appropriately.
3737 Most of my lists have no body detail so I like the look of collapsed
3738 lists with no blank lines better.
3739
3740 The following setting prevents creating blank lines before headings
3741 but allows list items to adapt to existing blank lines around the items:
3742 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3743 (setq org-blank-before-new-entry (quote ((heading)
3744 (plain-list-item . auto))))
3745 #+END_SRC
3746
3747 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3748 (setq org-reverse-note-order nil)
3749 (setq org-default-notes-file "~/notes.org")
3750 #+END_SRC
3751
3752 Enforce task blocking. Tasks can't go done when there is any subtask
3753 still open. Unless they have a property of =NOBLOCKING: t=
3754 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3755 (setq org-enforce-todo-checkbox-dependencies t)
3756 (setq org-enforce-todo-dependencies t)
3757 #+END_SRC
3758
3759 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3760 (setq org-fast-tag-selection-single-key (quote expert))
3761 (setq org-footnote-auto-adjust t)
3762 (setq org-hide-block-startup t)
3763 (setq org-icalendar-alarm-time 15)
3764 (setq org-icalendar-combined-description "Ganneffs Org-mode calendar entries")
3765 (setq org-icalendar-combined-name "\"Ganneffs OrgMode\"")
3766 (setq org-icalendar-honor-noexport-tag t)
3767 (setq org-icalendar-include-bbdb-anniversaries nil)
3768 (setq org-icalendar-include-body 200)
3769 (setq org-icalendar-include-todo nil)
3770 (setq org-icalendar-store-UID t)
3771 (setq org-icalendar-timezone "Europe/Berlin")
3772 (setq org-insert-mode-line-in-empty-file t)
3773 (setq org-log-done (quote note))
3774 (setq org-log-into-drawer t)
3775 (setq org-log-state-notes-insert-after-drawers nil)
3776 (setq org-log-reschedule (quote time))
3777 (setq org-log-states-order-reversed t)
3778 (setq org-mobile-agendas (quote all))
3779 (setq org-mobile-directory "/scpx:joerg@garibaldi.ganneff.de:/srv/www2.ganneff.de/htdocs/org/")
3780 (setq org-mobile-inbox-for-pull "~/org/refile.org")
3781 (setq org-remember-store-without-prompt t)
3782 (setq org-return-follows-link t)
3783 (setq org-reverse-note-order t)
3784
3785 ; regularly save our org-mode buffers
3786 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
3787
3788 (setq org-log-done t)
3789
3790 (setq org-enable-priority-commands t)
3791 (setq org-default-priority ?E)
3792 (setq org-lowest-priority ?E)
3793
3794
3795 #+END_SRC
3796
3797 Speed commands enable single-letter commands in Org-mode files when
3798 the point is at the beginning of a headline, or at the beginning of a
3799 code block.
3800
3801 See the `=org-speed-commands-default=' variable for a list of the keys
3802 and commands enabled at the beginning of headlines. All code blocks
3803 are available at the beginning of a code block, the following key
3804 sequence =C-c C-v h= (bound to `=org-babel-describe-bindings=') will
3805 display a list of the code blocks commands and their related keys.
3806
3807 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3808 (setq org-use-speed-commands nil)
3809 (setq org-speed-commands-user (quote (("0" . ignore)
3810 ("1" . ignore)
3811 ("2" . ignore)
3812 ("3" . ignore)
3813 ("4" . ignore)
3814 ("5" . ignore)
3815 ("6" . ignore)
3816 ("7" . ignore)
3817 ("8" . ignore)
3818 ("9" . ignore)
3819
3820 ("a" . ignore)
3821 ("d" . ignore)
3822 ("h" . bh/hide-other)
3823 ("i" progn
3824 (forward-char 1)
3825 (call-interactively 'org-insert-heading-respect-content))
3826 ("k" . org-kill-note-or-show-branches)
3827 ("l" . ignore)
3828 ("m" . ignore)
3829 ("q" . bh/show-org-agenda)
3830 ("r" . ignore)
3831 ("s" . org-save-all-org-buffers)
3832 ("w" . org-refile)
3833 ("x" . ignore)
3834 ("y" . ignore)
3835 ("z" . org-add-note)
3836
3837 ("A" . ignore)
3838 ("B" . ignore)
3839 ("E" . ignore)
3840 ("F" . bh/restrict-to-file-or-follow)
3841 ("G" . ignore)
3842 ("H" . ignore)
3843 ("J" . org-clock-goto)
3844 ("K" . ignore)
3845 ("L" . ignore)
3846 ("M" . ignore)
3847 ("N" . bh/narrow-to-org-subtree)
3848 ("P" . bh/narrow-to-org-project)
3849 ("Q" . ignore)
3850 ("R" . ignore)
3851 ("S" . ignore)
3852 ("T" . bh/org-todo)
3853 ("U" . bh/narrow-up-one-org-level)
3854 ("V" . ignore)
3855 ("W" . bh/widen)
3856 ("X" . ignore)
3857 ("Y" . ignore)
3858 ("Z" . ignore))))
3859
3860 (add-hook 'org-agenda-mode-hook
3861 (lambda ()
3862 (define-key org-agenda-mode-map "q" 'bury-buffer))
3863 'append)
3864
3865 (defvar bh/current-view-project nil)
3866 (add-hook 'org-agenda-mode-hook
3867 '(lambda () (org-defkey org-agenda-mode-map "V" 'bh/view-next-project))
3868 'append)
3869 #+END_SRC
3870
3871
3872 The following displays the contents of code blocks in Org-mode files
3873 using the major-mode of the code. It also changes the behavior of
3874 =TAB= to as if it were used in the appropriate major mode. This means
3875 that reading and editing code form inside of your Org-mode files is
3876 much more like reading and editing of code using its major mode.
3877
3878 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3879 (setq org-src-fontify-natively t)
3880 (setq org-src-tab-acts-natively t)
3881 #+END_SRC
3882
3883 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3884 (setq org-src-preserve-indentation nil)
3885 (setq org-edit-src-content-indentation 0)
3886 #+END_SRC
3887
3888
3889 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3890 (setq org-attach-directory "~/org/data/")
3891 #+END_SRC
3892 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3893 (setq org-agenda-sticky t)
3894 #+END_SRC
3895
3896 **** Checklist handling
3897 [2013-05-11 Sat 22:15]
3898
3899 #+BEGIN_SRC emacs-lisp :tangle yes :tangle yes
3900 (require 'org-checklist)
3901 #+END_SRC
3902
3903 ** perl / cperl
3904 I like /cperl-mode/ a bit more than the default /perl-mode/, so set it
3905 up here to be used.
3906 #+BEGIN_SRC emacs-lisp :tangle yes
3907 (use-package cperl-mode
3908 :commands cperl-mode
3909 :idle
3910 (progn
3911 (defalias 'perl-mode 'cperl-mode)
3912 (add-auto-mode 'cperl-mode "\\.\\([pP][Llm]\\|al\\)\\'")
3913 (add-auto-mode 'pod-mode "\\.pod$")
3914 (add-auto-mode 'tt-mode "\\.tt$")
3915 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
3916 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
3917 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
3918 )
3919 :config
3920 (progn
3921 (setq cperl-invalid-face nil
3922 cperl-close-paren-offset -4
3923 cperl-continued-statement-offset 0
3924 cperl-indent-level 4
3925 cperl-indent-parens-as-block t
3926 cperl-hairy t
3927 cperl-electric-keywords t
3928 cperl-electric-lbrace-space t
3929 cperl-electric-parens nil
3930 cperl-highlight-variables-indiscriminately t
3931 cperl-imenu-addback t
3932 cperl-invalid-face (quote underline)
3933 cperl-lazy-help-time 5
3934 cperl-scan-files-regexp "\\.\\([pP][Llm]\\|xs\\|cgi\\)$"
3935 cperl-syntaxify-by-font-lock t
3936 cperl-use-syntax-table-text-property-for-tags t)
3937
3938 ;; And have cperl mode give ElDoc a useful string
3939 (defun my-cperl-eldoc-documentation-function ()
3940 "Return meaningful doc string for `eldoc-mode'."
3941 (car
3942 (let ((cperl-message-on-help-error nil))
3943 (cperl-get-help))))
3944 (add-hook 'cperl-mode-hook
3945 (lambda ()
3946 (set (make-local-variable 'eldoc-documentation-function)
3947 'my-cperl-eldoc-documentation-function)
3948 (eldoc-mode))))
3949 )
3950 #+END_SRC
3951 ** puppet
3952 [2014-05-22 Thu 00:05]
3953 #+BEGIN_SRC emacs-lisp :tangle yes
3954 (use-package puppet-mode
3955 :mode ("\\.pp\\'" . puppet-mode)
3956 :commands puppet-mode
3957 :idle
3958 (progn
3959 (defun my-puppet-mode-hook ()
3960 (setq require-final-newline nil))
3961 (add-hook 'puppet-mode-hook 'my-puppet-mode-hook))
3962 :config
3963 (progn
3964 (use-package puppet-ext
3965 :init
3966 (progn
3967 (bind-key "C-x ?" 'puppet-set-anchor puppet-mode-map)
3968 (bind-key "C-c C-r" 'puppet-create-require puppet-mode-map)))))
3969 #+END_SRC
3970
3971 ** python
3972 Use elpy for the emacs python fun, but dont let it initialize all the
3973 various variables. Elpy author may like them, but I'm not him...
3974 #+BEGIN_SRC emacs-lisp :tangle yes
3975 (use-package elpy
3976 :defer t
3977 :mode ("\.py" . python-mode)
3978 :init
3979 (progn
3980 (safe-load (concat jj-elisp-dir "/elpy/elpy-autoloads.el"))
3981 )
3982 :config
3983 (progn
3984
3985 (use-package nose
3986 :ensure nose
3987 :commands (nosetests-all nosetests-module nosetests-one
3988 nosetests-failed nosetests-pdb-all
3989 nosetests-pdb-module nosetests-pdb-one)
3990 )
3991
3992 (use-package pyvenv
3993 :ensure pyvenv
3994 :commands (pyvenv-activate pyvenv-deactivate pyvenv-mode pyvenv-restart-python)
3995 )
3996
3997 (use-package idomenu
3998 :ensure idomenu
3999 :commands (idomenu)
4000 :defer t)
4001
4002 (use-package highlight-indentation
4003 :ensure t
4004 :commands (highlight-indentation-mode))
4005
4006 (use-package find-file-in-project
4007 :ensure t
4008 :commands (find-file-in-project ffip-project-files ffip ))
4009
4010 (use-package fuzzy
4011 :ensure t)
4012
4013 ;; Local variables in `python-mode'. This is not removed when Elpy
4014 ;; is disabled, which can cause some confusion.
4015 (add-hook 'python-mode-hook 'elpy-initialize-local-variables)
4016
4017 (defun my-python-mode-hook ()
4018 (setq require-final-newline nil)
4019 (setq mode-require-final-newline))
4020 (add-hook 'python-mode-hook 'my-python-mode-hook)
4021
4022 ;; Flymake support using flake8, including warning faces.
4023 (when (and (executable-find "flake8")
4024 (not (executable-find python-check-command)))
4025 (setq python-check-command "flake8"))
4026
4027 ;; `flymake-no-changes-timeout': The original value of 0.5 is too
4028 ;; short for Python code, as that will result in the current line to
4029 ;; be highlighted most of the time, and that's annoying. This value
4030 ;; might be on the long side, but at least it does not, in general,
4031 ;; interfere with normal interaction.
4032 (setq flymake-no-changes-timeout 60)
4033
4034 ;; `flymake-start-syntax-check-on-newline': This should be nil for
4035 ;; Python, as;; most lines with a colon at the end will mean the next
4036 ;; line is always highlighted as error, which is not helpful and
4037 ;; mostly annoying.
4038 (setq flymake-start-syntax-check-on-newline nil)
4039
4040 ;; `ac-auto-show-menu': Short timeout because the menu is great.
4041 (setq ac-auto-show-menu 0.4)
4042
4043 ;; `ac-quick-help-delay': I'd like to show the menu right with the
4044 ;; completions, but this value should be greater than
4045 ;; `ac-auto-show-menu' to show help for the first entry as well.
4046 (setq ac-quick-help-delay 0.5)
4047
4048 ;; `yas-trigger-key': TAB, as is the default, conflicts with the
4049 ;; autocompletion. We also need to tell yasnippet about the new
4050 ;; binding. This is a bad interface to set the trigger key. Stop
4051 ;; doing this.
4052 (let ((old (when (boundp 'yas-trigger-key)
4053 yas-trigger-key)))
4054 (setq yas-trigger-key "C-c C-i")
4055 (when (fboundp 'yas--trigger-key-reload)
4056 (yas--trigger-key-reload old)))
4057
4058 ;; yas-snippet-dirs can be a string for a single directory. Make
4059 ;; sure it's a list in that case so we can add our own entry.
4060 (when (not (listp yas-snippet-dirs))
4061 (setq yas-snippet-dirs (list yas-snippet-dirs)))
4062 (add-to-list 'yas-snippet-dirs
4063 (concat (file-name-directory (locate-library "elpy"))
4064 "snippets/")
4065 t)
4066
4067 ;; Now load yasnippets.
4068 (yas-reload-all)
4069 (elpy-enable t)
4070 (elpy-use-ipython)))
4071
4072 #+END_SRC
4073
4074 Below is old setup
4075 #+BEGIN_SRC emacs-lisp :tangle no
4076 (autoload 'python-mode "python-mode" "Python Mode." t)
4077 (add-auto-mode 'python-mode "\\.py\\'")
4078 (add-auto-mode 'python-mode "\\.py$")
4079 (add-auto-mode 'python-mode "SConstruct\\'")
4080 (add-auto-mode 'python-mode "SConscript\\'")
4081 (add-to-list 'interpreter-mode-alist '("python" . python-mode))
4082
4083 (after 'python-mode
4084 (set-variable 'py-indent-offset 4)
4085 (set-variable 'py-smart-indentation nil)
4086 (set-variable 'indent-tabs-mode nil)
4087 (define-key python-mode-map "\C-m" 'newline-and-indent)
4088 (turn-on-eldoc-mode)
4089 (defun python-auto-fill-comments-only ()
4090 (auto-fill-mode 1)
4091 (set (make-local-variable 'fill-nobreak-predicate)
4092 (lambda ()
4093 (not (python-in-string/comment)))))
4094 (add-hook 'python-mode-hook
4095 (lambda ()
4096 (python-auto-fill-comments-only)))
4097 ;; pymacs
4098 (autoload 'pymacs-apply "pymacs")
4099 (autoload 'pymacs-call "pymacs")
4100 (autoload 'pymacs-eval "pymacs" nil t)
4101 (autoload 'pymacs-exec "pymacs" nil t)
4102 (autoload 'pymacs-load "pymacs" nil t))
4103 #+END_SRC
4104
4105 If an =ipython= executable is on the path, then assume that IPython is
4106 the preferred method python evaluation.
4107 #+BEGIN_SRC emacs-lisp :tangle no
4108 (when (executable-find "ipython")
4109 (require 'ipython)
4110 (setq org-babel-python-mode 'python-mode))
4111
4112 (setq python-shell-interpreter "ipython")
4113 (setq python-shell-interpreter-args "")
4114 (setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
4115 (setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
4116 (setq python-shell-completion-setup-code
4117 "from IPython.core.completerlib import module_completion")
4118 (setq python-shell-completion-module-string-code
4119 "';'.join(module_completion('''%s'''))\n")
4120 (setq python-shell-completion-string-code
4121 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
4122 #+END_SRC
4123 ** rainbow-delimiters
4124 [2013-04-09 Di 23:38]
4125 [[http://www.emacswiki.org/emacs/RainbowDelimiters][EmacsWiki: Rainbow Delimiters]] is a “rainbow parentheses”-like mode
4126 which highlights parens, brackets, and braces according to their
4127 depth. Each successive level is highlighted a different color. This
4128 makes it easy to spot matching delimiters, orient yourself in the code,
4129 and tell which statements are at the same depth.
4130 #+BEGIN_SRC emacs-lisp :tangle yes
4131 (use-package rainbow-delimiters
4132 :ensure rainbow-delimiters
4133 :commands rainbow-delimiters-mode
4134 :init
4135 (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
4136 #+END_SRC
4137 ** rainbow-mode
4138 #+BEGIN_SRC emacs-lisp :tangle yes
4139 (use-package rainbow-mode
4140 :ensure rainbow-mode
4141 :defer t
4142 :diminish rainbow-mode)
4143 #+END_SRC
4144
4145 ** re-builder
4146 Saner regex syntax
4147 #+BEGIN_SRC emacs-lisp :tangle yes
4148 (use-package re-builder
4149 :commands re-builder
4150 :defer t
4151 :config
4152 (setq reb-re-syntax 'string))
4153 #+END_SRC
4154 ** recentf
4155 [2014-05-19 Mo 22:56]
4156 Recentf is a minor mode that builds a list of recently opened
4157 files. This list is is automatically saved across Emacs sessions.
4158 #+BEGIN_SRC emacs-lisp :tangle yes
4159 (use-package recentf
4160 :if (not noninteractive)
4161 :bind ("C-x C-r" . recentf-open-files)
4162 :defer t
4163 :init
4164 (progn
4165 (recentf-mode 1)
4166 (setq recentf-max-menu-items 25)
4167 (setq recentf-save-file (expand-file-name ".recentf" jj-cache-dir))
4168
4169 (defun recentf-add-dired-directory ()
4170 (if (and dired-directory
4171 (file-directory-p dired-directory)
4172 (not (string= "/" dired-directory)))
4173 (let ((last-idx (1- (length dired-directory))))
4174 (recentf-add-file
4175 (if (= ?/ (aref dired-directory last-idx))
4176 (substring dired-directory 0 last-idx)
4177 dired-directory)))))
4178
4179 (add-hook 'dired-mode-hook 'recentf-add-dired-directory)))
4180 #+END_SRC
4181 ** Region bindings mode
4182 [2013-05-01 Wed 22:51]
4183 This mode allows to have keybindings that are only alive when the
4184 region is active. Helpful for things that only do any useful action
4185 then, like for example the [[*multiple%20cursors][multiple cursors]] mode I load later.
4186 #+BEGIN_SRC emacs-lisp :tangle yes
4187 (use-package region-bindings-mode
4188 :ensure region-bindings-mode
4189 :init
4190 (region-bindings-mode-enable))
4191 #+END_SRC
4192 ** ruby
4193 [2013-05-22 Wed 22:33]
4194 Programming in ruby...
4195
4196 *** Auto-modes
4197 #+BEGIN_SRC emacs-lisp :tangle yes
4198 (add-auto-mode 'ruby-mode
4199 "Rakefile\\'" "\\.rake\\'" "\.rxml\\'"
4200 "\\.rjs\\'" ".irbrc\\'" "\.builder\\'" "\\.ru\\'"
4201 "\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
4202 #+END_SRC
4203
4204 *** Config
4205 #+BEGIN_SRC emacs-lisp :tangle yes
4206 (use-package ruby-mode
4207 :mode ("\\.rb\\'" . ruby-mode)
4208 :interpreter ("ruby" . ruby-mode)
4209 :defer t
4210 :config
4211 (progn
4212 (use-package yari
4213 :init
4214 (progn
4215 (defvar yari-helm-source-ri-pages
4216 '((name . "RI documentation")
4217 (candidates . (lambda () (yari-ruby-obarray)))
4218 (action ("Show with Yari" . yari))
4219 (candidate-number-limit . 300)
4220 (requires-pattern . 2)
4221 "Source for completing RI documentation."))
4222
4223 (defun helm-yari (&optional rehash)
4224 (interactive (list current-prefix-arg))
4225 (when current-prefix-arg (yari-ruby-obarray rehash))
4226 (helm 'yari-helm-source-ri-pages (yari-symbol-at-point)))))
4227
4228 (defun my-ruby-smart-return ()
4229 (interactive)
4230 (when (memq (char-after) '(?\| ?\" ?\'))
4231 (forward-char))
4232 (call-interactively 'newline-and-indent))
4233
4234 (use-package ruby-hash-syntax
4235 :ensure ruby-hash-syntax)
4236
4237 (use-package inf-ruby
4238 :ensure inf-ruby
4239 :commands inf-ruby-minor-mode
4240 :init
4241 (progn
4242 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)
4243 (bind-key "<return>" 'my-ruby-smart-return ruby-mode-map)
4244 ;(bind-key "<tab>" 'indent-for-tab-command ruby-mode-map)
4245
4246
4247 (set (make-local-variable 'yas-fallback-behavior)
4248 '(apply ruby-indent-command . nil))
4249 (bind-key "<tab>" 'yas-expand-from-trigger-key ruby-mode-map)))
4250
4251 ;; Stupidly the non-bundled ruby-mode isn't a derived mode of
4252 ;; prog-mode: we run the latter's hooks anyway in that case.
4253 (add-hook 'ruby-mode-hook
4254 (lambda ()
4255 (unless (derived-mode-p 'prog-mode)
4256 (run-hooks 'prog-mode-hook))))
4257 ))
4258 #+END_SRC
4259 ** sessions :FIXME:
4260 [2013-05-22 Wed 22:40]
4261 Save and restore the desktop
4262 #+BEGIN_SRC emacs-lisp :tangle yes
4263 (setq desktop-path (list jj-cache-dir))
4264 (desktop-save-mode 1)
4265 (defadvice desktop-read (around trace-desktop-errors activate)
4266 (let ((debug-on-error t))
4267 ad-do-it))
4268
4269 ;;----------------------------------------------------------------------------
4270 ;; Restore histories and registers after saving
4271 ;;----------------------------------------------------------------------------
4272 (use-package session
4273 :if (not noninteractive)
4274 :load-path "site-lisp/session/lisp/"
4275 :init
4276 (progn
4277 (setq session-save-file (expand-file-name "session" jj-cache-dir))
4278 (setq desktop-globals-to-save
4279 (append '((extended-command-history . 30)
4280 (file-name-history . 100)
4281 (grep-history . 30)
4282 (compile-history . 30)
4283 (minibuffer-history . 50)
4284 (query-replace-history . 60)
4285 (read-expression-history . 60)
4286 (regexp-history . 60)
4287 (regexp-search-ring . 20)
4288 (search-ring . 20)
4289 (comint-input-ring . 50)
4290 (shell-command-history . 50)
4291 kill-ring
4292 desktop-missing-file-warning
4293 tags-file-name
4294 register-alist)))
4295
4296 (session-initialize)
4297
4298 (defun remove-session-use-package-from-settings ()
4299 (when (string= (file-name-nondirectory (buffer-file-name)) "settings.el")
4300 (save-excursion
4301 (goto-char (point-min))
4302 (when (re-search-forward "^ '(session-use-package " nil t)
4303 (delete-region (line-beginning-position)
4304 (1+ (line-end-position)))))))
4305
4306 (add-hook 'before-save-hook 'remove-session-use-package-from-settings)
4307
4308 ;; expanded folded secitons as required
4309 (defun le::maybe-reveal ()
4310 (when (and (or (memq major-mode '(org-mode outline-mode))
4311 (and (boundp 'outline-minor-mode)
4312 outline-minor-mode))
4313 (outline-invisible-p))
4314 (if (eq major-mode 'org-mode)
4315 (org-reveal)
4316 (show-subtree))))
4317
4318 (add-hook 'session-after-jump-to-last-change-hook
4319 'le::maybe-reveal)
4320
4321 (defun save-information ()
4322 (with-temp-message "Saving Emacs information..."
4323 (recentf-cleanup)
4324
4325 (loop for func in kill-emacs-hook
4326 unless (memq func '(exit-gnus-on-exit server-force-stop))
4327 do (funcall func))
4328
4329 (unless (or noninteractive
4330 (eq 'listen (process-status server-process)))
4331 (server-start))))
4332
4333 (run-with-idle-timer 300 t 'save-information)
4334
4335 (if window-system
4336 (add-hook 'after-init-hook 'session-initialize t))))
4337
4338 #+END_SRC
4339 *** savehist
4340 [2013-04-21 So 20:25]
4341 Save a bit of history
4342 #+BEGIN_SRC emacs-lisp tangle no
4343 (require 'savehist)
4344 (setq savehist-additional-variables
4345 '(search ring regexp-search-ring kill-ring compile-history))
4346 ;; save every minute
4347 (setq savehist-autosave-interval 60)
4348 (setq savehist-file (expand-file-name "savehist" jj-cache-dir))
4349 (savehist-mode +1)
4350 #+END_SRC
4351
4352 *** saveplace
4353 Store at which point I have been in files.
4354 #+BEGIN_SRC emacs-lisp :tangle yes
4355 (setq-default save-place t)
4356 (require 'saveplace)
4357 (setq save-place-file (expand-file-name "saved-places" jj-cache-dir))
4358 #+END_SRC
4359 ** simple-httpd
4360 [2014-06-10 Tue 22:05]
4361 #+BEGIN_SRC emacs-lisp :tangle yes
4362 (use-package simple-httpd
4363 :ensure simple-httpd
4364 :commands (httpd-start httpd-stop)
4365 :config
4366 (progn
4367 (setq httpd-root "/srv/www")
4368 )
4369 )
4370 #+END_SRC
4371 ** sh
4372 Settings for shell scripts
4373 #+BEGIN_SRC emacs-lisp :tangle yes
4374 (use-package sh-script
4375 :defer t
4376 :config
4377 (progn
4378 (defvar sh-script-initialized nil)
4379 (defun initialize-sh-script ()
4380 (unless sh-script-initialized
4381 (setq sh-script-initialized t)
4382 (setq sh-indent-comment t)
4383 (info-lookup-add-help :mode 'shell-script-mode
4384 :regexp ".*"
4385 :doc-spec
4386 '(("(bash)Index")))))
4387
4388 (add-hook 'shell-mode-hook 'initialize-sh-script)))
4389 #+END_SRC
4390 ** sh-toggle
4391 #+BEGIN_SRC emacs-lisp :tangle yes
4392 (use-package sh-toggle
4393 :bind ("C-. C-z" . shell-toggle))
4394 #+END_SRC
4395 ** smartscan
4396 [2015-02-24 Tue 23:35]
4397 Make =M-n= and =M-p= go forward/backword to the symbol at point.
4398 #+BEGIN_SRC emacs-lisp :tangle yes
4399 (use-package smartscan
4400 :ensure smartscan
4401 :defer t
4402 :idle (global-smartscan-mode t))
4403 #+END_SRC
4404 ** timestamp
4405 By default, Emacs can update the time stamp for the following two
4406 formats if one exists in the first 8 lines of the file.
4407 - Time-stamp: <>
4408 - Time-stamp: " "
4409 #+BEGIN_SRC emacs-lisp :tangle yes
4410 (use-package time-stamp
4411 :commands time-stamp
4412 :idle
4413 (progn
4414 (add-hook 'write-file-hooks 'time-stamp)
4415 (setq time-stamp-active t))
4416 :config
4417 (progn
4418 (setq time-stamp-format "%02H:%02M:%02S (%z) - %02d.%02m.%:y from %u (%U) on %s")
4419 (setq time-stamp-old-format-warn nil)
4420 (setq time-stamp-time-zone nil)))
4421 #+END_SRC
4422
4423 ** tiny-tools
4424 We configure only a bit of the tiny-tools to load when I should need
4425 them. I don't need much actually, but these things are nice to have.
4426
4427 #+BEGIN_SRC emacs-lisp :tangle yes
4428 (autoload 'turn-on-tinyperl-mode "tinyperl" "" t)
4429 (add-hook 'perl-mode-hook 'turn-on-tinyperl-mode)
4430 (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode)
4431
4432 (autoload 'tinycomment-indent-for-comment "tinycomment" "" t)
4433 (autoload 'tinyeat-forward-preserve "tinyeat" "" t)
4434 (autoload 'tinyeat-backward-preserve "tinyeat" "" t)
4435 (autoload 'tinyeat-kill-line-backward "tinyeat" "" t)
4436 #+END_SRC
4437 *** Keyboard changes for tiny-tools
4438 #+BEGIN_SRC emacs-lisp :tangle yes
4439 (bind-key "\M-;" 'tinycomment-indent-for-comment)
4440 (bind-key "ESC C-k" 'tinyeat-kill-line-backward)
4441 (bind-key "ESC d" 'tinyeat-forward-preserve)
4442 (bind-key "<M-backspace>" 'tinyeat-backward-preserve)
4443 (bind-key "<S-backspace>" 'tinyeat-delete-whole-word)
4444 #+END_SRC
4445 ** tramp
4446 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
4447 #+BEGIN_SRC emacs-lisp :tangle yes
4448 (use-package tramp
4449 :defer t
4450 :config
4451 (progn
4452 (setq tramp-persistency-file-name (expand-file-name "tramp" jj-cache-dir))
4453 (setq shell-prompt-pattern "^[^a-zA-Z].*[#$%>] *")
4454 (add-to-list 'tramp-default-method-alist '("\\`localhost\\'" "\\`root\\'" "su"))
4455 (setq tramp-debug-buffer nil)
4456 (setq tramp-default-method "sshx")
4457 (tramp-set-completion-function "ssh"
4458 '((tramp-parse-sconfig "/etc/ssh_config")
4459 (tramp-parse-sconfig "~/.ssh/config")))
4460 (setq tramp-verbose 5)
4461 ))
4462 #+END_SRC
4463
4464 ** transient mark
4465 For some reason I prefer this mode more than the way without. I want to
4466 see the marked region.
4467 #+BEGIN_SRC emacs-lisp :tangle yes
4468 (transient-mark-mode 1)
4469 (make-variable-buffer-local 'transient-mark-mode)
4470 (put 'transient-mark-mode 'permanent-local t)
4471 (setq-default transient-mark-mode t)
4472 #+END_SRC
4473 ** undo-tree
4474 [2013-04-21 So 11:07]
4475 Emacs undo is pretty powerful - but can also be confusing. There are
4476 tons of modes available to change it, even downgrade it to the very
4477 crappy ways one usually knows from other systems which lose
4478 information. undo-tree is different - it helps keeping you sane while
4479 keeping the full power of emacs undo/redo.
4480 #+BEGIN_SRC emacs-lisp :tangle yes
4481 (use-package undo-tree
4482 :ensure undo-tree
4483 :diminish undo-tree-mode
4484 :init
4485 (progn
4486 (global-undo-tree-mode)
4487 (setq undo-tree-visualizer-timestamps t)
4488 (setq undo-tree-visualizer-diff t)
4489 ;; Keep region when undoing in region
4490 (defadvice undo-tree-undo (around keep-region activate)
4491 (if (use-region-p)
4492 (let ((m (set-marker (make-marker) (mark)))
4493 (p (set-marker (make-marker) (point))))
4494 ad-do-it
4495 (goto-char p)
4496 (set-mark m)
4497 (set-marker p nil)
4498 (set-marker m nil))
4499 ad-do-it))))
4500 #+END_SRC
4501 ** uniquify
4502 Always have unique buffernames. See [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html][Uniquify - GNU Emacs Manual]]
4503 #+BEGIN_SRC emacs-lisp :tangle yes
4504 (use-package uniquify
4505 :init
4506 (progn
4507 (setq uniquify-buffer-name-style 'post-forward)
4508 (setq uniquify-after-kill-buffer-p t)
4509 (setq uniquify-ignore-buffers-re "^\\*")))
4510 #+END_SRC
4511
4512 ** url
4513 url contains code to parse and handle URLs - who would have thought? I
4514 set it to send Accept-language header and tell it to not send email,
4515 operating system or location info.
4516 #+BEGIN_SRC emacs-lisp :tangle yes
4517 (setq url-mime-language-string "de,en")
4518 (setq url-privacy-level (quote (email os lastloc)))
4519 #+END_SRC
4520 ** visual-regexp
4521 [2014-06-01 Sun 21:38]
4522 visual-regexp for Emacs is like replace-regexp, but with live visual
4523 feedback directly in the buffer
4524 #+BEGIN_SRC emacs-lisp :tangle yes
4525 (use-package visual-regexp
4526 :ensure visual-regexp
4527 :bind (("C-M-%" . vr/replace)
4528 ("M-%" . vr/query-replace)
4529 ("C-c m" . vr/mc-mark))
4530 :defer t)
4531 #+END_SRC
4532 ** volatile highlights
4533 [2013-04-21 So 20:31]
4534 VolatileHighlights highlights changes to the buffer caused by commands
4535 such as ‘undo’, ‘yank’/’yank-pop’, etc. The highlight disappears at the
4536 next command. The highlighting gives useful visual feedback for what
4537 your operation actually changed in the buffer.
4538 #+BEGIN_SRC emacs-lisp :tangle yes
4539 (use-package volatile-highlights
4540 :ensure volatile-highlights
4541 :idle
4542 (volatile-highlights-mode t)
4543 :diminish volatile-highlights-mode)
4544 #+END_SRC
4545 ** windmove
4546 [2015-02-23 Mon 14:38]
4547 Easily move between splitted windows.
4548 #+BEGIN_SRC emacs-lisp :tangle yes
4549 (use-package windmove
4550 :init
4551 (progn
4552 (windmove-default-keybindings)
4553 ; maybe also:
4554 ;(setq org-replace-disputed-keys t)
4555 ))
4556 #+END_SRC
4557 ** winner mode - undo and redo window configuration
4558 [2015-02-24 Tue 23:11]
4559 =winner-mode= lets you use =C-c <left>= and =C-c <right>= to switch between
4560 window configurations. This is handy when something has popped up a
4561 buffer that you want to look at briefly before returning to whatever
4562 you were working on. When you're done, press =C-c <left>=.
4563 #+BEGIN_SRC emacs-lisp :tangle yes
4564 (use-package winner
4565 :ensure t
4566 :defer t
4567 :idle (winner-mode 1))
4568 #+END_SRC
4569 ** writegood
4570 This highlights some /weaselwords/, a mode to /aid in finding common
4571 writing problems/...
4572 [2013-04-27 Sa 23:29]
4573 #+BEGIN_SRC emacs-lisp :tangle no
4574 (use-package writegood-mode
4575 :ensure writegood-mode
4576 :defer t
4577 :init
4578 (bind-key "C-c g" 'writegood-mode))
4579 #+END_SRC
4580 ** web-mode
4581 [2014-06-01 Sun 22:48]
4582 #+BEGIN_SRC emacs-lisp :tangle yes
4583 (use-package web-mode
4584 :ensure web-mode
4585 :defer t
4586 :mode (("\\.phtml\\'" . web-mode)
4587 ("\\.tpl\\.php\\'" . web-mode)
4588 ("\\.jsp\\'" . web-mode)
4589 ("\\.as[cp]x\\'" . web-mode)
4590 ("\\.erb\\'" . web-mode)
4591 ("\\.mustache\\'" . web-mode)
4592 ("\\.html\\'" . web-mode)
4593 ("\\.css\\'" . web-mode)
4594 ("\\.djhtml\\'" . web-mode))
4595 :init
4596 (progn
4597 (add-hook 'web-mode-hook
4598 (lambda ()
4599 (setq web-mode-markup-indent-offset 2)
4600 (setq web-mode-css-indent-offset 2)
4601 (setq web-mode-code-indent-offset 2)
4602 (setq web-mode-enable-css-colorization t)
4603 (setq web-mode-enable-comment-keywords t)
4604 (setq web-mode-enable-current-element-highlight t))))
4605 :config
4606 (progn
4607 (setq web-mode-enable-current-element-highlight t)
4608 (setq web-mode-ac-sources-alist
4609 '(("css" . (ac-source-css-property))
4610 ("html" . (ac-source-words-in-buffer ac-source-abbrev))))
4611 (use-package impatient-mode
4612 :ensure impatient-mode
4613 :defer t
4614 :commands impatient-mode))
4615 )
4616
4617 #+END_SRC
4618 ** yafolding
4619 Yet another folding extension for the Emacs editor. Unlike many
4620 others, this one works by just using the existing indentation of the
4621 file, so basically works in every halfway structured file.
4622 #+BEGIN_SRC emacs-lisp :tangle yes
4623 (use-package yafolding
4624 :bind (("C-#" . yafolding)
4625 ("C-c C-f" . yafolding-toggle-all-by-current-level))
4626 :commands (yafolding yafolding-toggle-all-by-current-level)
4627 )
4628 #+END_SRC
4629 ** yaml-mode
4630 [2013-04-28 So 01:13]
4631 YAML is a nice format for data, which is both, human and machine
4632 readable/editable without getting a big headache.
4633 #+BEGIN_SRC emacs-lisp :tangle yes
4634 (use-package yaml-mode
4635 :ensure yaml-mode
4636 :mode ("\\.ya?ml\\'" . yaml-mode)
4637 :config
4638 (bind-key "C-m" 'newline-and-indent yaml-mode-map ))
4639 #+END_SRC
4640
4641 ** yasnippet
4642 [2013-04-27 Sa 23:16]
4643 Yasnippet is a template system. Type an abbreviation, expand it into
4644 whatever the snippet holds.
4645 #+BEGIN_SRC emacs-lisp :tangle yes
4646 (setq yas-snippet-dirs (expand-file-name "yasnippet/snippets" jj-elisp-dir))
4647 (use-package yasnippet
4648 :ensure yasnippet
4649 :defer t
4650 :diminish yas-minor-mode
4651 :commands yas-global-mode
4652 :idle
4653 (progn
4654 ;; Integrate hippie-expand with ya-snippet
4655 (add-to-list 'hippie-expand-try-functions-list
4656 'yas-hippie-try-expand)
4657 (yas-global-mode 1)
4658 (setq yas-expand-only-for-last-commands '(self-insert-command))
4659 (bind-key "\t" 'hippie-expand yas-minor-mode-map)
4660 ))
4661 #+END_SRC
4662 * Thats it
4663 And thats it for this file, control passes "back" to [[file:../initjj.org][initjj.org/el]]
4664 which then may load more files.