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