meedstrom / org-node

A notetaking system like Roam using Emacs Org-mode
GNU General Public License v3.0
90 stars 4 forks source link

rename function renaming dailies #30

Closed emacsomancer closed 3 weeks ago

emacsomancer commented 4 weeks ago

After the changes, the rename function tries to rename dailies.

meedstrom commented 4 weeks ago

Forgot to say. Check out the setting org-node-renames-exclude. Sorry about that.

emacsomancer commented 3 weeks ago

My dailies are in a subfolder of org-roam named daily, but they still get renamed by the hook. I tried even providing the variable the full path, but it still renames them (wrongly, thinking that they're non-dailies).

meedstrom commented 3 weeks ago

What does this return in your daily file?

M-: (string-match-p "daily/" buffer-file-name)
emacsomancer commented 3 weeks ago

35

meedstrom commented 3 weeks ago

Sorry for the delay, I waited out the GitHub outage just now.

Well, it should work, since that filter returns non-nil. I don't know what's going on. It works for me. You don't have the function defined to something else? :)

emacsomancer commented 3 weeks ago

I'm guessing it's an issue with org-node-renames-allowed-dirs.

I'm thinking that in:

              (cl-loop
               for dir in org-node-renames-allowed-dirs
               if (or (not (string-prefix-p dir path))
                      (string-match-p org-node-renames-exclude path))
               return nil
               finally return t)

the loop returns returns true if org-node-renames-allowed-dirs is empty.

maybe

  (when (null org-node-renames-allowed-dirs)
        (message "New user option `org-node-renames-allowed-dirs' should be configured"))

should be user-error instead of message?

meedstrom commented 3 weeks ago

the loop returns returns true if org-node-renames-allowed-dirs is empty.

Oh, well spotted. It was too confusingly written. I changed the loop so it's more readable and won't do that. Sorry for the inconvenience.

should be user-error instead of message?

Yea, if not interactive anyway. Fixed.

emacsomancer commented 3 weeks ago

Ok, I think it's working for me now.

But now nothing (i.e. non-daily roam files) gets renamed if I set org-node-renames-allowed-dirs to something like '("~/Documents/Org/org-roam/"), but it does if I do '("/home/emacsomancer/Documents/Org/org-roam/). Does it make sense to use a file-truename here?,e.g.

...
for dir in org-node-renames-allowed-dirs
               if (and (string-prefix-p (file-truename dir) path)
....
meedstrom commented 3 weeks ago

Oh, yes, probably.

meedstrom commented 3 weeks ago

Heads up, just in case: just edited this command a lot, but it still works in my testing.