elisp - A quick way to repeatedly enter a variable name in Emacs? -
i typing in sort of code nth time:
menu.add_item(spamspamspam, "spamspamspam");
and i'm wondering if there's faster way it.
i'd behavior similar yasnippet's mirrors, except don't want create snippet: argument order varies project project , language language.
the thing that's constant variable name needs repeated several times on same line.
i'd type in
menu.add_item($,"")
and point between quotes, call shortcut , start typing, , exit c-e.
this seems advantageous me, since there's 0 cursor movement. have idea of how this, i'm wondering if it's done, or if better/faster can done.
upd yasnippet way after all.
thanks thisirs answer. indeed yasnippet
code had in mind:
(defun yas-one-line () (interactive) (insert "$") (let ((snippet (replace-regexp-in-string "\\$" "$1" (substring-no-properties (delete-and-extract-region (line-beginning-position) (line-end-position)))))) (yas/expand-snippet snippet)))
but i'm still hoping see better/faster.
yasnippet
can used create snippet on-the-fly:
(defun yas-one-line () (interactive) (let ((snippet (delete-and-extract-region (line-beginning-position) (line-end-position)))) (yas-expand-snippet snippet)))
now type:
menu.add_item($1,"$1")
and call yas-one-line
. above snippet expanded yasnippet!
Comments
Post a Comment