]> git.eshelyaron.com Git - emacs.git/commitdiff
Insert skeletons at the correct point
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 7 Dec 2020 15:36:09 +0000 (16:36 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 7 Dec 2020 15:36:09 +0000 (16:36 +0100)
* lisp/skeleton.el (skeleton-read): Don't insert the skeleton at
an arbitrary point if the user moves around (bug#17752).

lisp/skeleton.el

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