emacs: retangle org config when any generated file is stale
This commit is contained in:
@@ -2950,11 +2950,26 @@ My org-mode configuration now lives in its own file org-config.org.
|
|||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(let* ((org-config (expand-file-name "org-config.org" user-emacs-directory))
|
(let* ((org-config (expand-file-name "org-config.org" user-emacs-directory))
|
||||||
(org-config-el (expand-file-name "org-config.el" user-emacs-directory)))
|
(org-config-el (expand-file-name "org-config.el" user-emacs-directory)))
|
||||||
(when (file-newer-than-file-p org-config org-config-el)
|
(let* ((outputs (mapcar (lambda (f) (expand-file-name f user-emacs-directory))
|
||||||
;; Tangle all outputs so org-config-bind.el/org-config-config.el are fresh.
|
'("org-config.el"
|
||||||
(org-babel-tangle-file org-config)
|
"org-config-preface.el"
|
||||||
(when (file-exists-p org-config-el)
|
"org-config-custom.el"
|
||||||
(set-file-times org-config-el)))
|
"org-config-bind.el"
|
||||||
|
"org-config-config.el")))
|
||||||
|
(needs-tangle nil))
|
||||||
|
;; Tangle if any output is missing or stale. This is more robust than only
|
||||||
|
;; checking org-config.el, since tangling can update some outputs without
|
||||||
|
;; touching org-config.el's contents.
|
||||||
|
(dolist (f outputs)
|
||||||
|
(when (or (not (file-exists-p f))
|
||||||
|
(file-newer-than-file-p org-config f))
|
||||||
|
(setq needs-tangle t)))
|
||||||
|
(when needs-tangle
|
||||||
|
(org-babel-tangle-file org-config)
|
||||||
|
;; Prevent re-tangling on every startup when files are unchanged.
|
||||||
|
(dolist (f outputs)
|
||||||
|
(when (file-exists-p f)
|
||||||
|
(set-file-times f)))))
|
||||||
(load-file org-config-el))
|
(load-file org-config-el))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** TeX
|
*** TeX
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#+PROPERTY: header-args:emacs-lisp :tangle org-config-config.el
|
||||||
|
|
||||||
* include-file-as-forms
|
* include-file-as-forms
|
||||||
We're going to use this to write separate parts of our config to different sections that will then be provided to our use package statment
|
We're going to use this to write separate parts of our config to different sections that will then be provided to our use package statment
|
||||||
#+begin_src emacs-lisp :tangle org-config.el
|
#+begin_src emacs-lisp :tangle org-config.el
|
||||||
@@ -775,7 +777,8 @@ SCHEDULED: %^t
|
|||||||
'org-babel-load-languages '((mermaid . t))))
|
'org-babel-load-languages '((mermaid . t))))
|
||||||
#+end_src
|
#+end_src
|
||||||
** frame-mode handling
|
** frame-mode handling
|
||||||
Note that this does not go into org-config-config.el. This is on purpose
|
This block is part of the runtime config. It is tangled via the default
|
||||||
|
`header-args:emacs-lisp` for this file (see the `#+PROPERTY` near the top).
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package org
|
(use-package org
|
||||||
:ensure nil
|
:ensure nil
|
||||||
|
|||||||
Reference in New Issue
Block a user