Auto-add :only-contents with #+glossary_sources

This commit is contained in:
TEC 2022-07-10 11:58:21 +08:00
parent 956cdacf38
commit 0c4ce4c14e
Signed by: tec
GPG Key ID: 779591AFDB81F06C
3 changed files with 17 additions and 5 deletions

View File

@ -1688,8 +1688,12 @@ location."
(mapcar
(lambda (source-short)
(let ((fq-source (concat org-glossary-collection-root source-short)))
(if (file-exists-p (concat fq-source ".org"))
(concat fq-source ".org") fq-source)))
(cond
((file-exists-p (concat fq-source ".org"))
(concat fq-source ".org"))
((string-match-p "\\.org::[*#]." fq-source)
(concat fq-source " :only-contents t"))
(t fq-source))))
(org-babel-balanced-split
(or (org-element-map (org-element-parse-buffer) 'keyword
(lambda (keyword)

View File

@ -139,7 +139,7 @@ This would be equivalent to:
#+begin_example
,#+include: COLLECTION-ROOT/abbrevs.org
,#+include: COLLECTION-ROOT/physics.org::*Quantum
,#+include: COLLECTION-ROOT/physics.org::*Quantum :only-contents t
,#+include: COLLECTION-ROOT/foo.org
,#+include: COLLECTION-ROOT/bar.org
#+end_example
@ -148,6 +148,10 @@ You could also set to an individual file with the beginning of a heading
specification, say ~file.org::*~. This would allow you to have all the terms
defined in one file and include groups by heading.
Not that sources with heading/custom-id searches will automatically have
=:only-contents t= added (as seen in the example). This allows for named headings
with glossary subheadings to work when ~org-glossary-toplevel-only~ is set.
*** Basic definitions
Org already has a very natural structure for term-definition associations,

View File

@ -246,7 +246,7 @@ This would be equivalent to:
@example
#+include: COLLECTION-ROOT/abbrevs.org
#+include: COLLECTION-ROOT/physics.org::*Quantum
#+include: COLLECTION-ROOT/physics.org::*Quantum :only-contents t
#+include: COLLECTION-ROOT/foo.org
#+include: COLLECTION-ROOT/bar.org
@end example
@ -255,6 +255,10 @@ You could also set to an individual file with the beginning of a heading
specification, say @code{file.org::*}. This would allow you to have all the terms
defined in one file and include groups by heading.
Not that sources with heading/custom-id searches will automatically have
@samp{:only-contents t} added (as seen in the example). This allows for named headings
with glossary subheadings to work when @code{org-glossary-toplevel-only} is set.
@node Basic definitions
@subsection Basic definitions
@ -742,7 +746,7 @@ instead make use of @code{setcdr} or @code{plist-put} like so:
(let ((latex-dspec (alist-get t (alist-get 'latex org-glossary-export-specs))))
(plist-put latex-dspec :backref "gls-%k-use-%r")
(plist-put latex-dspec :definition-structure
"*%d*\\emsp@{@}%v\\ensp@{@}@@@@latex:\\labelcpageref@{@@@@%b@@@@latex:@}@@@@"))
"*%d*\\emsp@{@}%v\\ensp@{@}@@@@latex:\\ifnum %n>0 \\labelcpageref@{@@@@%b@@@@latex:@}\\fi@@@@\n"))
@end example
This allows for any change in other backends or the defaults you're not