Confpkg: new "pre" option
This commit is contained in:
parent
e92e0a4f98
commit
f84904c35d
38
config.org
38
config.org
|
@ -481,12 +481,15 @@ modify the parent heading, and register the config group with the variables we
|
|||
created earlier.
|
||||
|
||||
#+name: confpkg
|
||||
#+begin_src elisp :var name="" needs="" after="" prefix="config-" via="copy" :results silent raw :noweb no-export
|
||||
#+begin_src elisp :var name="" needs="" after="" pre="" prefix="config-" via="copy" :results silent raw :noweb no-export
|
||||
;; Babel block for use with #+call
|
||||
;; Arguments:
|
||||
;; - name, the name of the config sub-package
|
||||
;; - needs, (when non-empty) required system executable(s)
|
||||
;; - after, required features
|
||||
;; - pre, a noweb reference to code that should be executed eagerly,
|
||||
;; and not deferred via after. The code is not included in the
|
||||
;; generated .el file and should only be used in dire situations.
|
||||
;; - prefix, the package prefix ("config-" by default)
|
||||
;; - via, how this configuration should be included in config.el,
|
||||
;; the current options are:
|
||||
|
@ -510,6 +513,7 @@ created earlier.
|
|||
((string-match-p "\\`[^()]+\\'" after)
|
||||
(intern after)) ; Single feature.
|
||||
(t after)))
|
||||
(pre (and (not (string-empty-p pre)) pre))
|
||||
(confpkg-name
|
||||
(concat prefix (replace-regexp-in-string
|
||||
"[^a-z-]" "-" (downcase name))))
|
||||
|
@ -525,6 +529,7 @@ created earlier.
|
|||
:package confpkg-name
|
||||
:file confpkg-file
|
||||
:after after
|
||||
:pre pre
|
||||
:via (intern via))
|
||||
confpkg--list)
|
||||
(format-spec
|
||||
|
@ -737,7 +742,8 @@ tempbuffer. We can call this with the finalising step.
|
|||
#+begin_src emacs-lisp
|
||||
(defun confpkg-create-config ()
|
||||
(let ((revert-without-query '("config\\.el"))
|
||||
(keywords (org-collect-keywords '("AUTHOR" "EMAIL"))))
|
||||
(keywords (org-collect-keywords '("AUTHOR" "EMAIL")))
|
||||
(original-buffer (current-buffer)))
|
||||
(with-temp-buffer
|
||||
(insert
|
||||
(format ";;; config.el -*- lexical-binding: t; -*-
|
||||
|
@ -807,16 +813,30 @@ tempbuffer. We can call this with the finalising step.
|
|||
(confpkg-create-record 'load-hooks 0.0 'config-defered)
|
||||
(confpkg-create-record 'requires 0.0 'root)\n"))
|
||||
(let ((after (plist-get confpkg :after))
|
||||
(pre (and (plist-get confpkg :pre)
|
||||
(org-babel-expand-noweb-references
|
||||
(list "emacs-lisp"
|
||||
(format "<<%s>>" (plist-get confpkg :pre))
|
||||
'((:noweb . "yes")
|
||||
(:comments . "none")))
|
||||
original-buffer)))
|
||||
(name (replace-regexp-in-string
|
||||
"config--?" ""
|
||||
(plist-get confpkg :package))))
|
||||
(when after
|
||||
(insert (format "(confpkg-with-record '%S\n"
|
||||
(list (concat "hook: " name) 'set-hooks))
|
||||
(format (if (symbolp after) ; If single feature.
|
||||
" (with-eval-after-load '%s\n"
|
||||
" (after! %s\n")
|
||||
after)))
|
||||
(if after
|
||||
(insert (format "(confpkg-with-record '%S\n"
|
||||
(list (concat "hook: " name) 'set-hooks))
|
||||
(if pre
|
||||
(concat ";; Begin pre\n" pre "\n;; End pre\n")
|
||||
"")
|
||||
(format (if (symbolp after) ; If single feature.
|
||||
" (with-eval-after-load '%s\n"
|
||||
" (after! %s\n")
|
||||
after))
|
||||
(when pre
|
||||
(insert "\n;; Begin pre (unnecesary since after is unused)\n"
|
||||
pre
|
||||
"\n;; End pre\n")))
|
||||
(insert
|
||||
(format "(confpkg-with-record '%S\n"
|
||||
(list (concat "load: " name)
|
||||
|
|
Loading…
Reference in New Issue