[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/yasnippet 23c7a6fa51 1/2: yasnippet.el: Minor simplific
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/yasnippet 23c7a6fa51 1/2: yasnippet.el: Minor simplifications |
|
Date: |
Wed, 17 Jan 2024 15:59:19 -0500 (EST) |
branch: externals/yasnippet
commit 23c7a6fa5171352753b0fd6e14f8447409d7f005
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
yasnippet.el: Minor simplifications
(yas--check-commit-snippet): De Morgan.
(yas-expand-snippet): Use `yas-current-field`.
---
yasnippet-tests.el | 5 ++++-
yasnippet.el | 14 +++++---------
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index 2d92765e4c..c096c7356d 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -711,7 +711,7 @@ mapconcat #'(lambda (arg)
;;; Snippet expansion and character escaping
-;;; Thanks to @zw963 (Billy) for the testing
+;; Thanks to @zw963 (Billy) for the testing
;;;
(ert-deftest escape-dollar ()
(with-temp-buffer
@@ -1227,6 +1227,9 @@ hello ${1:$(when (stringp yas-text) (funcall func
yas-text))} foo${1:$$(concat \
(defmacro yas-with-overriden-buffer-list (&rest body)
(declare (debug t))
+ ;; FIXME: This macro was added by commit 185c771dedea as part of the
+ ;; fix for https://github.com/joaotavora/yasnippet/issues/253,
+ ;; but I don't know why it was/is needed.
(let ((saved-sym (make-symbol "yas--buffer-list")))
`(let ((,saved-sym (symbol-function 'buffer-list)))
(cl-letf (((symbol-function 'buffer-list)
diff --git a/yasnippet.el b/yasnippet.el
index 980a585b68..0d9166a687 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -3606,8 +3606,8 @@ If so cleans up the whole snippet up."
(yas--commit-snippet snippet)
(setq exited-snippets-p t))
((and active-field
- (or (not yas--active-field-overlay)
- (not (overlay-buffer yas--active-field-overlay))))
+ (not (and yas--active-field-overlay
+ (overlay-buffer yas--active-field-overlay))))
;;
;; stacked expansion: this case is mainly for recent
;; snippet exits that place us back int the field of
@@ -3721,7 +3721,7 @@ Otherwise deletes a character normally by calling
`delete-char'."
(t (call-interactively 'delete-char))))
(defun yas--skip-and-clear (field &optional from)
- "Deletes the region of FIELD and sets it's modified state to t.
+ "Delete the region of FIELD and set its modified state to t.
If given, FROM indicates position to start at instead of FIELD's beginning."
;; Just before skipping-and-clearing the field, mark its children
;; fields as modified, too. If the children have mirrors-in-fields
@@ -3994,9 +3994,7 @@ for normal snippets, and a list for command snippets)."
(run-hooks 'yas-before-expand-snippet-hook)
(let* ((clear-field
- (let ((field (and yas--active-field-overlay
- (overlay-buffer yas--active-field-overlay)
- (overlay-get yas--active-field-overlay
'yas--field))))
+ (let ((field (yas-current-field)))
(and field (yas--skip-and-clear-field-p
field (point) (point) 0)
field)))
@@ -4043,9 +4041,7 @@ for normal snippets, and a list for command snippets)."
;; Stacked-expansion: This checks for stacked expansion, save the
;; `yas--previous-active-field' and advance its boundary.
- (let ((existing-field (and yas--active-field-overlay
- (overlay-buffer
yas--active-field-overlay)
- (overlay-get yas--active-field-overlay
'yas--field))))
+ (let ((existing-field (yas-current-field)))
(when existing-field
(setf (yas--snippet-previous-active-field snippet)
existing-field)
(yas--advance-end-maybe-previous-fields