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