You can find my .emacs configuration file on github. Checkout both the master and python branches.

     ____.     .__  .__            /\                                                 
    |    |__ __|  | |__| ____   ___)/  ______      ____   _____ _____    ____   ______
    |    |  |  \  | |  |/ __ \ /    \ /  ___/    _/ __ \ /     \\__  \ _/ ___\ /  ___/
/\__|    |  |  /  |_|  \  ___/|   |  \\___ \     \  ___/|  Y Y  \/ __ \\  \___ \___ \ 
\________|____/|____/__|\___  >___|  /____  >  /\ \___  >__|_|  (____  /\___  >____  >
                            \/     \/     \/   \/     \/      \/     \/     \/     \/

Emacs initialization as org file. It is a constant work in progress.




In order to have this file be the emacs initialization file, put the following snippet in your ~/.emacs.d/init.el file.

;; optionally remove default org install
;; https://lists.gnu.org/archive/html/emacs-orgmode/2013-09/msg00178.html

(setq load-path
      (delq nil
             (function (lambda (p)
                         (unless (string-match "lisp\\(/packages\\)?/org$" p)

(mapatoms (function
           (lambda (s)
             (let ((sn (symbol-name s)))
               (when (string-match "^\\(org\\|ob\\|ox\\)\\(-.*\\)?$" sn)
                 (setplist s nil)
                 (when (eq 'autoload (car-safe s))
                   (unintern s)))))))

;; if curating org-mode, remember to 'make autoloads'

(add-to-list 'load-path (expand-file-name "~/.emacs.d/git/org-mode/lisp"))

(add-to-list 'load-path
             (expand-file-name "~/.emacs.d/git/org-mode/contrib/lisp"))

;; now tangle in settings.org

(require 'cl)
(require 'ob-tangle)
(org-babel-load-file "~/git/dotemacs/settings.org")

General Settings

Everything in this section are general settings that should not need any non-default packages.

Keep customize settings in their own file

(setq custom-file "~/.emacs.d/git/dotemacs/custom.el")
(when (file-exists-p custom-file)
  (load custom-file))

Let's change to a less horrible color theme. The available default options are adwaita deeper-blue dichromacy leuven light-blue manoj-dark misterioso tango tango-dark tsdh-dark tsdh-light wheatgrass whiteboard wombat

(condition-case nil
    (load-theme 'leuven)
  ('error (message (format "Could not load leuven theme"))))


(defun jc/setup-osx-fonts ()
  (set-fontset-font "fontset-default" 'symbol "Monaco")
  (set-face-attribute 'default nil :height 120)
  (set-face-attribute 'fixed-pitch nil :height 120)
  ;; Anti-aliasing
  (setq mac-allow-anti-aliasing t))

(defun jc/setup-x11-fonts ()
  (set-frame-font "DejaVu Sans Mono")
  (set-face-attribute 'default nil :height 105))

 ((eq system-type 'darwin)
  (add-hook 'after-init-hook #'jc/setup-osx-fonts))
 ((eq window-system 'x)
  (add-hook 'after-init-hook #'jc/setup-x11-fonts))
 ;; default, do nothing
 (t nil))

Deal with additional paths

(defvar my-paths '("/usr/local/bin"))

(dolist (pth my-paths)
  (when (file-directory-p pth)
    (setenv "PATH" (concat (getenv "PATH") ":" (expand-file-name pth)))
    (setq exec-path (split-string (getenv "PATH") path-separator))))

Increase auto-save rate.

(setq auto-save-interval 20) ; twenty keystrokes
(setq auto-save-timeout 10) ; ten idle seconds

Don't need a startup message.

(setq inhibit-startup-message t)


(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-language-environment "UTF-8")
(prefer-coding-system 'utf-8)

y or n instead of yes or no

(fset 'yes-or-no-p 'y-or-n-p)

Turn on syntax highlighting for all buffers

(global-font-lock-mode t)

Turn off irrelevant stuff.

(if (fboundp 'menu-bar-mode)
    (menu-bar-mode  -1))
(if (fboundp 'tool-bar-mode)
    (tool-bar-mode  -1))
(if (fboundp 'set-scroll-bar-mode)
    (set-scroll-bar-mode 'nil))
(mouse-wheel-mode t)
(tooltip-mode -1)
(blink-cursor-mode -1)

Set up the fill-column to 80 characters and set tab width to 2.

(setq-default fill-column 80)
(setq-default default-tab-width 2)
;; never use tab characters for indentation
(setq-default indent-tabs-mode nil)

Function to join multiple lines.

(defun jc/join-lines ()
  (let ((fill-column 999999))
    (fill-paragraph nil)))

Hide the mouse while typing.

(setq make-pointer-invisible t)

It's okay to refer to a file by a symlink.

(setq-default find-file-visit-truename nil)

Require a newline at the end of files.

(setq require-final-newline t)

Always turn on whitespace mode

(whitespace-mode t)


(show-paren-mode 1)

Auto revert buffer.

(global-auto-revert-mode 1)

rename file and buffer http://emacsredux.com/blog/2013/05/04/rename-file-and-buffer/

(defun jc/rename-file-and-buffer ()
  "Rename the current buffer and file it is visiting."
  (let ((filename (buffer-file-name)))
    (if (not (and filename (file-exists-p filename)))
        (message "Buffer is not visiting a file!")
      (let ((new-name (read-file-name "New name: " filename)))
         ((vc-backend filename) (vc-rename-file filename new-name))
          (rename-file filename new-name t)
          (set-visited-file-name new-name t t)))))))

Upcase & Down Case

(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)

Text scale bigger or smaller

;; Font size
(define-key global-map (kbd "C-+") 'text-scale-increase)
(define-key global-map (kbd "C--") 'text-scale-decrease)


(setq eww-search-prefix "https://www.google.com/search?q=")
(setq browse-url-browser-function 'eww-browse-url)

Org mode Settings

At this point we still have not done anything special outside of what is possible in a default emacs programming environment. This will continue for this section.

Let's get the agenda going.

(define-key global-map "\C-ca" 'org-agenda)

Code blocks should be have syntax highlighting

(setq org-src-fontify-natively t)

Subtree navigation

(defun jc/org-narrow-backward ()
  "Move back subtree at same level, and narrow to it."
  (org-backward-heading-same-level 1)

(defun jc/org-narrow-forward ()
  "Move to the next subtree at same level, and narrow to it."
  (org-forward-heading-same-level 1)

(org-defkey org-mode-map [f7] 'jc/org-narrow-backward)
(org-defkey org-mode-map [f9] 'jc/org-narrow-forward)

Clocking commands

(defun jc/org-query-clock-out ()
    "Ask the user before clocking out.
      This is a useful function for adding to `kill-emacs-query-functions'."
    (if (and (featurep 'org-clock)
             (funcall 'org-clocking-p)
             (y-or-n-p "You are currently clocking time, clock out? "))
      t)) ; only fails on keyboard quit or error

(add-hook 'kill-emacs-query-functions 'jc/org-query-clock-out)

Ditaa is a command-line utility that converts diagrams drawn using ASCII art into bitmap graphics. Here is the Ditaa path:

 ((string-equal system-type "darwin")   ; Mac OS X
  (setq org-ditaa-jar-path "/usr/local/Cellar/ditaa/0.10/libexec/ditaa0_10.jar"))
 ((string-equal system-type "gnu/linux") ; linux
  (setq org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar")))

Inline image support

(defun jc/do-org-show-all-inline-images ()
  (org-display-inline-images t t))

(global-set-key (kbd "C-c C-x C v")

(defun jc/fix-inline-images ()
    (when org-inline-image-overlays

(add-hook 'org-babel-after-execute-hook 'jc/fix-inline-images)


(require 'ox-bibtex)
(setq org-latex-to-pdf-process (list "latexmk -pdf -bibtex %f"))

Manually Curated Packages

These modes are not in any package manager so curate them manually.

package description anchors
~/.emacs.d/git/emacs-rotate/ Buffer rotate rotate
~/.emacs.d/git/title-capitalization.el/ Title capitalization writing
~/.emacs.d/git/emacs-calfw/ Calendar framework for emacs calendar
(defvar p-packages (mapcar 'car (cdr packs)))

(dolist (pack p-packages)
  (when (file-directory-p  pack)
    (add-to-list 'load-path pack)))

Package Archives

We have a decent emacs configuration at this point. Now start loading external utilities.

First define the package archives and where they live.

;; Keep track of loading time
(defconst emacs-start-time (current-time))

;; initalize all ELPA packages
(require 'package)

;; define some package archives
(add-to-list 'package-archives 
   '("melpa-stable" . "http://stable.melpa.org/packages/"))
(add-to-list 'package-archives
  '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
  '("elpy" . "http://jorgenschaefer.github.io/packages/"))


;; Message how long it took to load everything (minus packages)
(let ((elapsed (float-time (time-subtract (current-time)
  (message "Loading settings...done (%.3fs)" elapsed))

Packages We Will Use

Define all the packages we are going to use. Note if you are viewing this table on github, the anchors will not take you anywhere. The anchors only work in emacs org mode.

package description anchors
helm helm completion engine helm
projectile Project navigation and management library projectile
helm-projectile Projectile helm integration projectile
ace-jump-mode ace-jump-mode ace
rw-hunspell spelling spelling
rw-ispell spelling spelling
rw-language-and-country-codes spelling spelling
flycheck on-the-fly syntax checking  
magit emacs git client git
git-gutter git gutter git
git-timemachine Walk through git revisions of a file git
fill-column-indicator 80 column rule fci
powerline A better mode line modeline
paredit structured editing of S-expression data paren
rainbow-delimiters rainbow parentheses paren
markdown-mode markdown for emacs markdown
yaml-mode yaml for emacs yaml
undo-tree undo tree undo
windresize arrow keys resize the window  
clojure-mode Mode for clojure clojure
cider Clojure IDE and REPL for Emacs clojure
clojure-snippets Yasnippets for clojure clojure
clj-refactor A collection of clojure refactoring functions clojure
company Modular text completion framework  
javap-mode Load .class file and get javap output  
sx Stack Exchange for Emacs sx
python Python mode for emacs python
dockerfile-mode Major mode for editing Docker's Dockerfiles  
csv-mode Major mode for editing comma separated values  
zoom-window Zoom window like tmux  
org-gcal Org sync with Google Calendar calendar
gnuplot gnuplot gnuplot
ob-http http request in org-mode babel No description for this link
direx Simple tree directory explorer dired
ipython ipython for emacs python
jedi Python auto-completion for Emacs python
elpy Emacs Python Development Environment python

In addition, elpy implicitly grabs these packages so they are unnecessary to import. And Python files will make use of eldoc, and flymake modes.

package description anchors
yasnippet Yet another snippet extension for Emacs python
pyvenv Python virtual environment interface python
company Modular text completion framework  
highlight-indentation Minor mode to highlight indentation  
package description anchors
ein Emacs IPython Notebook python
ob-ipython org-babel IPython python
org-present Minimal presentation mode for emacs org-present
emms The Emacs Multimedia System emms
restclient An interactive HTTP client for Emacs restclient
ob-restclient org-babel functions for restclient-mode restclient
ox-gfm Github Flavored Markdown markdown
synonymous Thesaurus writing
info+ Extensions to info.el info
multiple-cursors Multiple cursors for Emacs multi-cursor
github-issues GitHub project issues git

Download the packages we need.

(defvar install-packages (mapcar 'intern (mapcar 'car (cdr packs))))

(dolist (pack install-packages)
   (unless (package-installed-p pack)
     (package-install pack)))

Now handle unstable packages.

(defvar install-packages-unstable (mapcar 'intern (mapcar 'car (cdr packs))))

(add-to-list 'package-archives 
   '("melpa-unstable" . "http://melpa.org/packages/"))

(dolist (pack install-packages-unstable)
   (unless (package-installed-p pack)
     (package-install pack)))

Package Configuration


(require 'helm-config)
(require 'helm)
(helm-mode 1)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x C-f") 'helm-find-files) 
(global-set-key (kbd "C-x b") 'helm-mini)
(global-set-key (kbd "C-x C-b") 'helm-buffers-list)

(setq helm-mode-fuzzy-match t) 
(setq helm-completion-in-region-fuzzy-match t) 
(setq helm-candidate-number-limit 75)


(require 'projectile)
(setq projectile-enable-caching t)
(setq projectile-completion-system 'helm)

Ace Jump Mode

(require 'ace-jump-mode)
(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)

(add-hook 'org-mode-hook
          (lambda ()
            (local-set-key (kbd "\C-c SPC") 'ace-jump-mode)))


Using hunspell and friends. If on OS X make sure you have dictionaries in /Library/Spelling and/or ~/Library/Spelling or else you'll get a mysterious error. For English language dictionaries, it should be something like default.aff default.dic en_US.aff n_US.dic. The default files are soft-linked to the main dictionary of your choice (in this case en_US). Also make sure to brew install hunspell.

(if (file-exists-p "/usr/local/bin/hunspell")
      ;; Add english-hunspell as a dictionary
      (setq-default ispell-program-name "hunspell"))
  (progn (setq-default ispell-program-name "aspell")
         (setq ispell-extra-args '("--sug-mode=normal" "--ignore=3"))))

(add-to-list 'ispell-skip-region-alist '(":\\(PROPERTIES\\|LOGBOOK\\):" . ":END:"))
(add-to-list 'ispell-skip-region-alist '("#\\+BEGIN" . "#\\+END"))


(require 'yasnippet)
(add-to-list 'yas-snippet-dirs "~/.emacs.d/git/yasnippet-snippets/")
(yas-global-mode +1)

;; https://www.emacswiki.org/emacs/Yasnippet#toc4
(defun jc/yas-helm-prompt (prompt choices &optional display-fn)
  "Use helm to select a snippet. Put this into `yas-prompt-functions.'"
  (setq display-fn (or display-fn 'identity))
  (if (require 'helm-config)
      (let (tmpsource cands result rmap)
        (setq cands (mapcar (lambda (x) (funcall display-fn x)) choices))
        (setq rmap (mapcar (lambda (x) (cons (funcall display-fn x) x)) choices))
        (setq tmpsource
               (cons 'name prompt)
               (cons 'candidates cands)
               '(action . (("Expand" . (lambda (selection) selection))))
        (setq result (helm-other-buffer '(tmpsource) "*helm-select-yasnippet"))
        (if (null result)
            (signal 'quit "user quit!")
          (cdr (assoc result rmap))))

(add-to-list 'yas-prompt-functions 'jc/yas-helm-prompt)


git gutter

(global-git-gutter-mode t)

Magit stuff

(setq magit-last-seen-setup-instructions "1.4.0")
(global-set-key (kbd "C-x g") 'magit-status)

GitHub Issues

(require 'github-issues)

Fill Column Indicator

Turn off fci mode for now.

;; (add-hook 'clojure-mode-hook 'fci-mode)
;; (add-hook 'org-mode-hook 'fci-mode)


(defun fci-mode-override-advice (&rest args))

(advice-add 'org-html-fontify-code :around
            (lambda (fun &rest args)
              (advice-add 'fci-mode :override #'fci-mode-override-advice)
              (let ((result  (apply fun args)))
                (advice-remove 'fci-mode #'fci-mode-override-advice)

Mode line

This powerline theme is pretty much identical to the default powerline theme except that the red ★ indicates the buffer has been modified but not saved.

(require 'powerline)

(defun powerline-jc-theme ()
  "Setup Julien's mode-line."
  (setq-default mode-line-format
                   (let* ((active (powerline-selected-window-active))
                          (mode-line (if active 'mode-line 'mode-line-inactive))
                          (face1 (if active 'powerline-active1 'powerline-inactive1))
                          (face2 (if active 'powerline-active2 'powerline-inactive2))
                          (separator-left (intern (format "powerline-%s-%s"
                                                          (car powerline-default-separator-dir))))
                          (separator-right (intern (format "powerline-%s-%s"
                                                           (cdr powerline-default-separator-dir))))
                          (lhs (list (if (buffer-modified-p)
                                         (propertize "★" 'face '
                                                     (:background "black" :foreground "red"))
                                       (powerline-raw "%*" nil 'l))
                                     (powerline-buffer-size nil 'l)
                                     (powerline-raw mode-line-mule-info nil 'l)
                                     (powerline-buffer-id nil 'l)
                                     (when (and (boundp 'which-func-mode) which-func-mode)
                                       (powerline-raw which-func-format nil 'l))
                                     (powerline-raw " ")
                                     (funcall separator-left mode-line face1)
                                     (when (boundp 'erc-modified-channels-object)
                                       (powerline-raw erc-modified-channels-object face1 'l))
                                     (powerline-major-mode face1 'l)
                                     (powerline-process face1)
                                     (powerline-minor-modes face1 'l)
                                     (powerline-narrow face1 'l)
                                     (powerline-raw " " face1)
                                     (funcall separator-left face1 face2)
                                     (powerline-vc face2 'r)))
                          (rhs (list (powerline-raw global-mode-string face2 'r)
                                     (funcall separator-right face2 face1)
                                     (powerline-raw "%4l" face1 'l)
                                     (powerline-raw ":" face1 'l)
                                     (powerline-raw "%3c" face1 'r)
                                     (funcall separator-right face1 mode-line)
                                     (powerline-raw " ")
                                     (powerline-raw "%6p" nil 'r)
                                     (powerline-hud face2 face1))))
                     (concat (powerline-render lhs)
                             (powerline-fill face2 (powerline-width rhs))
                             (powerline-render rhs)))))))


(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
(add-hook 'ielm-mode-hook 'enable-paredit-mode)
(add-hook 'emacs-lisp-mode-hook 'enable-paredit-mode)




All the configuration crap recommended by https://github.com/clojure-emacs/cider

(add-hook 'clojure-mode-hook 'paredit-mode)

(add-hook 'cider-mode-hook #'eldoc-mode)

(add-hook 'cider-repl-mode-hook #'subword-mode)

(add-hook 'cider-repl-mode-hook #'paredit-mode)

(add-hook 'cider-repl-mode-hook #'rainbow-delimiters-mode)

(setq nrepl-log-messages t)

(setq nrepl-hide-special-buffers t)

(add-hook 'clojure-mode-hook 'prettify-symbols-mode)

(add-hook 'cider-repl-mode-hook 'prettify-symbols-mode)

(add-hook 'clojure-mode-hook (lambda ()
                               (clj-refactor-mode 1)
                               (cljr-add-keybindings-with-prefix "C-c C-m")))

(add-hook 'cider-repl-mode-hook #'company-mode)

(add-hook 'cider-mode-hook #'company-mode)


(add-to-list 'load-path "~/.emacs.d/git/org-mode/lisp")

(require 'org)
(require 'ob-clojure)

(setq org-babel-clojure-backend 'cider)
(require 'cider)


(autoload 'markdown-mode "markdown-mode"
   "Major mode for editing Markdown files" t)

(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))

git flavored markdown

(require 'ox-gfm)


(require 'yaml-mode)
    (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))

(add-hook 'yaml-mode-hook
      '(lambda ()
        (define-key yaml-mode-map "\C-m" 'newline-and-indent)))


(require 'emms-setup)

Stack Exchange

(require 'sx-load)



See here, here and custome.el for why (elpy-use-ipython) is commented out.



(require 'ein)


(require 'ob-ipython)

Fill column indicator

;; fill column indicator for python files
(add-hook 'python-mode-hook 'fci-mode)


;; installing jedi server http://tkf.github.io/emacs-jedi/latest/#pyinstall
(let ((j
        (remove-if-not (lambda (x) (string-match "jedi-core" x)) load-path)))
  (when j
    (setq jedi:server-command (list (concat (car j) "/jediepcserver.py")))))

(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)


;; fill column indicator for python files
(add-hook 'python-mode-hook 'flycheck-mode)

Electric Pair

(add-hook 'python-mode-hook 'electric-pair-mode)


(setq python-shell-interpreter "ipython"
      python-shell-interpreter-args "--simple-prompt -i")



(require 'org-present)


Buffer Rotation

(require 'rotate)
(global-set-key (kbd "C-x C-o") 'rotate-window)


Loading babel supported languages:

 '((ditaa . t)
   (emacs-lisp . t)
   (org . t)
   (gnuplot . t)
   (latex . t)
   (shell . t)
   (clojure . t)
   (http . t)
   (restclient . t)
   (ein . t)
   (ipython . t)
   (python . t)))

Language specific default headers for code blocks in org-mode

(add-to-list 'org-structure-template-alist
               "#+BEGIN_SRC python\n?\n#+END_SRC"
               "<src lang=\"python\">\n?\n</src>"))

(add-to-list 'org-structure-template-alist
               "#+BEGIN_SRC ipython :session\n?\n#+END_SRC"
               "<src lang=\"python\">\n?\n</src>"))

(add-to-list 'org-structure-template-alist
               "#+BEGIN_SRC clojure\n?\n#+END_SRC"
               "<src lang=\"clojure\">\n?\n</src>"))

(add-to-list 'org-structure-template-alist
               "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC"
               "<src lang=\"emacs-lisp\">\n?\n</src>"))


(require 'hideshow)
(require 'sgml-mode)
(require 'nxml-mode)

(add-to-list 'hs-special-modes-alist


(add-hook 'nxml-mode-hook 'hs-minor-mode)

;; optional key bindings, easier than hs defaults
(define-key nxml-mode-map (kbd "C-c h") 'hs-toggle-hiding)


eldoc for emacs lisp development

(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
(add-hook 'ielm-mode-hook 'turn-on-eldoc-mode)


(require 'restclient)


Info on dired-x

(add-hook 'dired-load-hook
          (lambda ()
            (load "dired-x")
            ;; Set dired-x global variables here.  For example:
            ;; (setq dired-guess-shell-gnutar "gtar")
            ;; (setq dired-x-hands-off-my-keys nil)

(add-hook 'dired-mode-hook
          (lambda ()
            ;; Set dired-x buffer-local variables here.  For example:
            ;; (dired-omit-mode 1)


(require 'direx)
(global-set-key (kbd "C-x C-j") 'direx:jump-to-directory)


(require 'synonymous)
(require 'title-capitalization)


(require 'info+)


(require 'calfw)
(require 'org-gcal)
(require 'calfw-org)


(require 'gnuplot)



(require 'ox-taskjuggler)


(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)

Emacs Shell Settings


(defun eshell/magit ()
  "Function to open magit-status for the current directory"
  (magit-status default-directory)

Clear buffer

(defun eshell/clear ()
  "Clear the eshell buffer"
  (let ((eshell-buffer-maximum-lines 0))

VT100 Escape Codes

(require 'ansi-color)

(defun jc/display-ansi-colors ()
  (ansi-color-apply-on-region (point-min) (point-max)))

Org-mode Header UUIDs

UUID headline anchors from Lee, of course.

(require 'org-id)

(setq org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id)

(defun jc/org-custom-id-get (&optional pom create prefix)
  "Get the CUSTOM_ID property of the entry at point-or-marker POM.  If POM is
   nil, refer to the entry at point. If the entry does not have an CUSTOM_ID,
   the function returns nil. However, when CREATE is non nil, create a CUSTOM_ID
   if none is present already. PREFIX will be passed through to `org-id-new'. In
   any case, the CUSTOM_ID of the entry is returned."
  (org-with-point-at pom
    (let ((id (org-entry-get nil "CUSTOM_ID")))
       ((and id (stringp id) (string-match "\\S-" id))
        (setq id (org-id-new (concat prefix "h")))
        (org-entry-put pom "CUSTOM_ID" (substring id 0 10))
        (org-id-add-location id (buffer-file-name (buffer-base-buffer)))

(defun jc/org-add-ids-to-headlines-in-file ()
  "Add CUSTOM_ID properties to all headlines in the current file which do not
   already have one. Only adds ids if the `auto-id' option is set to `t' in the
   file somewher, i.e., #+OPTIONS: auto-id:t"
    (goto-char (point-min))
    (when (re-search-forward "^#\\+OPTIONS:.*auto-id:t" (point-max) t)
      (org-map-entries (lambda () (jc/org-custom-id-get (point) 'create))))))
SourceLast updated on Wed Mar 22 02:23:15 2017 • julienchastang.com by Julien Chastang