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/snippet-table-fetch
(yas/current-snippet-table) (yas/current-snippet-table)
(buffer-substring-no-properties start end)) (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,9 +1117,7 @@ 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)
key)))
(if templates (if templates
(let ((template (if (null (cdr templates)) ; only 1 template (let ((template (if (null (cdr templates)) ; only 1 template
(yas/template-content (cdar templates)) (yas/template-content (cdar templates))
@ -1127,7 +1127,7 @@ when the condition evaluated to non-nil."
(let* ((yas/minor-mode nil) (let* ((yas/minor-mode nil)
(command (key-binding yas/trigger-key))) (command (key-binding yas/trigger-key)))
(when (commandp command) (when (commandp command)
(call-interactively 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."