Rely on file local safe `org-latex-src-block-backend' and clean up

This commit is contained in:
Gerard Vermeulen 2024-02-11 11:53:49 +01:00
parent 40aa233e3a
commit 3f54e524c4
1 changed files with 13 additions and 73 deletions

View File

@ -2335,7 +2335,7 @@ of the [[info:org#Top][Org (info)]] manual.
:CUSTOM_ID: sec:setup-org
:END:
I have split the initial [[https://orgmode.org/][Org-mode]] setup over fifteen listings. Here, follows a
I have split the initial [[https://orgmode.org/][Org-mode]] setup over fourteen listings. Here, follows a
list detailing and motivating each listing:
1. Listing [[lst:set-org-options]] handles basic [[https://orgmode.org/][Org-mode]] options.
2. Listing [[lst:undo-org-ctags]] undoes ~org-ctags~. See [[https://list.orgmode.org/87mt43agk6.fsf@localhost/][org-ctags land grab]] for
@ -2345,28 +2345,26 @@ list detailing and motivating each listing:
4. Listing [[lst:fake-org-babel-functions]] adds =org-babel-execute:<LANGUAGE>=
functions to silence src_emacs-lisp[:results silent]{(find-library
"org-lint")}.
5. Listing [[lst:org-babel-execute-named-block]] adds a function to execute a named
source block interactively.
6. Listing [[lst:ob-tangle-plus]] extends [[info:org#Noweb Reference Syntax][source code export (info)]] with the
5. Listing [[lst:ob-tangle-plus]] extends [[info:org#Noweb Reference Syntax][source code export (info)]] with the
possibility to tangle of for instance Emacs Lisp files (or other programming
mode files) into a directory specified by ~org-babel-post-tangle-dir~ which
~toggle-post-tangle-hook-dir-usage~ may change.
7. Listing [[lst:set-org-link-options]] handles [[https://orgmode.org/][Org-mode]] options specific to
6. Listing [[lst:set-org-link-options]] handles [[https://orgmode.org/][Org-mode]] options specific to
[[info:org#Hyperlinks][hyperlinks (info)]].
8. Listing [[lst:setup-org-mode-map-1]] and [[lst:setup-org-mode-map-2]] extend the
7. Listing [[lst:setup-org-mode-map-1]] and [[lst:setup-org-mode-map-2]] extend the
=org-mode-map= with useful key-bindings.
9. Listing [[lst:setup-org-src]] facilitates [[info:org#Editing Source Code][editing source code blocks]], and it
8. Listing [[lst:setup-org-src]] facilitates [[info:org#Editing Source Code][editing source code blocks]], and it
provides functions to change the indentation of all =org-src-mode= blocks.
10. Listing [[lst:setup-ob-python]] allows to pretty-print Python session source
block values with [[https://github.com/psf/black#readme][black]] instead of [[https://docs.python.org/3/library/pprint.html][pprint]]. This snippet may break in the
future, because it sets =org-babel-python--def-format-value= which is a
constant declared "private" by two dashes in its name!
11. Listing [[lst:set-org-export-options]] selects the =non-intrusive= expert user
9. Listing [[lst:setup-ob-python]] allows to pretty-print Python session source
block values with [[https://github.com/psf/black#readme][black]] instead of [[https://docs.python.org/3/library/pprint.html][pprint]]. This snippet may break in the
future, because it sets =org-babel-python--def-format-value= which is a
constant declared "private" by two dashes in its name!
10. Listing [[lst:set-org-export-options]] selects the =non-intrusive= expert user
interface for export dispatching.
12. Listing [[lst:setup-org-for-lualatex-export]] and
11. Listing [[lst:setup-org-for-lualatex-export]] and
[[lst:set-ox-latex-options-for-lualatex-export]] configure [[https://orgmode.org/][Org-mode]] to generate
output for the LuaLaTeX compiler.
13. Listing [[lst:setup-org-latex-classes]] defines [[info:org#LaTeXspecificexportsettings][org-latex-classes (info)]] for
12. Listing [[lst:setup-org-latex-classes]] defines [[info:org#LaTeXspecificexportsettings][org-latex-classes (info)]] for
backward compatibility. Type {{{kbd(C-h v org-latex-classes)}}} for an
explanation of the code in listing [[lst:setup-org-latex-classes]].
@ -2489,50 +2487,6 @@ list detailing and motivating each listing:
"NO-OP to silence warnings." nil))
#+end_src
#+caption[Add function to execute a named source block interactively]:
#+caption: Add function to execute a named source block interactively.
#+name: lst:org-babel-execute-named-block
#+begin_src emacs-lisp -n :results silent
(with-eval-after-load 'ob-core
(defun org-babel--source-block-names (&optional language)
"Return an alist of source block name strings and language symbols.
When LANGUAGE is non-nil, restrict the alist to named LANGUAGE blocks."
(when (stringp language)
(if (string= language "elisp")
(setq language nil)
(setq language (intern-soft language)))
(unless language
(user-error "Correct the LANGUAGE string or use a LANGUAGE symbol")))
(let (result)
(save-excursion
(goto-char (point-min))
(while (re-search-forward org-babel-src-block-regexp nil t)
(when (org-babel-active-location-p)
(when-let ((lang (intern-soft (match-string 2)))
(name (org-element-property :name (org-element-at-point))))
(when (or (not language) (eq lang language))
(push (cons name lang)
result))))))
(reverse result)))
(defun org-babel-execute-named-block (&optional arg)
"Execute a named source block after prompting for a source block name.
When prefix ARG is non-nil, prompt first for a language."
(interactive "P")
(let (language)
(when arg
(setq language (completing-read "language: " org-babel-load-languages)))
(if-let* ((names (org-babel--source-block-names language))
(name (completing-read "Block name: " names)))
(if (cl-remove-if-not (lambda (pair) (string= name (car pair))) names)
(save-excursion
(org-babel-goto-named-src-block name)
(org-babel-execute-maybe))
(user-error "There is no named %S of language %S block"
name (or language "any-org-babel-load-language")))
(user-error "There are no named language %S blocks" language)))))
#+end_src
#+caption[Change the =org-babel-tangle= destination to a specific directory]:
#+caption: Change the =org-babel-tangle= destination to a specific directory.
#+name: lst:ob-tangle-plus
@ -2855,7 +2809,6 @@ def __org_babel_python_format_value(result, result_file, result_params):
unicode=true,
urlcolor=blue,
}\n"
org-latex-src-block-backend 'minted
org-latex-minted-langs '((cc "c++")
(conf "text")
(cperl "perl")
@ -3567,20 +3520,6 @@ environments and non-floating breakable LaTeX environments by means of
(smart-latex-engrave-org-source-blocks)))
#+end_src
#+caption[Set ~org-latex-src-block-backend~]:
#+caption: Set ~org-latex-src-block-backend~.
#+name: lst:set-org-latex-src-block-backend
#+begin_src emacs-lisp -n :results silent
(defun set-org-latex-src-block-backend ()
"Set the LaTeX export backend which generates source code listings."
(interactive)
(when (require 'ox-latex nil 'noerror)
(let ((choice (completing-read
"Backend: " '(verbatim listings minted engraved) nil t)))
(setopt org-latex-src-block-backend (intern-soft choice)))
(org-babel-execute-named-block nil)))
#+end_src
*** [[https://oer.gitlab.io/org-re-reveal/Readme.html][Org-re-reveal]] :noexport:
:PROPERTIES:
:CUSTOM_ID: sec:org-re-reveal
@ -8019,5 +7958,6 @@ Only the [[info:org#Top][Org]] source file shows the local variables footer.
# compile-command: "latexmk -interaction=nonstopmode -lualatex -pvc -shell-escape README.tex"
# fill-column: 80
# org-edit-src-content-indentation: 0
# org-latex-src-block-backend: engraved
# eval: (org-eval-emacs-lisp-setup-blocks)
# End: