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