]> git.donarmstrong.com Git - emacs.git/blobdiff - .emacs
Add commands to add ids to org mode buffers
[emacs.git] / .emacs
diff --git a/.emacs b/.emacs
index 8a52710b8efa3e303777d9fdb034146bb5521516..30f236cdb5f5e404fb5d5cc1ba6e7f5d1f0cd943 100644 (file)
--- a/.emacs
+++ b/.emacs
          "* 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)
+        ("s" "schedule" entry (file "~/projects/notes/refile.org")
+         "* %? \n%^{scheduled:}t\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")
     (org-remove-empty-drawer-at "LOGBOOK" (point))))
 
 (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 'org-id-get-create)
+; create function to create headlines in file. This comes from
+; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
+(defun my/org-add-ids-to-headlines-in-file ()
+  "Add ID properties to all headlines in the current file which
+do not already have one."
+  (interactive)
+  (org-map-entries 'org-id-get-create))
+; if we wanted to do this to every buffer, do the following:
+; (add-hook 'org-mode-hook
+;           (lambda ()
+;             (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
 
 
 ; resolve clocks after 10 minutes of idle; use xprintidle
@@ -208,7 +223,7 @@ Message can be specified either by a path pointing inside a
 Maildir, or by Message-ID."
   (interactive "MPath or Message-ID: ")
   (shell-command
-   (format "xterm -e \"%s %s\""
+   (format "faf xterm -e \"%s %s\""
        (substitute-in-file-name "$HOME/bin/mutt_open") message)))
 
 ;; add support for "mutt:ID" links
@@ -581,7 +596,9 @@ Argument DESCRIPTION MIME description."
        (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
 (org-add-link-type "papers" 'open-research-paper)
 
-
+; I pretty much always want hiearchical checkboxes
+(setq org-hierachical-checkbox-statistics nil)
 ;; 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)
@@ -608,6 +625,21 @@ Argument DESCRIPTION MIME description."
 (setq org-icalendar-timezone "America/Los_Angeles")
 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
 (setq org-icalendar-store-UID t)
+
+;; org babel support
+(org-babel-do-load-languages
+ 'org-babel-load-languages
+ '((emacs-lisp . t )
+   (R . t)
+   (latex . t)))
+;; org-babel-by-backend
+(defmacro org-babel-by-backend (&rest body)
+   `(case (if (boundp 'backend) 
+              (org-export-backend-name backend)
+            nil) ,@body))
+
+
+
 ;; org latex
 ;; stolen from http://kieranhealy.org/esk/kjhealy.html
 (require 'org-latex)   
@@ -616,7 +648,7 @@ Argument DESCRIPTION MIME description."
 ;; default listings package instead, use
 ;; (setq org-latex-listings t)
 ;; and change references to "minted" below to "listings"
-(setq org-latex-listings 'minted)
+(setq org-latex-listings 'minted)
 
 ;; default settings for minted code blocks
 (setq org-latex-minted-options
@@ -649,44 +681,47 @@ Argument DESCRIPTION MIME description."
                ("\\subsection{%s}" . "\\subsection*{%s}")
                ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
 
+(add-to-list 'org-latex-classes
+             '("letter"
+               "\\documentclass[11pt]{letter}"
+               ("\\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.  
-(defun my-auto-tex-cmd ()
-  "When exporting from .org with latex, automatically run latex,
-                     pdflatex, or xelatex as appropriate, using latexmk."
-  (let ((texcmd)))
-  ;; default command: pdflatex 
-  (setq texcmd "latexmk -pdflatex='pdflatex -synctex=1 --shell-escape --' -pdf %f")        
-  ;; pdflatex -> .pdf
-  (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
-      (setq texcmd "latexmk -pdflatex='pdflatex -synctex=1 --shell-escape' -pdf %f"))
-  ;; xelatex -> .pdf
-  (if (string-match "LATEX_CMD: xelatex" (buffer-string))
-      (setq texcmd "latexmk -pdflatex='xelatex -syntex=1 --shell-escape' -bibtex -use-make -pdf %f"))
-  ;; LaTeX compilation command
-  (setq org-latex-to-pdf-process (list texcmd)))
-
-(add-hook 'org-latex-after-initial-vars-hook 'my-auto-tex-cmd)
+(setq org-latex-pdf-process '("latexmk -pdflatex=xelatex -bibtex -use-make -pdf %f"))
 
 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
+(setq org-latex-default-packages-alist
+      '())
 (setq org-latex-packages-alist
       '(("" "graphicx" t)
+        ("" "fontspec" t)
+        ("" "xunicode" t)
+        ("" "hyperref" t)
+        ("" "url" t)
+        ("" "rotating" t)
         ("" "longtable" nil)
         ("" "float" )))
 
-;; Custom packages
-(defun my-auto-tex-parameters ()
-  "Automatically select the tex packages to include. See https://github.com/kjhealy/latex-custom-kjh for the support files included here."
-  ;; default packages for ordinary latex or pdflatex export
-  (setq org-latex-default-packages-alist
-        '(("AUTO" "inputenc" t)
-          ("minted,minion" "org-preamble-pdflatex" t)))        
-  ;; Packages to include when xelatex is used
-  (if (string-match "LATEX_CMD: xelatex" (buffer-string))
-      (setq org-latex-default-packages-alist
-            '(("minted" "org-preamble-xelatex" t) ))))
-
-(add-hook 'org-latex-after-initial-vars-hook 'my-auto-tex-parameters)
+(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
+                                  (org-export-get-backend 'latex))
+                                 (org-export--get-inbuffer-options
+                                  (org-export-get-backend 'latex)))))
+    (org-latex-guess-babel-language
+     (org-latex-guess-inputenc
+      (org-splice-latex-header
+       org-format-latex-header
+       org-latex-default-packages-alist
+       nil t
+       (plist-get info :latex-header)))
+     info)))
+
 
 ; support ignoring headers in org mode export to latex
 ; from http://article.gmane.org/gmane.emacs.orgmode/67692