In Doom Emacs and org-mode, I want to use org-insert-link
pressing the minimum amount of keys.
So I want to combine two-four commands in one.
The default behaviour doesn't leave space before or after.
I have tried various variations of the following but it doesn't work:
(add-hook 'org-mode 'org-insert-link-with-space)
(defun org-insert-link-with-space ()
"org-insert-link-with-space, like org-insert-link but after prompt"
(interactive)
(insert " ") (org-insert-link) (insert " ") (evil-insert-state)
)
(map! :ne "SPC m l" #'org-insert-link-with-space)
I want to type this:
here is a link for you
pressing the minimum amount of keys:
hereSpaceisSpaceaEscSpacemll<copy/paste link and description description>RetforSpaceyou
How do I fix my snippet?
Update: I combined three answers (1, 2 and 3) from SE and ended up to what I currently use. It inserts a link like ViM's inoremap
by pressing jk only while in insert-mode:
(add-hook 'post-self-insert-hook
(lambda ()
(and (eq last-command-event ?k)
(looking-back "jk" (- (point) 2))
(if (> 1 2)
(message "True")
(call-interactively 'evil-delete-backward-char)
(call-interactively 'evil-delete-backward-char)
(call-interactively 'org-insert-link)
))))
It certainly needs some refinement, but for the time being it works perfectly!
map!
in doom, but you should not(add-hook 'org-mode 'org-insert-link-with-space)
add-hook
doesn't alter anythinghere is a http://stackexchange.com for you
2. Not very sure at the moment. 3. With the help of emacs.stackexchange.com/questions/24573/evil-equivalent-of-imap I'm trying to insert a link without leaving insert-mode, so without a keybinding being necessary and also saving extra key presses. It feels like I'm half-way through - when I wrote the question I was about ~30% towards my end goal. I really need to sit down and learn some elisp, because programming my editor worths it!