mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
the behavior when no snippet is found is now customizable through `yas/fall-back-behavior'
This commit is contained in:
parent
3deb5c9481
commit
bca01e5638
24
yasnippet.el
24
yasnippet.el
@ -166,6 +166,14 @@ Here's an example:
|
|||||||
'(require-snippet-condition . force-in-comment)
|
'(require-snippet-condition . force-in-comment)
|
||||||
t))))")
|
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
|
;; Internal variables
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
@ -1131,12 +1139,16 @@ when the condition evaluated to non-nil."
|
|||||||
(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))
|
||||||
(yas/popup-for-template templates))))
|
(yas/popup-for-template templates))))
|
||||||
(when template
|
(if template
|
||||||
(yas/expand-snippet start end template)))
|
(progn (yas/expand-snippet start end template)
|
||||||
(let* ((yas/minor-mode nil)
|
'expanded) ; expanded successfully
|
||||||
(command (key-binding yas/trigger-key)))
|
'interruptted)) ; interrupted by user
|
||||||
(when (commandp command)
|
(if (eq yas/fall-back-behavior 'return-nil)
|
||||||
(call-interactively command)))))))))
|
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 ()
|
(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."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user