obsidian.el icon indicating copy to clipboard operation
obsidian.el copied to clipboard

follow-link-at-point can't follow some wikilinks in incomplete tasks

Open herschelrs opened this issue 1 year ago • 8 comments

I get an error trying to use obsidian-follow-link-at-point to follow wikilinks when they're in an incomplete task that begins with a link, like this:

- [ ] [[some project page]]

I get this error: Wrong type argument: arrayp, nil.

However, links like this work fine:

- [ ] go do [[some project]]

Appending words to the first example doesn't fix the problem. Note that obsidian-follow-wiki-link-at-point actually still works.

I'm running emacs 28.2 (in particular obsidian-nox on ubuntu 23.04), I got obsidian.el from MELPA.

herschelrs avatar May 31 '23 06:05 herschelrs

I dug into this a bit and see that the issue is that the function markdown-link-p recognizes the two sets of square brackets as a markdown reference link even though there's a space between them. Note that if you make it two spaces then things work as expected.

I didn't think that spaces were allowed between sets of brackets in markdown reference links, so I filed issue 774 with the markdown-mode library that supplies that function. The regex they're using to recognize markdown reference links allows for a single space between the brackets which is what is causing the issue here. That said, there may be a reason for that regex allowing the space that I'm not aware of.

A possible solution that doesn't rely on changes to markdown-mode would be to modify obsidian-follow-link-at-point by swapping the order that it checks for markdown links and wiki links. Markdown links are checked first, and since the link referenced in this issue is mistakenly recognized as a markdown link, the operation results in an error. If wiki links were checked first, then this link would first be recognized as a wiki link and handled correctly. I don't know if such a swap would cause issues elsewhere.

jayemar avatar Jul 14 '23 00:07 jayemar

That sounds like a simple and elegant solution

licht1stein avatar Jul 14 '23 06:07 licht1stein

The necessary regex changes were made in markdown-mode pull #776 to resolve this issue

jayemar avatar Jul 16 '23 15:07 jayemar

So all we need is updating the markdown-mode version?

licht1stein avatar Jul 16 '23 16:07 licht1stein

Yes, we only need to update markdown-mode, no changes are necessary to obsidian.el.

Unfortunately, it doesn't look like the version of markdown-mode was bumped as it was 2.6-alpha was I created the issue, and it's still showing as 2.6-alpha today after I updated from elpa. But I can verify that the latest code in melpa fixes the issue. Looks like it's version 20230716.1308 in melpa.

jayemar avatar Jul 16 '23 16:07 jayemar

Let's copy the function then

licht1stein avatar Jul 17 '23 05:07 licht1stein

Maybe my last message was confusing. Once a user updates to the latest version of markdown-mode, this issue will be resolved; no changes are required in obsidiain.el.

Are you suggesting we copy the markdown-link-p function from markdown-mode into obisidian.el?

jayemar avatar Jul 17 '23 14:07 jayemar

We can increase the required version of the markdown-mode

licht1stein avatar Aug 21 '23 12:08 licht1stein