Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org-roam-insert should insert link AFTER the cursor in evil #14137

Closed
real-or-random opened this issue Nov 15, 2020 · 1 comment · Fixed by #15008
Closed

org-roam-insert should insert link AFTER the cursor in evil #14137

real-or-random opened this issue Nov 15, 2020 · 1 comment · Fixed by #15008

Comments

@real-or-random
Copy link
Contributor

Description :octocat:

When inserting a link via org-roam-insert, there's no space between the link and the preceding text.
This is very annoying because inserting links is the core feature of org-roam and fixing the space is non-trivial: Simply moving left and inserting a space inserts the space into the link, which is not what you want.

This is essentially org-roam/org-roam#4.
A workaround is available there.
We may want to apply a variant of this here.
(I have no idea how this is done with similar packages in evil mode.)

Reproduction guide 🪲

  • Start Emacs
  • Open an org-roam file (e.g. org-roam-dailies-today)
  • Enter insert state, type "bla"
  • Enter normal state
  • org-roam-insert a link to "file"

Observed behaviour: 👀 💔

  • "blafile" (no space between text and link)

Expected behaviour: ❤️ 😄

  • "bla file" (with space)

System Info 💻

  • OS: gnu/linux
  • Emacs: 27.1
  • Spacemacs: 0.300.0
  • Spacemacs branch: evil-set-undo-system-on-upgrade (rev. 3517cbc)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(csv html javascript systemd helm auto-completion better-defaults emacs-lisp git github markdown
     (org :variables org-enable-github-support t org-enable-roam-support t)
     spell-checking syntax-checking treemacs
     (latex :variables latex-enable-auto-fill nil)
     pdf yaml lua gtags
     (c-c++ :variables c-c++-backend 'lsp-ccls c-c++-lsp-enable-semantic-highlight 'rainbow)
     php python rust shell major-modes)
  • System configuration features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON PDUMPER LCMS2 GMP
@emacs18
Copy link
Contributor

emacs18 commented Nov 29, 2020

I too was annoyed by the fact that the link was insert before space character at cursor rather than affter.
Following works for me to deal with this.

(defadvice org-roam-insert (around append-if-in-evil-normal-mode activate compile)
  "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."
  (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))))

I know very little about evil stuff, so someone more familiar with evil probably could come up with much more robust code.

bhipple added a commit to bhipple/spacemacs that referenced this issue Aug 22, 2021
When we're adding links, without this they get smooshed together under the
curser. Tested to work; resolves syl20bnr#14137
lebensterben pushed a commit that referenced this issue Aug 23, 2021
When we're adding links, without this they get smooshed together under the
curser. Tested to work; resolves #14137

Co-authored-by: Richard Kim <emacs18@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants