branch: externals/denote commit d5cf35ec2e11fb2891f15e405644768105a6a119 Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
REMOVE recursive search for silo root; keep simpler check This was never a good idea but I wanted to see what the implications are. We do not need this anymore due to commit 3d2e1d5 which simplifies 'denote--silo-p'. Thanks to relict007, Hilde Rhyne, Mirko Hernández, Noboru Ota (nobiot), Alan Schmitt, and hapst3r for their participation in the relevant discussions: - https://lists.sr.ht/~protesilaos/denote/%3C87fsb72nge.fsf%40protesilaos.com%3E - https://lists.sr.ht/~protesilaos/denote/%3C80CBB671-D812-4EA8-8C80-85F9F4144051%40disroot.org%3E - https://lists.sr.ht/~protesilaos/denote/%3C87pma6t59i.fsf%40kotlak.com%3E - https://github.com/protesilaos/denote/issues/129 (GitHub mirror) --- README.org | 26 -------------------------- denote.el | 41 +---------------------------------------- 2 files changed, 1 insertion(+), 66 deletions(-) diff --git a/README.org b/README.org index b843b5598e..5f535355c8 100644 --- a/README.org +++ b/README.org @@ -770,32 +770,6 @@ to experiment with the best setup for their workflow. Feel welcome to ask for help if the information provided herein is not sufficient. The manual shall be expanded accordingly. -*** Determine levels of depth in a silo -:PROPERTIES: -:CUSTOM_ID: h:3aeacd4d-8cd2-49b7-bc49-15bbbf4281c0 -:END: - -[ Part of {{{development-version}}}. ] - -Silos have a directory-local variable that isolates them from the -default value of the user option ~denote-directory~. When the silo is -a flat directory, Denote can easily know about it. Otherwise it needs -to search the parents of the current directory in order to determine -if the current file belongs to a silo. - -#+vindex: denote-silo-nesting-depth -To this end, the user can specify a natural number as the value of the -user option ~denote-silo-nesting-depth~. The default value is =2=, -meaning that Denote will check the current directory and its parent -directory to determine if either of those paths constitute a silo. If -they are, Denote will return the given path, else it will use the -default (global) value of the ~denote-directory~. - -[[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate directory silos for notes]]. - -Levels of depth are needed to allow silos to have subdirectories. -Otherwise they are assume to be flat. - *** Use custom commands to select a silo :PROPERTIES: :CUSTOM_ID: h:0f72e6ea-97f0-42e1-8fd4-0684af0422e0 diff --git a/denote.el b/denote.el index 2a33249ac3..95ff41bec6 100644 --- a/denote.el +++ b/denote.el @@ -150,27 +150,6 @@ directory and also checks if a safe local value should be used." :link '(info-link "(denote) Maintain separate directories for notes") :type 'directory) -(defcustom denote-silo-nesting-depth 2 - "How many levels up to check if current file is in a silo. -Silos have a directory-local variable that isolates them from the -default value of the variable `denote-directory'. When the silo -is a flat directory, Denote can easily know about it. Otherwise -it needs to search the parents of the current directory in order -to determine if the current file belongs to a silo. - -The default value is 2, meaning that Denote will check the -current directory and its parent directory to determine if either -of those paths constitute a silo. If they are, Denote will -return the given path, else it will use the default (global) -value of the variable `denote-directory'. - -Levels of depth are needed to allow silos to have subdirectories. -Otherwise they are assume to be flat." - :group 'denote - :type 'natnum - :package-version '(denote . "1.3.0") - :link '(info-link "(denote) Maintain separate directories for notes")) - (defcustom denote-known-keywords '("emacs" "philosophy" "politics" "economics") "List of strings with predefined keywords for `denote'. @@ -523,27 +502,9 @@ things accordingly.") dir-locals) (t nil)))) -(defun denote--get-silo-path (&optional file levels) - "Try to determine if FILE belongs to a silo. - -Operate recursively up to optional LEVELS. If LEVELS is nil, use -`denote-silo-nesting-depth'. - -If no silo is found, return nil. See the function -`denote-directory'." - (when-let ((file-or-dir (if (and file (file-directory-p file)) file default-directory))) - (or (denote--silo-p file-or-dir) - (let ((path file-or-dir)) - (catch 'value - (dotimes (_n (or levels denote-silo-nesting-depth)) - (if (denote--silo-p path) - (throw 'value path) - (setq path (file-name-parent-directory path))))) - (denote--silo-p path))))) - (defun denote-directory () "Return path of variable `denote-directory' as a proper directory." - (let ((path (or (denote--get-silo-path) + (let ((path (or (denote--silo-p default-directory) (when (and (stringp denote-directory) (not (file-directory-p denote-directory))) (make-directory denote-directory t))