Skip to content

Instantly share code, notes, and snippets.

@jplindstrom
Created February 18, 2015 23:58
Show Gist options
  • Save jplindstrom/cf4c82bd4f92de6d39f6 to your computer and use it in GitHub Desktop.
Save jplindstrom/cf4c82bd4f92de6d39f6 to your computer and use it in GitHub Desktop.
Emacs, Perl add deref
(defun ps/edit-deref-type (sigil)
"Enclose the text from point and backwards to the preceeding $
in SIGIL{TEXT}."
(let ((end (point)))
(when (search-backward "$" nil t)
(insert sigil)
(insert "{")
(goto-char (+ 2 end))
(insert "}")
)
))
(defun ps/edit-deref-array ()
"Enclose the text from point and backwards to the preceeding $
in a @{YOUR-TEXT-HERE}."
(interactive)
(ps/edit-deref-type "@"))
(defun ps/edit-deref-hash ()
"Enclose the text from point and backwards to the preceeding $
in a %{YOUR-TEXT-HERE}."
(interactive)
(ps/edit-deref-type "%"))
(global-set-key (kbd "C-o e d") 'ps/edit-deref-array)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment