[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote a44600b4fa 11/19: Refactor denote-retrieve-filen
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote a44600b4fa 11/19: Refactor denote-retrieve-filename-title |
Date: |
Sat, 2 Dec 2023 03:57:53 -0500 (EST) |
branch: externals/denote
commit a44600b4fac9f5e4ac5a351da8dda510bba8274c
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
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.
---
README.org | 14 +++++++++-----
denote.el | 28 ++++++++++++++++++----------
2 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/README.org b/README.org
index 260a80dec6..f435a1d08e 100644
--- a/README.org
+++ b/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
diff --git a/denote.el b/denote.el
index 93cb46b8e4..86157b5343 100644
--- a/denote.el
+++ b/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.
- [elpa] externals/denote updated (529de46e1a -> 8ae30d4db9), ELPA Syncer, 2023/12/02
- [elpa] externals/denote fe870655a3 04/19: Add comment about denote--link-get-description-with-signature link format, ELPA Syncer, 2023/12/02
- [elpa] externals/denote 8ae30d4db9 19/19: Add faces for the files shown in various rename prompts, ELPA Syncer, 2023/12/02
- [elpa] externals/denote 1f3d3b05d6 14/19: Remove reference to obsolete denote-dired-rename-marked-files, ELPA Syncer, 2023/12/02
- [elpa] externals/denote 474c680e32 16/19: Reword a comment in the manual, ELPA Syncer, 2023/12/02
- [elpa] externals/denote e6a4bac215 13/19: Reinstate macro in denote-sort.el, ELPA Syncer, 2023/12/02
- [elpa] externals/denote 57eb0b4d54 07/19: Declare 'denote-find-link' and 'denote-find-backlink' as interactive only, ELPA Syncer, 2023/12/02
- [elpa] externals/denote e0480c7953 03/19: Always omit current file from Org dynamic blocks, ELPA Syncer, 2023/12/02
- [elpa] externals/denote a44600b4fa 11/19: Refactor denote-retrieve-filename-title,
ELPA Syncer <=
- [elpa] externals/denote 8e8cecde65 12/19: Clarify what 'denote-retrieve-filename-signature' fallback return value is, ELPA Syncer, 2023/12/02
- [elpa] externals/denote 13674e8f76 06/19: Expand the interactive spec of Org dynamic blocks to cover org-mode, ELPA Syncer, 2023/12/02
- [elpa] externals/denote 938a761ae8 09/19: Remove trailing space from denote-sort-component-prompt text, ELPA Syncer, 2023/12/02
- [elpa] externals/denote df82fcf176 01/19: Fix nil title error in denote-change-file-type-and-front-matter, ELPA Syncer, 2023/12/02
- [elpa] externals/denote ad644c88e8 02/19: Add 'omit-current' parameter to denote-sort-get-directory-files, ELPA Syncer, 2023/12/02
- [elpa] externals/denote 199609b3f3 08/19: Consolidate font-lock keywords into a single variable, ELPA Syncer, 2023/12/02
- [elpa] externals/denote 89ddd46996 15/19: Add TODOs for denote-org-capture-with-prompts, ELPA Syncer, 2023/12/02
- [elpa] externals/denote 981410d347 18/19: Add missing reference to denote-faces-signature, ELPA Syncer, 2023/12/02
- [elpa] externals/denote c686a9e16a 17/19: Make title prompt accept empty string; renaming now ignores/removes title if empty, ELPA Syncer, 2023/12/02
- [elpa] externals/denote 5f6501a40c 05/19: Make denote-link--prepare-links account for files with signature, ELPA Syncer, 2023/12/02