[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 6000313eec 118/355: Enforce sluggification of ke
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 6000313eec 118/355: Enforce sluggification of keywords; document it |
Date: |
Sun, 26 Jun 2022 23:58:11 -0400 (EDT) |
branch: externals/denote
commit 6000313eeccc31e03daebac8c0056d8909da4a7b
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Enforce sluggification of keywords; document it
---
README.org | 18 ++++++++++++++++++
denote.el | 32 ++++++++++++++++++++------------
2 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/README.org b/README.org
index 35450ae3b5..41a7d5ffe1 100644
--- a/README.org
+++ b/README.org
@@ -153,6 +153,24 @@ does not actually depend on org.el and/or its
accoutrements.
Notes are stored as a flat list in the ~denote-directory~ (i.e. no
subdirectories). The default path is =~/Documents/notes=.
+** Sluggified title and keywords
+:PROPERTIES:
+:CUSTOM_ID: h:ae8b19a1-7f67-4258-96b3-370a72c43f4e
+:END:
+
+Denote has to be highly opinionated about which characters can be used
+in file names and the file's front matter in order to enforce its
+file-naming scheme. The private variable ~denote--punctuation-regexp~
+holds the relevant value. In simple terms:
+
++ What we count as "illegal characters" are converted into hyphens.
+
++ Input for a file title is hyphenated and downcased. The original
+ value is preserved only in the note's contents
([[#h:13218826-56a5-482a-9b91-5b6de4f14261][Front matter]]).
+
++ Keywords should not have spaces or other delimiters. If they do, they
+ are converted into hyphens. Keywords are always downcased.
+
* Points of entry
:PROPERTIES:
:CUSTOM_ID: h:17896c8c-d97a-4faa-abf6-31df99746ca6
diff --git a/denote.el b/denote.el
index d24759233d..19e578811a 100644
--- a/denote.el
+++ b/denote.el
@@ -174,7 +174,8 @@ is suspended: we use whatever the user wants."
"Regular expression to match `denote-keywords'.")
(defconst denote--punctuation-regexp "[][{}!@#$%^&*()_=+'\"?,.\|;:~`‘’“”]*"
- "Regular expression of punctionation that should be removed.")
+ "Regular expression of punctionation that should be removed.
+We consider those characters illigal for our purposes.")
(defvar denote-last-path nil "Store last path.")
(defvar denote-last-title nil "Store last title.")
@@ -216,9 +217,15 @@ trailing hyphen."
(replace-regexp-in-string "--+\\|\s+" "-" str))))
(defun denote--sluggify (str)
- "Make STR an appropriate file name slug."
+ "Make STR an appropriate slug for file names and related."
(downcase (denote--slug-hyphenate (denote--slug-no-punct str))))
+(defun denote--sluggify-keywords (keywords)
+ "Sluggify KEYWORDS."
+ (if (listp keywords)
+ (mapcar #'denote--sluggify keywords)
+ (denote--sluggify keywords)))
+
(defun denote--file-empty-p (file)
"Return non-nil if FILE is empty."
(zerop (or (file-attribute-size (file-attributes file)) 0)))
@@ -358,15 +365,16 @@ keyword is just downcased.
With optional TYPE, format the keywords accordingly (this might
be `toml' or, in the future, some other spec that needss special
treatment)."
- (cond
- ((and (> (length keywords) 1) (not (stringp keywords)))
- (pcase type
- ('toml (format "[%s]" (denote--map-quote-downcase keywords)))
- (_ (mapconcat #'downcase keywords " "))))
- (t
- (pcase type
- ('toml (format "[%S]" (downcase keywords)))
- (_ (downcase keywords))))))
+ (let ((kw (denote--sluggify-keywords keywords)))
+ (cond
+ ((and (> (length kw) 1) (not (stringp kw)))
+ (pcase type
+ ('toml (format "[%s]" (denote--map-quote-downcase kw)))
+ (_ (mapconcat #'downcase kw " "))))
+ (t
+ (pcase type
+ ('toml (format "[%S]" (downcase kw)))
+ (_ (downcase kw)))))))
(defvar denote-tml-front-matter
"+++
@@ -435,7 +443,7 @@ Format current time, else use optional ID."
(denote--format-file
(file-name-as-directory denote-directory)
(format-time-string denote--id)
- keywords
+ (denote--sluggify-keywords keywords)
(denote--sluggify title)
(denote--file-extension))))
- [elpa] externals/denote 929157d424 089/355: Stop using link abbreviation, (continued)
- [elpa] externals/denote 929157d424 089/355: Stop using link abbreviation, ELPA Syncer, 2022/06/27
- [elpa] externals/denote a809e9ea1d 087/355: Clarify active development; things might break, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 3f9bfcb74e 101/355: Name the FSF as the copyright holder, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 299b8970ee 095/355: Add support for notes in Markdown and Plain Text, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 112a12e6e5 130/355: Remove duplicate word from face names, ELPA Syncer, 2022/06/27
- [elpa] externals/denote bca23b3e3d 115/355: Clarify how front matter variables are used, ELPA Syncer, 2022/06/27
- [elpa] externals/denote f91d2472c3 128/355: Make the field delimiter face a bit more subtle, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 8a35382067 126/355: Rename internal variable for clarity, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 308322afab 108/355: Fix markdown-toml identifier value, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 11be1d6b40 123/355: Change "tml" to "toml" in denote-toml-front-matter, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 6000313eec 118/355: Enforce sluggification of keywords; document it,
ELPA Syncer <=
- [elpa] externals/denote 82eeb381dc 110/355: Make all front matter abstractions consistent, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 73dc07ac00 113/355: Make front matter variables "public", ELPA Syncer, 2022/06/27
- [elpa] externals/denote 21e415e2e7 111/355: Remove obsolete symbol of command, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 60d64ca07c 117/355: Document ways to change the front matter, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 28518416f3 131/355: Name the faces in the manual, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 0bda79ef19 139/355: Move heading further up in the manual, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 890a335092 149/355: Add denote-dired-rename-expert user option, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 5977a9bc7b 164/355: Add warning about likely changes to denote-link.el, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 3f768cc438 168/355: Remove commented-out 'require', ELPA Syncer, 2022/06/27
- [elpa] externals/denote d6285c8c5a 182/355: Omit current file from backlinks, ELPA Syncer, 2022/06/27