emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote 7b719e6274 152/355: Add user option to disable m


From: ELPA Syncer
Subject: [elpa] externals/denote 7b719e6274 152/355: Add user option to disable multi-word keywords
Date: Sun, 26 Jun 2022 23:58:16 -0400 (EDT)

branch: externals/denote
commit 7b719e6274d0371173a70182ec74661d45bc6fd4
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add user option to disable multi-word keywords
---
 README.org |  9 +++++++--
 denote.el  | 21 ++++++++++++++++++++-
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/README.org b/README.org
index c68e16ec17..b86e939d92 100644
--- a/README.org
+++ b/README.org
@@ -136,15 +136,20 @@ automatically gets downcased and hyphenated.  An entry 
about "Economics
 in the Euro Area" produces an =economics-in-the-euro-area= string for
 the =TITLE= of the file name.
 
+#+vindex: denote-allow-multi-word-keywords
 The =KEYWORDS= field consists of one or more entries demarcated by an
 underscore (the separator is inserted automatically).  Each keyword is a
 string provided by the user at the relevant prompt which broadly
 describes the contents of the entry.  Keywords that need to be more than
 one-word-long must be written with hyphens: any other character, such as
-spaces or the plus sign is converted into a hyphen.  So when
-=emacs_library= appears in a file name, it is interpreted as two
+spaces or the plus sign is automatically converted into a hyphen.  So
+when =emacs_library= appears in a file name, it is interpreted as two
 distinct keywords, whereas =emacs-library= is one keyword.  This is
 reflected in how the keywords are recorded in the note 
([[#h:13218826-56a5-482a-9b91-5b6de4f14261][Front matter]]).
+While Denote supports multi-word keywords by default, the user option
+~denote-allow-multi-word-keywords~ can be set to nil to forcibly join
+all words into one, meaning that an input of =word1 word2= will be
+written as =word1word2=.
 
 #+vindex: denote-file-type
 The =EXTENSION= is the file type.  By default, it is =.org= (~org-mode~)
diff --git a/denote.el b/denote.el
index f1bb86434f..cd96e27952 100644
--- a/denote.el
+++ b/denote.el
@@ -112,6 +112,20 @@ If nil, show the keywords in their given order."
   :group 'denote
   :type 'boolean)
 
+(defcustom denote-allow-multi-word-keywords t
+  "If non-nil keywords can consist of multiple words.
+Words are automatically separated by a hyphen when using the
+`denote' command or related.  The hyphen is the only legal
+character---no spaces, no other characters.  If, for example, the
+user types <word1+word2> or <word1 word2>, it is converted to
+<word1-word2>.
+
+When nil, do not allow keywords to consist of multiple words.
+Reduce them to a single word, such as by turning <word1+word2> or
+<word1 word2> into <word1word2>."
+  :group 'denote
+  :type 'boolean)
+
 (defcustom denote-file-type nil
   "The file type extension for new notes.
 
@@ -218,7 +232,12 @@ trailing hyphen."
 
 (defun denote--sluggify (str)
   "Make STR an appropriate slug for file names and related."
-  (downcase (denote--slug-hyphenate (denote--slug-no-punct str))))
+  (downcase
+   (if denote-allow-multi-word-keywords
+       (denote--slug-hyphenate (denote--slug-no-punct str))
+     (replace-regexp-in-string
+      "-" ""
+      (denote--slug-hyphenate (denote--slug-no-punct str))))))
 
 (defun denote--sluggify-keywords (keywords)
   "Sluggify KEYWORDS."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]