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

denote-dired-mode ("fontification") not triggered in subdirectory if subdirectory is symlinked #346

Open
julian-hoch opened this issue May 11, 2024 · 5 comments

Comments

@julian-hoch
Copy link

I am not sure if this is a defect in Denote, or something that is just not possible in Emacs, but if
you

  • set up multiple subdirectories below your main denote directory
  • configure the hook for dired-mode
  • enable denote-mode in dired for subdirectories using denote-dired-directories-include-subdirectories

you will get dired mode only for subdirectories that are physical subdirectories, not symlinks. I am wondering if there is a way to make sure dired follows the symlink when determining whether to enable the denote mode.

A workaround is to manually add the symlinked directories to "denote-dired-directories", but obviously this only works if there are few subdirectories (and makes it a bit cumbersome to configure for cases where the same config is used on different computers with a different subfolder structure on the respective denote directory).

@protesilaos
Copy link
Owner

protesilaos commented May 13, 2024 via email

@julian-hoch
Copy link
Author

Hi Prot!
Yeah, the directories are all set up correctly.
I suspect that the issue lies here:

;; denote.el - defun denote-dired-mode-in-directories
[...]
             ((or (member (file-truename default-directory) dirs)
[...]

"file-truename" resolves symlinks, so this will compare the directories I configured in my emacs config with the "true" path of the dorectory I am in - which will not resolve to the same path in my case.

In my case, I set up the denote directories as ~/denote/private, ~/denote/customer, which link to ~/git/denote-private-kb and ~/git/denote-customer-kb, just for convenience. So the "member" test will fail if I access them via the symlink (but it works if I dired into the "real" path).

I suspect this could be fixed by also applying file-truename to all the directories in the "dirs" list.
Julian

@protesilaos
Copy link
Owner

Thank you for looking into this!

I suspect this could be fixed by also applying file-truename to all the directories in the "dirs" list.

Maybe we can just remove the file-truename? It has always been there but I am not sure it is necessary.

@julian-hoch
Copy link
Author

My understanding is that the advantage of using file-truename is that it does not matter if you use a symlink to look at your files.
So if you have your denote directory in one physical location, and then link to it from various other places, I would think people would typically want to enable the dired mode for all of these, I don't see a reason why you would not want that.
You could also make it optional - a configuration variable "follow-symlinks" or something (similar in the way ripgrep and other utilities handle it) so that if it is set to

  • true: all symlinks to your configured denoted dired directorys are rendered nicely or
  • false: only the configured path is considered
    In my opinion this is the Emacs way - make it configurable and up to the user, but provide a sensible default that works for most (probably 'true' in this case).
    The one thing that I would not recommend is to leave it as is, since it is simply inconsistent.
    Since I am new to emacs and elisp I am not super confident I can implement this myself, but if you don't have the time for it I can give it a go.

@protesilaos
Copy link
Owner

Since I am new to emacs and elisp I am not super confident I can implement this myself, but if you don't have the time for it I can give it a go.

What we can do is introduce a variable like denote-directory-check-path-function. Its default value will be the function we are using right now. Then we arrange to funcall this variable, so users who experience this problem can define the alternative that works for them.

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