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