branch: externals/denote-review
commit 15f1d41c4c8ca137a661c652b0d87f2bf385015e
Author: Matto Fransen <[email protected]>
Commit: Matto Fransen <[email protected]>

    Added support for denote-silos
---
 README.org          | 71 ++++++++++++++++++++++++++++++++++++-----------------
 my-denote-review.el | 42 ++++++++++++++++++++-----------
 2 files changed, 75 insertions(+), 38 deletions(-)

diff --git a/README.org b/README.org
index 57ea70205b..736b5d4258 100644
--- a/README.org
+++ b/README.org
@@ -3,7 +3,7 @@
 `my-denote-review' aims to provide a practical and simple manner to
 implement a review process for some of your [[ 
https://protesilaos.com/emacs/denote][denote]] notes.
 
-`my-denote-review' adds a single line to the frontmatter:
+`my-denote-review' adds a single line to the frontmatter, f.e.:
 
 ~#+reviewdate: [2024-06-12]~
 
@@ -16,8 +16,8 @@ The aim is to implement a process for reviewing your denote 
notes in a
 practical and simple manner.
 
 Not all notes have to be part of this system. Only notes that contain the
-~#+reviewdate~ field in the frontmatter will be part of it.
-The ~#+reviewdate~ frontmatter can be inserted or updated with a single
+~reviewdate~ field in the frontmatter will be part of it.
+The ~reviewdate~ frontmatter can be inserted or updated with a single
 key binding.
 
 To get started, select a number of denote notes in Dired and bulk
@@ -29,7 +29,15 @@ review date.
 On a regular bases, review some notes:
 
 - Request a list of notes sorted by review date.
-- Review one or more notes and set or update their review date.
+- Review one or more notes and update their review date.
+
+** Commands
+- ~my-denote-review-set-date~:
+  Insert current date as reviewdate or set existing reviewdate to current date.
+- ~my-denote-review-set-date-dired-marked-files~:
+  Insert current date as review date in notes marked in Dired.
+- ~my-denote-review-display-list~:
+  Create a tabulated list of notes order by review date.
 
 *** Add or update the review date of a note
 Open and revew a denote note. Add or update the date in the the
@@ -44,7 +52,7 @@ To make this easy, bind this command to a key, f.e.:
   field, it will be inserted, with the current date as review date.
 - When the  ~reviewdate~ field is already part of the frontmatter,
   the review date will be updated with the current date.
-  
+
 Example screenshot of the frontmatter of a note:
 
 #+CAPTION: /Example note showing frontmatter with the latest review date/
@@ -55,11 +63,11 @@ The command ~M-x my-denote-review-display-list~ creates a 
tabulated list of the
 notes that contain the ~reviewdate~ frontmatter. Notes without a ~reviewdate~
 are ignored.
 
-The script reads value of the variable ~denote-directory~. When this
-is a list, the script prompts the user to select a directory, using
-completion.
+It evaluates the value of the variables ~denote-directory~ and
+~denote-silo-directories~. When there is more than one directory, it
+prompts the user to select a directory, using completion.
 
-Example screenshot of the list with some notes:
+Example screenshot of the tabulated list with some notes:
 
 #+CAPTION: /Tabulated list to select a note to review/
 [[./images/denote-review-tabulated-view.png]]
@@ -71,6 +79,7 @@ newest. Click on a column header to change the order.
 
 - Click on a column to order according to the column contents.
 - Click again to reverse the order.
+- The key ~S~ (shift-s) in a column performs the same actions.
 
 Move point up or down to select a note. Open or view the note with
 one of the keys ~RET~, ~e~, or ~o~. Or request a random file from
@@ -79,12 +88,24 @@ refresh the list with ~g~.
 
 Key bindings in the tabulated list:
 
-- ~RET~ : open and edit the note in another window.
-- ~e~ : open and edit the note.
-- ~o~  : open the note in read only mode in another window.
-- ~r~ : open a random note from the list in another window.
-- ~g~ : update the tabulated list.
-- ~q~ : close the buffer with the tabulated list.
+Specific key bindings:
+
+- ~RET~ : Open and edit the note in another window.
+- ~e~ : Open and edit the note.
+- ~o~  : Open the note in read only mode in another window.
+- ~r~ : Open a random note from the list in another window.
+
+General tabulated list key bindings:
+
+- ~g~ : Update the tabulated list.
+- ~n~ : Goto next line.
+- ~p~ : Goto previous line.
+- ~SPC~ : Scroll up.
+- ~DEL~ : (Backspace) Scroll down.
+- ~S-SPC~: Scroll down.
+- ~q~ : Close the buffer with the tabulated list.
+
+For more, use ~M-x describe-mode~ (~C-h m~) in the buffer.
 
 *** Bulk insert a review date according to the identifier
 
@@ -95,14 +116,14 @@ Key bindings in the tabulated list:
 This will insert the ~reviewdate~ frontmatter in all selected notes,
 with a date according to the identifier in the filename.
 
-Notes where the ~reviewdate~ field is already part of the
-frontmatter, will be left untouched.
-
 For example, the note
 ~20240117T203111--add-a-query-link__demo_denote.org~ will get
 ~2024-01-17~ as review date.
 
-*** Bulk insert the current date as review date 
+Notes where the ~reviewdate~ field is already part of the
+frontmatter will be left untouched.
+
+*** Bulk insert the current date as review date
 How to bulk insert the current date as review date:
 
 - Open the denote directory in Dired.
@@ -135,17 +156,21 @@ point a few lines below your frontmatter and issue the 
command
 ~C-x =~ to see what a better value for
 ~my-denote-review-max-search-point~ could be.
 
-** Limitations
-`my-denote-review' doesn't support denote-silos yet.
-
 ** Source code. bugs and patches
 ~my-denote-review~ is developed at
 https://codeberg.org/mattof/my-denote-review
 
 Please use the "Issues" option in the Codeberg repository.
 
