the behavior when no snippet is found is now customizable through `yas/fall-back-behavior'

This commit is contained in:
Zhang Chiyuan 2008-04-10 05:11:01 +00:00
parent 3deb5c9481
commit bca01e5638

View File

@ -166,6 +166,14 @@ Here's an example:
'(require-snippet-condition . force-in-comment)
t))))")
(defvar yas/fall-back-behavior 'call-other-command
"The fall back behavior of YASnippet when it can't find a snippet
to expand.
* 'call-other-command means try to temporarily disable
YASnippet and call other command bound to `yas/trigger-key'.
* 'return-nil means return nil.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Internal variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -1131,12 +1139,16 @@ when the condition evaluated to non-nil."
(let ((template (if (null (cdr templates)) ; only 1 template
(yas/template-content (cdar templates))
(yas/popup-for-template templates))))
(when template
(yas/expand-snippet start end template)))
(let* ((yas/minor-mode nil)
(command (key-binding yas/trigger-key)))
(when (commandp command)
(call-interactively command)))))))))
(if template
(progn (yas/expand-snippet start end template)
'expanded) ; expanded successfully
'interruptted)) ; interrupted by user
(if (eq yas/fall-back-behavior 'return-nil)
nil ; return nil
(let* ((yas/minor-mode nil)
(command (key-binding yas/trigger-key)))
(when (commandp command)
(call-interactively command))))))))))
(defun yas/next-field-group ()
"Navigate to next field group. If there's none, exit the snippet."