X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=emacs_el%2Fconfiguration%2Forg-mode-configuration.el;h=0af973acbf05482bd1202a46a2c3612f346618f4;hb=9fc89af6c7a27cff07b3c25fa5a29497d799305f;hp=7d2e8cade816c1a9bbb5d000a1c6122ae63b9640;hpb=0c300e09b135c3ca316dc5e56b184d492b4e11cc;p=lib.git diff --git a/emacs_el/configuration/org-mode-configuration.el b/emacs_el/configuration/org-mode-configuration.el index 7d2e8ca..0af973a 100644 --- a/emacs_el/configuration/org-mode-configuration.el +++ b/emacs_el/configuration/org-mode-configuration.el @@ -2,9 +2,13 @@ (require 'reftex) (require 'gnus) +(require 'org) +(require 'org-agenda) +(require 'org-habit) ;; The following lines are always needed. Choose your own keys. (add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode)) -(require 'org) +(eval-when-compile + (require 'cl)) (global-set-key "\C-cl" 'org-store-link) (global-set-key "\C-ca" 'org-agenda) (global-set-key "\C-cb" 'org-iswitchb) @@ -91,7 +95,7 @@ ; org mode agenda files (setq org-agenda-files - (quote ("~/projects/debbugs/debbugs.org" + (quote ("~/projects/org-notes/debbugs.org" "~/projects/org-notes/notes.org" "~/projects/org-notes/refile.org" "~/projects/org-notes/diary.org" @@ -100,7 +104,9 @@ "~/projects/org-notes/chaim.org" "~/projects/org-notes/wildman.org" "~/projects/org-notes/uddin.org" - "~/projects/reviews/reviews.org" + "~/projects/org-notes/reviews.org" + "~/projects/org-notes/hpcbio.org" + "~/org-mode/from-mobile.org" "~/projects/org-notes/fh.org"))) (set-register ?n (cons 'file "~/projects/org-notes/notes.org")) @@ -116,30 +122,42 @@ (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"))) (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS") +;; add automatic reminders for appointments +(defadvice org-agenda-redo (after org-agenda-redo-add-appts) + "Pressing `r' on the agenda will also add appointments." + (progn + (setq appt-time-msg-list nil) + (org-agenda-to-appt))) + (setq org-default-notes-file "~/projects/org-notes/notes.org") +(setq org-id-link-to-org-use-id t) (setq org-capture-templates ;; mail-specific note template, identified by "m" '(("m" "Mail" entry (file+headline "~/projects/org-notes/refile.org" "Mail") "* %?\n\n Source: %u, %c\n %i") ("t" "todo" entry (file "~/projects/org-notes/refile.org") - "* TODO %?\n%U\n%a\n" :clock-in t :clock-resume t) + "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t) ("r" "respond" entry (file "~/projects/org-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/org-notes/refile.org") "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t) ("s" "schedule" entry (file "~/projects/org-notes/refile.org") - "* %? \n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t) + "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t) ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org") "* %?\n%U\n" :clock-in t :clock-resume t) ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org") "* TODO Review %c\n%U\n" :immediate-finish t) ("M" "Meeting" entry (file "~/projects/org-notes/refile.org") "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t) + ("S" "Seminar" entry (file "~/projects/org-notes/refile.org") + "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t) + ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile") + "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t) ("p" "Phone call" entry (file "~/projects/org-notes/refile.org") "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t) ("J" "job" entry (file "~/projects/org-notes/refile.org") - "* TODO Apply for %a%? :job:\nSCHEDULED: %(format-time-string \"<%Y-%m-%d %a 17:00-17:30>\")\n%U\n" :clock-in t :clock-resume t) + "* TODO Apply for %a%? :job:\nSCHEDULED: %(format-time-string \"<%Y-%m-%d 17:00-17:30>\")\n%U\n%a\n" :clock-in t :clock-resume t) ("h" "Habit" entry (file "~/projects/org-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") + "* NEXT %?\n%U\n%a\nSCHEDULED: %(format-time-string \"<%Y-%m-%d .+1d/3d>\")\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n%a\n") ) ) @@ -148,7 +166,7 @@ (interactive) (save-excursion (beginning-of-line 0) - (org-remove-empty-drawer-at "LOGBOOK" (point)))) + (org-remove-empty-drawer-at (point)))) (defun my/org-add-id () (interactive) @@ -178,9 +196,9 @@ ; change the outline mode prefix from C-c @ to C-c C-2 (setq outline-minor-mode-prefix "C-c C-2") -(add-hook 'outline-minor-mode-hook - (lambda () (local-set-key (kbd "C-c C-2") - outline-mode-prefix-map))) +;(add-hook 'outline-minor-mode-hook +; (lambda () (local-set-key (kbd "C-c C-2") +; outline-mode-prefix-map))) (global-set-key (kbd " I") 'bh/punch-in) (global-set-key (kbd " O") 'bh/punch-out) @@ -260,7 +278,7 @@ -(add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append) +; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append) ; add ids on creation of nodes (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id) ; create function to create headlines in file. This comes from @@ -321,7 +339,7 @@ do not already have one." ;; 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) +; (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" @@ -398,7 +416,7 @@ Maildir, or by Message-ID." "Open a paper pdf by bibtex key" (interactive "bibtex key: ") (shell-command - (format "%s -p evince %s" + (format "%s -p evince_annot %s" (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey))) (org-add-link-type "papers-pdf" 'open-research-paper-pdf) @@ -408,8 +426,12 @@ Maildir, or by Message-ID." ; I pretty much always want hiearchical checkboxes (setq org-hierachical-checkbox-statistics nil) - -;; stolen from + +;; Add \begin{equation}\end{equation} templates to the org mode easy templates +(add-to-list 'org-structure-template-alist + '("E" "\\begin{equation}\n?\n\\end{equation}")) + + ;; stolen from ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/ (defun my-rtcite-export-handler (path desc format) (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format) @@ -427,7 +449,9 @@ Maildir, or by Message-ID." 'my-rtcite-export-handler) -(setq-default org-mobile-directory "/rzlab.ucr.edu:/sites/dav.donarmstrong.com/root/org/") +(setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/") +(when (string= system-name "linnode.donarmstrong.com") + (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/")) (setq-default org-directory "/home/don/org-mode/") (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org") @@ -444,14 +468,22 @@ Maildir, or by Message-ID." (R . t) (latex . t) (ditaa . t) + (dot . t) )) +;; use graphviz-dot for dot things +(add-to-list 'org-src-lang-modes '("dot" . graphviz-dot)) ;; org-babel-by-backend (defmacro org-babel-by-backend (&rest body) `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body)) +(defun my/fix-inline-images () + (when org-inline-image-overlays + (org-redisplay-inline-images))) +(add-hook 'org-babel-after-execute-hook + 'my/fix-inline-images) ;; ;; org latex ;; ;; stolen from http://kieranhealy.org/esk/kjhealy.html @@ -520,13 +552,41 @@ Maildir, or by Message-ID." ("\\paragraph{%s}" . "\\paragraph*{%s}") ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) +(add-to-list 'org-latex-classes + '("dlacv" + "\\documentclass{dlacv} +[NO-DEFAULT-PACKAGES] +[NO-PACKAGES] +[NO-EXTRA]" + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ("\\paragraph{%s}" . "\\paragraph*{%s}") + ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) + + +(add-to-list 'org-latex-classes + '("dlaresume" + "\\documentclass{dlaresume} +[NO-DEFAULT-PACKAGES] +[NO-PACKAGES] +[NO-EXTRA]" + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ("\\paragraph{%s}" . "\\paragraph*{%s}") + ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) + + ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432 ;; but adapted to use latexmk 4.22 or higher. -(setq org-latex-pdf-process '("latexmk -pdflatex=xelatex -bibtex -use-make -pdf %f")) +(setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f")) ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex (setq org-latex-default-packages-alist - '()) + '(("" "amsmath" t) + ("" "unicode-math" t) + )) (setq org-latex-packages-alist '(("" "graphicx" t) ("" "fontspec" t) @@ -537,6 +597,9 @@ Maildir, or by Message-ID." ("" "longtable" nil) ("" "float" ))) +;; make equations larger +(setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0)) + (defun org-create-formula--latex-header () "Return LaTeX header appropriate for previewing a LaTeX snippet." (let ((info (org-combine-plists (org-export--get-global-options @@ -817,6 +880,7 @@ Skip project and sub-project tasks, habits, and loose non-project tasks." (setq org-clock-in-resume t) ;; Change tasks to NEXT when clocking in (setq org-clock-in-switch-to-state 'bh/clock-in-to-next) +;; (setq org-clock-in-switch-to-state "NEXT") ;; Separate drawers for clocking and logs (setq org-drawers (quote ("PROPERTIES" "LOGBOOK"))) ;; Save clock data and state changes and notes in the LOGBOOK drawer @@ -835,6 +899,8 @@ Skip project and sub-project tasks, habits, and loose non-project tasks." ;; Include current clocking task in clock reports (setq org-clock-report-include-clocking-task t) +;; the cache seems to be broken +(setq org-element-use-cache nil) (defvar bh/keep-clock-running nil) @@ -928,7 +994,7 @@ as the default task." (not org-clock-resolving-clocks-due-to-idleness)) (bh/clock-in-parent-task))) -(add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append) +; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append) (require 'org-id) (defun bh/clock-in-task-by-id (id) @@ -955,7 +1021,97 @@ A prefix arg forces clock in of the default task." (org-clock-in nil)))) +(defun org-export-to-ods () + (interactive) + (let ((csv-file "data.csv")) + (org-table-export csv-file "orgtbl-to-csv") + (org-odt-convert csv-file "ods" 'open))) + ; allow for zero-width-space to be a break in regexp too -(setcar org-emphasis-regexp-components "​ [:space:] \t('\"{") -(setcar (nthcdr 1 org-emphasis-regexp-components) "​ [:space:]- \t.,:!?;'\")}\\") -(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components) +; (setcar org-emphasis-regexp-components "​ [:space:] \t('\"{") +; (setcar (nthcdr 1 org-emphasis-regexp-components) "​ [:space:]- \t.,:!?;'\")}\\") +; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components) + +;; support inserting screen shots +(defun my/org-insert-screenshot () + "Take a screenshot into a time stamped unique-named file in the +same directory as the org-buffer and insert a link to this file." + (interactive) + (defvar my/org-insert-screenshot/filename) + (setq my/org-insert-screenshot/filename + (read-file-name + "Screenshot to insert: " + nil + (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png") + ) + ) + (call-process "import" nil nil nil my/org-insert-screenshot/filename) + (insert (concat "[[" my/org-insert-screenshot/filename "]]")) + (org-display-inline-images)) + +(defun my/fix-inline-images () + (when org-inline-image-overlays + (org-redisplay-inline-images))) + +(add-hook 'org-babel-after-execute-hook 'my/fix-inline-images) + +;; use xelatex to preview with imagemagick +(add-to-list 'org-preview-latex-process-alist + '(xelateximagemagick + :programs ("xelatex" "convert") + :description "pdf > png" + :message "you need to install xelatex and imagemagick" + :use-xcolor t + :image-input-type "pdf" + :image-output-type "png" + :image-size-adjust (1.0 . 1.0) + :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f") + :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O")) + ) +;; use xelatex by default +(setq org-preview-latex-default-process 'xelateximagemagick) + +; from http://orgmode.org/Changes.html +(defun my/org-repair-property-drawers () + "Fix properties drawers in current buffer. + Ignore non Org buffers." + (interactive) + (when (eq major-mode 'org-mode) + (org-with-wide-buffer + (goto-char (point-min)) + (let ((case-fold-search t) + (inline-re (and (featurep 'org-inlinetask) + (concat (org-inlinetask-outline-regexp) + "END[ \t]*$")))) + (org-map-entries + (lambda () + (unless (and inline-re (org-looking-at-p inline-re)) + (save-excursion + (let ((end (save-excursion (outline-next-heading) (point)))) + (forward-line) + (when (org-looking-at-p org-planning-line-re) (forward-line)) + (when (and (< (point) end) + (not (org-looking-at-p org-property-drawer-re)) + (save-excursion + (and (re-search-forward org-property-drawer-re end t) + (eq (org-element-type + (save-match-data (org-element-at-point))) + 'drawer)))) + (insert (delete-and-extract-region + (match-beginning 0) + (min (1+ (match-end 0)) end))) + (unless (bolp) (insert "\n")))))))))))) + +; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files +(defun org-agenda-timeline-all (&optional arg) + (interactive "P") + (with-temp-buffer + (dolist (org-agenda-file org-agenda-files) + (insert-file-contents org-agenda-file nil) + (end-of-buffer) + (newline)) + (write-file "/tmp/timeline.org") + (org-agenda arg "L"))) +(define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all) + +(provide 'org-mode-configuration)