Introduce new autodetect in headings customisation

This commit is contained in:
TEC 2024-06-08 22:41:12 +08:00
parent 1b9b7fd3d1
commit 421c13f80d
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
3 changed files with 16 additions and 6 deletions

View File

@ -94,6 +94,10 @@ If nil, they will be recognised anywhere in the document."
"Pick up on terms in plain text."
:type 'boolean)
(defcustom org-glossary-autodetect-in-headings nil
"Whether `org-glossary-automatic' should apply in headings."
:type 'boolean)
(defcustom org-glossary-plural-function #'org-glossary-english-plural
"A function which generates the plural form of a word."
:type 'function)
@ -759,7 +763,8 @@ When KEEP-UNUSED is non-nil, unused terms will be included in the result."
element-context (org-element-context element-at-point)))
(cond
((or (org-glossary--within-definition-p element-context)
(eq 'headline (org-element-type element-at-point))
(and (not org-glossary-autodetect-in-headings)
(eq 'headline (org-element-type element-at-point)))
(and (eq 'keyword (org-element-type element-at-point))
(not (member (org-element-property :key element-at-point)
org-element-parsed-keywords))))
@ -1756,7 +1761,8 @@ This should only be run as an export hook."
(setq element-at-point (org-element-at-point)
element-context (org-element-context element-at-point))
(when (and (not exit)
(not (eq 'headline (org-element-type element-at-point)))
(not (and (not org-glossary-autodetect-in-headings)
(eq 'headline (org-element-type element-at-point))))
(memq 'link (org-element-restriction element-context))
(if (eq 'keyword (org-element-type element-at-point))
(member (org-element-property :key element-at-point)

View File

@ -305,8 +305,10 @@ org-glossary-update-terms= first).
Note that as Org Glossary relies on links, recognised usages can only occur in
places where a link is appropriate (i.e. not inside a source block, verbatim
text, or another link, etc.). In addition terms in headings are ignored, as this
is considered broadly desirable.
text, or another link, etc.). The variable ~org-glossary-autodetect-in-headings~
determines whether terms in headings are automatically linked. By default, this
is off and headings are ignored, since this behaviour is generally seen as
undesirable.
In addition to all this, there's a bit of special behaviour for indexing. As
you can discuss a topic without explicitly stating it, we support

View File

@ -428,8 +428,10 @@ org-glossary-update-terms} first).
Note that as Org Glossary relies on links, recognised usages can only occur in
places where a link is appropriate (i.e. not inside a source block, verbatim
text, or another link, etc.). In addition terms in headings are ignored, as this
is considered broadly desirable.
text, or another link, etc.). The variable @code{org-glossary-autodetect-in-headings}
determines whether terms in headings are automatically linked. By default, this
is off and headings are ignored, since this behaviour is generally seen as
undesirable.
In addition to all this, there's a bit of special behaviour for indexing. As
you can discuss a topic without explicitly stating it, we support