~protesilaos/denote

3 2

Issue on dev with org-babel-tangle

Storms Elias <elias.storms@ap.be>
Details
Message ID
<15D55F4B-64D1-4083-AD5E-B5BACA8F1909@ap.be>
DKIM signature
missing
Download raw message
Hi all

After pulling the latest code, I get an error when attempting to call
org-babel-tangle on an Org-file (which should simply extract all source
blocks).

I get: "Cannot find ‘path/to/file/core.org’ as a file with a Denote
identifier"

The reason, as far as I've been able to trace it, has to do with
'denote-link-ol-store', which calls 'denote-retrieve-filename-identifier'
on the .org file, but throws an error as there is no identifier in the
filename.

I'm not sur how 'org-babel-tangle' works internally (but apparrently it calls
'org-store-link' and stumbles on the 'denote-link-ol-store’

I think it has to do with recent changes made in commit a74adca4.
In that commit, 'denote-link-ol-store' is changed and it now calls
(denote-file-is-note-p file), which throws the error.

Perhaps we need to rewrite denote-file-is-note-p to not throw an error
internally, but to return a value instead?

All the best
Elias
Details
Message ID
<87edvymja1.fsf@protesilaos.com>
In-Reply-To
<15D55F4B-64D1-4083-AD5E-B5BACA8F1909@ap.be> (view parent)
DKIM signature
missing
Download raw message
> From: Storms Elias <elias.storms@ap.be>
> Date: Mon, 26 Sep 2022 10:08:09 +0000
>
> Hi all

Hello Elias and thanks for reporting this!

> After pulling the latest code, I get an error when attempting to call
> org-babel-tangle on an Org-file (which should simply extract all source
> blocks).
>
> I get: "Cannot find ‘path/to/file/core.org’ as a file with a Denote
> identifier"
>
> The reason, as far as I've been able to trace it, has to do with
> 'denote-link-ol-store', which calls 'denote-retrieve-filename-identifier'
> on the .org file, but throws an error as there is no identifier in the
> filename.

Can you post a backtrace?  Or provide a sample file that I can use to
reproduce the issue?

> I'm not sur how 'org-babel-tangle' works internally (but apparrently it calls
> 'org-store-link' and stumbles on the 'denote-link-ol-store’
>
> I think it has to do with recent changes made in commit a74adca4.
> In that commit, 'denote-link-ol-store' is changed and it now calls
> (denote-file-is-note-p file), which throws the error.
>
> Perhaps we need to rewrite denote-file-is-note-p to not throw an error
> internally, but to return a value instead?

This is unexpected because, for example, the following returns nil on my
end.  No error involved:

    (denote-file-is-note-p "/home/prot/Documents/org/tasks.org")

Looking at commit a74adca4, I probably miswrote the 'when-let'.  It is
missing a pair of parentheses:

    (defun denote-link-ol-store()
      "Handler for `org-store-link' adding support for denote: links."
      (when-let* ((file (buffer-file-name))
                  ((denote-file-is-note-p file)) ; MISSING HERE
                  (file-type (denote-filetype-heuristics file))
                  (file-id (denote-retrieve-filename-identifier file))
                  (file-title (denote--retrieve-title-or-filename file file-type)))
        (org-link-store-props
         :type "denote"
         :description file-title
         :link (concat "denote:" file-id)))
      org-store-link-plist)

Though please share a sample file to test things.

All the best,
Prot

-- 
Protesilaos Stavrou
https://protesilaos.com
Details
Message ID
<m2a66mmfkg.fsf@MBA21.fritz.box>
In-Reply-To
<87edvymja1.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
Hi Prot

> Looking at commit a74adca4, I probably miswrote the 'when-let'.  It is
> missing a pair of parentheses

I was writing an example file and copying the backtrace, but after fixing
the parentheses you mentioned, the problem is resolved! So it seems like
the missing parentheses were the issue indeed.

Below is still the example file & backtrace, but you probably won't need
it as you already fixed it.

All the best
Elias


# Example file (saved as ~/test.org


  #+title: Test

  #+begin_src emacs-lisp :tangle "~/test.el"
  (denote-file-is-note-p "~/test.org")
  #+end_src


