avoid the problem where the condition is evaluated twice

This commit is contained in:
Zhang Chiyuan 2008-04-10 04:39:56 +00:00
parent 60cf669105
commit 6f220b1243

View File

@ -451,19 +451,21 @@ the template of a snippet in the current snippet-table."
(let ((start (point)) (let ((start (point))
(end (point)) (end (point))
(syntaxes yas/key-syntaxes) (syntaxes yas/key-syntaxes)
syntax done) syntax done templates)
(while (and (not done) syntaxes) (while (and (not done) syntaxes)
(setq syntax (car syntaxes)) (setq syntax (car syntaxes))
(setq syntaxes (cdr syntaxes)) (setq syntaxes (cdr syntaxes))
(save-excursion (save-excursion
(skip-syntax-backward syntax) (skip-syntax-backward syntax)
(setq start (point))) (setq start (point)))
(if (yas/snippet-table-fetch (setq templates
(yas/current-snippet-table) (yas/snippet-table-fetch
(buffer-substring-no-properties start end)) (yas/current-snippet-table)
(buffer-substring-no-properties start end)))
(if templates
(setq done t) (setq done t)
(setq start end))) (setq start end)))
(list (buffer-substring-no-properties start end) (list templates
start start
end))) end)))
@ -1115,19 +1117,17 @@ when the condition evaluated to non-nil."
(symbolp (cdr local-condition))) (symbolp (cdr local-condition)))
(cdr local-condition) (cdr local-condition)
nil))) nil)))
(multiple-value-bind (key start end) (yas/current-key) (multiple-value-bind (templates start end) (yas/current-key)
(let ((templates (yas/snippet-table-fetch (yas/current-snippet-table) (if templates
key))) (let ((template (if (null (cdr templates)) ; only 1 template
(if templates (yas/template-content (cdar templates))
(let ((template (if (null (cdr templates)) ; only 1 template (yas/popup-for-template templates))))
(yas/template-content (cdar templates)) (when template
(yas/popup-for-template templates)))) (yas/expand-snippet start end template)))
(when template (let* ((yas/minor-mode nil)
(yas/expand-snippet start end template))) (command (key-binding yas/trigger-key)))
(let* ((yas/minor-mode nil) (when (commandp command)
(command (key-binding yas/trigger-key))) (call-interactively command)))))))))
(when (commandp command)
(call-interactively command))))))))))
(defun yas/next-field-group () (defun yas/next-field-group ()
"Navigate to next field group. If there's none, exit the snippet." "Navigate to next field group. If there's none, exit the snippet."