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

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

[elpa] externals/denote e1bd4c9cb8 094/355: BREAKING Put keywords after


From: ELPA Syncer
Subject: [elpa] externals/denote e1bd4c9cb8 094/355: BREAKING Put keywords after the title
Date: Sun, 26 Jun 2022 23:58:03 -0400 (EDT)

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

    BREAKING Put keywords after the title
    
    Putting the tags/keywords at the end of the file has several advantages:
    
    1. It is consistent with how such interfaces are designed, such as with
       the 'elfeed', 'notmuch', and 'mu4e' Emacs packages.
    
    2. It makes it easier to read the title of the file even if it is
       truncated.
    
    3. Makes fontification look better, as the more intensely coloured
       keywords are further apart from the date/identifier which is also
       colourful.
    
    One way to update existing file names in Dired:
    
    * Switch to wdired (C-x C-q by default)
    * M-x isearch-forward-regexp (bound to C-M-s by default)
    * Search for (without the quotes) '--\(.*?\)--\(.*?\)\.org'
    * While in isearch, type M-%
    * For the replacement use (without the quotes) '--\2--\1.org'
    * Verify the conversion as you go through the query-replace.
    
    A similar series of steps can be followed for file contents (e.g. by
    making the grep buffer editable with the wgrep package).
---
 README.org      | 18 +++++++++---------
 denote-dired.el | 18 +++++++++++++++---
 denote.el       | 14 +++++++-------
 3 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/README.org b/README.org
index 4f7a73b395..ee6c2eb000 100644
--- a/README.org
+++ b/README.org
@@ -83,7 +83,7 @@ the creation of such files.
 
 Every note produced by Denote follows this pattern:
 
-: DATE--KEYWORDS--TITLE.org
+: DATE--TITLE--KEYWORDS.org
 
 The =DATE= field represents the date in year-month-day format followed
 by the capital letter =T= (for "time") and the current time in
@@ -91,6 +91,11 @@ hour-minute-second notation.  The presentation is compact:
 =20220531T091625=.  The =DATE= serves as the unique identifier of each
 note.
 
+The =TITLE= field is the title of the note, as provided by the user,
+that 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.
+
 The =KEYWORDS= field consists of one or more entries demarcated by a
 plus sign (the separator is inserted automatically).  Each keyword is a
 string provided by the user at the relevant prompt which broadly
@@ -99,16 +104,11 @@ one-word-long must be written with an underscore.  So when
 =emacs_library= appears in a file name, it is interpreted as a single
 keyword, whereas =emacs+library= are two distinct keywords.
 
-The =TITLE= field is the title of the note, as provided by the user,
-that 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.
-
 Examples:
 
-: 20220107T124941--economics--plentiful-and-predictable-liquidity.org
-: 20220214T104945--emacs+git--git-patch-formatting.org
-: 20220420T113805--three_word_keyword--this-is-a-test.org
+: 20220107T124941--plentiful-and-predictable-liquidity--economics.org
+: 20220214T104945--git-patch-formatting--emacs+git.org
+: 20220420T113805--this-is-a-test--three_word_keyword.org
 
 While files end in the =.org= extension, the Denote code base does not
 actually depend on org.el and/or its accoutrements.
diff --git a/denote-dired.el b/denote-dired.el
index c467bac47b..f69a2878e2 100644
--- a/denote-dired.el
+++ b/denote-dired.el
@@ -122,6 +122,16 @@ renaming attachments that the user adds to their notes."
   "Face for file name time in `dired-mode' buffers."
   :group 'denote-dired)
 
+(defface denote-dired-dired-field-title
+  '((t ))
+  "Face for file name title in `dired-mode' buffers."
+  :group 'denote-dired)
+
+(defface denote-dired-dired-field-extension
+  '((t :inherit shadow))
+  "Face for file extension type in `dired-mode' buffers."
+  :group 'denote-dired)
+
 (defface denote-dired-dired-field-keywords
   '((default :inherit bold)
     (((class color) (min-colors 88) (background light))
@@ -142,12 +152,14 @@ renaming attachments that the user adds to their notes."
   :group 'denote-dired)
 
 (defconst denote-dired-font-lock-keywords
-  `((,denote--file-regexp
+  `((,denote--keyword-regexp
      (1 'denote-dired-dired-field-date)
      (2 'denote-dired-dired-field-time)
      (3 'denote-dired-dired-field-delimiter)
-     (4 'denote-dired-dired-field-keywords)
-     (5 'denote-dired-dired-field-delimiter)))
+     (4 'denote-dired-dired-field-title)
+     (5 'denote-dired-dired-field-delimiter)
+     (6 'denote-dired-dired-field-keywords)
+     (7 'denote-dired-dired-field-extension)))
   "Keywords for fontification.")
 
 ;;;###autoload
diff --git a/denote.el b/denote.el
index b27f5b526d..0bc0ae3cbc 100644
--- a/denote.el
+++ b/denote.el
@@ -111,13 +111,14 @@ specifiers."
 (defconst denote--id-regexp "\\([0-9]\\{8\\}\\)\\(T[0-9]\\{6\\}\\)"
   "Regular expression to match `denote--id'.")
 
-(defconst denote--keyword-regexp "\\(--\\)\\([0-9A-Za-z_+]*\\)\\(--\\)"
-  "Regular expression to match `denote-keywords'.")
-
 (defconst denote--file-regexp
-  (concat denote--id-regexp denote--keyword-regexp "\\(.*\\)\\.?.*")
+  (concat denote--id-regexp "\\(--\\)\\(.*\\)\\(--\\)")
   "Regular expression to match file names from `denote-new-note'.")
 
+(defconst denote--keyword-regexp
+  (concat denote--file-regexp "\\([0-9A-Za-z_+]*\\)\\(\\.?.*\\)")
+  "Regular expression to match `denote-keywords'.")
+
 (defconst denote--punctuation-regexp "[][{}!@#$%^&*()_=+'\"?,.\|;:~`‘’“”]*"
   "Regular expression of punctionation that should be removed.")
 
@@ -206,8 +207,7 @@ With optional N, search in the Nth line from point."
   "Produce list of keywords in `denote--directory-files'."
   (delq nil (mapcar
              (lambda (x)
-               (denote--extract
-                (concat denote--id-regexp denote--keyword-regexp) x 3))
+               (denote--extract denote--keyword-regexp x 6))
              (denote--directory-files))))
 
 (defun denote--inferred-keywords ()
@@ -286,7 +286,7 @@ is specified."
                  (denote--keywords-combine keywords)
                keywords))
         (ext (or extension ".org")))
-    (format "%s%s--%s--%s%s" path id kws slug ext)))
+    (format "%s%s--%s--%s%s" path id slug kws ext)))
 
 (defun denote--file-meta-header (title date keywords id)
   "Front matter for new notes.



reply via email to

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