mirror of
https://github.com/protesilaos/denote.git
synced 2026-09-15 09:46:24 -04:00
Refactor denote-retrieve-filename-title
We now return an empty string if no title is present. This makes the behaviour consistent with 'denote-retrieve-filename-keywords' and 'denote-retrieve-filename-signature'. The use of 'file-name-base' is now subject to a non-nil optional argument. This makes it easier for the caller to handle cases as they see fit.
This commit is contained in:
parent
b13d899c01
commit
a44600b4fa
14
README.org
14
README.org
|
|
@ -3905,15 +3905,19 @@ might change them without further notice.
|
|||
~denote-create-unique-file-identifier~ function.
|
||||
|
||||
#+findex: denote-retrieve-filename-title
|
||||
+ Function ~denote-retrieve-filename-title~ :: Extract title from
|
||||
=FILE= name, else return ~file-name-base~. Run ~denote-desluggify~
|
||||
on the title if the extraction is successful.
|
||||
+ Function ~denote-retrieve-filename-title~ :: Extract Denote title
|
||||
component from =FILE= name, else return an empty string. With
|
||||
optional =FILE-NAME-BASE-FALLBACK= return ~file-name-base~ if no
|
||||
Denote title component exists. If the extraction is succcessful
|
||||
(when no ~file-name-base~ is involved) run ~denote-desluggify~ on
|
||||
the title. [ Revised as part of {{{development-version}}} to return
|
||||
an empty string if no title is present and to make the use of
|
||||
~file-name-base~ optional. ]
|
||||
|
||||
#+findex: denote-retrieve-filename-keywords
|
||||
+ Function ~denote-retrieve-filename-keywords~ :: Extract keywords
|
||||
from =FILE= name, if present, else return an empty string. Return
|
||||
matched keywords as a single string. [ Part of
|
||||
{{{development-version}}} . ]
|
||||
matched keywords as a single string. [ Part of {{{development-version}}} . ]
|
||||
|
||||
#+findex: denote-retrieve-filename-signature
|
||||
+ Function ~denote-retrieve-filename-signature~ :: Extract signature
|
||||
|
|
|
|||
28
denote.el
28
denote.el
|
|
@ -1415,15 +1415,23 @@ Return matched keywords as a single string."
|
|||
(match-string 1 filename)
|
||||
"")))
|
||||
|
||||
(defun denote-retrieve-filename-title (file)
|
||||
"Extract title from FILE name, else return `file-name-base'.
|
||||
Run `denote-desluggify' on title if the extraction is sucessful."
|
||||
(if-let (((file-exists-p file))
|
||||
((denote-file-has-identifier-p file))
|
||||
((string-match denote-title-regexp file))
|
||||
(title (match-string 1 file)))
|
||||
(denote-desluggify title)
|
||||
(file-name-base file)))
|
||||
(defun denote-retrieve-filename-title (file &optional file-name-base-fallback)
|
||||
"Extract Denote title component from FILE name, else return an empty string.
|
||||
|
||||
With optional FILE-NAME-BASE-FALLBACK return `file-name-base' if
|
||||
no Denote title component exists.
|
||||
|
||||
If the extraction is succcessful (when no `file-name-base' is
|
||||
involved) run `denote-desluggify' on the title"
|
||||
(unless (file-exists-p file)
|
||||
(error "%s does not exist as a file" file))
|
||||
(cond
|
||||
((and (denote-file-has-identifier-p file)
|
||||
(string-match denote-title-regexp file))
|
||||
(denote-desluggify (match-string 1 file)))
|
||||
(file-name-base-fallback
|
||||
(file-name-base file))
|
||||
(t "")))
|
||||
|
||||
(defun denote--file-with-temp-buffer-subr (file)
|
||||
"Return path to FILE or its buffer together with the appropriate function.
|
||||
|
|
@ -1496,7 +1504,7 @@ that internally)."
|
|||
(title (denote-retrieve-title-value file type))
|
||||
((not (string-blank-p title))))
|
||||
title
|
||||
(denote-retrieve-filename-title file)))
|
||||
(denote-retrieve-filename-title file :file-name-base-as-fallback)))
|
||||
|
||||
(defun denote--retrieve-location-in-xrefs (identifier)
|
||||
"Return list of xrefs for IDENTIFIER with their respective location.
|
||||
|
|
|
|||
Loading…
Reference in a new issue