Remove redundant arg to yas-expand-snippet

* yasnippet.el (yas--expand-or-visit-from-menu)
(yas--expand-or-prompt-for-template)
(yas-visit-snippet-file, yas-tryout-snippet): Don't pass expand-env
when to yas-expand-snippet when first arg is a yas--template record.
This commit is contained in:
Noam Postavsky 2019-05-02 18:13:15 -04:00
parent c432e78ffd
commit 55c448b991

View File

@ -1692,10 +1692,8 @@ Here's a list of currently recognized directives:
(let ((where (if (region-active-p) (let ((where (if (region-active-p)
(cons (region-beginning) (region-end)) (cons (region-beginning) (region-end))
(cons (point) (point))))) (cons (point) (point)))))
(yas-expand-snippet (yas--template-content yas--current-template) (yas-expand-snippet yas--current-template
(car where) (car where) (cdr where)))))))
(cdr where)
(yas--template-expand-env yas--current-template)))))))
(defun yas--key-from-desc (text) (defun yas--key-from-desc (text)
"Return a yasnippet key from a description string TEXT." "Return a yasnippet key from a description string TEXT."
@ -2400,14 +2398,12 @@ template objects if CMD is nil (this is useful as a more general predicate)."
Prompt the user if TEMPLATES has more than one element, else Prompt the user if TEMPLATES has more than one element, else
expand immediately. Common gateway for expand immediately. Common gateway for
`yas-expand-from-trigger-key' and `yas-expand-from-keymap'." `yas-expand-from-trigger-key' and `yas-expand-from-keymap'."
(let ((yas--current-template (or (and (cl-rest templates) ;; more than one (let ((yas--current-template
(yas--prompt-for-template (mapcar #'cdr templates))) (or (and (cl-rest templates) ;; more than one
(cdar templates)))) (yas--prompt-for-template (mapcar #'cdr templates)))
(cdar templates))))
(when yas--current-template (when yas--current-template
(yas-expand-snippet (yas--template-content yas--current-template) (yas-expand-snippet yas--current-template start end))))
start
end
(yas--template-expand-env yas--current-template)))))
;; Apropos the trigger key and the fallback binding: ;; Apropos the trigger key and the fallback binding:
;; ;;
@ -2552,10 +2548,7 @@ by condition."
(cons (region-beginning) (region-end)) (cons (region-beginning) (region-end))
(cons (point) (point))))) (cons (point) (point)))))
(if yas--current-template (if yas--current-template
(yas-expand-snippet (yas--template-content yas--current-template) (yas-expand-snippet yas--current-template (car where) (cdr where))
(car where)
(cdr where)
(yas--template-expand-env yas--current-template))
(yas--message 1 "No snippets can be inserted here!")))) (yas--message 1 "No snippets can be inserted here!"))))
(defun yas-visit-snippet-file () (defun yas-visit-snippet-file ()
@ -2843,17 +2836,17 @@ DEBUG is for debugging the YASnippet engine itself."
:name (nth 2 parsed) :name (nth 2 parsed)
:expand-env (nth 5 parsed))))) :expand-env (nth 5 parsed)))))
(cond (yas--current-template (cond (yas--current-template
(let ((buffer-name (format "*testing snippet: %s*" (yas--template-name yas--current-template)))) (let ((buffer-name
(format "*testing snippet: %s*"
(yas--template-name yas--current-template))))
(kill-buffer (get-buffer-create buffer-name)) (kill-buffer (get-buffer-create buffer-name))
(switch-to-buffer (get-buffer-create buffer-name)) (switch-to-buffer (get-buffer-create buffer-name))
(setq buffer-undo-list nil) (setq buffer-undo-list nil)
(condition-case nil (funcall test-mode) (error nil)) (condition-case nil (funcall test-mode) (error nil))
(yas-minor-mode 1) (yas-minor-mode 1)
(setq buffer-read-only nil) (setq buffer-read-only nil)
(yas-expand-snippet (yas--template-content yas--current-template) (yas-expand-snippet yas--current-template
(point-min) (point-min) (point-max))
(point-max)
(yas--template-expand-env yas--current-template))
(when (and debug (when (and debug
(require 'yasnippet-debug nil t)) (require 'yasnippet-debug nil t))
(yas-debug-snippets "*YASnippet trace*" 'snippet-navigation) (yas-debug-snippets "*YASnippet trace*" 'snippet-navigation)