From 5dac639bc0949f0b688f1f139a985679233d1a1f Mon Sep 17 00:00:00 2001 From: dx Date: Fri, 24 Apr 2020 01:57:43 +0100 Subject: ~refactor custom functions oreodave/->dx: e.g. oreodave/debug -> dx:debug This makes namespacing a lot more noticeable, and less cringy to look at. --- doom.d/org/literate.org | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'doom.d/org/literate.org') diff --git a/doom.d/org/literate.org b/doom.d/org/literate.org index 19829cf..47a8a64 100644 --- a/doom.d/org/literate.org +++ b/doom.d/org/literate.org @@ -10,8 +10,8 @@ Initialise some basic constants for where stuff is. - literate/preloaded-files: Relative to ~$DOOM~, which files are already preloaded/don't need to be compiled #+BEGIN_SRC elisp -(setq oreodave/literate/bin-dir (expand-file-name (concat doom-private-dir "bin/"))) -(setq oreodave/literate/preloaded-files (list "README.org" "org/packages.org" +(setq dx:literate/bin-dir (expand-file-name (concat doom-private-dir "bin/"))) +(setq dx:literate/preloaded-files (list "README.org" "org/packages.org" "org/config.org" "org/literate.org")) #+END_SRC * Remove function @@ -21,7 +21,7 @@ specific remove function that will remove entries from a given list and return the new list, given the fact that the files variable will be a list of fully expanded file names. #+BEGIN_SRC elisp -(defun oreodave/literate/remove-mult (remove-files files) +(defun dx:literate/remove-mult (remove-files files) "Remove any occurrences of `remove-files' from `files'" (let ((parsed-remove-files (map 'list #'(lambda (i) (expand-file-name (concat doom-private-dir i))) @@ -34,17 +34,17 @@ case the bin folder in the private directory This is not fitted onto the parser because the parser could be fitted to multiple /differing/ outputs easily if it isn't specified a destination. #+BEGIN_SRC elisp -(defun oreodave/literate/destination(SRC) +(defun dx:literate/destination(SRC) "Parse a src.org file to a bin/src.el file" (replace-regexp-in-string ".*/\\(\\w+\\).org" - (expand-file-name (concat oreodave/literate/bin-dir "\\1.el")) SRC)) + (expand-file-name (concat dx:literate/bin-dir "\\1.el")) SRC)) #+END_SRC * Parser First we need to get some sort of parser which can, given a source org file and a destination, parse and produce an Emacs lisp file. We'll copy this from the literate module of doom. #+BEGIN_SRC elisp -(defun oreodave/literate/tangle (SRC DEST) +(defun dx:literate/tangle (SRC DEST) "Tangle a source org file into a destination el file using a new emacs instance" (let ((default-directory doom-private-dir)) (when (file-newer-than-file-p SRC DEST) @@ -69,16 +69,16 @@ 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 -(defun oreodave/literate/compile-hook () +(defun dx:literate/compile-hook () "Any org file within $DOOM/org will be compiled on save" (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 (concat doom-private-dir "org"))) (not (string= buffer-file-name (expand-file-name (concat doom-private-dir "README.org"))))) - (oreodave/literate/tangle buffer-file-name (oreodave/literate/destination buffer-file-name)))) + (dx:literate/tangle buffer-file-name (dx:literate/destination buffer-file-name)))) (after! org - (add-hook 'after-save-hook #'oreodave/literate/compile-hook)) + (add-hook 'after-save-hook #'dx:literate/compile-hook)) #+END_SRC * Procedure for all files A procedure that parses all the org files in a given directory into Emacs lisp @@ -88,7 +88,7 @@ The location is not set because this function could be easily programmed to use multiple /differing/ sources to produce the config. The tangle function is set because this is the function we'll be using for tangling all org files to ELisp files. #+BEGIN_SRC elisp -(defun oreodave/literate/tangle-all (&optional location) +(defun dx:literate/tangle-all (&optional location) "Tangle all org files in `location' to el files in the `destination'" (interactive) (or location (setq location doom-private-dir)) @@ -96,7 +96,7 @@ because this is the function we'll be using for tangling all org files to ELisp (let ((files (directory-files-recursively location ".org"))) (dolist (file files) (message "Compiling and parsing %s" file) - (oreodave/literate/tangle file (oreodave/literate/destination file))))) + (dx:literate/tangle file (dx:literate/destination file))))) #+END_SRC * Load configuration Final step of the literate cycle: load the config for the first time. @@ -106,6 +106,6 @@ Remove the config.el and literate.el files from the load list because: #+BEGIN_SRC elisp (let ((files (directory-files-recursively "~/.doom.d/org/" ".org"))) ; Load - (dolist (file (oreodave/literate/remove-mult oreodave/literate/preloaded-files files)) - (load (oreodave/literate/destination file)))) + (dolist (file (dx:literate/remove-mult dx:literate/preloaded-files files)) + (load (dx:literate/destination file)))) #+END_SRC -- cgit v1.2.3-13-gbd6f