# Backtrace

  Debugger entered--Lisp error: (error "Cannot find ‘/Users/elias/test.org’ as a file with...")
    signal(error ("Cannot find ‘/Users/elias/test.org’ as a file with..."))
    error("Cannot find `%s' as a file with a Denote identifie..." "/Users/elias/test.org")
    (if (denote-file-has-identifier-p file) (progn (string-match denote--id-regexp file) (match-string 0 file)) (error "Cannot find `%s' as a file with a Denote identifie..." file))
    denote-retrieve-filename-identifier("/Users/elias/test.org")
    (and file-type (denote-retrieve-filename-identifier file))
    (let* ((file (and t (buffer-file-name))) (denote-file-is-note-p (and file file)) (file-type (and denote-file-is-note-p (denote-filetype-heuristics file))) (file-id (and file-type (denote-retrieve-filename-identifier file))) (file-title (and file-id (denote--retrieve-title-or-filename file file-type)))) (if file-title (org-link-store-props :type "denote" :description file-title :link (concat "denote:" file-id))))
    denote-link-ol-store()
    org-store-link(nil)
    org-babel-tangle-single-block(1)
    org-babel-tangle-collect-blocks(nil nil)
    org-babel-tangle(nil)
    funcall-interactively(org-babel-tangle nil)
    call-interactively(org-babel-tangle nil nil)
    command-execute(org-babel-tangle)

Protesilaos Stavrou <info@protesilaos.com> writes:

>> From: Storms Elias <elias.storms@ap.be>
>> Date: Mon, 26 Sep 2022 10:08:09 +0000
>>
>> Hi all
>
> Hello Elias and thanks for reporting this!
>
>> After pulling the latest code, I get an error when attempting to call
>> org-babel-tangle on an Org-file (which should simply extract all source
>> blocks).
>>
>> I get: "Cannot find ‘path/to/file/core.org’ as a file with a Denote
>> identifier"
>>
>> The reason, as far as I've been able to trace it, has to do with
>> 'denote-link-ol-store', which calls 'denote-retrieve-filename-identifier'
>> on the .org file, but throws an error as there is no identifier in the
>> filename.
>
> Can you post a backtrace?  Or provide a sample file that I can use to
> reproduce the issue?
>
>> I'm not sur how 'org-babel-tangle' works internally (but apparrently it calls
>> 'org-store-link' and stumbles on the 'denote-link-ol-store’
>>
>> I think it has to do with recent changes made in commit a74adca4.
>> In that commit, 'denote-link-ol-store' is changed and it now calls
>> (denote-file-is-note-p file), which throws the error.
>>
>> Perhaps we need to rewrite denote-file-is-note-p to not throw an error
>> internally, but to return a value instead?
>
> This is unexpected because, for example, the following returns nil on my
> end.  No error involved:
>
>     (denote-file-is-note-p "/home/prot/Documents/org/tasks.org")
>
> Looking at commit a74adca4, I probably miswrote the 'when-let'.  It is
> missing a pair of parentheses:
>
>     (defun denote-link-ol-store()
>       "Handler for `org-store-link' adding support for denote: links."
>       (when-let* ((file (buffer-file-name))
>                   ((denote-file-is-note-p file)) ; MISSING HERE
>                   (file-type (denote-filetype-heuristics file))
>                   (file-id (denote-retrieve-filename-identifier file))
>                   (file-title (denote--retrieve-title-or-filename file file-type)))
>         (org-link-store-props
>          :type "denote"
>          :description file-title
>          :link (concat "denote:" file-id)))
>       org-store-link-plist)
>
> Though please share a sample file to test things.
>
> All the best,
> Prot
Details
Message ID
<877d1qdy86.fsf@protesilaos.com>
In-Reply-To
<m2a66mmfkg.fsf@MBA21.fritz.box> (view parent)
DKIM signature
missing
Download raw message
> From: Elias Storms <elias.storms@gmail.com>
> Date: Mon, 26 Sep 2022 15:21:20 +0200
>
>
> Hi Prot

Hello Elias,

>> Looking at commit a74adca4, I probably miswrote the 'when-let'.  It is
>> missing a pair of parentheses
>
> I was writing an example file and copying the backtrace, but after fixing
> the parentheses you mentioned, the problem is resolved! So it seems like
> the missing parentheses were the issue indeed.

I suspected this had to be it.  Otherwise the code was doing the same
thing.

> Below is still the example file & backtrace, but you probably won't need
> it as you already fixed it.

Thanks for the effort!

I mentioned you and this thread in the commit message I made:

    commit f0dedb320bcaab509fab1e5625b18e0fbb9a2872
    Author: Protesilaos Stavrou <info@protesilaos.com>
    Date:   Mon Sep 26 15:22:38 2022 +0300

        Fix missing parens in denote-link-ol-store

        This was a regression caused by commit a74adca.  Thanks to Elias
        Storms for reporting a potentially related bug on the mailing list:
        <https://lists.sr.ht/~protesilaos/denote/%3C15D55F4B-64D1-4083-AD5E-B5BACA8F1909%40ap.be%3E>.

     denote.el | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)

All the best,
Prot

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