Tangle to ./site-lisp to zap user-emacs-directory' from
load-path'
This commit is contained in:
parent
26cedb1ec0
commit
c09ed7bbb9
67
README.org
67
README.org
@ -315,8 +315,6 @@ recommendation of [[info:emacs#Saving Customizations][saving customizations (inf
|
|||||||
#+caption: Set the third set of Emacs options: upgrade Org and transient.
|
#+caption: Set the third set of Emacs options: upgrade Org and transient.
|
||||||
#+name: lst:3rd-setopt-call
|
#+name: lst:3rd-setopt-call
|
||||||
#+begin_src emacs-lisp -n
|
#+begin_src emacs-lisp -n
|
||||||
;; To test my own stuff in my `emacs-user-directory:'
|
|
||||||
(push (expand-file-name user-emacs-directory) load-path)
|
|
||||||
;; To use an Org git clone:
|
;; To use an Org git clone:
|
||||||
(push (expand-file-name "~/VCS/org-mode/lisp") load-path)
|
(push (expand-file-name "~/VCS/org-mode/lisp") load-path)
|
||||||
;; Postpone (require 'org) after shadowing Org and sh-script faces below.
|
;; Postpone (require 'org) after shadowing Org and sh-script faces below.
|
||||||
@ -2246,8 +2244,9 @@ list detailing and motivating each listing:
|
|||||||
1. Listing [[lst:set-org-options]] handles basic [[https://orgmode.org/][Org-mode]] options.
|
1. Listing [[lst:set-org-options]] handles basic [[https://orgmode.org/][Org-mode]] options.
|
||||||
2. Listing [[lst:setup-org-babel]] handles basic [[https://orgmode.org/][Org-mode]] options specific to
|
2. Listing [[lst:setup-org-babel]] handles basic [[https://orgmode.org/][Org-mode]] options specific to
|
||||||
[[info:org#Working with Source Code][work with source code (info)]].
|
[[info:org#Working with Source Code][work with source code (info)]].
|
||||||
3. Listing [[lst:ob-tangle-plus]] extends [[info:org#Noweb Reference Syntax][source code export (info)]] with user
|
3. Listing [[lst:ob-tangle-plus]] extends [[info:org#Noweb Reference Syntax][source code export (info)]] with the
|
||||||
friendly commands.
|
possibility to tangle Emacs Lisp files into a directory specified by a
|
||||||
|
top-level variable.
|
||||||
4. Listing [[lst:set-org-link-options]] handles [[https://orgmode.org/][Org-mode]] options specific to
|
4. Listing [[lst:set-org-link-options]] handles [[https://orgmode.org/][Org-mode]] options specific to
|
||||||
[[info:org#Hyperlinks][hyperlinks (info)]].
|
[[info:org#Hyperlinks][hyperlinks (info)]].
|
||||||
5. Listing [[lst:setup-org-mode-map]] extends the =org-mode-map= with useful
|
5. Listing [[lst:setup-org-mode-map]] extends the =org-mode-map= with useful
|
||||||
@ -2340,46 +2339,32 @@ list detailing and motivating each listing:
|
|||||||
#+name: lst:ob-tangle-plus
|
#+name: lst:ob-tangle-plus
|
||||||
#+begin_src emacs-lisp -n
|
#+begin_src emacs-lisp -n
|
||||||
(with-eval-after-load 'emacs
|
(with-eval-after-load 'emacs
|
||||||
(defun set-org-babel-language-activity (lang active)
|
;; Modified from https://emacs.stackexchange.com/a/61364 which replies to
|
||||||
"Set the `org-babel' activity of language LANG to ACTIVE.
|
;; https://emacs.stackexchange.com/questions/61359/
|
||||||
|
;; "How to specify a directory to tangle all code blocks into".
|
||||||
|
(defvar post-tangle-hook-dir nil
|
||||||
|
"Destination directory used by `dir+org-babel-post-tangle'.
|
||||||
|
May be changed by `toggle-post-tangle-hook-dir-usage'.")
|
||||||
|
|
||||||
Let `org-babel-do-load-languages' load ob-LANG when ACTIVE is t or
|
(defun dir+org-babel-post-tangle ()
|
||||||
unbind the `org-babel' interface functions when ACTIVE is nil."
|
"Function to hook on `org-babel-post-tangle-hook'."
|
||||||
(if (locate-library (format "ob-%s" lang))
|
(when (and (bound-and-true-p post-tangle-hook-dir)
|
||||||
(or (org-babel-do-load-languages
|
(derived-mode-p '(emacs-lisp-mode)))
|
||||||
'org-babel-load-languages
|
(message "Tangle into `%S'" post-tangle-hook-dir)
|
||||||
(cons (cons lang active)
|
(rename-file (buffer-file-name) post-tangle-hook-dir t)))
|
||||||
(assq-delete-all
|
|
||||||
lang (default-toplevel-value 'org-babel-load-languages))))
|
|
||||||
org-babel-load-languages)
|
|
||||||
(warn "Can't locate `ob-%s', hence don't set `%s' activity" lang lang)))
|
|
||||||
|
|
||||||
(defun activate-org-babel-language (lang)
|
(defun toggle-post-tangle-hook-dir-usage ()
|
||||||
"Activate LANG for `org-babel'."
|
"Toggle tangling to `post-tangle-hook-dir' by `dir+org-babel-post-tangle'."
|
||||||
(interactive "SActivate language: ")
|
|
||||||
(if (set-org-babel-language-activity lang t)
|
|
||||||
(message "Did activate `%s' for `org-babel'" lang)
|
|
||||||
(message "Can't activate `%s' for `org-babel'" lang)))
|
|
||||||
|
|
||||||
(defun deactivate-org-babel-language (lang)
|
|
||||||
"Activate LANG for `org-babel'."
|
|
||||||
(interactive "SDeactivate language: ")
|
|
||||||
(if (set-org-babel-language-activity lang nil)
|
|
||||||
(message "Did deactivate `%s' for `org-babel'" lang)
|
|
||||||
(message "Can't deactivate `%s' for `org-babel'" lang)))
|
|
||||||
|
|
||||||
;; https://readingworldmagazine.com/emacs/2023-06-11-introducing-org-mode/
|
|
||||||
(defun org-babel-tangle-block()
|
|
||||||
"Tangle single source blocks."
|
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((current-prefix-arg '(4))) ;; C-u C-c C-v t
|
(if (member 'dir+org-babel-post-tangle org-babel-post-tangle-hook)
|
||||||
(call-interactively 'org-babel-tangle)))
|
(progn
|
||||||
|
(setq post-tangle-hook-dir nil)
|
||||||
(defun org-babel-tangle-collect()
|
(message "Disable tangling into `post-tangle-hook-dir'")
|
||||||
"Collect all source blocks with the same target file and tangle."
|
(remove-hook 'org-babel-post-tangle-hook #'dir+org-babel-post-tangle))
|
||||||
(interactive)
|
(setq post-tangle-hook-dir (org-entry-get nil "post-tangle-hook-dir" t))
|
||||||
(let ((current-prefix-arg '(16))) ;; C-u C-u C-c C-v t
|
(message "Enable tangling into `post-tangle-hook-dir' which equals `%S'"
|
||||||
(call-interactively 'org-babel-tangle))))
|
post-tangle-hook-dir)
|
||||||
|
(add-hook 'org-babel-post-tangle-hook #'dir+org-babel-post-tangle))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+caption[Set =org-link= options]:
|
#+caption[Set =org-link= options]:
|
||||||
|
Loading…
Reference in New Issue
Block a user