( defun starter-kit-load (file &optional header-or-tag) "Load configuration from other starter-kit-*.org files. If the optional argument is the id of a subtree then only configuration from within that subtree will be loaded. If it is not an id then it will be interpreted as a tag, and only subtrees marked with the given tag will be loaded. For example, to load all of starter-kit-lisp.org simply add (starter-kit-load \"lisp\") to your configuration. To load only the 'window-system' config from starter-kit-misc-recommended.org add (starter-kit-load \"misc-recommended\" \"window-system\") to your configuration." ( let ((file (expand-file-name ( if (string-match "starter-kit-.+\.org" file) file (format "starter-kit-%s.org" file)) starter-kit-dir))) (org-babel-load-file ( if header-or-tag ( let* ((base (file-name-nondirectory file)) (dir (file-name-directory file)) (partial-file (expand-file-name (concat "." (file-name-sans-extension base) ".part." header-or-tag ".org" ) dir))) ( unless (file-exists-p partial-file) ( with-temp-file partial-file (insert ( with-temp-buffer (insert-file-contents file) ( save-excursion ( condition-case nil ;; collect as a header ( progn (org-link-search (concat "#" header-or-tag)) (org-narrow-to-subtree) (buffer-string)) ( error ;; collect all entries with as tags ( let (body) (org-map-entries ( lambda () ( save-restriction (org-narrow-to-subtree) (setq body (concat body "

" (buffer-string))))) header-or-tag) body)))))))) partial-file) file))))