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