X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=emacs_el%2Fconfiguration%2Forg-mode-configuration.el;h=835e23123409cd18b11c072cd2ba1081e4ddd3ce;hb=eaf7e11775004ebf863636b3fe8569fbcb8449b2;hp=6ec0bef3e19d4350e0999b62167ac405ee16d4e9;hpb=989835fc62cc79d04d08eea04f52d4653ffc76e6;p=lib.git diff --git a/emacs_el/configuration/org-mode-configuration.el b/emacs_el/configuration/org-mode-configuration.el index 6ec0bef..835e231 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) @@ -102,6 +106,7 @@ "~/projects/org-notes/uddin.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")) @@ -118,17 +123,18 @@ (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS") (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") @@ -142,9 +148,9 @@ ("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") ) ) @@ -183,9 +189,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) @@ -265,7 +271,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 @@ -326,7 +332,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" @@ -403,7 +409,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) @@ -455,14 +461,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 @@ -548,6 +562,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 @@ -828,6 +845,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 @@ -846,6 +864,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) @@ -939,7 +959,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) @@ -966,6 +986,12 @@ 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.,:!?;'\")}\\") @@ -982,10 +1008,47 @@ same directory as the org-buffer and insert a link to this file." "Screenshot to insert: " nil (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png") - nil - nil ) ) (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) + +; 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")))))))))))) + +(provide 'org-mode-configuration)