* Slightly nicer (yas/debug-tables) function, helpful for debugging as

the name clearly suggests
This commit is contained in:
capitaomorte 2009-10-06 16:36:57 +00:00
parent 493c923b40
commit a18e5fda5d

View File

@ -922,7 +922,8 @@ Has the following fields:
;; Apropos storing/updating, this is works with two steps: ;; Apropos storing/updating, this is works with two steps:
;; ;;
;; 1. Remove any existing mappings, with two searches: ;; 1. `yas/remove-snippet' to remove any existing mappings, with two
;; searches:
;; ;;
;; a) Try to get the existing namehash from TABLE using key. ;; a) Try to get the existing namehash from TABLE using key.
;; ;;
@ -940,7 +941,7 @@ Has the following fields:
;; If any existing namesomething is found it is deleted, and is ;; If any existing namesomething is found it is deleted, and is
;; maybe added later on: ;; maybe added later on:
;; ;;
;; 2. Add the mappings again ;; 2. `yas/add-snippet' to add the mappings again:
;; ;;
;; Create or index the entry in TABLES's `yas/snippet-table-hash' ;; Create or index the entry in TABLES's `yas/snippet-table-hash'
;; linking KEY to a namehash. That namehash links NAME to ;; linking KEY to a namehash. That namehash links NAME to
@ -953,7 +954,6 @@ Has the following fields:
;; fails if both the key and the name have changed. In that case, ;; fails if both the key and the name have changed. In that case,
;; it's as if a brand new snippet had been created. ;; it's as if a brand new snippet had been created.
;; ;;
(defvar yas/better-guess-for-replacements nil (defvar yas/better-guess-for-replacements nil
"If non-nil `yas/store' guesses snippet replacements \"better\".") "If non-nil `yas/store' guesses snippet replacements \"better\".")
@ -3613,19 +3613,19 @@ object satisfying `yas/field-p' to restrict the expansion to.")))
(defun yas/debug-tables () (defun yas/debug-tables ()
(interactive) (interactive)
(with-output-to-temp-buffer "*YASnippet tables*" (with-output-to-temp-buffer "*YASnippet tables*"
(dolist (symbol (remove nil (append (list major-mode) (dolist (table (yas/get-snippet-tables))
(if (listp yas/mode-symbol) (princ (format "Table hash keys for %s:\n\n" (yas/snippet-table-name table))
yas/mode-symbol
(list yas/mode-symbol)))))
(princ (format "Snippet table hash keys for %s:\n\n" symbol))
(let ((keys)) (let ((keys))
(maphash #'(lambda (k v) (maphash #'(lambda (k v)
(push k keys)) (push k keys))
(yas/snippet-table-hash (gethash symbol yas/snippet-tables))) (yas/snippet-table-hash table))
(princ keys)) (dolist (key keys)
(princ (format " key %s maps snippets: %s\n" key
(princ (format "Keymap for %s:\n\n" symbol)) (let ((names))
(princ (gethash symbol yas/menu-table))))) (maphash #'(lambda (k v)
(push k names))
(gethash key (yas/snippet-table-hash table)))
names)))))))))
(defun yas/debug-snippet-vars () (defun yas/debug-snippet-vars ()
"Debug snippets, fields, mirrors and the `buffer-undo-list'." "Debug snippets, fields, mirrors and the `buffer-undo-list'."