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