[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 76755e9a3c 6/6: Merge pull request #223 from jea
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/denote 76755e9a3c 6/6: Merge pull request #223 from jeanphilippegg/denote--replace-consecutive-token-characters |
|
Date: |
Thu, 18 Jan 2024 09:57:43 -0500 (EST) |
branch: externals/denote
commit 76755e9a3c1dba2bd3eff1f658b673c570265429
Merge: fb1ed38229 d1ee270784
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: GitHub <noreply@github.com>
Merge pull request #223 from
jeanphilippegg/denote--replace-consecutive-token-characters
Always remove consecutives -,_ or = from file names
---
denote.el | 34 ++++++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/denote.el b/denote.el
index 9dbd80e537..680df2206f 100644
--- a/denote.el
+++ b/denote.el
@@ -666,18 +666,36 @@ leading and trailing hyphen."
"-\\{2,\\}" "-"
(replace-regexp-in-string "_\\|\s+" "-" str))))
+(defun denote--replace-consecutive-token-characters (str)
+ "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,\\}" "_"
+ (replace-regexp-in-string
+ "=\\{2,\\}" "=" str))))
+
(defun denote-sluggify (component str)
"Make STR an appropriate slug for file name COMPONENT.
Apply the function specified in `denote-file-name-slug-function'
-to COMPONENT which is one of `title', `signature', `keyword'."
- (let ((slug-function (alist-get component denote-file-name-slug-functions)))
- (cond ((eq component 'title)
- (funcall (or slug-function #'denote-sluggify-title) str))
- ((eq component 'keyword)
- (funcall (or slug-function #'denote-sluggify-keyword) str))
- ((eq component 'signature)
- (funcall (or slug-function #'denote-sluggify-signature) str)))))
+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."
+ (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))
+ ((eq component 'keyword)
+ (replace-regexp-in-string
+ "_" ""
+ (funcall (or slug-function
#'denote-sluggify-keyword) str)))
+ ((eq component 'signature)
+ (funcall (or slug-function
#'denote-sluggify-signature) str)))))
+ (denote--replace-consecutive-token-characters str-slug)))
(make-obsolete
'denote-letter-case
- [elpa] externals/denote updated (99709c7a62 -> 76755e9a3c), ELPA Syncer, 2024/01/18
- [elpa] externals/denote d1ee270784 3/6: Add denote--replace-consecutive-token-characters and use it in denote-sluggify, ELPA Syncer, 2024/01/18
- [elpa] externals/denote e715d68338 2/6: Add denote-link-description-function, ELPA Syncer, 2024/01/18
- [elpa] externals/denote 8d3900f8bf 1/6: Add denote--command-with-features and denote-save-buffer-after-creation, ELPA Syncer, 2024/01/18
- [elpa] externals/denote 76755e9a3c 6/6: Merge pull request #223 from jeanphilippegg/denote--replace-consecutive-token-characters,
ELPA Syncer <=
- [elpa] externals/denote e83a377d08 4/6: Merge pull request #221 from jeanphilippegg/denote--command-with-features, ELPA Syncer, 2024/01/18
- [elpa] externals/denote fb1ed38229 5/6: Merge pull request #222 from jeanphilippegg/denote-link-description-function, ELPA Syncer, 2024/01/18