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

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

[elpa] externals/denote afe1f37d4f 1/7: Remove denote-user-enforced-deno


From: ELPA Syncer
Subject: [elpa] externals/denote afe1f37d4f 1/7: Remove denote-user-enforced-denote-directory
Date: Wed, 14 Feb 2024 03:57:57 -0500 (EST)

branch: externals/denote
commit afe1f37d4f1795f4745c30bb12faaf2a274af0ea
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Remove denote-user-enforced-denote-directory
---
 README.org               | 45 +++++++++++++-----------------------------
 denote-journal-extras.el |  2 +-
 denote-silo-extras.el    |  6 +++---
 denote.el                | 51 ++++++++++++++++--------------------------------
 tests/denote-test.el     | 10 ----------
 5 files changed, 35 insertions(+), 79 deletions(-)

diff --git a/README.org b/README.org
index 097db9e358..9005c298bc 100644
--- a/README.org
+++ b/README.org
@@ -825,7 +825,7 @@ file, with the following contents:
 ;;;
 ;;;     (info "(emacs) Directory Variables")
 
-((nil . ((denote-directory . default-directory))))
+((nil . ((denote-directory . "/path/to/silo/"))))
 #+end_src
 
 When inside the directory that contains this =.dir-locals.el= file, all
@@ -871,7 +871,7 @@ silo-specific value.  For example, this one changes the
 ;;;
 ;;;     (info "(emacs) Directory Variables")
 
