~protesilaos/denote

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH 1/2] Fix: Handle signature in denote-dired-rename-marked-files-with-keywords

Details
Message ID
<20231117152700.70695-1-ved.manerikar@gmail.com>
DKIM signature
missing
Download raw message
Patch: +1 -1
I hit this bug when I called `M-x
denote-dired-rename-marked-files-with-keywords` on the file at point
in a dired buffer. The stack-trace is as follows:

```
Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
  replace-regexp-in-string("[][{}!@#$%^&*()=+'\"?,.|;:~`‘’“”/]*-" "" nil)
  denote--slug-no-punct(nil "-")
  denote-sluggify-signature(nil)
  denote-dired-rename-marked-files-with-keywords()
  ```

`denote-sluggify-signature` gets a `nil` input which it cannot handle.
This happens because the signature is extracted using
`denote-retrieve-filename-signature`, which can return a `nil` value.

The fix is to only call `denote-sluggify-signature` when we have a
signature to handle.
---
 denote.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/denote.el b/denote.el
index 23e074d..9d8e006 100644
--- a/denote.el
+++ b/denote.el
@@ -2530,7 +2530,7 @@ Specifically, do the following:
                 (file-type (denote-filetype-heuristics file))
                 (title (denote--retrieve-title-or-filename file file-type))
                 (extension (denote-get-file-extension file))
                 (new-name (denote-format-file-name dir id keywords (denote-sluggify title 'title) extension (denote-sluggify-signature signature))))
                 (new-name (denote-format-file-name dir id keywords (denote-sluggify title 'title) extension (when signature (denote-sluggify-signature signature)))))
            (denote-rename-file-and-buffer file new-name)
            (when (denote-file-is-writable-and-supported-p new-name)
              (if (denote--edit-front-matter-p new-name file-type)
-- 
2.42.0

[PATCH 2/2] Fix: Ensure signature is sluggified correctly when renaming

Details
Message ID
<20231117152700.70695-2-ved.manerikar@gmail.com>
In-Reply-To
<20231117152700.70695-1-ved.manerikar@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Patch: +2 -2
Based on the bug found in the previous commit, I looked at all the
call-sites for `denote-sluggify-signature` and
`denote-retrieve-filename-signature` and found two other places:

1. `denote-rename-file`: Add check to ensure signature exists when
   trying to sluggify it.

2. `denote-rename-file-using-front-matter`: Sluggify the signature
   before creating the new file-name.
---
 denote.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/denote.el b/denote.el
index 9d8e006..c6137f6 100644
--- a/denote.el
+++ b/denote.el
@@ -2429,7 +2429,7 @@ place."
         (title (or title (denote--retrieve-title-or-filename file file-type)))
         (keywords (or keywords (denote-retrieve-keywords-value file file-type)))
         (signature (or signature (denote-retrieve-filename-signature file)))
         (new-name (denote-format-file-name dir id keywords (denote-sluggify title 'title) extension (denote-sluggify-signature signature)))
         (new-name (denote-format-file-name dir id keywords (denote-sluggify title 'title) extension (when signature (denote-sluggify-signature signature))))
         (max-mini-window-height denote-rename-max-mini-window-height))
    (when (or denote-rename-no-confirm (denote-rename-file-prompt file new-name))
      (denote-rename-file-and-buffer file new-name)
@@ -2573,7 +2573,7 @@ does internally."
             (signature (denote-retrieve-filename-signature file))
             (extension (denote-get-file-extension file))
             (dir (file-name-directory file))
             (new-name (denote-format-file-name dir id keywords sluggified-title extension signature)))
             (new-name (denote-format-file-name dir id keywords sluggified-title extension (when signature (denote-sluggify-signature signature)))))
        (when (or auto-confirm
                  (denote-rename-file-prompt file new-name))
          (denote-rename-file-and-buffer file new-name)
-- 
2.42.0
Details
Message ID
<875y1zsajg.fsf@protesilaos.com>
In-Reply-To
<20231117152700.70695-1-ved.manerikar@gmail.com> (view parent)
DKIM signature
missing
Download raw message
> From: Vedang Manerikar <ved.manerikar@gmail.com>
> Date: Fri, 17 Nov 2023 20:56:59 +0530
>
> I hit this bug when I called `M-x
> denote-dired-rename-marked-files-with-keywords` on the file at point
> in a dired buffer. The stack-trace is as follows:
>
> ```
> Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
>   replace-regexp-in-string("[][{}!@#$%^&*()=+'\"?,.|;:~`‘’“”/]*-" "" nil)
>   denote--slug-no-punct(nil "-")
>   denote-sluggify-signature(nil)
>   denote-dired-rename-marked-files-with-keywords()
>   ```

> [... 25 lines elided]

Thank you, Vedang! I installed your patch.

-- 
Protesilaos Stavrou
https://protesilaos.com

Re: [PATCH 2/2] Fix: Ensure signature is sluggified correctly when renaming

Details
Message ID
<8734x3sahg.fsf@protesilaos.com>
In-Reply-To
<20231117152700.70695-2-ved.manerikar@gmail.com> (view parent)
DKIM signature
missing
Download raw message
> From: Vedang Manerikar <ved.manerikar@gmail.com>
> Date: Fri, 17 Nov 2023 20:57:00 +0530
>
> Based on the bug found in the previous commit, I looked at all the
> call-sites for `denote-sluggify-signature` and
> `denote-retrieve-filename-signature` and found two other places:
>
> 1. `denote-rename-file`: Add check to ensure signature exists when
>    trying to sluggify it.
>
> 2. `denote-rename-file-using-front-matter`: Sluggify the signature
>    before creating the new file-name.

> [... 26 lines elided]

I installed this patch as well. Thank you, Vedang!

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