meedstrom / org-node

GNU General Public License v3.0
74 stars 2 forks source link

org-node-insert-link doesn't use region #10

Closed emacsomancer closed 2 months ago

emacsomancer commented 2 months ago

Given the function definition, as far as I can tell, it seems that org-node-insert-link should (desirably) behave differently if there's an active region (like org-roam-node-insert does), but in practice it seems to ignore the region, at least as far as (pre-)searching the index for selected text/region.

meedstrom commented 2 months ago

That's interesting, I used org-roam-node-insert many times but I never became conscious that it pastes the text into the minibuffer. So I didn't reproduce that behavior. I must have just subconsciously erased it as clutter, because of course there were always 0 matches.

How do you use it? Select a region that really is a substring of some node that you know you have?

emacsomancer commented 2 months ago

Yes, either a region that's a substring of a node I think I already have, or else one I want to create. (Sometimes I've typed out a bunch of things first, and am going back to add links/nodes.)

meedstrom commented 2 months ago

Alright, not sure I like it as a default, so I made an alternative command org-node-insert-link* :)

emacsomancer commented 2 months ago

Using org-node-insert-link*, I get an error if I try to insert a non-existing node:

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
  org-node-insert-link*()
  funcall-interactively(org-node-insert-link*)
  command-execute(org-node-insert-link*)

edit: actually, I get it with plain org-node-insert-link too, so perhaps this should be a new issue?

meedstrom commented 2 months ago

What's your org-node-creation-fn? I guess org-node-new-by-roam-capture? Does it happen with all your capture templates or only some?

emacsomancer commented 2 months ago

Yes, I have (setq org-node-creation-fn #'org-node-new-by-roam-capture) in my config, as per the example.

I'm just trying calling org-node-insert-link(*) directly, and it happens with both.

The only thing I can think is that I use vertico and have C-j setup in order to force enter with a non-match via

....
:bind (:map vertico-map
              ("C-j" . vertico-exit-input))
...

in my vertico setup.

meedstrom commented 1 month ago

Then if you turn off vertico-mode, it works?

meedstrom commented 1 month ago

Hm, it works for me even with that C-j setting. Anyway I wonder where the arrayp check is happening...

emacsomancer commented 1 month ago

Then if you turn off vertico-mode, it works?

No, same thing, even with vertico turned off.

Not sure where the arrayp check comes from.

emacsomancer commented 1 month ago

(It doesn't happen with org-node-find.)

meedstrom commented 1 month ago

That is, when you use org-node-find to create a new node, it works?

Got anything in 'org-node-insert-link-hook?

Also, got the newest version of this package? :) What's your Emacs version, btw?

emacsomancer commented 1 month ago

Yes, I can create new nodes with org-node-find.

org-node-insert-link-hook is nil.

I updated all packages this morning.

I'm using Emacs 30.0.50, fairly close to master.