Skip to content

Instantly share code, notes, and snippets.

@darrylhebbes
Created April 29, 2016 20:36
Show Gist options
  • Select an option

  • Save darrylhebbes/015f58e11534938b74ba7efec688e761 to your computer and use it in GitHub Desktop.

Select an option

Save darrylhebbes/015f58e11534938b74ba7efec688e761 to your computer and use it in GitHub Desktop.
Robert Adesam - Emacs init file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Emacs init file by
;;; Robert Adesam, [email protected]
;;; http://www.adesam.se/robert/
;;;
;;; This is my init file for Emacs 22, 23, and 24 on MacOSX, Linux,
;;; and Windows/Cygwin
;;;
;;; TODO: Solaris
;;;
;;; N.B. Alot of this is reused from other Emacs users that have
;;; published their init-files on the Internet. Thank you! :)
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; $Revision:: 578 $: Revision of last commit
;;; $Date:: 2011-06-29 08:46:19 #$: Date of last commit
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Load-path, exec-path, info-path
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; load-path
(setq load-path (cons "~/.emacs.d" load-path))
(if (eq system-type 'darwin)
(setq exec-path
(append
'("/Applications/Firefox3.app/Contents/MacOS"
"/usr/local/bin"
"/opt/local/bin")
exec-path)))
;; I only want my info-pages
(setq Info-default-directory-list (quote ("~/.emacs.d/info"))
Info-directory-list (quote ("~/.emacs.d/info")))
;; Setting PATH... why... my Emacs does not seem to inherit PATH from
;; .MacOSX/environment.plist, ~/.bash_profile, nor /etc/bashrc on my Mac :(
(if (eq system-type 'darwin)
(setenv "PATH" "/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Windows/Cygwin
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs on Windows 7, M-x version output:
;; GNU Emacs 24.0.50.1 (i386-mingw-nt6.1.7600)
;; of 2011-01-17 on 3249CTO
;;
;; N.B. executed
;;
;; setx HOME c:\cygwin\home\robert
;;
;; in cmd.exe to set the HOME environment variable
;; Adding cygwin stuff
(if (eq system-type 'windows-nt)
(progn
(setenv "PATH"
(concat
"c:\\cygwin\\usr\\local\\bin" ";"
"c:\\cygwin\\usr\\bin" ";"
"c:\\cygwin\\bin" ";"
(getenv "PATH")))
(setq exec-path (cons "c:/cygwin/bin/" exec-path))
;; Adding cygwin mounts
(require 'cygwin-mount)
(cygwin-mount-activate)
;; Adding cygwin bash shell
(setq shell-file-name "c:/cygwin/bin/bash")
(setenv "SHELL" shell-file-name)
(setq explicit-shell-file-name shell-file-name)
(setq ediff-shell shell-file-name)
(setq explicit-shell-args '("--login" "-i"))
(setq w32-quote-process-args ?\") ;"
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Load local packages
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; I install quite alot of local Emacs packages,
;; maybe they should be installed elsewhere...
;; in ~/.emacs.d?
(let ((start-dir
(cond
((eq system-type 'windows-nt)
"c:/cygwin/usr/local/share/emacs/site-lisp/site-start.d")
((eq system-type 'darwin)
"/usr/local/share/emacs/site-lisp/site-start.d")
((eq system-type 'gnu/linux)
"/usr/local/share/emacs/site-lisp/site-start.d"))))
(if (file-exists-p start-dir)
(mapc 'load (directory-files start-dir t "\\.el\\'"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Server
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Only on Windows-NT Emacs
(if (eq system-type 'windows-nt)
(server-start))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Environment
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Some things I do not want...
(setq inhibit-startup-echo-area-message "robert"
inhibit-startup-screen t
initial-scratch-message nil)
(menu-bar-mode -1)
(tool-bar-mode -1)
(if window-system
(progn
(set-scroll-bar-mode nil)
(tooltip-mode nil)))
(blink-cursor-mode -1)
(setq vc-handled-backends nil)
;; ...other things I do
(column-number-mode t)
(global-font-lock-mode t)
(transient-mark-mode t)
(setq mark-even-if-inactive t)
(auto-compression-mode t)
(setq display-time-format " %R, %d %b v%V "
display-time-load-average-threshold 1)
(display-time-mode)
(setq read-file-name-completion-ignore-case t)
;; Frames, colours etc
;; TODO: these should be system-name dependent, not system-type
(setq default-frame-alist
(cond
((string= system-name "SKRUTT") ; windows 7 on 10" netbook @home
'((scroll-bar-width . 2)
(foreground-color . "gray15")
(background-color . "antiquewhite1")
(cursor-color . "gray30")
(left-fringe . 5)
(right-fringe . 5)
(width . 98)
(height . 35)
(left . 200)))
((eq system-type 'darwin) ; MacOS X 10.5.x on Mac Mini @work
'((scroll-bar-width . 2)
(foreground-color . "gray15")
(background-color . "antiquewhite1")
(cursor-color . "gray30")
(left-fringe . 3)
(right-fringe . 3)
(width . 141)
(height . 60)
(left . 400)))
((eq system-type 'gnu/linux) ; Mandriva Linux 2010.0 on 14" ThinkPad T60 @work
'((height . 80)
(width . 103)
(left . 2)
(scroll-bar-width . 2)
(left-fringe . 5)
(right-fringe . 5)))))
;; Faces
(if (eq system-type 'gnu/linux)
(custom-set-faces
'(default
((t (:inherit nil
:stipple nil
:background "antiquewhite2"
:foreground "Black"
:inverse-video nil
:box nil
:strike-through nil
:overline nil
:underline nil
:slant normal
:weight normal
:height 90
:width normal
:foundry "unknown"
:family "DejaVu Sans Mono"))))
'(org-column
((t (:inherit default
:background "grey90"
:height 90
:family "DejaVu Sans Mono"))))))
;; This is needed when running Emacs 23, vm-mail otherwise crashes
;; emacs -nw when setting frame name, Fatal Error (10). Reported, see
;; http://debbugs.gnu.org/cgi/bugreport.cgi?bug=4765
(if window-system (set-frame-name
;; everybody loves emacs :)
;; (concat "∀x(person(x)→∃y(emacs(y)∧♥(x,y)))")
;; emacs is loved by everybody :)
(concat "∃x∀y(emacs(x)∧(person(y)→♥(y,x)))")
))
;; Character encoding
(if (eq system-type 'darwin)
(progn
(prefer-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(if (< emacs-major-version 23)
(set-keyboard-coding-system 'utf-8))
(set-clipboard-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)))
(if (or (eq system-type 'gnu/linux)
(eq system-type 'windows-nt))
(progn
(prefer-coding-system 'utf-8-unix)
(load-library "iso-transl")))
(define-coding-system-alias 'utf-8-emacs 'utf-8) ; needed by bbdb...
;; Fullscreen, does not work on my Emacs for Mac... yet...
;; (cond
;; ((eq system-type 'darwin)
;; (defun fullscreen (&optional f)
;; (interactive)
;; (set-frame-parameter f 'fullscreen
;; (if (frame-parameter f 'fullscreen) nil 'fullboth))))
;; ((eq system-type 'gnu/linux)
;; (require 'fullscreen)))
;; (add-hook 'after-make-frame-functions 'fullscreen)
;; Text
(setq sentence-end-double-space nil)
;; Misc
(setq-default tab-width 2 indent-tabs-mode nil)
(setq initial-major-mode (quote org-mode)) ; move to org-mode section?
(setq password-cache-expiry 7200)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Persona
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq user-full-name "Robert Adesam"
user-mail-address "[email protected]")
;; Function for inserting my son's first text
;; written with Emacs. He was only 8 months old
;; when producing this master piece.
;; I am a very proud father! :)
(defun alexanders-first-emacs-text ()
(interactive)
(insert " , ..lölökojjoinnnbhm,mmm,7hij,jj,.ölmetz in y5t
yy8byb89tryb85yb8rn9b4n8b9trbtbbtbjkp
¨pöööj09hu6u b5bitntintin4hghhe"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Calendar/Diary
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq diary-file
(cond
((eq system-type 'windows-nt)
"c:/Users/robert/My Dropbox/gtd/diary")
((eq system-type 'darwin)
"~/gtd/diary")
((eq system-type 'gnu/linux)
"~/gtd/diary")))
(setq calendar-date-style 'iso
diary-show-holidays-flag nil
calendar-week-start-day 1
calendar-mark-diary-entries-flag t)
;; TODO: Fix function calling python-script for syncing with Google
;; calendar
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Printing
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq ps-paper-type 'a4
ps-line-number nil
ps-line-number-step 3
ps-n-up-printing 1
ps-header-lines 0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Global keys
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; When using Emacs version > 22 on darwin
(if (and (> emacs-major-version 22)
(eq system-type 'darwin))
(progn
(setq mac-command-modifier 'meta)
(setq mac-option-modifier nil)))
;; Global keyboard tweaks
(global-set-key [f9] "[")
(global-set-key [f10] "]")
(global-set-key [f11] "{")
(global-set-key [f12] "}")
(global-set-key [f5] 'fullscreen)
(global-set-key "\C-xf" 'find-file) ; i always hit the wrong key-combo
(global-set-key "\C-xm" 'vm-mail)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key "\C-cr" 'org-capture)
(global-set-key "\C-cg" 'ra/gtd)
(global-set-key "\C-cn" 'ra/note)
(global-set-key "\C-cw" 'ra/review)
;; Wheel mouse
(defun up-slightly () (interactive) (scroll-up 5))
(defun down-slightly () (interactive) (scroll-down 5))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Filename extensions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq auto-mode-alist
(append
'(("\\.ale$" . ale-prolog-mode) ;; file.ale loads ale-prolog-mode
("\\.pl$" . prolog-mode) ;; file.pl loads prolog-mode
("\\.dcg$" . prolog-mode) ;; file.dcg loads prolog-mode
("\\.\\(cgi\\|pe?rl\\)" . cperl-mode)
("\\.vm$" . emacs-lisp-mode)
("\\.cl$" . lisp-mode)
("\\.script$" . fst-mode)
("\\.x?html\\...$" . nxhtml-mode)
("environment" . shell-script-mode)
("alias" . shell-script-mode)
("path" . shell-script-mode)
("cshrc.final" . shell-script-mode)
("\\.xml$" . nxml-mode)
("\\.xsl$" . nxml-mode)
("cms\\.it\\.gu\\.se.*\\.txt$" . nxhtml-mumamo-mode)
("www\\.blogger\\.com.*\\.txt$" . nxhtml-mumamo-mode)
("\\.org$" . org-mode)
("\\.org.old$" . org-mode)
("\\.sorg$" . org-mode)
("\\.pho$" . mbrola-mode))
auto-mode-alist))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Email
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; I use VM, please check my .vm file for additional settings.
(setq read-mail-command 'vm)
;; smtp settings
(if (eq system-type 'windows-nt)
(progn
(setq mail-archive-file-name "m:/mail/SENT"
sendmail-program "c:/cygwin/usr/sbin/msmtp.exe"
send-mail-function 'sendmail-send-it
mail-host-address "gu.se"))
(progn
(setq mail-archive-file-name "~/mail/SENT"
send-mail-function 'smtpmail-send-it
message-send-mail-function 'smtpmail-send-it
;; smtp to smtpgw.gu.se
smtpmail-starttls-credentials
'(("smtpgw.gu.se" 587 nil nil))
smtpmail-auth-credentials
'(("smtpgw.gu.se" 587 "USERNAME" nil))
smtpmail-default-smtp-server "smtpgw.gu.se"
smtpmail-smtp-server "smtpgw.gu.se"
smtpmail-smtp-service 587
smtpmail-sendto-domain "gslt.hum.gu.se"
smtpmail-debug-info t)))
(require 'smtpmail)
;; smtp to google via smtpmail
;; (setq smtpmail-starttls-credentials
;; '(("smtp.gmail.com" 587 nil nil))
;; smtpmail-auth-credentials
;; '(("smtp.gmail.com" 587 "USERNAME" nil))
;; smtpmail-default-smtp-server "smtp.gmail.com"
;; smtpmail-smtp-server "smtp.gmail.com"
;; smtpmail-smtp-service 587
;; smtpmail-debug-info t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; GNUS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; should be in ~/.gnus.el? is usenet dying?
(setq gnus-select-method
'(nntp "oravannahka.helsinki.fi"))
(setq gnus-secondary-select-methods
'((nntp "news.gmane.org")))
(setq gnus-posting-styles
'((".*"
(name "Robert Adesam")
(address "[email protected]")
(organization "University of Gothenburg")
(signature-file "~/.signature.gnus")))) ; one less row
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Supercite
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'filladapt)
(autoload 'sc-cite-original "supercite" "Supercite 3.1" t)
(autoload 'sc-submit-bug-report "supercite" "Supercite 3.1" t)
(add-hook 'mail-citation-hook 'sc-cite-original)
(add-hook 'sc-load-hook
(cond
((eq system-type 'darwin)
'sc-setup-filladapt)
((eq system-type 'windows-nt)
'sc-setup-filladapt)
((eq system-type 'gnu/linux)
(lambda ()
(filladapt-mode 1)))))
(setq message-cite-function 'sc-cite-original
news-reply-header-hook nil
sc-citation-leader ""
sc-preferred-attribution-list
'("sc-lastchoice"
"x-attribution"
"sc-consult"
"initials"
"firstname"
"lastname")
sc-electric-references-p t ; allows me to select header n,p,RET
sc-cite-region-limit t ; no default citing to avoid filling
sc-nested-citation-p nil
sc-auto-fill-region-p nil
sc-blank-lines-after-headers nil
sc-attrib-selection-list
'(("sc-from-address" ((".*" . (bbdb/sc-consult-attr (sc-mail-field "sc-from-address"))))))
sc-mail-glom-frame
'((begin (setq sc-mail-headers-start (point)))
("^x-attribution:[ \t]+.*$" (sc-mail-fetch-field t) nil t)
("^\\S +:.*$" (sc-mail-fetch-field) nil t)
("^$" (progn (bbdb/sc-default)
(list 'abort '(step . 0))))
("^[ \t]+" (sc-mail-append-field))
(sc-mail-warn-if-non-rfc822-p (sc-mail-error-in-mail-field))
(end (setq sc-mail-headers-end (point))))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; bbdb
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'bbdb)
(bbdb-initialize 'vm)
(setq bbdb-file
(cond
((eq system-type 'windows-nt)
"c:/cygwin/home/robert/mail/.database.bbdb")
((eq system-type 'darwin)
"~/mail/.database.bbdb")
((eq system-type 'gnu/linux)
"~/mail/.database.bbdb"))
bbdb-readonly-p nil
bbdb-send-mail-style 'vm
bbdb-offer-save 'automatic
bbdb-use-pop-up nil
bbdb-completion-display-record nil
bbdb/mail-auto-create-p 'bbdb-ignore-most-messages-hook
bbdb-change-hook 'bbdb-timestamp-hook
bbdb-auto-notes-alist
'(("Subject" (".*" last-subj 0 t))
("From" ("@filosofi.gu.se" company "University of Gothenburg, Department of Philosopy, Linguistics, and Theory of Science"))
("From" ("@gslt.hum.gu.se" company "University of Gothenburg, Department of Philosopy, Linguistics, and Theory of Science, Swedish National Graduate School of Language Technology"))
("From" ("@flov.gu.se" company "University of Gothenburg, Department of Philosopy, Linguistics, and Theory of Science"))
("From" ("@ling.gu.se" company "University of Gothenburg, Department of Philosopy, Linguistics, and Theory of Science"))
("From" ("@cling.gu.se" company "University of Gothenburg, Educational Programme in Language Technology, Department of Philosopy, Linguistics, and Theory of Science"))
("From" ("@cs.chalmers.se" company "Chalmers University of Technology, Department of Computer Science and Engineering "))
("From" ("@sics.se" company "SICS"))
("From" ("@svenska.gu.se" company "University of Gothenburg, Department of Swedish Language"))
("Organization" (".*" company 0 t)))
bbdb-notice-hook 'bbdb-auto-notes-hook
bbdb-ignore-most-messages-alist
'(("To" . "cl4rande")
("To" . "robert")
("To" . "robert\.andersson")
("To" . "robert\.adesam")
("To" . "ra@c?ling")
("Cc" . "cl4rande")
("Cc" . "ra@c?ling")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NXML and NXHTML
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Use as external editor when
(setq as-external-alist
'(("/itsalltext/.*wiki" as-external-for-wiki)
("www\\.blogger\\.com.*\\.txt" as-external-its-all-text-default)
(as-external-its-all-text-regexp as-external-its-all-text-default))
nxml-slash-auto-complete-flag t)
;; mumamo, like mumin
(add-hook 'nxhtml-mumamo-mode-hook
(lambda ()
(setq nxhtml-validation-header-if-mumamo 1)
;; (nxhtml-validation-header-mode 1)
(rng-validate-mode nil)
(mumamo-post-command)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LaTeX
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq TeX-PDF-mode t
font-latex-title-fontify 'color ; this gets rid of
font-latex-title-fontity 'color ; the large fonts
font-latex-fontify-sectioning 'color ; in sections etc
TeX-output-view-style
(cond
((eq system-type 'darwin)
(quote
(("^pdf$" "." "open -a preview %s.pdf")
("^html?$" "." "open %o"))))
((eq system-type 'windows-nt)
(quote
(("^pdf$" "." "\"C:/Program Files/SumatraPDF/SumatraPDF.exe\" %o")
("^html?$" "." "start %o"))))
((eq system-type 'gnu/linux)
(quote
(("^pdf$" "." "okular %s.pdf")
("^html?$" "." "open %o"))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; GPG
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'epa-setup)
(setq epg-gpg-program "gpg") ; why?
;; hack to setenv GnuPG info in Emacs 23 on Mac,
;; TODO: need alternative solution
;; (setq ra/gpg-agent-info-file "~/.gpg-agent-info")
;; (defun ra/gpg-agent-info-from-file (file)
;; "Reads the GnuPG agent info file and returns a list"
;; (with-temp-buffer
;; (insert-file-contents file)
;; (split-string (buffer-string) "\n" t)))
;; (defun ra/gpg-agent-info (file)
;; "Sets environment variables in the GnuPG agent info file"
;; (mapcar '(lambda (gpg-info-pair)
;; (setenv (nth 0 gpg-info-pair) (nth 1 gpg-info-pair)))
;; (mapcar '(lambda (gpg-info-row)
;; (split-string gpg-info-row "=" t))
;; (ra/gpg-agent-info-from-file file))))
;; (if (and (eq system-type 'darwin)
;; (file-readable-p ra/gpg-agent-info-file))
;; (ra/gpg-agent-info ra/gpg-agent-info-file)
;; )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Mairix Search
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'mairix)
(setq mairix-file-path "~/mail"
mairix-mail-program (quote vm)
mairix-search-file "search")
;; Redefined 20110518
(defun mairix-call-mairix (query file threads)
"Call Mairix with QUERY and output FILE.
If FILE is nil, use default. If THREADS is non-nil, also return
whole threads. Function returns t if messages were found."
(let* ((commandsplit (split-string mairix-command))
(args (cons (car commandsplit)
`(nil ,(get-buffer-create mairix-output-buffer) nil)))
rval)
(with-current-buffer mairix-output-buffer
(erase-buffer))
(when (> (length commandsplit) 1)
(setq args (append args (cdr commandsplit))))
(when threads
(setq args (append args '("-t"))))
(when (stringp query)
(setq query (split-string query)))
(setq mairix-last-search (list (mapconcat 'identity query " ")
file threads))
(when (not file)
(setq file mairix-search-file))
(setq file
(concat
(file-name-as-directory
(expand-file-name
mairix-file-path))
file))
;; Filter to prune away the c:/cygwin part from file added by
;; expand-file-name on Windows-NT Emacs 23.2. See blog post on URL
;; http://robert-adesam.blogspot.com/2011/05/mairix-on-windows-nt-emacs.html
;; for more info.
(if (eq system-type 'windows-nt)
(setq file
(replace-regexp-in-string "^c:/cygwin" "" file)))
(setq rval
(apply 'call-process
(append args (list "-o" file) query)))
(if (zerop rval)
(with-current-buffer mairix-output-buffer
(goto-char (point-min))
(re-search-forward "^Matched.*messages")
(message (match-string 0)))
(if (and (= rval 1)
(with-current-buffer mairix-output-buffer
(goto-char (point-min))
(looking-at "^Matched 0 messages")))
(message "No messages found")
(error "Error running Mairix. See buffer %s for details"
mairix-output-buffer)))
(zerop rval)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Org-mode and remember
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'org-install)
;; functions for special org-files
(defun ra/gtd ()
(interactive)
(find-file
(cond
((eq system-type 'windows-nt)
"c:/Users/robert/My Dropbox/gtd/tasks.org")
((eq system-type 'darwin)
"~/gtd/tasks.org")
((eq system-type 'gnu/linux)
"~/gtd/tasks.org")))
(delete-other-windows))
(defun ra/note ()
(interactive)
(find-file
(cond
((eq system-type 'windows-nt)
"c:/Users/robert/My Dropbox/gtd/notes.org")
((eq system-type 'darwin)
"~/gtd/notes.org")
((eq system-type 'gnu/linux)
"~/gtd/notes.org")))
(delete-other-windows))
(defun ra/review ()
(interactive)
(find-file
(cond
((eq system-type 'windows-nt)
"c:/Users/robert/My Dropbox/gtd/review.org")
((eq system-type 'darwin)
"~/gtd/review.org")
((eq system-type 'gnu/linux)
"~/gtd/review.org")))
(delete-other-windows))
(defun ra/order ()
(interactive)
(find-file "~/Documents/admin/orders.org")
(delete-other-windows))
(defun ra/gtd-inbox ()
(interactive)
(find-file
(cond
((eq system-type 'windows-nt)
"c:/Users/robert/My Dropbox/gtd/inbox.org")
((eq system-type 'darwin)
"~/gtd/inbox.org")
((eq system-type 'gnu/linux)
"~/gtd/inbox.org")))
(delete-other-windows))
;; main org directory
(setq org-directory
(cond
((eq system-type 'windows-nt)
"c:/Users/robert/My Dropbox/gtd")
((eq system-type 'darwin)
"~/gtd")
((eq system-type 'gnu/linux)
"~/gtd")))
;; misc setup
(setq org-modules
'(org-bbdb org-bibtex org-crypt)
;; how to archive
org-archive-location "archive/%s.old::* Archive"
;; logging
org-log-done nil ; using the logbook instead
org-log-into-drawer "LOGBOOK"
org-clock-into-drawer t
;; refiling
org-refile-targets
'(("someday.org" :level . 1)
("inbox.org" :level . 1)
("tasks.org" :level . 1)
("projects.org" :maxlevel . 2))
;; setup todo keywords and efforts
org-todo-keywords
'("TODO(t!)" "NEXT(n!)" "WAITING(w@/!)" "|" "CANCELLED(c@)" "DEFERRED(m@)" "DONE(d!)")
org-effort-property "effort"
org-global-properties
'(("effort_ALL" . "0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 8:00"))
;; global tags
org-tag-alist
'(("@home" . ?h)
("@office" . ?o)
("@phone" . ?p)
("@cms" . ?w)
("@computer" . ?c)
("@errands" . ?e)
("@bvc" . ?b)
("@ltlunch" . ?l)
("@2020" . ?2)
("someday" . ?s)
("@gul" . ?g)
("flov" . ?f))
;; blank lines
org-cycle-separator-lines 2
org-blank-before-new-entry
'((heading)
(plain-list-item))
;; links
org-link-mailto-program '(vm-mail "%a" "%s")
org-email-link-description-format "Email %c: %.50s"
org-link-frame-setup
'((vm . vm-visit-folder)
(gnus . gnus)
(file . find-file-other-window)))
;; agenda setup
(setq org-agenda-files
;; add notes.org?
(cond
((eq system-type 'windows-nt)
(list
"c:/Users/robert/My Dropbox/gtd/inbox.org"
"c:/Users/robert/My Dropbox/gtd/tasks.org"
"c:/Users/robert/My Dropbox/gtd/projects.org"))
((eq system-type 'darwin)
(list
"~/gtd/inbox.org"
"~/gtd/tasks.org"
"~/gtd/projects.org"))
((eq system-type 'gnu/linux)
(list
"~/gtd/inbox.org"
"~/gtd/tasks.org"
"~/gtd/projects.org"))))
(setq org-agenda-include-diary t
org-agenda-include-all-todo t
org-columns-default-format "%60ITEM %TODO %TAGS %6effort(EFFORT){:}"
org-tags-column -90)
;; custom agenda commands
(setq org-agenda-custom-commands
'(("i" "Inbox entries" tags "CATEGORY=\"Stuff\"")))
;; higiligt the cursor row in agenda view
(add-hook 'org-agenda-mode-hook
(lambda ()
(hl-line-mode t)
(local-set-key (kbd "r") 'org-agenda-refile)
(local-set-key (kbd "R") 'org-agenda-redo)))
;; adding shortcuts
(add-hook 'org-mode-hook
(lambda ()
(auto-fill-mode 1)
(local-set-key (kbd "C-c t") 'org-todo)
(local-set-key (kbd "C-c e") 'org-set-effort)
(local-set-key (kbd "C-c i") 'ra/gtd-inbox)
(local-set-key (kbd "C-c C-r") 'org-decrypt-entry)))
;; publish web pages
(require 'org-publish)
(setq org-publish-project-alist
'(("org-web"
:base-directory "~/web"
:base-extension "org"
:publishing-directory "/Volumes/robert/.www"
:recursive t
:publishing-function org-publish-org-to-html
:headline-levels 4
:auto-preamble t)
("org-web-static"
:base-directory "~/web"
:base-extension "css\\|js\\|png\\|jpg\\|jpeg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
:publishing-directory "/Volumes/robert/.www"
:recursive t
:publishing-function org-publish-attachment)
("web" :components ("org-web" "org-web-static"))))
;; latex export
(setq org-export-latex-classes
'(("article"
"\\documentclass{article}
\\usepackage[utf8x]{inputenc}
\\usepackage{graphicx}
\\usepackage{longtable}
\\usepackage{hyperref}
\\usepackage[swedish]{babel}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
;; remember-mode is since org-mode version 7 replaced by org-capture
(setq org-default-notes-file (concat org-directory "/inbox.org"))
(setq org-capture-templates
'(("y" "Task" entry
(file+headline "inbox.org" "Inbox")
"* TODO %^{description} %^g%^{effort}p\n :LOGBOOK:\n - State \"TODO\" from \"\" %U\n :END:\n\n %?%i \n :%a:")
("t" "Task woL" entry
(file+headline "inbox.org" "Inbox")
"* TODO %^{description} %^g%^{effort}p\n :LOGBOOK:\n - State \"TODO\" from \"\" %U\n :END:\n\n %?%i \n")
("s" "Someday" entry
(file+headline "inbox.org" "Inbox")
"* %^{description} :someday:%^g%^{effort}p\n :PROPERTIES:\n :added: %U\n :END:\n\n %?%i \n")))
;; We also want to be able to encrypt subtrees in org-mode, requires
;; the epa-setup package
(require 'org-crypt)
(org-crypt-use-before-save-magic)
(setq org-crypt-key "93A4BE9DEAB7218E")
;; Org-babel
(require 'org-babel-init)
;; Load babel support for Emacs lisp
(require 'org-babel-emacs-lisp)
;; Load helper functions etc
(org-babel-load-library-of-babel)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Org-VM-Mairix
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Add mairix as new link type in org
(org-add-link-type "mairix" 'ra/org-vm-mairix-open)
(add-hook 'org-store-link-functions 'ra/org-vm-store-mairix-link)
;; Store link as mairix search for message ID
;; Most from org-vm-store-link in org-vm.el, stripped and modded
(defun ra/org-vm-store-mairix-link ()
"Store a link to the current VM message as a Mairix search for
its Message ID."
(when
(and (or (eq major-mode 'vm-summary-mode)
(eq major-mode 'vm-presentation-mode))
(save-window-excursion
(vm-select-folder-buffer) buffer-file-name))
(and (eq major-mode 'vm-presentation-mode)
(vm-summarize))
(vm-follow-summary-cursor)
(save-excursion
(vm-select-folder-buffer)
(let* (;; Collect properties
(message (car vm-message-pointer))
(subject (vm-su-subject message))
(from (vm-get-header-contents message "From"))
(to (vm-get-header-contents message "To"))
(message-id (vm-su-message-id message))
(link (org-make-link
"mairix:"
(format "m:%s"
(org-remove-angle-brackets message-id)))))
;; TODO: Store even more properties so
;; org-email-link-description-format could be used in full
(org-store-link-props :from from
:to to
:subject subject
:link link)
(org-add-link-props :description (org-email-link-description))
;; Save mail folder and update the mairix db
(vm-save-folder)
(mairix-update-database) ; Make sure mairix-synchronous-update
; is nil, default, so we do not have
; to wait
;; TODO: Suppress message from
;; mairix-sentinel-mairix-update-finished
link))))
;; Open the mairix link, making use of mairix.el to make the search
;; and display the results
(defun ra/org-vm-mairix-open (msearch)
"Search for messages with mairix, and display them in a VM
folder. This requires a proper mairix.el setup."
(mairix-search msearch t))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SQL-mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq sql-sqlite-program "sqlite3")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; No more debug on error
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq debug-on-error nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Temp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; while working on the mailmove project
(setq auto-mode-alist
(append
'(("\\.gu.se$" . org-mode)
) auto-mode-alist))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment