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.
|
||||
#+name: lst:3rd-setopt-call
|
||||
#+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:
|
||||
(push (expand-file-name "~/VCS/org-mode/lisp") load-path)
|
||||
;; 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.
|
||||
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)]].
|
||||
3. Listing [[lst:ob-tangle-plus]] extends [[info:org#Noweb Reference Syntax][source code export (info)]] with user
|
||||
friendly commands.
|
||||
3. Listing [[lst:ob-tangle-plus]] extends [[info:org#Noweb Reference Syntax][source code export (info)]] with the
|
||||
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
|
||||
[[info:org#Hyperlinks][hyperlinks (info)]].
|
||||
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
|
||||
#+begin_src emacs-lisp -n
|
||||
(with-eval-after-load 'emacs
|
||||
(defun set-org-babel-language-activity (lang active)
|
||||
"Set the `org-babel' activity of language LANG to ACTIVE.
|
||||
;; Modified from https://emacs.stackexchange.com/a/61364 which replies to
|
||||
;; 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
|
||||
unbind the `org-babel' interface functions when ACTIVE is nil."
|
||||
(if (locate-library (format "ob-%s" lang))
|
||||
(or (org-babel-do-load-languages
|
||||
'org-babel-load-languages
|
||||
(cons (cons lang active)
|
||||
(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 dir+org-babel-post-tangle ()
|
||||
"Function to hook on `org-babel-post-tangle-hook'."
|
||||
(when (and (bound-and-true-p post-tangle-hook-dir)
|
||||
(derived-mode-p '(emacs-lisp-mode)))
|
||||
(message "Tangle into `%S'" post-tangle-hook-dir)
|
||||
(rename-file (buffer-file-name) post-tangle-hook-dir t)))
|
||||
|
||||
(defun activate-org-babel-language (lang)
|
||||
"Activate LANG for `org-babel'."
|
||||
(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."
|
||||
(defun toggle-post-tangle-hook-dir-usage ()
|
||||
"Toggle tangling to `post-tangle-hook-dir' by `dir+org-babel-post-tangle'."
|
||||
(interactive)
|
||||
(let ((current-prefix-arg '(4))) ;; C-u C-c C-v t
|
||||
(call-interactively 'org-babel-tangle)))
|
||||
|
||||
(defun org-babel-tangle-collect()
|
||||
"Collect all source blocks with the same target file and tangle."
|
||||
(interactive)
|
||||
(let ((current-prefix-arg '(16))) ;; C-u C-u C-c C-v t
|
||||
(call-interactively 'org-babel-tangle))))
|
||||
(if (member 'dir+org-babel-post-tangle org-babel-post-tangle-hook)
|
||||
(progn
|
||||
(setq post-tangle-hook-dir nil)
|
||||
(message "Disable tangling into `post-tangle-hook-dir'")
|
||||
(remove-hook 'org-babel-post-tangle-hook #'dir+org-babel-post-tangle))
|
||||
(setq post-tangle-hook-dir (org-entry-get nil "post-tangle-hook-dir" t))
|
||||
(message "Enable tangling into `post-tangle-hook-dir' which equals `%S'"
|
||||
post-tangle-hook-dir)
|
||||
(add-hook 'org-babel-post-tangle-hook #'dir+org-babel-post-tangle))))
|
||||
#+end_src
|
||||
|
||||
#+caption[Set =org-link= options]:
|
||||
|
Loading…
x
Reference in New Issue
Block a user