mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 05:03:04 +00:00
Reinstate the old debug behaviour for yas-tryout-snippet
During a redesign of the debug facilities, the old shortcut C-u C-t available and useful in snippet-mode, was lost. * yasnippet-debug.el (yas-debug-snippets): Add docstring. Add post-command-hook locally if HOOK is snippet-navigation. Concisely describe parent field (not just mention it). * yasnippet.el (yas-tryout-snippet): Call yas-debug-snippets and display buffer. Tweak docstring. (yas-debug-snippets): Forward declare function defined in yasnippet-debug.el
This commit is contained in:
parent
ff26e3ba7f
commit
8b421bc78d
@ -193,7 +193,11 @@
|
||||
(yas-debug-live-range field)
|
||||
(buffer-substring-no-properties (yas--field-start field) (yas--field-end field))
|
||||
(yas--debug-format-fom-concise (yas--field-next field))
|
||||
(if (yas--field-parent-field field) "(has a parent)" "")))
|
||||
(if (yas--field-parent-field field)
|
||||
(format " parent: %s"
|
||||
(yas--debug-format-fom-concise
|
||||
(yas--field-parent-field field)))
|
||||
"")))
|
||||
(dolist (mirror (yas--field-mirrors field))
|
||||
(unless (consp (yas--mirror-start mirror))
|
||||
(printf "\t\tmirror: %s covering \"%s\" next: %s\n"
|
||||
@ -224,6 +228,14 @@
|
||||
(clrhash yas-debug-live-indicators))
|
||||
|
||||
(defun yas-debug-snippets (&optional outbuf hook)
|
||||
"Print debug information on active snippets to buffer OUTBUF.
|
||||
If OUTBUF is nil, use a buffer named \"*YASsnippet trace*\".
|
||||
If HOOK is non-nil, install `yas-debug-snippets' in
|
||||
`post-command-hook' to update the information on every command
|
||||
after this one. If it is `snippet-navigation' then install hook
|
||||
buffer-locally, otherwise install it globally. If HOOK is
|
||||
`edebug-create', also instrument the function
|
||||
`yas--snippet-parse-create' with `edebug' and show its source."
|
||||
(interactive (list nil t))
|
||||
(condition-case err
|
||||
(yas-debug-with-tracebuf outbuf
|
||||
@ -253,11 +265,12 @@
|
||||
(ad-activate 'yas--snippet-parse-create)
|
||||
(ad-enable-advice 'yas--commit-snippet 'after 'yas-debug-untarget-snippet)
|
||||
(ad-activate 'yas--commit-snippet)
|
||||
(add-hook 'post-command-hook #'yas-debug-snippets)
|
||||
(add-hook 'post-command-hook #'yas-debug-snippets
|
||||
nil (eq hook 'snippet-navigation))
|
||||
;; Window management is slapped together, it does what I
|
||||
;; want when the caller has a single window open. Good
|
||||
;; enough for now.
|
||||
(when (eq hook 'create)
|
||||
(when (eq hook 'edebug-create)
|
||||
(edebug-instrument-function 'yas--snippet-parse-create)
|
||||
(let ((buf-point (find-function-noselect 'yas--snippet-parse-create)))
|
||||
(with-current-buffer (car buf-point)
|
||||
|
11
yasnippet.el
11
yasnippet.el
@ -2705,8 +2705,11 @@ and `kill-buffer' instead."
|
||||
(save-buffer)))
|
||||
(quit-window kill)))
|
||||
|
||||
(declare-function yas-debug-snippets "yasnippet-debug")
|
||||
|
||||
(defun yas-tryout-snippet (&optional debug)
|
||||
"Test current buffer's snippet template in other buffer."
|
||||
"Test current buffer's snippet template in other buffer.
|
||||
DEBUG is for debugging the YASnippet engine itself."
|
||||
(interactive "P")
|
||||
(let* ((major-mode-and-parent (yas--compute-major-mode-and-parents buffer-file-name))
|
||||
(parsed (yas--parse-template))
|
||||
@ -2736,9 +2739,9 @@ and `kill-buffer' instead."
|
||||
(point-max)
|
||||
(yas--template-expand-env yas--current-template))
|
||||
(when (and debug
|
||||
(require 'yasnippet-debug nil t)
|
||||
(fboundp 'yas-debug-snippet-vars))
|
||||
(add-hook 'post-command-hook #'yas-debug-snippet-vars nil t))))
|
||||
(require 'yasnippet-debug nil t))
|
||||
(yas-debug-snippets "*YASnippet trace*" 'snippet-navigation)
|
||||
(display-buffer "*YASnippet trace*"))))
|
||||
(t
|
||||
(yas--message 1 "Cannot test snippet for unknown major mode")))))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user