~protesilaos/denote

1

Function denote-directory returns wrong value

Details
Message ID
<80CBB671-D812-4EA8-8C80-85F9F4144051@disroot.org>
DKIM signature
pass
Download raw message
Hi Prot,
thanks for creating and maintaining this wonderful package.

I would like to share a weird behavior of denote related to recent updates :)

The function denote-directory returns an incorrect value when default-directory
contains .dir-locals.el doesn't have a local value of denote-directory.
In that condition, the current folder should not be a silo.

In my opinion, this weird behavior could be related to the function
denote--silo-p:

(defun denote--silo-p (path)
  "Return path to silo if PATH is a silo."
  (when (and path (file-directory-p path))
    (with-temp-buffer
      (when-let* ((files (directory-files path))
                  ((member ".dir-locals.el" files))
                  (val (buffer-local-value
                        'denote-directory
                        ;; TODO 2023-02-12: Clean up the created buffer
                        (get-buffer-create (find-file-noselect path)))))
        path))))

The buffer-local-value should be modified to local-variable-p, so that a
folder contains .dir-locals.el without a local value of denote-directory
will not be considered a silo.
-- 
Hilde Rhyne
Details
Message ID
<87k00dmhly.fsf@protesilaos.com>
In-Reply-To
<80CBB671-D812-4EA8-8C80-85F9F4144051@disroot.org> (view parent)
DKIM signature
pass
Download raw message
> From: Hilde Rhyne <hilde.rhyne@disroot.org>
> Date: Mon, 20 Feb 2023 03:36:41 +0800
>
> Hi Prot,

Hello there!

> thanks for creating and maintaining this wonderful package.

You are welcome!

> I would like to share a weird behavior of denote related to recent updates :)
>
> The function denote-directory returns an incorrect value when default-directory
> contains .dir-locals.el doesn't have a local value of denote-directory.
> In that condition, the current folder should not be a silo.
>
> In my opinion, this weird behavior could be related to the function
> denote--silo-p:
>
> (defun denote--silo-p (path)
>   "Return path to silo if PATH is a silo."
>   (when (and path (file-directory-p path))
>     (with-temp-buffer
>       (when-let* ((files (directory-files path))
>                   ((member ".dir-locals.el" files))
>                   (val (buffer-local-value
>                         'denote-directory
>                         ;; TODO 2023-02-12: Clean up the created buffer
>                         (get-buffer-create (find-file-noselect path)))))
>         path))))
>
> The buffer-local-value should be modified to local-variable-p, so that a
> folder contains .dir-locals.el without a local value of denote-directory
> will not be considered a silo.

Good point!  Note though that we are currently discussing this part and
it will probably be revised/removed.  Relevant threads:

- https://lists.sr.ht/~protesilaos/denote/%3C87pma6t59i.fsf%40kotlak.com%3E
- https://github.com/protesilaos/denote/issues/129

All the best,
Prot

-- 
Protesilaos Stavrou
https://protesilaos.com
Reply to thread Export thread (mbox)