mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
yasnippet.el: Minor simplifications
(yas--check-commit-snippet): De Morgan. (yas-expand-snippet): Use `yas-current-field`.
This commit is contained in:
parent
c6488ac6fb
commit
23c7a6fa51
@ -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)
|
||||
|
14
yasnippet.el
14
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user