Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links and Custom Folders #16

Closed
svnsbck opened this issue Jun 17, 2022 · 14 comments
Closed

Links and Custom Folders #16

svnsbck opened this issue Jun 17, 2022 · 14 comments

Comments

@svnsbck
Copy link

svnsbck commented Jun 17, 2022

Hi Prot!
I'm sure I'm missing something somewhere, but I get some funny results creating links.

When I'm in my default notes folder, linking to and opening links works as expected. I do however get duplicates when using denote-link-add-links and searching only for date, say 20220617. I guess this is because the regex searches both filename and title, hence creates duplicates.

When I'm though in another folder, say Docs/journal and do the same search it searches the /notes folder and respectively adds files matching the same files with the difference that I can't seem to open them. Adding a link via denote-link-insert-link adds the right link, but I'm unable to open it.

I tried to add a local-variables file, but that rather broke stuff :-)

@protesilaos
Copy link
Owner

Hi Sven,

I do however get duplicates when using denote-link-add-links and
searching only for date, say 20220617. I guess this is because the
regex searches both filename and title, hence creates duplicates.

If your files have a date in their title field, then yes those results
you are getting are to be expected.

If you want to match the start of the file where the identifier/date is,
start your regexp with ^. For example ^20220617.

When I'm though in another folder, say Docs/journal and do the same
search it searches the /notes folder and respectively adds files
matching the same files with the difference that I can't seem to open
them. Adding a link via denote-link-insert-link adds the right link,
but I'm unable to open it.

Does this other folder have a .dir-locals.el which sets the
denote-directory to the current directory?

protesilaos added a commit that referenced this issue Jun 17, 2022
This relates to the example we cover in the manual, which was updated in
commit 47a9024.

Thanks to Sven Seebeck for reporting the bug in issue 16 over at the
GitHub mirror: <#16>.
@protesilaos
Copy link
Owner

I found the bug and pushed a change. If you were using .dir-locals.el as the manual suggested, update its contents to this:

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((nil . ((denote-directory . default-directory))))

The old value was faulty and I forgot to review it earlier.

Please let me know if this addresses your problems.

@svnsbck
Copy link
Author

svnsbck commented Jun 18, 2022

Hi Prot,

thanks for your reply. I just now had the chance to do some testing and the new code for the .dir-locals file fixes the issue with the links. Adding links via "denote-link-find-file" and following those links via "denote-link-find-file" does now work as expected.

Adding links via denote-link-insert-links-matching-regexp"though doesn't seem to work and the error Opening input file: No such file or directory, (below that it shows the path and filename of the current document) comes up in the Minibuffer. This would be in the secondary folder containing the .dir-locals.el file.

In the primary folder it works, but still produces duplicates when for example searching for ^20220617 as you suggested. But that might be because I'm not familiar with regex (I would like to say "yet").

I also found something in the Backlinks buffer:

I'm not sure if this is intended or not, but it seems that the backlinks-buffer is build and fontified correctly, but it doesn't seem to be possible to open any of the links at the moment (Buffer is read only). The buffer also produces duplicates and also includes a link to the current document.

I noticed this behaviour both in the default folder, as well as in the secondary folder, that is the one containing the .dir-locals.el file.

protesilaos added a commit that referenced this issue Jun 18, 2022
Sorting them after they are inserted breaks them.  Thanks to Sven
Seebeck for reporting the regression in issue 16 over at the GitHub
mirror: <#16>.
@protesilaos
Copy link
Owner

Hello Sven,

the new code for the .dir-locals file fixes the issue with the links. Adding links via "denote-link-find-file" and following those links via "denote-link-find-file" does now work as expected.

Good!

Adding links via denote-link-insert-links-matching-regexp"though doesn't seem to work and the error Opening input file: No such file or directory, (below that it shows the path and filename of the current document) comes up in the Minibuffer. This would be in the secondary folder containing the .dir-locals.el file.

I can reproduce this. Will figure out what the problem is and report back to you.

In the primary folder it works, but still produces duplicates when for example searching for ^20220617 as you suggested. But that might be because I'm not familiar with regex (I would like to say "yet").

You mean duplicates as in the same file more than once or matches that are not exactly what you would like? If you show me some examples, I can help further.

I also found something in the Backlinks buffer:

I broke this yesterday when I added the sort mechanism. It should be fixed now per commit 429763c, aab484d.

@svnsbck
Copy link
Author

svnsbck commented Jun 18, 2022

Great!

And I just figured out why there are duplicates showing.

Screenshot from 2022-06-18 07-35-57
Both instances open the same document, but looking at the folder in the files-app and not Dired reveals two files, but one with an .org~ ending. I guess that's an autosave or such file?

@protesilaos
Copy link
Owner

I guess that's an autosave or such file?

Yes, I noticed this a few minutes ago and pushed some changes. Thanks!

Now working on the error you reported.

@protesilaos
Copy link
Owner

Oh, I should ask here: the ~ in those files is only at the end? If so, I need to tweak the filter.

@svnsbck
Copy link
Author

svnsbck commented Jun 18, 2022

Oh, I should ask here: the ~ in those files is only at the end? If so, I need to tweak the filter.

Yes, only at the end (checked also in eshell)
Screenshot from 2022-06-18 08-09-24
I should maybe set a different backup/autosave location in the process :--)

@protesilaos
Copy link
Owner

I should maybe set a different backup/autosave location in the process :--)

In principle, there should be no need to change that (if you like it that way). I just improved the check for it.

protesilaos added a commit that referenced this issue Jun 18, 2022
This would override the default-directory when using something like 'M-x
denote-link-add-links' from a file whose directory had a local value for
'denote-directory'.

Thanks to Sven Seebeck for reporting the bug in issue 16 over at the
GitHub mirror: <#16>.
@protesilaos
Copy link
Owner

I believe I fixed the bug now. Please check.

@svnsbck
Copy link
Author

svnsbck commented Jun 18, 2022

Great! Adding links the in a secondary folder works now as one might expect.

I noticed though that the Backlinks-Buffer also includes links to the backup/autosave files, which might cause confusion. This happens in both folders, the default and the secondary/alternative one.

protesilaos added a commit that referenced this issue Jun 18, 2022
This should remove the false positives reported by Sven Seebeck in issue
16 over at the GitHub mirror:
<#16>.

It also eliminates the potential problem with the use of "^" against
full paths, where it would always fail.
@protesilaos
Copy link
Owner

Great! Adding links the in a secondary folder works now as one might expect.

Very well!

I noticed though that the Backlinks-Buffer also includes links to the backup/autosave files, which might cause confusion. This happens in both folders, the default and the secondary/alternative one.

Just pushed a change. It should remove all false positive. Please give it a try.

@svnsbck
Copy link
Author

svnsbck commented Jun 18, 2022

Nice! Everything seems to work as expected! Perfect!

@protesilaos
Copy link
Owner

Excellent! Thanks again for the feedback! I am now closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants