[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 9983491 8/8: Update packages/yasnippet by subtree-merging
From: |
João Távora |
Subject: |
[elpa] master 9983491 8/8: Update packages/yasnippet by subtree-merging from its github-based upstream |
Date: |
Mon, 07 Mar 2016 08:52:59 +0000 |
branch: master
commit 99834918e1d9dc8e49356fdaac0853473487806d
Merge: ab7d7f3 572c73d
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Update packages/yasnippet by subtree-merging from its github-based upstream
packages/yasnippet/snippets is left untouched in GNU ELPA. The
upstream version uses a submodule pointing to a snippets repo which
lives at https://github.com/AndreaCrotti/yasnippet-snippets.git
Conflicts: packages/yasnippet/snippets
---
packages/yasnippet/.gitmodules | 2 +-
packages/yasnippet/yasnippet-tests.el | 34 +++++++++++++++++++++++++++++++++
packages/yasnippet/yasnippet.el | 29 +++++++++++++++++++--------
3 files changed, 55 insertions(+), 10 deletions(-)
diff --git a/packages/yasnippet/.gitmodules b/packages/yasnippet/.gitmodules
index e9a0388..a8cc391 100644
--- a/packages/yasnippet/.gitmodules
+++ b/packages/yasnippet/.gitmodules
@@ -1,7 +1,7 @@
[submodule "snippets"]
path = snippets
url = https://github.com/AndreaCrotti/yasnippet-snippets.git
- branch = master
+ branch = master
[submodule "yasmate"]
path = yasmate
url = https://github.com/capitaomorte/yasmate.git
diff --git a/packages/yasnippet/yasnippet-tests.el
b/packages/yasnippet/yasnippet-tests.el
index 648e4f3..844cd94 100644
--- a/packages/yasnippet/yasnippet-tests.el
+++ b/packages/yasnippet/yasnippet-tests.el
@@ -143,6 +143,36 @@
;; (should (string= (yas--buffer-contents)
;; "brother from another mother!"))))
+(ert-deftest dont-clear-on-partial-deletion-issue-515 ()
+ "Ensure fields are not cleared when user doesn't really mean to."
+ (with-temp-buffer
+ (yas-minor-mode 1)
+ (yas-expand-snippet "my ${1:kid brother} from another ${2:mother}")
+
+ (ert-simulate-command '(kill-word 1))
+ (ert-simulate-command '(delete-char 1))
+
+ (should (string= (yas--buffer-contents)
+ "my brother from another mother"))
+ (should (looking-at "brother"))
+
+ (ert-simulate-command '(yas-next-field))
+ (should (looking-at "mother"))
+ (ert-simulate-command '(yas-prev-field))
+ (should (looking-at "brother"))))
+
+(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 sibling")
+ (should (string= (yas--buffer-contents)
+ "my little sibling from another mother"))
+ (ert-simulate-command '(yas-next-field))
+ (ert-simulate-command '(yas-prev-field))
+ (should (looking-at "little sibling"))))
+
;;; Snippet expansion and character escaping
;;; Thanks to @zw963 (Billy) for the testing
@@ -829,6 +859,10 @@ add the snippets associated with the given mode."
(let ((last-command-event (aref string i)))
(ert-simulate-command '(self-insert-command 1)))))
+(defun yas-mock-yank (string)
+ (let ((interprogram-paste-function (lambda () string)))
+ (ert-simulate-command '(yank nil))))
+
(defun yas-make-file-or-dirs (ass)
(let ((file-or-dir-name (car ass))
(content (cdr ass)))
diff --git a/packages/yasnippet/yasnippet.el b/packages/yasnippet/yasnippet.el
index dcec0e2..b68389f 100644
--- a/packages/yasnippet/yasnippet.el
+++ b/packages/yasnippet/yasnippet.el
@@ -202,10 +202,9 @@ created with `yas-new-snippet'. "
(defvaralias 'yas/root-directory 'yas-snippet-dirs)
(defcustom yas-new-snippet-default "\
-# -*- mode: snippet; require-final-newline: nil -*-
+# -*- mode: snippet -*-
# name: $1
-# key: ${2:${1:$(yas--key-from-desc yas-text)}}${3:
-# binding: ${4:direct-keybinding}}
+# key: ${2:${1:$(yas--key-from-desc yas-text)}}
# --
$0"
"Default snippet to use when creating a new snippet.
@@ -213,8 +212,7 @@ If nil, don't use any snippet."
:type 'string
:group 'yasnippet)
-(defcustom yas-prompt-functions '(yas-x-prompt
- yas-dropdown-prompt
+(defcustom yas-prompt-functions '(yas-dropdown-prompt
yas-completing-prompt
yas-maybe-ido-prompt
yas-no-prompt)
@@ -3385,7 +3383,22 @@ Move the overlay, or create it if it does not exit."
(overlay-put yas--active-field-overlay 'insert-behind-hooks
'(yas--on-field-overlay-modification))))
-(defun yas--on-field-overlay-modification (overlay after? _beg _end &optional
_length)
+(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 (not (yas--field-modified-p field))
+ (= (point) (yas--field-start field))
+ (require 'delsel)
+ ;; `yank' sets `this-command' to t during execution.
+ (let* ((command (if (commandp this-command) this-command
+ this-original-command))
+ (clearp (if (symbolp command) (get 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.
Only clears the field if it hasn't been modified and point is at
@@ -3401,9 +3414,7 @@ field start. This hook does nothing if an undo is in
progress."
(yas--field-update-display field))
(yas--update-mirrors snippet))
(field
- (when (and (eq this-command 'self-insert-command)
- (not (yas--field-modified-p field))
- (= (point) (yas--field-start field)))
+ (when (yas--skip-and-clear-field-p field beg end)
(yas--skip-and-clear field))
(setf (yas--field-modified-p field) t))))))
- [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, 2016/03/07
- [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 <=