~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
1

[PATCH] Fix: denote-extract-keywords-from-front-matter should always return a list

Details
Message ID
<20231105104313.73804-1-ved.manerikar@gmail.com>
DKIM signature
missing
Download raw message
Patch: +2 -2
I hit this bug when I called `M-x
denote-change-file-type-and-front-matter` on an Org file with empty
filetags, to convert it to Markdown-YAML format.

This is the front-matter of the original file:
```
   #+title:      Great Content is the Heart of Audience Building
   #+filetags:
   #+date:       [2023-03-08 Wed 18:51]
   #+identifier: 20230308T185100
```

The stack-trace is as follows:
```
Debugger entered--Lisp error: (error "‘’ is not a list")
  signal(error ("‘’ is not a list"))
  error("`%s' is not a list" "")
  denote-sluggify-keywords("")
  denote--format-front-matter-keywords("" markdown-yaml)
  denote--format-front-matter("Great Content is the Heart of Audience Building" "2023-03-08T18:51:00+05:30" "" "20230308T185100" markdown-yaml)
  denote--add-front-matter("/.../20230308T18..." "Great Content is the Heart of Audience Building" "" "20230308T185100" markdown-yaml)
  denote-change-file-type-and-front-matter("/.../20230308T18..." markdown-yaml)
```

Following the chain of commands shows that the culprit is the line
```
(denote-retrieve-keywords-value file old-file-type)
```
in `denote-change-file-type-and-front-matter`, which returns an
empty string when the rest of the functions expect a list of strings.

I looked at where `denote-extract-keywords-from-front-matter` is being
used and why the code was originally returning an empty string, and it
looks to me that returning an empty list from it now is the right
thing to do.
---
 denote.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/denote.el b/denote.el
index 5796c69..88fdcbf 100644
--- a/denote.el
+++ b/denote.el
@@ -1129,11 +1129,11 @@ for how this is used."
(defun denote-extract-keywords-from-front-matter (keywords-string)
  "Extract keywords list from front matter KEYWORDS-STRING.
Split KEYWORDS-STRING into a list of strings.  If KEYWORDS-STRING
satisfies `string-blank-p', return an empty string.
satisfies `string-blank-p', return an empty list.

Consult the `denote-file-types' for how this is used."
  (if (string-blank-p keywords-string)
      ""
      '()
    (split-string keywords-string "[:,\s]+" t "[][ \"']+")))

(defvar denote-file-types
-- 
2.42.0
Details
Message ID
<87cywm83m6.fsf@protesilaos.com>
In-Reply-To
<20231105104313.73804-1-ved.manerikar@gmail.com> (view parent)
DKIM signature
missing
Download raw message
> From: Vedang Manerikar <ved.manerikar@gmail.com>
> Date: Sun,  5 Nov 2023 16:13:13 +0530

> [... 37 lines elided]

>  denote.el | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Thank you, Vedang! I just installed your patch.

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