+** Limitations
+
+The file extension of a note does not affect ~my-denote-review~.
+
+Searching for the review date frontmatter uses a pattern that depends
+on the value of the variable `denote-file-type'.  Just as the format
+for inserting and updating the review date.
+
 ** Distribution
 ~my-denote-review.el~ and all other source files in this
 directory are distributed under the GNU Public License, Version 3,
 or any later version.
-
diff --git a/my-denote-review.el b/my-denote-review.el
index 00980d300b..05d7ec1dc3 100644
--- a/my-denote-review.el
+++ b/my-denote-review.el
@@ -29,10 +29,10 @@
 ;; It is soleley made for denote notes in org mode format with the
 ;; default filenaming scheme.
 
-;; `my-denote-review' adds a single line to the frontmatter:
+;; `my-denote-review' adds a single line to the frontmatter, f.e.:
 ;; #+reviewdate: [2024-06-12]
 
-;; In tabulated list mode the notes are shown with their last
+;; In `tabulated list mode' the notes are shown with their last
 ;; review date, sorted from oldest to newest review date.
 ;; Click on a column header to change the order.
 
@@ -50,11 +50,11 @@
 (defun my-denote-review-search-regexp-for-filetype ()
   "Regexp to search for the reviewdate.
 Defaults to regexp for org filetype."
-  (cond ((string= denote-file-type "markdown-yaml")
+  (cond ((string= denote-file-type 'markdown-yaml)
          "\\(^reviewdate:[ \t]\\)\\([^\t\n]+\\)")
-        ((string= denote-file-type "markdown-toml")
+        ((string= denote-file-type 'markdown-toml)
          "\\(^reviewdate[ \t]\\)= \\([^\t\n]+\\)")
-        ((string= denote-file-type "text")
+        ((string= denote-file-type 'text)
          "\\(^reviewdate:[ \t]\\)\\([^\t\n]+\\)")
         (t "\\(^#\\+reviewdate:[ \t]\\[\\)\\([^\t\n]+\\)\\]")))
 
@@ -71,7 +71,7 @@ Defaults to regexp for org filetype."
 
 (defun my-denote-review-insert-reviewdate-line (mydate)
   "Insert the review date MYDATE frontmatter line.
-Format according to denote-file-type. 
+Format according to variable `denote-file-type'.
 Insert just after the identifier line."
   (cond ((string= denote-file-type "markdown-yaml")
          (format "reviewdate: %s" mydate))
@@ -83,7 +83,8 @@ Insert just after the identifier line."
 
 (defun my-denote-review-insert-date (&optional thisdate insert-regexp)
   "Insert current date in ISO 8601 format as reviewdate.
-Or use THISDATE, when not nil."
+Or use THISDATE, when not nil.
+INSERT-REGEXP is regepx to search for appropriate insert location."
   (goto-char (point-min))
   (let ((mydate (format-time-string "%F")))
     (unless (null thisdate)
@@ -108,7 +109,8 @@ Replace an existing reviewdate."
     (my-denote-review-insert-regexp-location-for-filetype)))))
 
 (defun my-denote-review-get-date (search-regexp)
-  "Get the reviewdate from current buffer."
+  "Get the reviewdate from current buffer.
+SEARCH-REGEXP set to match format based on variable `denote-file-type'"
     (save-excursion
       (goto-char (point-min))
       (when (re-search-forward search-regexp
@@ -119,7 +121,10 @@ Replace an existing reviewdate."
 
 (defun my-denote-review-set-initial-date (thisdate search-regexp insert-regexp)
   "Insert reviewdate with THISDATE.
-Only do this when no reviewdate already exist."
+Only do this when no reviewdate already exist.
+SEARCH-REGEXP is regexp to search for existing reviewdate.
+INSERT-REGEXP is regepx to search for appropriate insert location.
+Both regexp's set to match format based on variable `denote-file-type'"
   (when (null (my-denote-review-get-date search-regexp))
     (my-denote-review-insert-date thisdate insert-regexp)))
 
@@ -163,10 +168,15 @@ Does not overwrite existing reviewdates."
 
 (defun my-denote-review-get-path ()
   "Prompt for a path when needed."
-  (if (listp denote-directory)
-      (completing-read "Select a directory (using completion): "
-                       denote-directory)
-    denote-directory))
+  (let ((mypath '()))
+    (when (boundp 'denote-directory)
+      (setq mypath (append mypath denote-directory)))
+    (when (boundp 'denote-silo-directories)
+      (setq mypath (append mypath denote-silo-directories)))
+    (if (listp mypath)
+    (completing-read
+     "Select a directory (using completion): " mypath)
+    denote-directory)))
 
 (defun my-denote-review-get-keyword-list (denotepath)
   "Fetch keywords from the filenames in directory DENOTEPATH."
@@ -191,7 +201,9 @@ Does not overwrite existing reviewdates."
 ;; Collect data to fill the tabular mode list
 
 (defun my-denote-review-check-date-of-file (myfile search-regexp)
-  "Get the reviewdate of MYFILE."
+  "Get the reviewdate of MYFILE.
+SEARCH-REGEXP is regexp to search for reviewdate.
+It is set to match format based on variable `denote-file-type'"
   (let ((mybuffer (find-file myfile))
         myreviewdate)
     (setq myreviewdate (my-denote-review-get-date
@@ -279,7 +291,7 @@ Initially sort by reviewdate."
 
 (defun my-denote-review-display-list (denotepath-and-keyword)
   "Show buffer with reviewdates.
- DENOTEPATH-AND-KEYWORD is a cons of a path and a keyword.
+DENOTEPATH-AND-KEYWORD is a cons of a path and a keyword.
  Filter by keyword."
   (interactive (list (my-denote-review-select-keyword)))
   (with-current-buffer (get-buffer-create "*my-denote-review-results*")

Reply via email to