]> git.donarmstrong.com Git - emacs.git/commitdiff
add org mode integration with emacs
authorDon Armstrong <don@donarmstrong.com>
Fri, 1 Feb 2013 22:04:08 +0000 (14:04 -0800)
committerDon Armstrong <don@donarmstrong.com>
Fri, 1 Feb 2013 22:04:08 +0000 (14:04 -0800)
.emacs

diff --git a/.emacs b/.emacs
index 6ff129a5be7e8c1e0606ad47256606ca2deb91dc..3f3a66f32bc321da167e76d9cccf5df7cf34717f 100644 (file)
--- a/.emacs
+++ b/.emacs
  '(user-mail-address "don@donarmstrong.com")
  '(vc-delete-logbuf-window nil)
  '(vc-follow-symlinks t))
+
+
+;; switch back to the old primary selection method
+(setq x-select-enable-clipboard nil)
+(setq x-select-enable-primary t)
+; (setq mouse-drag-copy-region t)
+
 (fset 'perl-mode 'cperl-mode)
 ;;(load-file "cperl-mode.el")
 (add-to-list 'load-path '"~/lib/emacs_el/")
 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/other")
 ;;(add-to-list 'Tex-style-path '"~/lib/emacs_el/auctex/")
 
-; org mode agenda files
-(setq org-agenda-files (quote ("~/projects/debbugs/notes.org"
-                               "~/projects/notes/notes.org"
-                               "~/projects/origins_of_life/ool.org"
-                               "~/projects/sysadmin/sndservers/sndservers.org"
-                               "~/projects/chaim/chaim.org"
-                               "~/projects/fh/fh.org")))
-
 (setq tinyprocmail--procmail-version "v3.22")
 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install)
 (require 'tinyprocmail)
 (require 'org-google-weather)
 (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
 
+; org mode agenda files
+(setq org-agenda-files
+      (quote ("~/projects/debbugs/notes.org"
+             "~/projects/notes/notes.org"
+             "~/projects/origins_of_life/ool.org"
+             "~/projects/sysadmin/sndservers/sndservers.org"
+             "~/projects/chaim/chaim.org"
+             "~/projects/fh/fh.org")))
+
+(setq org-default-notes-file "~/projects/notes/notes.org")
+(setq org-capture-templates  ;; mail-specific note template, identified by "m"
+      '(("m" "Mail" entry (file+headline "~/projects/notes/refile.org" "Mail")
+         "* %?\n\n  Source: %u, %c\n  %i")
+        ("t" "todo" entry (file "~/projects/notes/refile.org")
+         "* TODO %?\n%U\n%a\n" :clock-in t :clock-resume t)
+        ("r" "respond" entry (file "~/projects/notes/refile.org")
+         "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
+        ("n" "note" entry (file "~/projects/notes/refile.org")
+         "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
+        ("j" "Journal" entry (file+datetree "~/projects/notes/diary.org")
+         "* %?\n%U\n" :clock-in t :clock-resume t)
+        ("w" "org-protocol" entry (file "~/projects/notes/refile.org")
+         "* TODO Review %c\n%U\n" :immediate-finish t)
+        ("p" "Phone call" entry (file "~/projects/notes/refile.org")
+         "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
+        ("h" "Habit" entry (file "~/projects/notes/refile.org")
+         "* 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")
+        )
+      )
+
+;; Remove empty LOGBOOK drawers on clock out
+(defun bh/remove-empty-drawer-on-clock-out ()
+  (interactive)
+  (save-excursion
+    (beginning-of-line 0)
+    (org-remove-empty-drawer-at "LOGBOOK" (point))))
+
+(add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
+
+
+; this is from http://doc.norang.ca/org-mode.html#Capture
+; use C-M-r for org mode capture
+(global-set-key (kbd "C-M-r") 'org-capture)
+
+; Targets include this file and any file contributing to the agenda - up to 9 levels deep
+(setq org-refile-targets (quote ((nil :maxlevel . 9)
+                                 (org-agenda-files :maxlevel . 9))))
+
+; Use full outline paths for refile targets - we file directly with IDO
+(setq org-refile-use-outline-path t)
+
+; Targets complete directly with IDO
+(setq org-outline-path-complete-in-steps nil)
+
+; Allow refile to create parent tasks with confirmation
+(setq org-refile-allow-creating-parent-nodes (quote confirm))
+
+; Use IDO for both buffer and file completion and ido-everywhere to t
+(setq org-completion-use-ido t)
+(setq ido-everywhere t)
+(setq ido-max-directory-size 100000)
+(ido-mode (quote both))
+
+;;;; Refile settings
+; Exclude DONE state tasks from refile targets
+(defun bh/verify-refile-target ()
+  "Exclude todo keywords with a done state from refile targets"
+  (not (member (nth 2 (org-heading-components)) org-done-keywords)))
+
+(setq org-refile-target-verify-function 'bh/verify-refile-target)
+
+;; ensure that emacsclient will show just the note to be edited when invoked
+;; from Mutt, and that it will shut down emacsclient once finished;
+;; fallback to legacy behavior when not invoked via org-protocol.
+(require 'org-protocol)
+(add-hook 'org-capture-mode-hook 'delete-other-windows)
+(setq my-org-protocol-flag nil)
+(defadvice org-capture-finalize (after delete-frame-at-end activate)
+  "Delete frame at remember finalization"
+  (progn (if my-org-protocol-flag (delete-frame))
+         (setq my-org-protocol-flag nil)))
+(defadvice org-capture-kill (after delete-frame-at-end activate)
+  "Delete frame at remember abort"
+  (progn (if my-org-protocol-flag (delete-frame))
+         (setq my-org-protocol-flag nil)))
+(defadvice org-protocol-capture (before set-org-protocol-flag activate)
+  (setq my-org-protocol-flag t))
 
 (global-set-key "\C-xp" 'server-edit)
 
 
 (put 'downcase-region 'disabled nil)
 
+(put 'narrow-to-region 'diabled nil)
+
 ;; The following lines are always needed. Choose your own keys.
 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
 (add-hook 'org-mode-hook 'turn-on-font-lock) ; not needed when global-font-lock-mode is on
 ; use iedit
 (require 'iedit)
 (define-key global-map (kbd "C-;") 'iedit-mode)
+(global-set-key  (kbd "C-;") 'iedit-mode)
 
 (require 'multi-web-mode)
 (setq mweb-default-major-mode 'html-mode)
                   (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
 (multi-web-global-mode 1)
+
+
+; apparently things like to step on C-;, so we'll use a hack from
+; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
+
+(defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
+
+; use iedit everywhere
+(define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
+
+(define-minor-mode my-keys-minor-mode
+  "A minor mode so that my key settings override annoying major modes."
+  t " my-keys" 'my-keys-minor-mode-map)
+
+(my-keys-minor-mode 1)
+(defun my-minibuffer-setup-hook ()
+  (my-keys-minor-mode 0))
+
+(add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
+(defadvice load (after give-my-keybindings-priority)
+  "Try to ensure that my keybindings always have priority."
+  (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
+      (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
+        (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
+        (add-to-list 'minor-mode-map-alist mykeys))))
+(ad-activate 'load)