Closed garrett-hopper closed 4 years ago
Err, it should only be expanded if (neuron--detect-zettelkasten pwd)
returns non-nil.
(defun neuron--get-zettelkasten (&optional pwd)
"Return the location of the current zettelkasten.
Assuming the current working directory is PWD, first try to
detect the zettelkasten automatically by traversing the hierarchy
upwards until a neuron.dhall file is found. When no neuron.dhall
file is found, return `neuron-default-zettelkasten-directory'.
Lastly, if the default zettelkasten location doesn't point to
an actual directory, return nil."
(interactive "P")
(or
(if-let ((x (neuron--detect-zettelkasten pwd)))
(expand-file-name x))
(let ((root neuron-default-zettelkasten-directory))
(and (f-exists? root) (f-directory? root) neuron-default-zettelkasten-directory))))
You should be able to expand the path directly when setting neuron-default-zettelkasten-directory
, I have tested (setq neuron-default-zettelkasten-directory (expand-file-name "~/zet"))
(where ~/zet
is a symlink to my actual zk directory) and it appears to work.
I remember voluntarily not expanding the file name automatically, mimicking what I had seen in other emacs lisp code, but actually I don't see any downside to do this, which indeed would be more intuitive.
However, I can't quite reproduce your error. I can see the same error, but it occurs when I am NOT in my actual zettelkasten directory, and it works just fine with neuron--detect-zettelkasten
. That is a bit odd, do you mind detailing exactly what were the values of neuron-default-zettelkasten-directory
and (pwd)
?
Maybe you can try with the latest master. The https://github.com/felko/neuron-mode/commit/18d230ce6b126fe7193db9c20ac93811ccfe779d commit expands all file names.
This appears to be working correctly now, thanks!
I have
~/zet
as a symbolic link to another data directory. This works fine for the most part, however when I'm actually in the directory in Emacs (mypwd
is a child of that directory),neuron--get-zettelkasten
returns the unexpanded~/zet
instead of the full/home/garrett/zet
which would work. I was able to fix this by adding anexpand-file-name
around(neuron--detect-zettelkasten pwd)
.It's worth noting that doing some debugging shows that
pwd
isnil
whenneuron--detect-zettelkasten
is called.This is the error I got when
~/zet
wasn't being expanded:user-error: Command "neuron --zettelkasten-dir \~/zet/ query --uri z\:zettels" exited with code 1: neuron: user error (Zettelkasten directory ~/zet/ does not exist.)