-((nil . ((denote-directory . default-directory)
+((nil . ((denote-directory . "/path/to/silo/")
          (denote-known-keywords . ("food" "drink")))))
 #+end_src
 
@@ -882,7 +882,7 @@ This one is like the above, but also disables 
~denote-infer-keywords~:
 ;;;
 ;;;     (info "(emacs) Directory Variables")
 
-((nil . ((denote-directory . default-directory)
+((nil . ((denote-directory . "/path/to/silo/")
          (denote-known-keywords . ("food" "drink"))
          (denote-infer-keywords . nil))))
 #+end_src
@@ -895,7 +895,7 @@ modes, we can do something like this:
 ;;;
 ;;;     (info "(emacs) Directory Variables")
 
-((nil . ((denote-directory . default-directory)
+((nil . ((denote-directory . "/path/to/silo/")
          (denote-known-keywords . ("food" "drink"))
          (denote-infer-keywords . nil)))
  (org-mode . ((org-hide-emphasis-markers . t)
@@ -903,24 +903,6 @@ modes, we can do something like this:
               (org-hide-leading-stars . t))))
 #+end_src
 
-IMPORTANT If your silo contains sub-directories of notes, you
-should replace ~default-directory~ in the above examples with an
-absolute path to your silo directory, otherwise links from files
-within the sub-directories cannot be made to files in the parent
-directory. For example:
-
-#+begin_src emacs-lisp
-;;; Directory Local Variables.  For more information evaluate:
-;;;
-;;;     (info "(emacs) Directory Variables")
-  ((nil . ((denote-directory . "~/my-silo")
-           (denote-known-keywords . ("food" "drink"))
-           (denote-infer-keywords . nil)))
-   (org-mode . ((org-hide-emphasis-markers . t)
-                (org-hide-macro-markers . t)
-                (org-hide-leading-stars . t))))
-#+end_src
-
 As not all user options have a "safe" local value, Emacs will ask the
 user to confirm their choice and to store it in the Custom code
 snippet that is normally appended to init file (or added to the file
@@ -955,7 +937,6 @@ read the video's path when called from there (e.g. by using 
Emacs'
 
 [[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate directory silos 
for notes]].
 
-#+vindex: denote-user-enforced-denote-directory
 There are cases where the user (i) wants to maintain multiple silos
 and (ii) prefers an interactive way to switch between them without
 going through Dired.  Since this is specific to the user's workflow,
@@ -992,7 +973,7 @@ added to the user's Denote configuration:
          (intern (completing-read
                   "Run command in silo: "
                   my-denote-commands-for-silos nil t))))
-  (let ((denote-user-enforced-denote-directory silo))
+  (let ((denote-directory silo))
     (call-interactively command)))
 #+end_src
 
@@ -1000,12 +981,14 @@ With this in place, =M-x 
my-denote-pick-silo-then-command= will use
 minibuffer completion to select a silo among the predefined options
 and then ask for the command to run in that context.
 
-Note the use of the variable ~denote-user-enforced-denote-directory~.
-This variable is specially meant for custom commands to select
-silos. When it is set, it overrides the global default value of
-~denote-directory~ as well as the value provided by the
-=.dir-locals.el= file. Use it only when writing wrapper functions like
-~my-denote-pick-silo-then-command~.
+Note that =let= binding ~denote-directory~ can be used in custom
+commands and other wrapper functions to override the global default
+value of ~denote-directory~ to select silos.
+
+To see another example of a wrapper function that =let= binds
+~denote-directory~, see:
+
+[[#h:d0c7cb79-21e5-4176-a6af-f4f68578c8dd][Extending Denote: Split an Org 
subtree into its own note]].
 
 *** The =denote-silo-extras.el=
 :PROPERTIES:
@@ -3956,7 +3939,7 @@ might change them without further notice.
   ~denote-directory~ as a proper directory, also because it accepts a
   directory-local value for what we internally refer to as "silos"
   ([[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate directories 
for notes]]).  Custom Lisp code can
-  ~let~ bind the value of the variable ~denote-user-enforced-denote-directory~
+  ~let~ bind the value of the variable ~denote-directory~
   to override what this function returns.
 
 #+findex: denote-directory-files
diff --git a/denote-journal-extras.el b/denote-journal-extras.el
index 017bed805b..5345e7fc38 100644
--- a/denote-journal-extras.el
+++ b/denote-journal-extras.el
@@ -160,7 +160,7 @@ that covered in the documentation of the `denote' function. 
 It
 is internally processed by `denote-journal-extras--get-date'."
   (interactive (list (when current-prefix-arg (denote-date-prompt))))
   (let ((internal-date (denote-journal-extras--get-date date))
-        (denote-user-enforced-denote-directory 
(denote-journal-extras-directory)))
+        (denote-directory (denote-journal-extras-directory)))
     (denote
      (denote-journal-extras-daily--title-format internal-date)
      `(,denote-journal-extras-keyword)
diff --git a/denote-silo-extras.el b/denote-silo-extras.el
index 74e9b50152..1e4cfd5155 100644
--- a/denote-silo-extras.el
+++ b/denote-silo-extras.el
@@ -71,7 +71,7 @@ SILO is a file path from `denote-silo-extras-directories'.
 
 When called from Lisp, SILO is a file system path to a directory."
   (interactive (list (denote-silo-extras--directory-prompt)))
-  (let ((denote-user-enforced-denote-directory silo))
+  (let ((denote-directory silo))
     (call-interactively #'denote)))
 
 ;;;###autoload
@@ -81,7 +81,7 @@ SILO is a file path from `denote-silo-extras-directories'.
 
 When called from Lisp, SILO is a file system path to a directory."
   (interactive (list (denote-silo-extras--directory-prompt)))
-  (let ((denote-user-enforced-denote-directory silo))
+  (let ((denote-directory silo))
     (call-interactively #'denote-open-or-create)))
 
 ;;;###autoload
@@ -95,7 +95,7 @@ When called from Lisp, SILO is a file system path to a 
directory."
    (list
     (denote-silo-extras--directory-prompt)
     (denote-command-prompt)))
-  (let ((denote-user-enforced-denote-directory silo))
+  (let ((denote-directory silo))
     (call-interactively command)))
 
 (provide 'denote-silo-extras)
diff --git a/denote.el b/denote.el
index ab791ed402..8c92b15a30 100644
--- a/denote.el
+++ b/denote.el
@@ -123,28 +123,14 @@
 
 ;; About the autoload: (info "(elisp) File Local Variables")
 
-;;;###autoload (put 'denote-directory 'safe-local-variable (lambda (val) (or 
(eq val 'local) (eq val 'default-directory))))
+;;;###autoload (put 'denote-directory 'safe-local-variable (lambda (val) (or 
(stringp val) (eq val 'local) (eq val 'default-directory))))
 (defcustom denote-directory (expand-file-name "~/Documents/notes/")
   "Directory for storing personal notes.
 
-A safe local value of either `default-directory' or `local' can
-be added as a value in a .dir-local.el file.  Do this if you
-intend to use multiple directory silos for your notes while still
-relying on a global value (which is the value of this variable).
-The Denote manual has a sample (search for '.dir-locals.el').
-Those silos do not communicate with each other: they remain
-separate.
-
-The local value influences where commands such as `denote' will
-place the newly created note.  If the command is called from a
-directory or file where the local value exists, then that value
-take precedence, otherwise the global value is used.
-
 If you intend to reference this variable in Lisp, consider using
-the function `denote-directory' instead: it returns the path as a
-directory and also checks if a safe local value should be used."
+the function `denote-directory' instead."
   :group 'denote
-  :safe (lambda (val) (or (eq val 'local) (eq val 'default-directory)))
+  :safe (lambda (val) (or (stringp val) (eq val 'local) (eq val 
'default-directory)))
   :package-version '(denote . "2.0.0")
   :link '(info-link "(denote) Maintain separate directories for notes")
   :type 'directory)
@@ -658,25 +644,22 @@ Like `denote--completion-table' but also disable sorting."
   (when (not (file-directory-p denote-directory))
     (make-directory denote-directory :parents)))
 
-(defvar denote-user-enforced-denote-directory nil
-  "Value of the variable `denote-directory'.
-Use this to `let' bind a directory path, thus overriding what the
-function `denote-directory' ordinarily returns.")
-
 (defun denote-directory ()
   "Return path of variable `denote-directory' as a proper directory.
-Custom Lisp code can `let' bind the value of the variable
-`denote-user-enforced-denote-directory' to override what this
-function returns.
-
-Otherwise, the order of precedence is to first check for a silo
-before falling back to the value of the variable
-`denote-directory'."
-  (let ((path (or denote-user-enforced-denote-directory
-                  (denote--default-directory-is-silo-p)
-                  (denote--make-denote-directory)
-                  (default-value 'denote-directory))))
-    (file-name-as-directory (expand-file-name path))))
+Custom Lisp code can `let' bind the variable `denote-directory'
+to override what this function returns."
+  ;; TODO 2024-02-09: Remove this condition eventually.
+  (if-let (((or (eq denote-directory 'default-directory) (eq denote-directory 
'local)))
+           (silo-dir (denote--default-directory-is-silo-p)))
+      silo-dir
+    (let ((denote-directory (file-name-as-directory (expand-file-name 
denote-directory))))
+      (denote--make-denote-directory)
+      denote-directory)))
+
+(make-obsolete
+ 'denote-user-enforced-denote-directory
+ 'denote-directory
+ "3.0.0")
 
 (defun denote--slug-no-punct (str &optional extra-characters)
   "Remove punctuation from STR.
diff --git a/tests/denote-test.el b/tests/denote-test.el
index 41e5784798..28ee7c3c0a 100644
--- a/tests/denote-test.el
+++ b/tests/denote-test.el
@@ -31,16 +31,6 @@
 (require 'ert)
 (require 'denote)
 
-;; TODO 2023-05-22: Incorporate an actual silo in this test directory
-;; and modify the test accordingly.
-(ert-deftest denote-test-denote--default-directory-is-silo-p ()
-  "Test that `denote--default-directory-is-silo-p' returns a path."
-  (let ((path (denote--default-directory-is-silo-p)))
-    (should (or (null path)
-                (and (stringp path)
-                     (file-exists-p path)
-                     (file-directory-p path))))))
-
 (ert-deftest denote-test--denote--make-denote-directory ()
   "Test that `denote--make-denote-directory' creates the directory."
   (should (null (denote--make-denote-directory))))



reply via email to

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