2 ;; custom-set-variables was added by Custom.
3 ;; If you edit it by hand, you could mess it up, so be careful.
4 ;; Your init file should contain only one such instance.
5 ;; If there is more than one, they won't work right.
6 '(bibtex-user-optional-fields (quote (("annote" "Personal annotation (ignored)") ("abstract" "") ("pmid" "") ("doi" ""))))
7 '(calendar-latitude [33 57 north])
8 '(calendar-longitude [117 24 west])
10 '(confirm-kill-emacs (quote y-or-n-p))
11 '(cperl-lazy-help-time nil)
12 '(debian-changelog-mailing-address "don@debian.org" t)
14 '(display-time-24hr-format t)
15 '(display-time-day-and-date t)
16 '(display-time-mode t)
17 '(font-latex-fontify-script nil)
18 '(font-latex-fontify-sectioning (quote color))
19 '(font-latex-script-display (quote (nil)))
20 '(global-auto-revert-mode t)
21 '(global-font-lock-mode t nil (font-lock))
22 '(global-set-key "\347" t)
24 '(iswitchb-prompt-newbuffer nil)
25 '(log-edit-keep-buffer t)
26 '(mail-user-agent (quote sendmail-user-agent))
27 '(markdown-enable-math t)
28 '(markdown-follow-wiki-link-on-enter nil)
29 '(mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
30 '(post-email-address "don@donarmstrong.com")
31 '(post-kill-quoted-sig nil)
32 '(post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
33 '(post-uses-fill-mode nil)
34 '(ps-footer-font-size (quote (8 . 10)))
35 '(ps-header-font-size (quote (8 . 10)))
36 '(ps-header-title-font-size (quote (10 . 10)))
37 '(ps-line-number-color "blue")
39 '(ps-print-footer-frame nil)
40 '(ps-print-only-one-header t)
41 '(safe-local-variable-values (quote ((auto-save-default) (make-backup-files))))
42 '(sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
44 '(sentence-end-double-space nil)
46 '(tool-bar-mode nil nil (tool-bar))
47 '(user-mail-address "don@donarmstrong.com")
48 '(vc-delete-logbuf-window nil)
49 '(vc-follow-symlinks t))
51 ;; use git before SVN; use CVS earlier, because I have CVS
52 ;; repositories inside of git directories
53 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
55 ;; switch back to the old primary selection method
56 (setq x-select-enable-clipboard nil)
57 (setq x-select-enable-primary t)
58 ; (setq mouse-drag-copy-region t)
60 (fset 'perl-mode 'cperl-mode)
61 ;;(load-file "cperl-mode.el")
62 (add-to-list 'load-path '"~/lib/emacs_el/")
63 ;; this is the tiny-tools module from https://github.com/jaalto/project--emacs-tiny-tools.git
64 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/tiny")
65 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/other")
66 ;;(add-to-list 'Tex-style-path '"~/lib/emacs_el/auctex/")
68 (setq tinyprocmail--procmail-version "v3.22")
69 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install)
70 (require 'tinyprocmail)
78 ;;(require 'emacs-wiki)
82 (require 'google-weather)
83 (require 'org-google-weather)
84 (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
86 ; http://julien.danjou.info/projects/emacs-packages#rainbow-mode
87 ; this colorizes color strings
88 (require 'rainbow-mode)
89 ; add ess to the x major mode
90 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
91 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
93 ; org mode agenda files
94 (setq org-agenda-files
95 (quote ("~/projects/debbugs/debbugs.org"
96 "~/projects/notes/notes.org"
97 "~/projects/origins_of_life/ool.org"
98 "~/projects/sysadmin/sndservers/sndservers.org"
99 "~/projects/chaim/chaim.org"
100 "~/projects/chaim/papers/gwas_paper_2012/gwas_paper.org"
101 "~/projects/reviews/reviews.org"
102 "~/projects/fh/fh.org")))
104 (setq org-global-properties '(("Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00")))
105 (setq org-columns-default-format "%40ITEM(Task) %TAGS %PRIORITY %TODO %13SCHEDULED %13DEADLINE %6Effort{:} %CLOCKSUM")
107 (setq org-default-notes-file "~/projects/notes/notes.org")
108 (setq org-capture-templates ;; mail-specific note template, identified by "m"
109 '(("m" "Mail" entry (file+headline "~/projects/notes/refile.org" "Mail")
110 "* %?\n\n Source: %u, %c\n %i")
111 ("t" "todo" entry (file "~/projects/notes/refile.org")
112 "* TODO %?\n%U\n%a\n" :clock-in t :clock-resume t)
113 ("r" "respond" entry (file "~/projects/notes/refile.org")
114 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
115 ("n" "note" entry (file "~/projects/notes/refile.org")
116 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
117 ("s" "schedule" entry (file "~/projects/notes/refile.org")
118 "* %? \n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
119 ("j" "Journal" entry (file+datetree "~/projects/notes/diary.org")
120 "* %?\n%U\n" :clock-in t :clock-resume t)
121 ("w" "org-protocol" entry (file "~/projects/notes/refile.org")
122 "* TODO Review %c\n%U\n" :immediate-finish t)
123 ("p" "Phone call" entry (file "~/projects/notes/refile.org")
124 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
125 ("h" "Habit" entry (file "~/projects/notes/refile.org")
126 "* NEXT %?\n%U\n%a\nSCHEDULED: %(format-time-string \"<%Y-%m-%d %a .+1d/3d>\")\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n")
130 ;; Remove empty LOGBOOK drawers on clock out
131 (defun bh/remove-empty-drawer-on-clock-out ()
134 (beginning-of-line 0)
135 (org-remove-empty-drawer-at "LOGBOOK" (point))))
137 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
138 ; add ids on creation of nodes
139 (add-hook 'org-capture-prepare-finalize-hook 'org-id-get-create)
140 ; create function to create headlines in file. This comes from
141 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
142 (defun my/org-add-ids-to-headlines-in-file ()
143 "Add ID properties to all headlines in the current file which
144 do not already have one."
146 (org-map-entries 'org-id-get-create))
147 ; if we wanted to do this to every buffer, do the following:
148 ; (add-hook 'org-mode-hook
150 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
153 ; resolve clocks after 10 minutes of idle; use xprintidle
154 (setq org-clock-idle-time 10)
155 (setq org-clock-x11idle-program-name "xprintidle")
157 ; this is from http://doc.norang.ca/org-mode.html#Capture
158 ; use C-M-r for org mode capture
159 (global-set-key (kbd "C-M-r") 'org-capture)
161 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
162 (setq org-refile-targets (quote ((nil :maxlevel . 9)
163 (org-agenda-files :maxlevel . 9))))
165 ; Use full outline paths for refile targets - we file directly with IDO
166 (setq org-refile-use-outline-path t)
168 ; Targets complete directly with IDO
169 (setq org-outline-path-complete-in-steps nil)
171 ; Allow refile to create parent tasks with confirmation
172 (setq org-refile-allow-creating-parent-nodes (quote confirm))
174 ; Use IDO for both buffer and file completion and ido-everywhere to t
175 (setq org-completion-use-ido t)
176 (setq ido-everywhere t)
177 (setq ido-max-directory-size 100000)
178 (ido-mode (quote both))
181 ; Exclude DONE state tasks from refile targets
182 (defun bh/verify-refile-target ()
183 "Exclude todo keywords with a done state from refile targets"
184 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
186 (setq org-refile-target-verify-function 'bh/verify-refile-target)
188 ;; ensure that emacsclient will show just the note to be edited when invoked
189 ;; from Mutt, and that it will shut down emacsclient once finished;
190 ;; fallback to legacy behavior when not invoked via org-protocol.
191 (require 'org-protocol)
192 (add-hook 'org-capture-mode-hook 'delete-other-windows)
193 (setq my-org-protocol-flag nil)
194 (defadvice org-capture-finalize (after delete-frame-at-end activate)
195 "Delete frame at remember finalization"
196 (progn (if my-org-protocol-flag (delete-frame))
197 (setq my-org-protocol-flag nil)))
198 (defadvice org-capture-refile (around delete-frame-after-refile activate)
199 "Delete frame at remember refile"
200 (if my-org-protocol-flag
202 (setq my-org-protocol-flag nil)
207 (defadvice org-capture-kill (after delete-frame-at-end activate)
208 "Delete frame at remember abort"
209 (progn (if my-org-protocol-flag (delete-frame))
210 (setq my-org-protocol-flag nil)))
211 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
212 (setq my-org-protocol-flag t))
216 (add-to-list 'org-modules 'org-habit)
218 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
219 (defun open-mail-in-mutt (message)
220 "Open a mail message in Mutt, using an external terminal.
222 Message can be specified either by a path pointing inside a
223 Maildir, or by Message-ID."
224 (interactive "MPath or Message-ID: ")
226 (format "faf xterm -e \"%s %s\""
227 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
229 ;; add support for "mutt:ID" links
230 (org-add-link-type "mutt" 'open-mail-in-mutt)
233 (global-set-key "\C-xp" 'server-edit)
235 (setq-default auto-mode-alist (cons '("\.wml$" .
236 (lambda () (html-mode) (auto-fill-mode)))
239 ;; Use c-mode for perl .xs files
240 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
241 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
242 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
243 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
244 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
246 ; use markdown mode for mdwn files
247 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
253 (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . message-mode))
254 (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
256 (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . message-mode))
257 (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
258 (defun my-message-mode-settings ()
259 (font-lock-add-keywords nil
260 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
261 (0 'message-multiply-quoted-text-face))
262 ("^[ \t]*>[ \t]*>.*$"
263 (0 'message-double-quoted-text-face))))
264 (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
266 (add-hook 'message-mode-hook 'my-message-mode-settings)
268 (defun my-post-attach-file ()
269 "Prompt for an attachment."
271 (let ((file (read-file-name "Attach file: " nil nil t nil))
272 (description (string-read "Description: ")))
273 (my-header-attach-file file description)))
275 (symbol-function 'my-post-attach-file)
277 (defun my-header-attach-file (file description)
278 "Attach a FILE to the current message (works with Mutt).
279 Argument DESCRIPTION MIME description."
280 (interactive "fAttach file: \nsDescription: ")
281 (when (> (length file) 0)
286 (goto-char (point-min))
287 (search-forward-regexp "^$")
288 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
290 (message (concat "Attached '" file "'."))
291 (setq post-has-attachment t))))))
295 (setq mail-yank-prefix "> ")
297 (global-unset-key "\M-g")
298 (global-set-key "\M-g" 'goto-line)
300 ;;(autoload 'perl-mode "cperl-mode"
301 ;; "alternate mode for editing Perl programs" t)
303 ;; self-insert-command hack.
304 ;; Without this, "if<SP>" expands to
307 ;; which really should be,
312 cperl-auto-newline nil
313 cperl-auto-newline-after-colon nil
314 cperl-continued-statement-offset 4
315 cperl-brace-offset -1
316 cperl-continued-brace-offset 0
317 cperl-label-offset -4
318 cperl-highlight-variables-indiscriminately t
319 cperl-electric-lbrace-space nil
320 cperl-indent-parens-as-block nil
321 cperl-close-paren-offset -1
322 cperl-tab-always-indent t)
323 ;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
327 ;(load-library "php-mode")
329 (setq-default c-indent-level 4)
330 (setq-default c-brace-imaginary-offset 0)
331 (setq-default c-brace-offset -4)
332 (setq-default c-argdecl-indent 4)
333 (setq-default c-label-offset -4)
334 (setq-default c-continued-statement-offset 4)
336 (setq-default indent-tabs-mode nil)
337 (setq-default tab-width 4)
340 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
341 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
342 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
343 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
344 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
346 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
347 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
348 (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
349 (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
350 (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
351 (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
352 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
353 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
354 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
355 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
357 ; use smart quotes by default instead of `` and ''
358 ; taken from http://kieranhealy.org/esk/kjhealy.html
359 (setq TeX-open-quote "“")
360 (setq TeX-close-quote "”")
362 ;; (TeX-add-style-hook
367 ;; (custom-set-variables
368 ;; '(font-latex-user-keyword-classes
371 ;; font-lock-function-name-face 2 (command 1 t))))
374 (require 'font-latex)
375 (setq font-latex-match-reference-keywords
391 ; (setq font-latex-match-warning-keywords
399 (setq-default TeX-parse-self t)
400 (setq-default TeX-auto-save t)
401 (setq-default TeX-master nil)
403 ;; this doesn't seem to work; not currently sure why
404 ; (setq font-latex-user-keyword-classes
405 ; '(("my-warning-commands"
412 ; (:foreground "red" :weight bold :underline (:color foreground-color :style line)))
416 (defun insert-date ()
417 "Insert date at point."
419 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
420 (global-set-key "\C-[d" 'insert-date)
422 (defun unfill-paragraph (arg)
423 "Pull this whole paragraph up onto one line."
425 (let ((fill-column 10000))
426 (fill-paragraph arg))
429 ;(iswitchb-default-keybindings)
431 (column-number-mode t)
432 (setq-default reftex-plug-into-AUCTeX t)
436 (require 'mode-compile)
438 (setq-default reftex-default-bibliography
441 (defadvice server-process-filter (after post-mode-message first activate)
442 "If the buffer is in post mode, overwrite the server-edit
443 message with a post-save-current-buffer-and-exit message."
444 (if (eq major-mode 'post-mode)
446 (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
447 ; This is also needed to see the magic message. Set to a higher
448 ; number if you have a faster computer or read slower than me.
449 '(font-lock-verbose 1000)
450 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
451 ; (add-hook 'server-switch-hook
452 ; (function (lambda()
453 ; (cond ((string-match "Post" mode-name)
455 ; set-buffer-file-coding-system 'utf-8
459 (add-hook 'post-mode-hook
462 ; abbrev mode settings
463 ; load abbreviations from
464 (setq abbrev-file-name
465 "~/.emacs_abbrev_def")
467 ; read the abbrev file if it exists
468 (if (file-exists-p abbrev-file-name)
469 (quietly-read-abbrev-file))
471 ; for now, use abbrev mode everywhere
472 (setq default-abbrev-mode t)
475 (defun insert-function-documentation ()
476 "Insert function documentation"
478 (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
479 (global-set-key "\M-f" 'insert-function-documentation)
481 (eval-after-load "lilypond-mode"
483 (load-library "lyqi-mode")
484 (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
486 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
488 (desktop-load-default)
492 ;; custom-set-faces was added by Custom.
493 ;; If you edit it by hand, you could mess it up, so be careful.
494 ;; Your init file should contain only one such instance.
495 ;; If there is more than one, they won't work right.
496 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
498 (defun ess-change-directory (path)
499 "Set the current working directory to PATH for both *R* and Emacs."
500 (interactive "DDirectory to change to: ")
502 (when (file-exists-p path)
503 (ess-command (concat "setwd(\"" path "\")\n"))
504 ;; use file-name-as-directory to ensure it has trailing /
505 (setq default-directory (file-name-as-directory path))))
507 (put 'upcase-region 'disabled nil)
508 (put 'downcase-region 'disabled nil)
509 (put 'narrow-to-region 'disabled nil)
511 ;; The following lines are always needed. Choose your own keys.
512 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
513 (add-hook 'org-mode-hook 'turn-on-font-lock) ; not needed when global-font-lock-mode is on
514 (global-set-key "\C-cl" 'org-store-link)
515 (global-set-key "\C-ca" 'org-agenda)
516 (global-set-key "\C-cb" 'org-iswitchb)
517 (setq-default org-log-done 'time)
518 (setq-default org-agenda-ndays 5)
521 (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
522 (add-hook 'message-mode-hook 'turn-on-flyspell)
523 (add-hook 'text-mode-hook 'turn-on-flyspell)
524 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
525 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
526 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
527 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
528 (defun turn-on-flyspell ()
529 "Force flyspell-mode on using a positive arg. For use in hooks."
533 ;;; outlining support for ess modes
534 (add-hook 'ess-mode-hook
537 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
538 (defun outline-level ()
539 (cond ((looking-at "^##### ") 1)
540 ((looking-at "^#### ") 2)
541 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
545 ; Outline-minor-mode key map
546 (define-prefix-command 'cm-map nil "Outline-")
548 (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
549 (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
550 (define-key cm-map "o" 'hide-other) ; Hide other branches
551 (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
552 (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
553 (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
555 (define-key cm-map "a" 'show-all) ; Show (expand) everything
556 (define-key cm-map "e" 'show-entry) ; Show this heading's body
557 (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
558 (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
559 (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
561 (define-key cm-map "u" 'outline-up-heading) ; Up
562 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
563 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
564 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
565 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
566 (global-set-key "\M-o" cm-map)
568 (defun my-org-mode-setup ()
569 (load-library "reftex")
570 (and (buffer-file-name)
571 (file-exists-p (buffer-file-name))
574 (reftex-set-cite-format
575 '((?b . "[[bib::%l][%l-bib]]")
576 (?n . "[[note::%l][%l-notes]]")
578 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l paper]]")))
580 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
581 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
582 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
583 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
585 (add-hook 'org-mode-hook 'my-org-mode-setup)
587 (defun org-mode-reftex-search ()
589 (org-open-link-from-string (format "[[notes:%s]]" (reftex-citation t))))
591 (defun open-research-paper (bibtexkey)
592 "Open a paper by bibtex key"
593 (interactive "bibtex key: ")
596 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
597 (org-add-link-type "papers" 'open-research-paper)
599 ; I pretty much always want hiearchical checkboxes
600 (setq org-hierachical-checkbox-statistics nil)
603 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
604 (defun my-rtcite-export-handler (path desc format)
605 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
606 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
607 (match-string 1 path)))
608 (path (substring path 0 (match-beginning 0))))
609 (cond ((eq format 'latex)
611 (equal 0 (search "rtcite:" desc)))
612 (format "\\cite{%s}" search)
613 (format "\\cite[%s]{%s}" desc search))))))
615 (org-add-link-type "rtcite"
617 'my-rtcite-export-handler)
620 (setq-default org-mobile-directory "/rzlab.ucr.edu:/sites/dav.donarmstrong.com/root/org/")
621 (setq-default org-directory "/home/don/org-mode/")
622 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
624 ;; org mode ical export
625 (setq org-icalendar-timezone "America/Los_Angeles")
626 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
627 (setq org-icalendar-store-UID t)
630 (org-babel-do-load-languages
631 'org-babel-load-languages
635 ;; org-babel-by-backend
636 (defmacro org-babel-by-backend (&rest body)
637 `(case (if (boundp 'backend)
638 (org-export-backend-name backend)
644 ;; stolen from http://kieranhealy.org/esk/kjhealy.html
646 ;; Choose either listings or minted for exporting source code blocks.
647 ;; Using minted (as here) requires pygments be installed. To use the
648 ;; default listings package instead, use
649 ;; (setq org-latex-listings t)
650 ;; and change references to "minted" below to "listings"
651 ; (setq org-latex-listings 'minted)
653 ;; default settings for minted code blocks
654 (setq org-latex-minted-options
655 '(;("frame" "single")
656 ("bgcolor" "bg") ; bg will need to be defined in the preamble of your document. It's defined in org-preamble-pdflatex.sty and org-preamble-xelatex.sty below.
657 ("fontsize" "\\small")
659 ;; turn off the default toc behavior; deal with it properly in headers to files.
660 (defun org-latex-no-toc (depth)
662 (format "%% Org-mode is exporting headings to %s levels.\n"
664 (setq org-latex-format-toc-function 'org-latex-no-toc)
667 (add-to-list 'org-latex-classes
669 "\\documentclass[11pt,oneside,article]{memoir}\n"
670 ("\\section{%s}" . "\\section*{%s}")
671 ("\\subsection{%s}" . "\\subsection*{%s}")
672 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
673 ("\\paragraph{%s}" . "\\paragraph*{%s}")
674 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
676 (add-to-list 'org-latex-classes
678 "\\documentclass[11pt,oneside]{memoir}\n"
679 ("\\chapter{%s}" . "\\chapter*{%s}")
680 ("\\section{%s}" . "\\section*{%s}")
681 ("\\subsection{%s}" . "\\subsection*{%s}")
682 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
684 (add-to-list 'org-latex-classes
686 "\\documentclass[11pt]{letter}"
687 ("\\section{%s}" . "\\section*{%s}")
688 ("\\subsection{%s}" . "\\subsection*{%s}")
689 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
690 ("\\paragraph{%s}" . "\\paragraph*{%s}")
691 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
693 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
694 ;; but adapted to use latexmk 4.22 or higher.
695 (setq org-latex-pdf-process '("latexmk -pdflatex=xelatex -bibtex -use-make -pdf %f"))
697 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
698 (setq org-latex-default-packages-alist
700 (setq org-latex-packages-alist
710 (defun org-create-formula--latex-header ()
711 "Return LaTeX header appropriate for previewing a LaTeX snippet."
712 (let ((info (org-combine-plists (org-export--get-global-options
713 (org-export-get-backend 'latex))
714 (org-export--get-inbuffer-options
715 (org-export-get-backend 'latex)))))
716 (org-latex-guess-babel-language
717 (org-latex-guess-inputenc
718 (org-splice-latex-header
719 org-format-latex-header
720 org-latex-default-packages-alist
722 (plist-get info :latex-header)))
726 ; support ignoring headers in org mode export to latex
727 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
728 (defadvice org-latex-headline (around my-latex-skip-headlines
729 (headline contents info) activate)
730 (if (member "ignoreheading" (org-element-property :tags headline))
731 (setq ad-return-value contents)
735 (setq-default debian-changelog-mailing-address "don@debian.org")
736 (setq-default debian-changelog-full-name "Don Armstrong")
738 ; ediff configuration
739 ; don't use the multi-window configuration
740 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
744 (define-key global-map (kbd "C-;") 'iedit-mode)
745 (global-set-key (kbd "C-;") 'iedit-mode)
747 ; fix up css mode to not be silly
748 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
749 (setq cssm-indent-level 4)
750 (setq cssm-newline-before-closing-bracket t)
751 (setq cssm-indent-function #'cssm-c-style-indenter)
752 (setq cssm-mirror-mode nil)
754 (require 'multi-web-mode)
755 (setq mweb-default-major-mode 'html-mode)
756 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
757 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
758 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
759 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
760 (multi-web-global-mode 1)
762 ; clean-mode-line from http://www.masteringemacs.org/articles/2012/09/10/hiding-replacing-modeline-strings/
763 (defvar mode-line-cleaner-alist
764 `((auto-complete-mode . " α")
765 (yas/minor-mode . " υ")
766 (paredit-mode . " π")
769 (my-keys-minor-mode . "")
771 (lisp-interaction-mode . "λ")
776 (org-agenda-mode . "øα")
778 (emacs-lisp-mode . "EL")
779 (nxhtml-mode . "nx"))
780 "Alist for `clean-mode-line'.
782 When you add a new element to the alist, keep in mind that you
783 must pass the correct minor/major mode symbol and a string you
784 want to use in the modeline *in lieu of* the original.")
787 (defun clean-mode-line ()
789 (loop for cleaner in mode-line-cleaner-alist
790 do (let* ((mode (car cleaner))
791 (mode-str (cdr cleaner))
792 (old-mode-str (cdr (assq mode minor-mode-alist))))
794 (setcar old-mode-str mode-str))
796 (when (eq mode major-mode)
797 (setq mode-name mode-str)))))
800 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
802 ;;; alias the new `flymake-report-status-slim' to
803 ;;; `flymake-report-status'
804 (defalias 'flymake-report-status 'flymake-report-status-slim)
805 (defun flymake-report-status-slim (e-w &optional status)
806 "Show \"slim\" flymake status in mode line."
808 (setq flymake-mode-line-e-w e-w))
810 (setq flymake-mode-line-status status))
811 (let* ((mode-line " Φ"))
812 (when (> (length flymake-mode-line-e-w) 0)
813 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
814 (setq mode-line (concat mode-line flymake-mode-line-status))
815 (setq flymake-mode-line mode-line)
816 (force-mode-line-update)))
818 ; load sql-indent when sql is loaded
819 (eval-after-load "sql"
820 '(load-library "sql-indent"))
822 ; fix up tmux xterm keys
823 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
826 (let ((x 2) (tkey ""))
846 ;; ctrl + alt + shift
848 (setq tkey "C-M-S-"))
851 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
852 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
853 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
854 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
856 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
858 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
860 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
862 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
864 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
866 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
868 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
870 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
872 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
874 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
876 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
878 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
880 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
882 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
884 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
886 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
888 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
890 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
892 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
894 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
896 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
898 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
900 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
902 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
904 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
906 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
913 ; apparently things like to step on C-;, so we'll use a hack from
914 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
916 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
918 ; use iedit everywhere
919 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
921 (define-minor-mode my-keys-minor-mode
922 "A minor mode so that my key settings override annoying major modes."
923 t " my-keys" 'my-keys-minor-mode-map)
925 (my-keys-minor-mode 1)
926 (defun my-minibuffer-setup-hook ()
927 (my-keys-minor-mode 0))
929 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
930 (defadvice load (after give-my-keybindings-priority)
931 "Try to ensure that my keybindings always have priority."
932 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
933 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
934 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
935 (add-to-list 'minor-mode-map-alist mykeys))))