I have been upset about this one too. But later on, I started to utilize M-SPC
more and not leaving insert mode so often. It just fixed itself that way.
Emacs
A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!
Get Emacs
Rules
- Posts should be emacs related
- Be kind please
- Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.
Emacs Resources
Emacs Tutorials
- Beginner’s Guide to Emacs
- Absolute Beginner's Guide to Emacs
- How to Learn Emacs: A Hand-drawn One-pager for Beginners
Useful Emacs configuration files and distributions
Quick pain-saver tip
If I understood correctly, the problem turned out to be caused by evil but the post doesn't mention evil anywhere! Always mention evil, and, more generally, explain how to reproduce the problem.
My apologies, I've edited the Op
This is link example with org-roam id:
something interesting is in this [[id:aaaa-aaa-aaa-aaaa-aaaa][A]] link. Check it out...
This is link example with file location:
This is link example: something interesting is in this [[file:parent/b.org][B]] link. Check it out...
And they gonna look like this.
I feel I haven't explained properly. Typing links out manually works fine (like your example).
But I don't get the preceeding space using org-store-link
(or using org-roam-node-insert
or org-roam-node-find
- presumably these call org-store-link
.
My workflow is:
- In insert mode, type text, with a trailing space before where I want the link;
- Somehow when I exit insert mode, the trailing space after my text gets deleted; and
- In normal mode, call
org-store-link
(or one of the roam ones).
What I end up with is the link nestled against the last non-space charachter of my text
Your problem is about the evil mode(or anything hooks with it) not the org-roam itself...
Are you sure the space isn’t after the insert? What happens if you put 2 spaces?
- Somehow when I exit insert mode, the trailing space after my text gets deleted
Have a look at the variable evil-move-cursor-back
and evil-move-beyond-eol
. May be this could help you.
evil-move-cursor-back
This was what I was after - thanks
Inserting stuff from normal mode ends up before the cursor, which is not what I want if I just typed text ending with a space character, I want it after. I've been using this for a bunch of insert functions:
(defmacro my/insert-after-space (&rest fs)
`(progn
,@(mapcar
(lambda (f)
;; If in evil normal mode and cursor is on a whitespace
;; character, then go into append mode first before inserting
;; the link. This is to put the link after the space rather
;; than before.
`(defadvice ,f (around append-if-in-evil-normal-mode activate compile)
(let ((is-in-evil-normal-mode (and (bound-and-true-p evil-mode)
(not (bound-and-true-p
evil-insert-state-minor-mode))
(looking-at "[[:blank:]]"))))
(if (not is-in-evil-normal-mode)
ad-do-it
(evil-append 0)
ad-do-it
(evil-normal-state)))))
fs)))
(my/insert-after-space org-roam-node-insert
emojify-insert-emoji
org-web-tools-insert-link-for-url)
This is really helpful thanks - I ended up changing a variable and now it works (for my purposes)
what did you change? i've tried using this for org-insert-link but it's not working for me, unfortunately
Because I use evil mode, I changed evil-move-cursor-backward
You use org-roam-node-insert
? Can you copy-paste a result here?
Oh, do your nodes have a #+TITLE
line? If there's no #+TITLE
, it defaults to using the filename.