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