Skip to content

Latest commit

 

History

History
182 lines (153 loc) · 6.37 KB

org-config.org

File metadata and controls

182 lines (153 loc) · 6.37 KB

Org mode

Define setup functions

Configure org-goto to pick a headline via completion

Extracted from org mode - how to jump directly to an org-headline? - Emacs Stack Exchange.

(defun rp/configure-org-goto()
  "Configure 'org-goto' function to pick a headline via completion."
  (progn
    (setq org-goto-interface 'outline-path-completion)
    (setq org-outline-path-complete-in-steps nil)))

Configure org-mode

(use-package org
  :ensure org-contrib
  :defer t
  :bind (:map global-map
              ("C-c c" . org-capture)
              ("C-c a" . org-agenda)
         :map org-mode-map
              ("C-c l" . org-store-link)
         :map org-agenda-mode-map
              ("C-c l" . org-store-link))
  :config (progn
            (require 'ox-extra)
            (ox-extras-activate '(ignore-headlines))

            (require 'org-habit)
            (add-to-list 'org-modules 'org-habit)
            (setq org-todo-keyword-faces
                  '(("TODO" . (:foreground "GoldenRod" :weight bold))
                    ("STARTED" . (:foreground "SteelBlue" :weight bold))
                    ("READING" . (:foreground "SpringGreen4" :weight bold))
                    ("WAITING" . (:foreground "IndianRed1" :weight bold))
                    ("DONE" . (:foreground "LimeGreen" :weight bold))))
            (setq org-adapt-indentation t)
            (setq org-enforce-todo-checkbox-dependencies t)
            (setq org-enforce-todo-dependencies t)
            ;; leave an empty line before a new heading but not before plain list item
            (setq org-blank-before-new-entry (quote ((heading . t)
                                                     (plain-list-item . nil))))
            ;; C-a, and C-e will move the cursor to the start, and respectively
            ;; end of the heading.
            (setq org-special-ctrl-a/e t)
            (setq org-auto-align-tags t)
            (setq org-default-notes-file "~/org/notes.org")
            (rp/configure-org-goto)))

Enable org-indent-mode in all org buffers

(add-hook 'org-mode-hook 'org-indent-mode)

Enable variable-pitch-mode in all org buffers

(add-hook 'org-mode-hook 'variable-pitch-mode)

Prettify org-mode

Taken from yet another blog post about ricing Emacs.

(custom-theme-set-faces
 'user
 '(org-block ((t (:inherit fixed-pitch))))
 '(org-code ((t (:inherit (shadow fixed-pitch)))))
 '(org-document-info ((t (:foreground "dark orange"))))
 '(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
 '(org-indent ((t (:inherit (org-hide fixed-pitch)))))
 '(org-link ((t (:foreground "royal blue" :underline t))))
 '(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))))
 '(org-property-value ((t (:inherit fixed-pitch))) t)
 '(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch)))))
 '(org-table ((t (:inherit fixed-pitch :foreground "#83a598"))))
 '(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 0.8))))
 '(org-verbatim ((t (:inherit (shadow fixed-pitch))))))

Automatically export to pdf

(defun is-beamer-presentation()
  (save-excursion
    (goto-char (point-min))
    (search-forward-regexp "#\\+latex_class:[[:blank:]]+beamer")))

(defun beamer-export-to-pdf()
  (when (and (equal major-mode 'org-mode)
             (is-beamer-presentation))
    (progn
      (message "Current buffer is beamer presentation. Automatic export will use org-beamer-export-to-pdf.")
      (org-beamer-export-to-pdf t))))

(defun export-to-pdf-async()
  (when (equal major-mode 'org-mode)
    (progn
      (message "Automatic export will use org-latex-export-to-pdf.")
      (org-latex-export-to-pdf t))))

(defun rp/toggle-export-to-pdf-async ()
  (interactive)
  (if (memq 'export-to-pdf-async after-save-hook)
      (progn
        (remove-hook 'after-save-hook 'export-to-pdf-async t)
        (message "Disabled automatic export to pdf for current buffer."))
    (add-hook 'after-save-hook 'export-to-pdf-async t t)
    (message "Enabled automatic export to pdf for current buffer.")))

It seems that org-ref-export-to-pdf does a better job of exporting to PDF than the built-in org-latex-export-to-pdf; however, it’s best to keep them both.

(defun rp/org-ref-export-to-pdf()
  (when (equal major-mode 'org-mode)
    (progn
      (message "Automatic export will use org-ref-export-to-pdf.")
      (org-ref-export-to-pdf))))

(defun rp/toggle-org-ref-export-to-pdf-async ()
  (interactive)
  (if (memq 'rp/org-ref-export-to-pdf after-save-hook)
      (progn
        (remove-hook 'after-save-hook 'rp/org-ref-export-to-pdf t)
        (message "Disabled automatic export to pdf (via org-ref) for current buffer."))
    (add-hook 'after-save-hook 'rp/org-ref-export-to-pdf t t)
    (message "Enabled automatic export to pdf (via org-ref) for current buffer.")))

Automatically export to html

(defun rp/export-to-html-async()
  (when (equal major-mode 'org-mode)
    (org-html-export-to-html t)))

(defun rp/toggle-export-to-html-async()
  (interactive)
  (if (memq 'rp/export-to-html-async after-save-hook)
      (progn
        (remove-hook 'after-save-hook 'rp/export-to-html-async t)
        (message "Disabled automatic export to HTML for current buffer."))
    (progn
      (add-hook 'after-save-hook 'rp/export-to-html-async t t)
      (message "Enabled automatic export to HTML for current buffer."))))

Setup org-bullets

(use-package org-bullets
  :defer t
  :after org
  :hook (org-mode . org-bullets-mode))

Load org-babel languages

(org-babel-do-load-languages
 (quote org-babel-load-languages)
 (quote ((emacs-lisp . t)
         (dot . t)
         (python . t)
         (gnuplot . t)
         (shell . t)
         (org . t)
         (latex . t))))