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