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