I am trying to simplify user input of Pod formatting sequences in
cperl-mode. For example, if you type
C<> is a Pod formatting sequence for entering code, similar to the use of backticks in Markdown.
The idea is that the user should only have to type
C< and then Emacs will ask for the code text and add the ending
> followed by as space automatically. Here is an example; for simplicity I have not added the function to
cperl-mode-hook yet, so you can test this by doing
emacs -Q -l init.el, where
(defun my-perl-pod-format-start () "Simplify entering of Pod formatting sequences." (interactive) (let ((char (preceding-char))) (insert "<") (when (or (char-equal char ?C) (char-equal char ?I) (char-equal char ?B)) (insert (read-string "Pod formatting code: ")) (insert "> ")))) (global-set-key (kbd "<") #'my-perl-pod-format-start))
This seems to work fine, but there is at least one drawback: the flow of writing is interrupted, since as soon as the user type the
< the focus is moved to the minibuffer. So I wondered, is it possible to do this input (similar to
read-string) at the current cursor position (for example like in
auto-complete-mode) instead of in the minibuffer?