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

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

[elpa] externals/denote 9b91ddf735 2/2: Add user option denote-excluded-


From: ELPA Syncer
Subject: [elpa] externals/denote 9b91ddf735 2/2: Add user option denote-excluded-keywords-regexp
Date: Sat, 10 Dec 2022 22:57:33 -0500 (EST)

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

    Add user option denote-excluded-keywords-regexp
    
    Thanks to Stefan Thesing for proposing this idea in issue 115 on the
    GitHub mirror: <https://github.com/protesilaos/denote/issues/115>.
    
    [ Other people participate in that thread and there will be something
      more coming out of it. ]
---
 README.org | 22 ++++++++++++++++++++--
 denote.el  | 25 ++++++++++++++++++++++---
 2 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/README.org b/README.org
index 3e7b9cde13..5bee4eaa2c 100644
--- a/README.org
+++ b/README.org
@@ -675,6 +675,23 @@ The match is performed with ~string-match-p~.
 
 [[#h:c916d8c5-540a-409f-b780-6ccbd90e088e][For developers or advanced users]].
 
+** Exclude certain keywords from being inferred
+:PROPERTIES:
+:CUSTOM_ID: h:69e518ee-ed43-40ab-a5f4-c780a23e5358
+:END:
+
+[ Part of {{{development-version}}}. ]
+
+#+vindex: denote-excluded-keywords-regexp
+The user option ~denote-excluded-keywords-regexp~ omits keywords that
+match a regular expression from the list of inferred keywords.
+
+Keywords are inferred from file names and provided at relevant prompts
+as completion candidates when the user option ~denote-infer-keywords~
+is non-nil.
+
+The match is performed with ~string-match-p~.
+
 * Renaming files
 :PROPERTIES:
 :CUSTOM_ID: h:532e8e2a-9b7d-41c0-8f4b-3c5cbb7d4dca
@@ -2447,6 +2464,7 @@ Everything is in place to set up the package.
 (setq denote-file-type nil) ; Org is the default, set others here
 (setq denote-prompts '(title keywords))
 (setq denote-excluded-directories-regexp nil)
+(setq denote-excluded-keywords-regexp nil)
 
 ;; Pick dates, where relevant, with Org's advanced interface:
 (setq denote-date-prompt-use-org-read-date t)
@@ -3552,8 +3570,8 @@ Denote is meant to be a collective effort.  Every bit of 
help matters.
   Federico Stilman, Florian, Frank Ehmsen, Guo Yong, Hanspeter Gisler,
   Jack Baty, Jeremy Friesen, Juanjo Presa, Johan Bolmsjö, Kaushal
   Modi, M. Hadi Timachi, Paul van Gelder, Peter Prevos, Shreyas
-  Ragavan, Summer Emacs, Sven Seebeck, Taoufik, Viktor Haag, Yi Liu,
-  Ypot, atanasj, hpgisler, pRot0ta1p, sienic, sundar bp.
+  Ragavan, Stefan Thesing, Summer Emacs, Sven Seebeck, Taoufik, Viktor
+  Haag, Yi Liu, Ypot, atanasj, hpgisler, pRot0ta1p, sienic, sundar bp.
 
 Special thanks to Peter Povinec who helped refine the file-naming
 scheme, which is the cornerstone of this project.
diff --git a/denote.el b/denote.el
index 0c52899099..f133d9cdd2 100644
--- a/denote.el
+++ b/denote.el
@@ -159,6 +159,9 @@ If nil, refrain from inferring keywords.  The aforementioned
 completion prompt only shows the `denote-known-keywords'.  Use
 this if you want to enforce a restricted vocabulary.
 
+The user option `denote-excluded-keywords-regexp' can be used to
+exclude keywords that match a regular expression.
+
 Inferred keywords are specific to the value of the variable
 `denote-directory'.  If a silo with a local value is used, as
 explained in that variable's doc string, the inferred keywords
@@ -392,6 +395,17 @@ and `denote-subdirectory'.
 Functions that check for files include `denote-directory-files'
 and `denote-directory-subdirectories'.
 
+The match is performed with `string-match-p'."
+  :group 'denote
+  :package-version '(denote . "1.2.0")
+  :type 'string)
+
+(defcustom denote-excluded-keywords-regexp nil
+  "Regular expression of keywords to not infer.
+Keywords are inferred from file names and provided at relevant
+prompts as completion candidates when the user option
+`denote-infer-keywords' is non-nil.
+
 The match is performed with `string-match-p'."
   :group 'denote
   :package-version '(denote . "1.2.0")
@@ -767,14 +781,19 @@ If PATH has no such keywords, return nil."
   "Extract keywords from `denote-directory-files'.
 This function returns duplicates.  The `denote-keywords' is the
 one that doesn't."
-  (mapcan #'denote-extract-keywords-from-path
-          (denote-directory-files)))
+  (let ((kw (mapcan #'denote-extract-keywords-from-path 
(denote-directory-files))))
+    (if-let ((regexp denote-excluded-keywords-regexp))
+        (seq-filter (lambda (k) (not (string-match-p regexp k))) kw)
+      kw)))
 
 (defun denote-keywords ()
   "Return appropriate list of keyword candidates.
 If `denote-infer-keywords' is non-nil, infer keywords from
 existing notes and combine them into a list with
-`denote-known-keywords'.  Else use only the latter."
+`denote-known-keywords'.  Else use only the latter.
+
+Inferred keywords are filtered by the user option
+`denote-excluded-keywords-regexp'."
   (delete-dups
    (if denote-infer-keywords
        (append (denote--inferred-keywords) denote-known-keywords)



reply via email to

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