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

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

[elpa] externals/denote ca1c534ac9 09/12: Make denote-region obey denote


From: ELPA Syncer
Subject: [elpa] externals/denote ca1c534ac9 09/12: Make denote-region obey denote-prompts
Date: Thu, 4 Jan 2024 06:57:54 -0500 (EST)

branch: externals/denote
commit ca1c534ac99e85d060673c39eff3bd5326cab17d
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>

    Make denote-region obey denote-prompts
---
 README.org | 11 ++++-------
 denote.el  | 20 ++++++++++++++------
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/README.org b/README.org
index 02aa3d7863..f32d34e32d 100644
--- a/README.org
+++ b/README.org
@@ -2758,13 +2758,10 @@ Sources for ~tmr~:
 
 #+findex: denote-region
 The command ~denote-region~ takes the contents of the active region
-and then prompts for a title and keywords.  Once a new note is
-created, it inserts the contents of the region therein.  This is
-useful to quickly elaborate on some snippet of text or capture it for
-future reference.
-
-If there is no active region, ~denote-region~ simply calls the
-~denote~ command which will behave the way it does ordinarily.
+and then calls the ~denote~ command.  Once a new note is created, it
+inserts the contents of the region therein.  This is useful to
+quickly elaborate on some snippet of text or capture it for future
+reference.
 
 #+vindex: denote-region-after-new-note-functions
 When the ~denote-region~ command is called with an active region, it
diff --git a/denote.el b/denote.el
index 04b0750afc..e245423591 100644
--- a/denote.el
+++ b/denote.el
@@ -1794,6 +1794,15 @@ increment it 1 second at a time until an available id is 
found."
 
 ;;;;; The `denote' command and its prompts
 
+(defvar denote--use-region-in-denote-command t
+  "If non-nil, the region can be used by the `denote' command.
+
+The `denote' command uses the region as the default title when
+prompted for a title.  When this variable is nil, the `denote'
+command ignores the region.  This variable is meant to be used in
+commands such as `denote-region' which have their own way of
+handling the region.")
+
 ;;;###autoload
 (defun denote (&optional title keywords file-type subdirectory date template 
signature)
   "Create a new note with the appropriate metadata and file name.
@@ -1832,7 +1841,8 @@ When called from Lisp, all arguments are optional.
      (dolist (prompt denote-prompts)
        (pcase prompt
          ('title (aset args 0 (denote-title-prompt
-                               (when (use-region-p)
+                               (when (and denote--use-region-in-denote-command
+                                          (use-region-p))
                                  (buffer-substring-no-properties
                                   (region-beginning)
                                   (region-end))))))
@@ -2104,10 +2114,7 @@ is set to \\='(signature title keywords)."
 
 ;;;###autoload
 (defun denote-region ()
-  "Call `denote' and insert therein the text of the active region.
-Prompt for title and keywords.  With no active region, call
-`denote' ordinarily (refer to its documentation for the
-technicalities)."
+  "Call `denote' and insert therein the text of the active region."
   (declare (interactive-only t))
   (interactive)
   (if-let (((region-active-p))
@@ -2115,7 +2122,8 @@ technicalities)."
            ;; the moment `insert' is called.
            (text (buffer-substring-no-properties (region-beginning) 
(region-end))))
       (progn
-        (denote (denote-title-prompt) (denote-keywords-prompt))
+        (let ((denote--use-region-in-denote-command nil))
+          (call-interactively 'denote))
         (push-mark (point))
         (insert text)
         (run-hook-with-args 'denote-region-after-new-note-functions (mark) 
(point)))



reply via email to

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