[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master acf2cdd 2/8: Decide field clearing commands based on delse
From: |
João Távora |
Subject: |
[elpa] master acf2cdd 2/8: Decide field clearing commands based on delsel |
Date: |
Mon, 07 Mar 2016 08:44:02 +0000 |
branch: master
commit acf2cdd03e504e5ed6bcced842c213c23d75740f
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Decide field clearing commands based on delsel
* yasnippet.el (yas--skip-and-clear-field-p): Check `delete-selection'
of `this-command'.
Fix #644, close #645.
---
yasnippet-tests.el | 13 +++++--------
yasnippet.el | 14 +++++++++++---
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index 040c83a..cf8ace9 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -160,20 +160,17 @@
(ert-simulate-command '(yas-prev-field))
(should (looking-at "brother"))))
-(ert-deftest dont-clear-on-yank-issue-515 ()
- "A yank shouldn't clear and unmodified field." ; or should it? -- jt
+(ert-deftest do-clear-on-yank-issue-515 ()
+ "A yank should clear an unmodified field."
(with-temp-buffer
(yas-minor-mode 1)
(yas-expand-snippet "my ${1:kid brother} from another ${2:mother}")
-
- (yas-mock-yank "little")
- (yas-mock-insert " ")
-
+ (yas-mock-yank "little sibling")
(should (string= (yas--buffer-contents)
- "my little kid brother from another mother"))
+ "my little sibling from another mother"))
(ert-simulate-command '(yas-next-field))
(ert-simulate-command '(yas-prev-field))
- (should (looking-at "little kid brother"))))
+ (should (looking-at "little sibling"))))
;;; Snippet expansion and character escaping
diff --git a/yasnippet.el b/yasnippet.el
index 5a14529..59285a6 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -3388,9 +3388,17 @@ Move the overlay, or create it if it does not exit."
(defun yas--skip-and-clear-field-p (field _beg _end &optional _length)
"Tell if newly modified FIELD should be cleared and skipped.
BEG, END and LENGTH like overlay modification hooks."
- (and (eq this-command 'self-insert-command)
- (not (yas--field-modified-p field))
- (= (point) (yas--field-start field))))
+ (and (not (yas--field-modified-p field))
+ (= (point) (yas--field-start field))
+ (require 'delsel)
+ ;; `yank' sets `this-command' to t during execution.
+ (let ((clearp (get (if (commandp this-command) this-command
+ this-original-command)
+ 'delete-selection)))
+ (when (and (not (memq clearp '(yank supersede kill)))
+ (functionp clearp))
+ (setq clearp (funcall clearp)))
+ clearp)))
(defun yas--on-field-overlay-modification (overlay after? beg end &optional
length)
"Clears the field and updates mirrors, conditionally.
- [elpa] master updated (ab7d7f3 -> 9983491), João Távora, 2016/03/07
- [elpa] master 4a6d923 1/8: Slightly improve on fix for #515: Refactor code and add tests, João Távora, 2016/03/07
- [elpa] master acf2cdd 2/8: Decide field clearing commands based on delsel,
João Távora <=
- [elpa] master 80941c0 3/8: Update snippets submodule, João Távora, 2016/03/07
- [elpa] master 42601d2 4/8: Apply changes from GNU ELPA, João Távora, 2016/03/07
- [elpa] master 8632262 5/8: Don't use yas-x-prompt by default, João Távora, 2016/03/07
- [elpa] master 88b7950 6/8: Reduce `yas-new-snippet-default', João Távora, 2016/03/07
- [elpa] master 572c73d 7/8: Avoid error in case this-command isn't a symbol., João Távora, 2016/03/07
- [elpa] master 9983491 8/8: Update packages/yasnippet by subtree-merging from its github-based upstream, João Távora, 2016/03/07