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