[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 5a7b408b4a 8/9: Merge pull request #331 from jea
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 5a7b408b4a 8/9: Merge pull request #331 from jeanphilippegg/title-sluggification |
Date: |
Sat, 27 Apr 2024 00:58:02 -0400 (EDT) |
branch: externals/denote
commit 5a7b408b4ae5c6168d8136f43125c483de41ca92
Merge: be3ca425d6 ac21068d3c
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: GitHub <noreply@github.com>
Merge pull request #331 from jeanphilippegg/title-sluggification
Fix issue #271 (Allow -- in titles)
---
denote.el | 48 +++++++++++++++++++++++++++++-------------------
1 file changed, 29 insertions(+), 19 deletions(-)
diff --git a/denote.el b/denote.el
index 1360a3196a..eb70cd8aaa 100644
--- a/denote.el
+++ b/denote.el
@@ -711,13 +711,13 @@ The note's ID is derived from the date and time of its
creation.")
(defconst denote-id-regexp "\\([0-9]\\{8\\}\\)\\(T[0-9]\\{6\\}\\)"
"Regular expression to match `denote-id-format'.")
-(defconst denote-signature-regexp "==\\([^.]*?\\)\\(--.*\\|__.*\\|\\..*\\)*$"
+(defconst denote-signature-regexp
"==\\([^.]*?\\)\\(==.*\\|--.*\\|__.*\\|\\..*\\)*$"
"Regular expression to match the SIGNATURE field in a file name.")
-(defconst denote-title-regexp "--\\([^.]*?\\)\\(--.*\\|__.*\\|\\..*\\)*$"
+(defconst denote-title-regexp "--\\([^.]*?\\)\\(==.*\\|__.*\\|\\..*\\)*$"
"Regular expression to match the TITLE field in a file name.")
-(defconst denote-keywords-regexp "__\\([^.]*?\\)\\(--.*\\|__.*\\|\\..*\\)*$"
+(defconst denote-keywords-regexp
"__\\([^.]*?\\)\\(==.*\\|--.*\\|__.*\\|\\..*\\)*$"
"Regular expression to match the KEYWORDS field in a file name.")
(defconst denote-excluded-punctuation-regexp
"[][{}!@#$%^&*()=+'\"?,.\|;:~`‘’“”/]*"
@@ -821,23 +821,32 @@ leading and trailing hyphen."
(replace-regexp-in-string "_\\|\s+" "-" str))))
(defun denote--remove-dot-characters (str)
- "Remove the dot character from STR."
+ "Remove dot characters from STR."
(replace-regexp-in-string "\\." "" str))
-(defun denote--trim-right-token-characters (str)
- "Remove =, - and _ from the end of STR."
- (string-trim-right str "[=_-]+"))
+(defun denote--trim-right-token-characters (str component)
+ "Remove =, - and _ from the end of STR.
+The removal is done only if necessary according to COMPONENT."
+ (if (eq component 'title)
+ (string-trim-right str "[=_]+")
+ (string-trim-right str "[=_-]+")))
-(defun denote--replace-consecutive-token-characters (str)
+(defun denote--replace-consecutive-token-characters (str component)
"Replace consecutive characters with a single one in STR.
-Spaces, underscores and equal signs are replaced with a single
-one in str."
- (replace-regexp-in-string
- "-\\{2,\\}" "-"
- (replace-regexp-in-string
- "_\\{2,\\}" "_"
+Hyphens, underscores and equal signs are replaced with a single
+one in str, if necessary according to COMPONENT."
+ ;; -- are allowed in titles
+ (if (eq component 'title)
+ (replace-regexp-in-string
+ "_\\{2,\\}" "_"
+ (replace-regexp-in-string
+ "=\\{2,\\}" "=" str))
(replace-regexp-in-string
- "=\\{2,\\}" "=" str))))
+ "-\\{2,\\}" "-"
+ (replace-regexp-in-string
+ "_\\{2,\\}" "_"
+ (replace-regexp-in-string
+ "=\\{2,\\}" "=" str)))))
(defun denote-sluggify (component str)
"Make STR an appropriate slug for file name COMPONENT.
@@ -845,9 +854,10 @@ one in str."
Apply the function specified in `denote-file-name-slug-function'
to COMPONENT which is one of `title', `signature', `keyword'. If
the resulting string still contains consecutive -,_ or =, they
-are replaced by a single occurence of the character. If
-COMPONENT is `keyword', remove underscores from STR as they are
-used as the keywords separator in file names."
+are replaced by a single occurence of the character, if necessary
+according to COMPONENT. If COMPONENT is `keyword', remove
+underscores from STR as they are used as the keywords separator
+in file names."
(let* ((slug-function (alist-get component denote-file-name-slug-functions))
(str-slug (cond ((eq component 'title)
(funcall (or slug-function #'denote-sluggify-title)
str))
@@ -859,7 +869,7 @@ used as the keywords separator in file names."
(funcall (or slug-function
#'denote-sluggify-signature) str)))))
(denote--trim-right-token-characters
(denote--replace-consecutive-token-characters
- (denote--remove-dot-characters str-slug)))))
+ (denote--remove-dot-characters str-slug) component) component)))
(make-obsolete
'denote-letter-case
- [elpa] externals/denote updated (31e94d0568 -> 0a7560882e), ELPA Syncer, 2024/04/27
- [elpa] externals/denote 63c65c0cc0 2/9: Compare identifier with what denote-retrieve-filename-identifier returns, ELPA Syncer, 2024/04/27
- [elpa] externals/denote 337e99abaf 6/9: Merge pull request #329 from jeanphilippegg/refactoring, ELPA Syncer, 2024/04/27
- [elpa] externals/denote 503967372e 4/9: Include signature delimiter in denote-*-regexp variables, ELPA Syncer, 2024/04/27
- [elpa] externals/denote be3ca425d6 7/9: Merge pull request #330 from jeanphilippegg/denote--used-ids, ELPA Syncer, 2024/04/27
- [elpa] externals/denote ac21068d3c 5/9: Allow consecutive hyphens in file name titles, ELPA Syncer, 2024/04/27
- [elpa] externals/denote 5894fe704f 1/9: Use denote-retrieve-front-matter-title-value instead of an alias, ELPA Syncer, 2024/04/27
- [elpa] externals/denote ee13dc8641 3/9: Add denote--used-ids and simplify renaming commands, ELPA Syncer, 2024/04/27
- [elpa] externals/denote 5a7b408b4a 8/9: Merge pull request #331 from jeanphilippegg/title-sluggification,
ELPA Syncer <=
- [elpa] externals/denote 0a7560882e 9/9: Update the denote-sluggify entry in the manual, ELPA Syncer, 2024/04/27