this post was submitted on 23 Nov 2023
0 points (50.0% liked)

Emacs

313 readers
3 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

tl;dr why do my org links not have a space before them (e.g. check out thisLINK)? I feel I'm missing something very basic here.

I was using org-roam today in doom emacs and forgot how irritating adding a new node is while writing.

It nestles nicely up to the text before it - with no space in between. After posting on r/orgroam a kind soul told me this might be a wider issue - at least related to org itself, and maybe doom.

Does anyone know how to get a leading space before the node name / link? For example; my nodes come out looking like:

something interesting is in thisNODENAME/LINK check it out

For the love of RMS I want a space between this and NODENAME

I'm clearly being dumb, but can't figure this out. Surely enough people use emacs / doom emacs / org mode, and they are not all adding links everywhere with no leading space?

A suggestion on r/orgroam was put a double space before a link - is that it?

you are viewing a single comment's thread
view the rest of the comments
[–] wonko7@alien.top 0 points 1 year ago (1 children)

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)
[–] thephatmaster@alien.top 1 points 1 year ago (1 children)

This is really helpful thanks - I ended up changing a variable and now it works (for my purposes)

[–] lwalker043@alien.top 1 points 1 year ago (1 children)

what did you change? i've tried using this for org-insert-link but it's not working for me, unfortunately

[–] thephatmaster@alien.top 1 points 1 year ago

Because I use evil mode, I changed evil-move-cursor-backward