Clean up the implementation of the org-mode kbd macro
This commit is contained in:
parent
1a8e96e6f2
commit
75b2eec102
50
README.org
50
README.org
@ -885,7 +885,7 @@ in listing [[lst:configure-tex]] corrects this by advising to override
|
|||||||
:END:
|
:END:
|
||||||
|
|
||||||
The code in listing [[lst:customize-org-babel]], [[lst:customize-org]], and
|
The code in listing [[lst:customize-org-babel]], [[lst:customize-org]], and
|
||||||
[[lst:customize-org-export]] does basic customization of [[https://orgmode.org/][Org Mode]] variables.
|
[[lst:customize-org-export]] does basic customization of [[https://orgmode.org/][Org mode]] variables.
|
||||||
|
|
||||||
#+caption[Customize =org-babel=]:
|
#+caption[Customize =org-babel=]:
|
||||||
#+caption: Customize =org-babel=.
|
#+caption: Customize =org-babel=.
|
||||||
@ -987,7 +987,7 @@ The code in listing [[lst:customize-org-babel]], [[lst:customize-org]], and
|
|||||||
(diff "diff")
|
(diff "diff")
|
||||||
(shell-script "bash")
|
(shell-script "bash")
|
||||||
(caml "ocaml")
|
(caml "ocaml")
|
||||||
(org "latex")))
|
(org "text")))
|
||||||
'(org-latex-minted-options '(("bgcolor" "LightGoldenrodYellow")))
|
'(org-latex-minted-options '(("bgcolor" "LightGoldenrodYellow")))
|
||||||
`(org-latex-logfiles-extensions
|
`(org-latex-logfiles-extensions
|
||||||
',(cl-union '("lof" "lot") org-latex-logfiles-extensions :test #'equal))
|
',(cl-union '("lof" "lot") org-latex-logfiles-extensions :test #'equal))
|
||||||
@ -1311,7 +1311,7 @@ Evaluation of the source block in listing
|
|||||||
[[lst:make-source-block-with-export-keyword-settings]] produces the source block
|
[[lst:make-source-block-with-export-keyword-settings]] produces the source block
|
||||||
that exports to listing [[lst:source-file-export-keyword-settings]] which shows the
|
that exports to listing [[lst:source-file-export-keyword-settings]] which shows the
|
||||||
first six lines of this [[file:README.org]] file. The last two lines show that
|
first six lines of this [[file:README.org]] file. The last two lines show that
|
||||||
[[file:setup-include.org][setup-include.org]] is argument for [[info:org#Export Settings][#+SETUPFILE:]] *and* [[info:org#Export Settings][#+INCLUDE:]].
|
[[file:setup-include.org][setup-include.org]] is the argument for [[info:org#Export Settings][#+SETUPFILE:]] *and* [[info:org#Export Settings][#+INCLUDE:]].
|
||||||
|
|
||||||
#+caption[Make setup and include file export keyword settings source block]:
|
#+caption[Make setup and include file export keyword settings source block]:
|
||||||
#+caption: The shell script to make the source block containing the export
|
#+caption: The shell script to make the source block containing the export
|
||||||
@ -1343,21 +1343,41 @@ first six lines of this [[file:README.org]] file. The last two lines show that
|
|||||||
#+end_src
|
#+end_src
|
||||||
:end:
|
:end:
|
||||||
|
|
||||||
Listing [[lst:setup-include-export-keyword-settings]], [[lst:use-latex-header-1]],
|
Listing [[lst:setup-include-export-keyword-settings]] tangles into the
|
||||||
[[lst:use-latex-header-2]], [[lst:use-latex-header-3]], and [[lst:use-latex-header-4]]
|
[[file:setup-include.org][setup-include.org]] file and listing [[lst:by-backend-kbd-org-macro]] defines
|
||||||
tangle into the [[file:setup-include.org][setup-include.org]] file.
|
the tools for the [[https://orgmode.org/][Org mode]] =kbd= macro in [[file:setup-include.org][setup-include.org]].
|
||||||
|
|
||||||
#+caption[Setup and include file export keyword settings]:
|
#+caption[Setup and include file export keyword settings]:
|
||||||
#+caption: Setup and include file export keyword settings.
|
#+caption: Setup and include file export keyword settings.
|
||||||
#+name: lst:setup-include-export-keyword-settings
|
#+name: lst:setup-include-export-keyword-settings
|
||||||
#+begin_src org
|
#+begin_src org
|
||||||
,#+babel: :cache no
|
,#+babel: :cache no
|
||||||
,#+macro: kbd (eval (by-backend (html (format "@@html:<kbd>%s</kbd>@@" (htmlize-protect-string $1))) (latex (format "@@latex:\\colorbox{PowderBlue}{\\texttt{%s}}@@" $1))))
|
,#+macro: kbd (eval (by-backend-kbd-org-macro $1))
|
||||||
,#+property: header-args:emacs-lisp :exports code :results silent :tangle init.el
|
,#+property: header-args:emacs-lisp :exports code :results silent :tangle init.el
|
||||||
,#+property: header-args:org :tangle setup-include.org
|
,#+property: header-args:org :tangle setup-include.org
|
||||||
,#+startup: content
|
,#+startup: content
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
#+caption[Define the tools of the org-mode =kbd= macro]:
|
||||||
|
#+caption: Define the tools for the org-mode =kbd= macro.
|
||||||
|
#+name: lst:by-backend-kbd-org-macro
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(with-eval-after-load 'ox
|
||||||
|
(autoload 'htmlize-protect-string "htmlize" nil t)
|
||||||
|
|
||||||
|
(defmacro by-backend (&rest body)
|
||||||
|
`(cl-case org-export-current-backend ,@body))
|
||||||
|
|
||||||
|
(defun by-backend-kbd-org-macro (keys)
|
||||||
|
(by-backend
|
||||||
|
(html (format "@@html:<kbd>%s</kbd>@@" (htmlize-protect-string keys)))
|
||||||
|
(latex (format "@@latex:\\colorbox{PowderBlue}{\\texttt{%s}}@@" keys)))))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
Listing [[lst:use-latex-header-1]], [[lst:use-latex-header-2]], [[lst:use-latex-header-3]],
|
||||||
|
and [[lst:use-latex-header-4]] tangle into the [[file:setup-include.org][setup-include.org]] file in order to
|
||||||
|
create the [[https://www.latex-project.org/][LaTeX]] preamble.
|
||||||
|
|
||||||
#+caption[LaTeX preamble: language, lists and floats]:
|
#+caption[LaTeX preamble: language, lists and floats]:
|
||||||
#+caption: LaTeX preamble: language, lists and floats.
|
#+caption: LaTeX preamble: language, lists and floats.
|
||||||
#+name: lst:use-latex-header-1
|
#+name: lst:use-latex-header-1
|
||||||
@ -1610,25 +1630,15 @@ Listing [[lst:emacs-lisp-setup-call]] initializes the buffer local variables
|
|||||||
,#+end_src
|
,#+end_src
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+caption[Specify export backend dependent header arguments]:
|
|
||||||
#+caption: Specify export backend dependent header arguments.
|
|
||||||
#+name: lst:header-arguments-by-backend
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(with-eval-after-load 'ox
|
|
||||||
(defmacro by-backend (&rest body)
|
|
||||||
`(cl-case org-export-current-backend ,@body)))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
This section updates the outdated [[https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#orgcc214c1][Worg: backend dependent execution]] example to
|
This section updates the outdated [[https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#orgcc214c1][Worg: backend dependent execution]] example to
|
||||||
Emacs-27.2 and Org-9.5.2. It shows how to export [[https://en.wikipedia.org/wiki/PGF/TikZ][PGF/TikZ]] images to:
|
Emacs-27.2 and Org-9.5.2. It shows how to export [[https://en.wikipedia.org/wiki/PGF/TikZ][PGF/TikZ]] images to:
|
||||||
1. [[https://en.wikipedia.org/wiki/PDF][PDF]] by embedding in [[https://www.latex-project.org/][LaTeX]].
|
1. [[https://en.wikipedia.org/wiki/PDF][PDF]] by embedding in [[https://www.latex-project.org/][LaTeX]].
|
||||||
2. [[https://en.wikipedia.org/wiki/HTML][HTML]] by passing from [[https://www.latex-project.org/][LaTeX]] by [[https://en.wikipedia.org/wiki/PDF][PDF]] and to [[https://en.wikipedia.org/wiki/Scalable_Vector_Graphics][SVG]].
|
2. [[https://en.wikipedia.org/wiki/HTML][HTML]] by passing from [[https://www.latex-project.org/][LaTeX]] by [[https://en.wikipedia.org/wiki/PDF][PDF]] and to [[https://en.wikipedia.org/wiki/Scalable_Vector_Graphics][SVG]].
|
||||||
Listing [[lst:backend-dependent-execution-update]] tangles to
|
Listing [[lst:backend-dependent-execution-update]] tangles to
|
||||||
[[file:worg-backend-dependent-execution-update.org][worg-backend-dependent-execution-update.org]] as either a standalone example or an
|
[[file:worg-backend-dependent-execution-update.org][worg-backend-dependent-execution-update.org]] as either a standalone example or an
|
||||||
example for inclusion. Listing [[lst:header-arguments-by-backend]] tangles to the
|
example for inclusion. Finally, inclusion of
|
||||||
=user-init-file= to make the convenience =by-backend= macro always available.
|
[[file:worg-backend-dependent-execution-update.org][worg-backend-dependent-execution-update.org]] produces here the figure with the
|
||||||
Finally, inclusion of [[file:worg-backend-dependent-execution-update.org][worg-backend-dependent-execution-update.org]] produces here
|
nodes 1, 2, 3, and 4:\\
|
||||||
the figure with the nodes 1, 2, 3, and 4:\\
|
|
||||||
#+include: worg-backend-dependent-execution-update.org
|
#+include: worg-backend-dependent-execution-update.org
|
||||||
How to include such figures as floats remains an open question.
|
How to include such figures as floats remains an open question.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user