Insert skeletons at the correct point

* lisp/skeleton.el (skeleton-read): Don't insert the skeleton at
an arbitrary point if the user moves around (bug#17752).
This commit is contained in:
Lars Ingebrigtsen 2020-12-07 16:36:09 +01:00
parent b218c8b6b5
commit 3ee94cc7bb

View file

@ -312,10 +312,15 @@ automatically, and you are prompted to fill in the variable parts.")))
(save-excursion (insert "\n"))) (save-excursion (insert "\n")))
(unwind-protect (unwind-protect
(setq prompt (cond ((stringp prompt) (setq prompt (cond ((stringp prompt)
(read-string (format prompt skeleton-subprompt) ;; The user may issue commands to move
(setq initial-input ;; around (like `C-M-v'). Ensure that we
(or initial-input ;; insert the skeleton at the correct
(symbol-value 'input))))) ;; (initial) point.
(save-excursion
(read-string (format prompt skeleton-subprompt)
(setq initial-input
(or initial-input
(symbol-value 'input))))))
((functionp prompt) ((functionp prompt)
(funcall prompt)) (funcall prompt))
(t (eval prompt)))) (t (eval prompt))))