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