Support expanding a snippet inside another snippet (only if not inside a field)

This commit is contained in:
Zhang Chiyuan 2008-03-14 01:27:22 +00:00
parent dbada984cf
commit e98815c030

View File

@ -797,7 +797,8 @@ Run `indent-for-tab-command'."
(interactive) (interactive)
(let ((command (key-binding (kbd "TAB")))) (let ((command (key-binding (kbd "TAB"))))
(if (and command (if (and command
(not (eq command 'yas/expand))) (not (eq command 'yas/expand))
(not (eq command 'yas/next-field-group)))
(call-interactively command) (call-interactively command)
(call-interactively 'indent-for-tab-command)))) (call-interactively 'indent-for-tab-command))))
@ -927,14 +928,14 @@ the menu if `yas/use-menu' is `t'."
(tabstop (car tabstops) (car tabstops))) (tabstop (car tabstops) (car tabstops)))
((or (null tabstops) ((or (null tabstops)
done) done)
(unless done (message "Not in a snippet field."))) (unless done (call-interactively 'yas/expand)))
(when (= (point) (when (= (point)
(overlay-start (overlay-start
(yas/field-overlay (yas/field-overlay
(yas/group-primary-field tabstop)))) (yas/group-primary-field tabstop))))
(setq done t) (setq done t)
(yas/navigate-group tabstop t))) (yas/navigate-group tabstop t)))
(message "Not in a snippet field.")))))) (call-interactively 'yas/expand))))))
(defun yas/prev-field-group () (defun yas/prev-field-group ()
"Navigate to prev field group. If there's none, exit the snippet." "Navigate to prev field group. If there's none, exit the snippet."