[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 8f5ff8c5fe 1/4: Make denote--slug-no-punct actua
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/denote 8f5ff8c5fe 1/4: Make denote--slug-no-punct actually work as intended |
|
Date: |
Tue, 28 Nov 2023 03:57:49 -0500 (EST) |
branch: externals/denote
commit 8f5ff8c5fe73714051db43f1246b2a5c87fa93cb
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make denote--slug-no-punct actually work as intended
We need a loop here because the previous 'concat' was simply matching
the first component it would fine, whereas we want to remove all the
matches.
---
denote.el | 25 +++++++++++--------------
tests/denote-test.el | 14 +++++++-------
2 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/denote.el b/denote.el
index f7af3051d9..4a4e2c5038 100644
--- a/denote.el
+++ b/denote.el
@@ -622,21 +622,18 @@ before falling back to the value of the variable
(defun denote--slug-no-punct (str &optional extra-characters)
"Remove punctuation from STR.
-Concretely, replace with spaces anything that matches the
-`denote-excluded-punctuation-regexp' and
+Concretely, replace with an empty string anything that matches
+the `denote-excluded-punctuation-regexp' and
`denote-excluded-punctuation-extra-regexp'.
-With optional EXTRA-CHARACTERS as a string, include them in the
-regexp to be replaced."
- (replace-regexp-in-string
- (concat "\\("
- denote-excluded-punctuation-regexp
- "\\|"
- denote-excluded-punctuation-extra-regexp
- "\\|"
- extra-characters
- "\\)")
- "" str))
+EXTRA-CHARACTERS is an optional string that has the same meaning
+as the aforementioned variables."
+ (dolist (regexp (list denote-excluded-punctuation-regexp
+ denote-excluded-punctuation-extra-regexp
+ extra-characters))
+ (when (stringp regexp)
+ (setq str (replace-regexp-in-string regexp "" str))))
+ str)
(defun denote--slug-hyphenate (str)
"Replace spaces and underscores with hyphens in STR.
@@ -681,7 +678,7 @@ any leading and trailing signs."
(defun denote-sluggify-signature (str)
"Make STR an appropriate slug for signatures.
Perform letter casing according to `denote-file-name-letter-casing'."
- (denote-letter-case 'signature (denote--slug-put-equals
(denote--slug-no-punct str "-"))))
+ (denote-letter-case 'signature (denote--slug-put-equals
(denote--slug-no-punct str "-+"))))
(defun denote-sluggify-and-join (str)
"Sluggify STR while joining separate words."
diff --git a/tests/denote-test.el b/tests/denote-test.el
index 26a601b5d7..fe24240080 100644
--- a/tests/denote-test.el
+++ b/tests/denote-test.el
@@ -86,7 +86,7 @@ Denote file name."
"Test that `denote-sluggify-signature' sluggifies the string for file
signatures.
This is like `denote-test--denote-sluggify', except that it also
accounts for what we describe in `denote-test--denote--slug-put-equals'."
- (should (equal (denote-sluggify-signature " ___ !~!!$%^ This iS a tEsT ++ ??
")
+ (should (equal (denote-sluggify-signature "--- ___ !~!!$%^ This -iS- a tEsT
++ ?? ")
"this=is=a=test")))
(ert-deftest denote-test--denote-sluggify-and-join ()
@@ -95,7 +95,7 @@ In this context, to join words is to elimitate any space or
delimiter between them.
Otherwise, this is like `denote-test--denote-sluggify'."
- (should (equal (denote-sluggify-and-join " ___ !~!!$%^ This iS a tEsT ++ ??
")
+ (should (equal (denote-sluggify-and-join "--- ___ !~!!$%^ This iS a - tEsT
++ ?? ")
"thisisatest")))
(ert-deftest denote-test--denote-sluggify-keywords ()
@@ -103,7 +103,7 @@ Otherwise, this is like `denote-test--denote-sluggify'."
The function also account for the value of the user option
`denote-allow-multi-word-keywords'."
(should
- (equal (denote-sluggify-keywords '("one !@# one" " two" "__ three __"))
+ (equal (denote-sluggify-keywords '("one !@# --- one" " two" "__ three
__"))
'("oneone" "two" "three"))))
(ert-deftest denote-test--denote-desluggify ()
@@ -185,10 +185,10 @@ Extend what we do in
`denote-test--denote-file-type-extensions'."
(ert-deftest denote-test--denote--format-front-matter ()
"Test that `denote--format-front-matter' formats front matter correctly."
(should (and (equal (denote--format-front-matter "" "" '("") "" 'text)
- "title:
-date:
-tags:
-identifier:
+ "title:
+date:
+tags:
+identifier:
---------------------------
")