]> code.delx.au - gnu-emacs-elpa/commitdiff
Fix #515; only clear field on self-insert
authorNoam Postavsky <npostavs@users.sourceforge.net>
Sun, 13 Dec 2015 05:38:09 +0000 (00:38 -0500)
committerNoam Postavsky <npostavs@users.sourceforge.net>
Sun, 27 Dec 2015 23:24:01 +0000 (18:24 -0500)
* yasnippet.el (yas--on-field-overlay-modification): Only clear field if
  `this-command' is `self-insert-command'.  Clean up docstring.

Close #639.

yasnippet.el

index f468aabc8b750b9dbcd318b482e135324cdf9ea3..592742ffc0d00d6bd0da3049ff7154bb269eb8f2 100644 (file)
@@ -3385,9 +3385,8 @@ Move the overlay, or create it if it does not exit."
 (defun yas--on-field-overlay-modification (overlay after? _beg _end &optional _length)
   "Clears the field and updates mirrors, conditionally.
 
-Only clears the field if it hasn't been modified and it point it
-at field start.  This hook doesn't do anything if an undo is in
-progress."
+Only clears the field if it hasn't been modified and point is at
+field start.  This hook does nothing if an undo is in progress."
   (unless (or yas--inhibit-overlay-hooks
               (not (overlayp yas--active-field-overlay)) ; Avoid Emacs bug #21824.
               (yas--undo-in-progress))
@@ -3399,7 +3398,8 @@ progress."
                (yas--field-update-display field))
              (yas--update-mirrors snippet))
             (field
-             (when (and (not (yas--field-modified-p field))
+             (when (and (eq this-command 'self-insert-command)
+                        (not (yas--field-modified-p field))
                         (= (point) (yas--field-start field)))
                (yas--skip-and-clear field))
              (setf (yas--field-modified-p field) t))))))