"Pedro A. Aranda" <[email protected]> writes:
> Long list, thanks. Went through it, item per item.
> Current version in git reflects answers.
> Comments inline...
Thanks! I will first comment on your responses to the previous points
and then continue with second iteration of the review.
> > > +(defun string-or-null-p (object)
> > > + "Return non-nil when `object' is a string or nil"
> > > + (or (null object)
> > > + (stringp object)))
> >
> > Please remove. This is a function from subr.el. I am not sure why you
> > need to copy its definition.
>
> Wasn't sure it was there and included it therefore.
> Removed.
If you need some function from new versions of Emacs, copying it is not
the right approach. Instead, you should add compatibility wrapper into
org-compat.el. See inside for many examples. Typical approach is (1)
prefix function name with org-; (2) make it an alias when built-in Emacs
function is available; (3) use copied definition if built-in is not
available.
When you define a function as you did, it will create conflicts with
Emacs itself. For example, when Emacs changes the built-in function
definition (e.g. by fixing some bug), Org's version will re-define the
built-in, bringing the bug back not only for Org, but for all the uses
during Emacs session with Org mode loaded.
More generally, ignoring package namespace is a very bad practice in
Elisp. We should always prefix org functions with org-.
> I notice that you are using tabs for indentation. Our convention (and
> settings in .dir-locals.el) disable indent-tabs-mode.
Did you miss this comment?
> >> +(defcustom org-latex-babel-languages nil
> >> + "A string with the babel languages.
> >> +This is an alternative to adding the package in the LaTeX header"
> >> + :group 'org-export-latex
> >> + :package-version '(Org . "9.8")
> >> + :type '(choice (const :tag "No babel languages" nil)
> >> + (string :tag "babel language list"))
> >> + :safe #'string-or-null-p)
> >
> >This option is not used anywhere.
>
> Part of our discussions... commented out
Which discussion are you referring to?
> >You can use `org-string-nw-p'
>
> I'll keep it like that. The DOCSTRING was written to describe the logic and
> I think it is clean enough. ()
Ok.
> >Also, avoid TODO comments in the docstring. Instead, put them in the
> >code, if you think they are necessary and mark them FIXME:, not
> >TODO. TODO is way too common in org code as a keyword. FIXME is more
> distinct.
>
> Done.
Not fully. You missed `org-latex--get-doc-scripts'. There is still a
FIXME inside docstring.
> > More generally, please review the docstrings to follow the Elisp
> > conventions I linked to earlier.
>
> In progress...
M-x checkdoc can help.
> >You can simply use `concat'. (concat "a" nil "b") => "ab"
>
> You may, but this will be easier to remember (IMHO)
A slight downside is overhead creating a new buffer. Not major though. I
will not object.
> >> (unicode-math-options nil) ;; TODO
> >
> >What does this TODO mean?
>
> I leave these options FFS
Then one alternative comment: Please use FIXME: instead of TODO. Search
code for TODO in Org will yield way too many irrelevant matches (TODO keywords).
FIXME is more unique.
> >> ;; These change inside `with-temp-buffer'
> >> (fontspec-config org-latex-fontspec-config)
> >
> >You can actually do (org-latex-fontspec-config org-latex-fontspec-config)
> >That will make it unnecessary to invent new variable names.
>
> Let's keep this for a second iteration... It doesn't harm, does it?
That's optional suggestion, but IMHO it will make things more
readable. For example, a typical workflow for looking how
org-latex-fontspec-config is used in the code is grepping the file for
its instances. When you let-bind it to other variable name, grepping no
longer works so easier, and you need to check for those extra local names
separately. IMHO as a person who had to read a lot of code in Org
codebase.
> >> (warn "polyglossia isn't supported by pdflatex!"))
> >*Polyglossia
> >Messages in Emacs start from capital letter.
>
> Reworded: Polyglossia with capital P looks strange to me.
Yeah, but you will otherwise get compiler warnings :)
An alternative is (with-no-warnings (warn "...")) - suppress compiler
warnings for this particular line of code.
> >> ;; Insert newline at the beginning to avoid too many empty lines
> in the export
> >> (cl-loop for lang in polyglossia-list do
> >
> > This comment does not seem relevant.
>
> Made sense to me while coding...
I think you can simply move the comment closer to where you actually add
that newline at the beginning.
> >> (insert (format "\n\\set%slanguage%s{%s}"
> >> lang-type
> >> (org-latex--mk-options lang-variant)
> >> lang))
> >> (setq lang-type "other")))
> >
> >I suggest moving let-binding of LANG-TYPE variable close to this part of
> >the code. It is only used here anyway. AFAIR, you can probably define it
> >right inside cl-loop (via let keyword).
>
> I moved the binding to the beginning of the loop. The docs on cl-loop
> are not
> self-evident.
5.7.6 Other Clauses
-------------------
This section describes the remaining loop clauses.
‘with VAR = VALUE’
This clause binds a variable to a value around the loop, but
otherwise leaves the variable alone during the loop. The following
loops are basically equivalent:
(cl-loop with x = 17 do ...)
(let ((x 17)) (cl-loop do ...))
(cl-loop for x = 17 then x do ...)
;)
`let' right around cl-loop will also do.
> >> (defun org-latex--babel-langs-as-option(langs)
> >
> >This function is not used anywhere in the code.
>
> Commented out. (2140)
Why not removed? Do you plan changes that will use this function?
> >> ;; Tracing lost chars:
> https://tex.stackexchange.com/questions/548901
> >> ;; TODO: do we really need fontspec??
> >> (insert "\\tracinglostchars=2\n%%\\usepackage{fontspec}")
> >
> > What is this TODO about?
>
> Including fontspec seems sometimes redundant, but I'm still not 100% fine
> with not including it because of tracinglostchars.
Does \tracinglostchars have anything to do with fontspec package? It
seems to be a TeX primitive:
https://tug.org/utilities/plain/cseq.html#tracinglostchars-rp
Also, what about \tracinglostchars=3 (throw an error when there is
missing char)?
> >> (insert (format"\n\\babelprovide[main,import]{%s}"
> (org-latex--get-babel-lang (pop latex-babel-langs))))
> >
> >Please do not use pop. It will modify the list by side effect and might
> >modify the actual customization by reference chain.
>
> This is why I 'duplicate' variables in the let binding. Try this:
> (setq test-list '("How" "do" "you" "do?"))
> (let ((test-copy test-list))
> (message "Inside let, before pop -> %s" test-copy)
> (pop test-copy)
> (message "Inside let, after pop -> %s" test-copy))
> (message "Outside let -> %s" test-list)
You are right, but that only works because how the code is written
now. To avoid future regression I'd prefer to not use pop when not
necessary. In this particular case, a simple (car ...) and (cdr ...)
will work just fine, AFAIU. We should generally be careful with
functions that modify things by side effect. Bugs arising from their
misuse are often hard to debug.
> > > (cl-loop for bab-lang in latex-babel-langs
> >
> > Using cl-loop here is an overkill. Just do
> >
> > (dolist (babel-lang latex-babel-langs) ...)
>
> AFAIU it will translate into dolist internally. Since I'm also using it
>
> for (cl-loop for (key . val) in alist ...
>
> I was using it to make the function more uniform as for the number of
> constructs it uses. It makes it easier to read (for me) and therefore
> to program.
As a general stylistic rule, we should use simpler constructs when we
can. Some people have trouble reading cl-loop constructs, and we should
only use it when it clearly benefits the code. IMHO inherited from
Nicolas.
> > Also, you seem to be shortening the variable names. IMHO, it is not
> > desirable as it reduces readability. I prefer to have more readable
> > (even if verbose) variable names in the code. This makes reading the
> > code easier.
>
> See above. Just being defensive, to avoid potential side effects.
> IMvHO readability is marginally affected and the gain is worth it.
FYI, I had hard time parsing what "fbf-fname" and friends mean.
> > (let* ((props (alist-get bab-lang doc-babel-font-config nil nil #'string=))
> > (provide (or (plist-get props :provide) "import"))) ...)
>
> What would happen in `props' is nil?
(alist-get "foo" nil nil nil #'string=) ; => nil
> >>Why are you talking about using polyglossia in
> > (defun org-latex--lualatex-fontspec-config (info)
> > "Returns the font prelude when we are on Lua/XeLaTeX and
> > we are using neither bale nor polyglossia"
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> To stress that it is a fontspec-only. Anyhow, changed...
I did not mean that it needs to be changed. Just highlighted that the
commentary contradicted the docstring.
> >> (when fallback-alist
> >> (unless (equal compiler "lualatex")
> >> (setq fallback-alist nil)
> >> (warn "Fallback fonts only work with lualatex!")))
> >
> >AFAIU, this warning will be displayed every single time latex export is
> >using xelatex, if there are fallback fonts in the fontspec-config. Is it
> >really desired? Should be there an option to provide separate fontspec
> >configuration to xelatex?
>
> Well, I'd rather keep it. If someone doesn't fully understand this and
> keeps trying to use xelatex with fallbacks, he should be warned each
> single time.
It is fine to keep the warning, but what should be done for someone who
uses both lualatex and xelatex? The configuration is shared.
> >> ;; TODO: what about xpinyin??
> >
> >Why would you need xpinyin? It add latex commands to provide pinyin
> >spelling of Chinese characters. AFAIU, it does not do anything
> >automatically; you need to explicitly put a command. So, it does not
> >seem necessary for automatic font configuration.
>
> Not now. But why not let the possibility open and point to a
> a possible place in the code to add it in the future?
But why should we? There is org-latex-packages-alist where users can add
default packages. xpinyin might (or might not) be a nice default package
to load, by it has little to do with babel/polyglossia/font configuration.
-----
Now, next set of comments on the updated code.
> (defcustom org-latex-multi-lang nil
> "The multi-lingual support package used by the LaTeX backend.
> Can also be set in buffers via #+LATEX_MULTI_LANG.
>
> Possible values are \"polyglossia\",\"babel\" , \"fontspec\" or nil.
> \"polyglossia\" activates new implementation for polyglossia,
> \"babel\" activates new implementation for babel
> t activates new font/multi-lingual support,
t is leftover from previous iterations and should be removed.
Also, "new implementation" sounds strange.
I think "multi-lingual support package" is self-evident. We should only
really explain nil value.
> (defun list-or-null-p (object)
> "Return non-nil when `object' is a list or nil"
> (or (null object)
> (listp object)))
Please avoid polluting global namespace. Rename to org-list-or-null-p.
Also, if we do introduce a generic function like org-list-or-null-p, it
should live in org-macs.el.
> FIXME: Ignore text that will not be exported. (somehow difficult though)
What about searching inside LaTeX CONTENTS rather than inside the Org source?
> (defun org-latex--fontenc-options (langs)
> "Return options string for LANGS for the fontenc package.
> The first language in LANGS is considered the default language."
Note that change in the docsting. I re-worded it to (1) make sure that
the first line is a full sentence and does not exceed column-width; (2)
Avoid describing the technical implementation of the function; just
logic.
> (let* ((lang-list (if (stringp langs) (string-split langs "," t) langs))
> (enc-list (mapcar #'org-latex--pdflatex-encode lang-list)))
> (org-latex--mk-options (reverse (seq-uniq enc-list)))))
I think that stringp check is not necessary as LANGS passed to this
function is always a list.
> (defun org-latex--pdflatex-ldf (lang)
> ...
Cleaned up docstring and the code:
(defun org-latex--pdflatex-ldf (lang)
"Return ldf code for LANG from :babel property in `org-latex-language-alist'.
Triggers an error for languages that are not based on ldf files. See
https://latex3.github.io/babel/guides/which-method-for-which-language.html"
(if-let* ((lang-plist (alist-get (string-trim lang) org-latex-language-alist
nil nil #'string=))
(babel-lang (plist-get lang-plist :babel)))
babel-lang
(error "No ldf method for pdflatex and LANG=%s" lang)))
> (with-temp-buffer
> (goto-char (point-min))
I think that goto-char is redundant. with-temp-buffer will create new
empty buffer anyway.
> (when multi-lang
> (insert "%% \\usepackage[utf8]{inputenc}\n")
Why do you need to insert a commented-out usepackage call?
> (let ((def-feat-list
> (cl-loop for (feat . val) in current-default-features
> collect (concat feat "=" val) into result
> finally return (mapconcat #'identity result ",\n "))))
> (insert (format "\n\\defaultfontfeatures{\n %s\n}"
> def-feat-list))))
What about
(insert (format "\n\\defaultfontfeatures{\n %s\n}}"
(mapconcat (pcase-lambda (`(,feature . ,value)) (concat feature
"=" value))
current-default-features ",\n ")))
(The same for `org-latex--lualatex-fontspec-config')
> (let* ((lang-list (assoc lang org-latex-language-alist))
> (lang-plist (cdr lang-list))
(let* ((lang-plist (alist-get lang org-latex-language-alist nil nil #'equal))
> (let ((lang-tag lang))
> ;; (message "new font family: (%s . %s)" lang props)
> (if-let* ((lang-alist (assoc lang org-latex-language-alist))
> (lang-plist (cdr lang-alist)))
> (setq lang-tag (plist-get lang-plist :polyglossia)))
> ;; (message "polyglossia language name is %s" lang-tag)
> (insert (format "\n\\newfontfamily{\\%sfont%s}%s{%s}"
Should the above comments be removed?
> do (let* ((props (alist-get bab-lang doc-babel-font-config nil
> nil #'string=))
> (provide (when props (plist-get props :provide))))
> ;; \\babelprovide needs language and provide
> ;; it doesn't work on the default language
> (unless provide
> (setq provide "import"))
When PROPS is nil, plist-get will always return nil. So
(provide (or (plist-get props :provide) "import)) will work.
Indeed (or (plist-get nil :provide) "import") ; => "import"
> (dolist (fconfig current-fontspec-config)
> (when-let* ((fname (car fconfig))
> (config-plist (cdr fconfig))
> (fallback (plist-get config-plist :fallback)))
> (push (cons fname (concat "fallback_" fname)) fallback-alist)))
Here, you can use cl-loop, I think :)
> (defun org-latex--get-lang (lang)
I suggest renaming LANG to LANGS. That will make it more clear that the
value is expected to be a list.
Finally, see the attached amendments to the docstrings and comments.
>From 58ed59c21883768b58d8107072215789c77c2edf Mon Sep 17 00:00:00 2001
Message-ID: <58ed59c21883768b58d8107072215789c77c2edf.1762082701.git.yanta...@posteo.net>
From: Ihor Radchenko <[email protected]>
Date: Sun, 2 Nov 2025 12:24:38 +0100
Subject: [PATCH] lisp/ox-latex.el: Fix formatting of some docstrings and FIXME
comments
---
lisp/ox-latex.el | 141 +++++++++++++++++++++--------------------------
1 file changed, 64 insertions(+), 77 deletions(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 8194fae23..a4c4e429c 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1584,13 +1584,12 @@ (defun list-or-null-p (object)
(listp object)))
(defcustom org-latex-fontspec-config nil
- "This variable stores the configuration for the fontspec package.
-By default, this variable is set to nil to generate no configuration.
-
-Each element is defined as
-(`font-name' . `font-plist')
- where `font-name' is the name in `\\set...font{}'
- and `font-plist' is a plist. The keys for this plist are
+ "Configuration for the fontspec package.
+When nil, generate no configuration.
+When non-nil, should be an alist with elements defined as
+\\(FONT-NAME . FONT-PLIST)
+FONT-NAME is a string - is the name in `\\set...font{}'
+FONT-PLIST is a plist. The keys for this plist are
`:font': system font name (mandatory)
`:features': string or list of strings with font features.
A potential fallback will be appended.
@@ -1600,7 +1599,7 @@ (`font-name' . `font-plist')
For example, this could be placed in your .dir-locals.el:
-((org-mode
+\\((org-mode
. ((org-latex-fontspec-config
. ((\"main\" :font \"TeXGyreSchola\")
(\"sans\" :font \"TeXGyreHeros\"
@@ -1616,15 +1615,15 @@ ((org-mode
:safe #'list-or-null-p)
(defcustom org-latex-fontspec-default-features nil
- "This variable stores the list of default features for the fontspec package.
+ "List of default features for the fontspec package.
When nil, no default features are assumed.
-Else it is an associative list of strings (FEATURE . VALUE) that is used to
-generate:
+When non-nil, the value should be an alist of (FEATURE . VALUE) that is
+used to generate:
\\defaultfontfeatures{FEATURE=VALUE,...}
in the LaTeX header.
-"
+FEATURE and VALUE should be strings."
:group 'org-export-latex
:package-version '(Org . "9.8")
:type '(choice (const :tag "No template" nil)
@@ -1632,14 +1631,12 @@ (defcustom org-latex-fontspec-default-features nil
:safe #'list-or-null-p)
(defcustom org-latex-polyglossia-font-config nil
- "This variable stores the font specifications for polyglossia.
-By defauly, this variable is set to nil to generate no configuration.
-
-It is an associative list, where each element is defined as
-(`language' . `lang-plist')
-where
-`language' is the language name as a string (e.g. \"english\") and
-`lang-plist' is the language plist, with the following keys:
+ "Font specifications for polyglossia.
+When nil, generate no configuration.
+When non-nil, the value should be an alist, where each element is
+defined as (LANGUAGE . LANG-PLIST).
+LANGUAGE is the language name as a string (e.g. \"english\") and
+LANG-PLIST is the language plist, with the following keys:
`:font': a string with the system font name, mandatory
`:variant': a string for the font variant, (e.g. \"sf\", \"tt\", etc.)
`:tag': a string will substitute the language in the font definition.
@@ -1657,8 +1654,7 @@ (`language' . `lang-plist')
(\"hebrew\" :variant \"tt\"
:props \"Script=Hebrew\" :font \"Noto Mono Hebrew\")
in
- \\newfontfamily{\\hebrewfonttt}[Script=Hebrew]{Noto Mono Hebrew}
-"
+ \\newfontfamily{\\hebrewfonttt}[Script=Hebrew]{Noto Mono Hebrew}"
:group 'org-export-latex
:package-version '(Org . "9.8")
:type '(choice (const :tag "No polyglossia font config" nil)
@@ -1666,24 +1662,23 @@ (`language' . `lang-plist')
:safe #'list-or-null-p)
(defcustom org-latex-babel-font-config nil
- "A property list array to map babel language names to the fonts
-used when exporting to babel. Each entry maps a string with the
-language name to a `:fonts' property list:
- (ORG-LANG :fonts (PLIST))
-Use nil in ORG-LANG for the document's default fonts.
-
-Each element in the `:fonts' property list has the form
-(SCRIPT FONT-PLIST).
- SCRIPT is one of the script codes:
+ "Mapping of language names to fonts when using babel.
+Each entry maps a string with the
+language name to a `:fonts' property list: (ORG-LANG :fonts FONTS)
+ORG-LANG is a language name as defined in `org-latex-language-alist'.
+ORG-LANG can also be nil for the document's default fonts.
+
+Each element in FONTS is (SCRIPT . FONT-PLIST).
+SCRIPT is one of the script codes:
\"rm\" for the roman (serif) font
\"sf\" for the sans serif font
\"tt\" for the teletype (monospaced) font.
-FONT-PLIST is a property list containing a mandatory property `:font' with a
-system font name and an optional property `:props' which is either a
-string or a list of strings storing extra properties to control the
-font's appearance. For example:
+FONT-PLIST is a property list containing a mandatory property `:font'
+with a system font name and an optional property `:props' which is
+either a string or a list of strings storing extra properties to
+control the font's appearance. For example:
-((nil
+\\((nil
:fonts
((\"rm\" :font \"CMU Serif\")
(\"tt\" :font \"DejaVu Sans Mono\" :props \"Scale=MatchLowercase\"))))
@@ -1691,7 +1686,6 @@ ((nil
indicates that the default roman font is CMU Serif and that the default
monotype font, DejaVu Sans Mono, needs to be scaled to better match the
roman font's appearance."
-
:group 'org-export-latex
:package-version '(Org . "9.8")
:type '(choice (const :tag "No babel font config" nil)
@@ -1967,14 +1961,13 @@ (defun org-latex--get-doc-scripts ()
scripts))
(defun org-latex--mk-options (opts)
- "Return a string that is interpreted as an options string
-in LaTeX from OPTS, e.g [opt] or [opt1,opt2].
+ "Return an options string for LaTeX from OPTS, e.g [opt] or [opt1,opt2].
Return empty string if OPTS is nil or a zero-length string.
If OPTS is a non-empty string, enclose it in square brackets.
-If OPTS is a list of strings, trim each string in the list
-before concatenating to a comma separated list and
-returning the list enclosed in square brackets."
+If OPTS is a list of strings, trim each string in the list before
+concatenating to a comma-separated list and returning the list
+enclosed in square brackets."
(cond ((null opts) "")
((stringp opts) (if (length= opts 0 ) "" (format "[%s]" opts)))
(t (format "[%s]" (mapconcat #'string-trim opts ",")))))
@@ -1982,8 +1975,8 @@ (defun org-latex--mk-options (opts)
(defun org-latex--pdflatex-encode (lang)
"Return the encoding for pdflatex based on LANG.
-Gets the :fontenc property from `org-latex-language-alist' and
-signals an error if it is not defined."
+Get the :fontenc property from `org-latex-language-alist' and signal
+an error if it is not defined."
;; FIXME: more languages and possible error conditions.
(let ((candidate))
(if-let* ((lang (string-trim lang))
@@ -2031,14 +2024,14 @@ (defun org-latex--babel-ldf-list (langs)
(mapconcat #'org-latex--pdflatex-ldf langs ","))))
(defun org-latex--pdflatex-fontconfig (info)
- "Return a string with the font configuration prelude for pdflatex,
-extracting the information from INFO.
+ "Return the font configuration preamble for pdflatex.
+Extract the information from INFO.
-pdflatex and babel play together, but we will only return a basic version,
-of the babel header, defining languages. Font definitions imply fontspec,
-and that cannot be used with pdf-latex.
+pdflatex and babel play together, but we will only return a basic
+version, of the babel header, defining languages. Font definitions
+imply fontspec, and that cannot be used with pdf-latex.
-Using babel is only possible when you are sure that the ldf method can be used."
+Using babel is only possible when ldf method can be used."
(let ((latex-langs (plist-get info :languages))
(multi-lang (plist-get info :latex-multi-lang)))
(with-temp-buffer
@@ -2051,11 +2044,11 @@ (defun org-latex--pdflatex-fontconfig (info)
(buffer-string))))
(defun org-latex--lualatex-polyglossia-config (info)
- "Return a string with the prelude part for polyglossia for lualatex or
-xelatex using the document information from INFO."
+ "Return preamble part for polyglossia for lualatex or xelatex.
+Extract the information from INFO."
(let* ((compiler (plist-get info :compiler))
(polyglossia-list (plist-get info :languages))
- ;; TODO: Read more about unicode-math and its options
+ ;; FIXME: Read more about unicode-math and its options
(unicode-math-options nil)
;; These change inside `with-temp-buffer'
(fontspec-config org-latex-fontspec-config)
@@ -2139,28 +2132,23 @@ (defun org-latex--get-babel-lang (lang &optional default-lang)
;; ","))
(defun org-latex--lualatex-babel-config (info)
- "Return a string with the preamble part for
-babel on lualatex/xelatex.
-
-Prefer #+LATEX_COMPILER: over `org-latex-compiler' and
-and #+LANGUAGE over `org-export-default-language'.
+ "Return preamble for babel on LuaLaTeX/XeLaTeX.
+INFO is the export communication channel.
The structure is intended to cover most examples from URL
`https://github.com/latex3/babel/tree/main/samples.'
-Use fontspec as a last resort and when defined.
-"
-
+Use fontspec as a last resort and when defined."
(let* ((compiler (plist-get info :latex-compiler))
(latex-babel-langs (plist-get info :languages))
(doc-fontspec org-latex-fontspec-config)
(doc-babel-font-config org-latex-babel-font-config)
(babel-options (concat "bidi=" (if (equal compiler "lualatex") "basic" "default")))
- (unicode-math-options nil)) ;; TODO: define document option for this
+ (unicode-math-options nil)) ;; FIXME: define document option for this
(with-temp-buffer
(goto-char (point-min))
;; Tracing lost chars: https://tex.stackexchange.com/questions/548901
- ;; TODO: do we really need fontspec??
+ ;; FIXME: do we really need fontspec??
(insert "\\tracinglostchars=2\n%%\\usepackage{fontspec}")
;; do *not* include languages here
(insert (format "\n\\usepackage%s{babel}" (org-latex--mk-options babel-options)))
@@ -2195,7 +2183,7 @@ (defun org-latex--lualatex-babel-config (info)
(org-latex--mk-options props)
font))))))
;; Last resort... use fontspec-config if no babel specific fonts are defined
- ;; TODO: check if fallbacks are accepted, call fontspec config instead earlier
+ ;; FIXME: check if fallbacks are accepted, call fontspec config instead earlier
(unless doc-babel-font-config
(cl-loop for (fname . fprops) in doc-fontspec
do (let ((font (plist-get fprops :font))
@@ -2204,15 +2192,15 @@ (defun org-latex--lualatex-babel-config (info)
(buffer-string))))
(defun org-latex--lualatex-fontspec-config (info)
- "Return the font preamble when we are on Lua/XeLaTeX
-rely on fontspec only."
+ "Return the font preamble for Lua/XeLaTeX relying on fontspec only.
+INFO is the export communication channel."
(let ((compiler (plist-get info :latex-compiler))
;; Copy these to temp variable... (with-temp-buffer) overwrites them
(current-fontspec-config org-latex-fontspec-config)
(current-default-features org-latex-fontspec-default-features)
(doc-scripts (org-latex--get-doc-scripts))
;;
- (unicode-math-options nil) ;; TODO add unicode-math features to config
+ (unicode-math-options nil) ;; FIXME: add unicode-math features to config
(cjk-packages nil) ;; will we need the packages to support CJK fonts?
(directlua nil) ;; Did we write the \\directlua{} block?
(fallback-alist)) ;; an alist (font_name . fallback-name)
@@ -2279,7 +2267,7 @@ (defun org-latex--lualatex-fontspec-config (info)
;; it is assumed to be a font name that needs it at the end
(unless (string-match-p ":" fname)
(setq fname (concat fname ":")))
- ;; TODO; when (car fpair) in document charsets
+ ;; FIXME: when (car fpair) in document charsets
(insert (format " \"%s\",\n" fname)))
(insert " })\n")))))
(when directlua ;; if we have found any lua fallbacks, close the lua block
@@ -2309,19 +2297,19 @@ (defun org-latex--lualatex-fontspec-config (info)
(message "Adding the CJK packages")
(goto-char (point-min))
(forward-line 2)
- ;; TODO: what about xpinyin??
+ ;; FIXME: what about xpinyin??
(insert "\\usepackage[CJKspace]{xeCJK}\n"))
(buffer-string))))
(defun org-latex-fontspec-to-string (info)
"Return the font preamble for the current buffer as a string.
+INFO is the export communication channel.
Dispatches to the different preamble generation routines depending
on the current LaTeX compiler and language support backend.
-If `org-latex-multi-lang' is nil, return an empty string
-and rely on the legacy routines for language and babel guessing.
-"
+If `org-latex-multi-lang' is nil, return an empty string and rely on the
+legacy routines for language and babel guessing."
(let ((compiler (plist-get info :latex-compiler))
(multi-lang (plist-get info :latex-multi-lang)))
(cond ((null multi-lang) "") ;; delegate
@@ -2333,12 +2321,11 @@ (defun org-latex-fontspec-to-string (info)
(org-latex--lualatex-polyglossia-config info))
(t ;; else lualatex or xelatex with fontspec
(org-latex--lualatex-fontspec-config info)))))
-;;
-;;
+
(defun org-latex--keep-pkg (pkg use-driver)
- "This function filters out the font management packages.
-Keep the package if we are in legacy mode or
-if it is not a font management package."
+ "Return non-nil, when PKG is not automatically loaded.
+Keep the package if we are in legacy mode (USE-DRIVER is nil) or if it
+is not a font management package."
(or (null use-driver)
(not (member-ignore-case pkg '("fontenc" "fontspec" "inputenc" "unicode-math")))))
--
2.50.1
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>