Skip to content

Instantly share code, notes, and snippets.

@jnpn
Created March 1, 2024 00:35
Show Gist options
  • Save jnpn/9f1152783c494ac52719b13b059d6c8e to your computer and use it in GitHub Desktop.
Save jnpn/9f1152783c494ac52719b13b059d6c8e to your computer and use it in GitHub Desktop.
line templating utils
;;; quick naive contextual template WIP
(defun replace-by-transient-overlay ()
"copy word at point as w
kill-word
create overlay with text `w'
overlay map -> any char -> delete overlay"
:todo)
(defun l/line-template-at-point ()
(interactive)
(let* ((bol (line-beginning-position))
(eol (line-end-position))
(pt (point))
(delta (- pt bol))
(current-line (buffer-substring-no-properties bol eol)))
(end-of-line)
(newline)
(insert current-line)
(beginning-of-line)
(forward-char delta)
;; (replace-by-transient-overlay)
(kill-word 1)))
;;; example, '.' indicates cursor position
"here comes .the sun"
"here comes . sun"
"my friends are so different"
"my fri are so different"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment