~moved add-hook to inside the hook function decl
Hook function is in tandem with the add-hook declaration. ~README.org is to be ignored when coding the config, it's not a literate component
This commit is contained in:
@@ -68,16 +68,18 @@ directory contribute to the config.
|
|||||||
The location is not set because this function could be easily programmed to use
|
The location is not set because this function could be easily programmed to use
|
||||||
multiple /differing/ sources to produce the config.
|
multiple /differing/ sources to produce the config.
|
||||||
* Hook on save
|
* Hook on save
|
||||||
Now we need to make a hook that, when the current buffer is an org file in the
|
Now we need to make a hook function that, when the current buffer is an org file
|
||||||
doom directory, will run the literate config procedure from above.
|
in the doom directory, will run the literate config procedure from above. Use
|
||||||
|
this hook function and add it to the after-save-hook once org mode has been
|
||||||
|
loaded. README.org has been added as an exception because it doesn't contain
|
||||||
|
literate contents.
|
||||||
#+BEGIN_SRC elisp
|
#+BEGIN_SRC elisp
|
||||||
(defun oreodave/literate/compile-hook ()
|
(defun oreodave/literate/compile-hook ()
|
||||||
(when (and (eq major-mode 'org-mode)
|
(when (and (eq major-mode 'org-mode)
|
||||||
(or (file-in-directory-p buffer-file-name doom-private-dir)))
|
(file-in-directory-p buffer-file-name doom-private-dir)
|
||||||
(oreodave/literate/tangle-all)))
|
(not (string= buffer-file-name (expand-file-name (concat doom-private-dir "README.org")))))
|
||||||
#+END_SRC
|
(oreodave/literate/tangle buffer-file-name (oreodave/literate/destination buffer-file-name))))
|
||||||
* Add hook to org-mode
|
|
||||||
#+BEGIN_SRC elisp
|
|
||||||
(after! org
|
(after! org
|
||||||
(add-hook 'after-save-hook #'oreodave/literate/compile-hook))
|
(add-hook 'after-save-hook #'oreodave/literate/compile-hook))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|||||||
Reference in New Issue
Block a user