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