fix a bug in condition system.

This commit is contained in:
Zhang Chiyuan 2008-05-01 03:21:32 +00:00
parent db6a74078f
commit 0e1456f4b8
2 changed files with 15 additions and 12 deletions

View File

@ -1,4 +1,5 @@
#name : if ... end #name : if ... end
#condition : (looking-back "^[[:blank:]]*if")
# -- # --
if ${1:condition} if ${1:condition}
$0 $0

View File

@ -367,18 +367,20 @@ have, compare through the start point of the overlay."
* If the template has no condition, it is kept. * If the template has no condition, it is kept.
* If the template's condition eval to non-nil, it is kept. * If the template's condition eval to non-nil, it is kept.
* Otherwise (eval error or eval to nil) it is filtered." * Otherwise (eval error or eval to nil) it is filtered."
(remove-if '(lambda (pair) (remove-if-not '(lambda (pair)
(let ((condition (yas/template-condition (cdr pair)))) (let ((condition (yas/template-condition (cdr pair))))
(if (null condition) (if (null condition)
(if yas/require-template-condition (if yas/require-template-condition
t nil
nil) t)
(let ((result (let ((result
(yas/template-condition-predicate condition))) (yas/template-condition-predicate condition)))
(if (eq yas/require-template-condition t) (if yas/require-template-condition
result (if (eq yas/require-template-condition t)
(not (eq result yas/require-template-condition))))))) result
templates)) (eq result yas/require-template-condition))
result)))))
templates))
(defun yas/snippet-table-fetch (table key) (defun yas/snippet-table-fetch (table key)
"Fetch a snippet binding to KEY from TABLE. If not found, "Fetch a snippet binding to KEY from TABLE. If not found,