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