obsidian.el
obsidian.el copied to clipboard
follow-link-at-point can't follow some wikilinks in incomplete tasks
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.
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.
That sounds like a simple and elegant solution
The necessary regex changes were made in markdown-mode pull #776 to resolve this issue
So all we need is updating the markdown-mode version?
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.
Let's copy the function then
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?
We can increase the required version of the markdown-mode