emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master c744148 03/40: Make yas-describe-tables easier to use from


From: Noam Postavsky
Subject: [elpa] master c744148 03/40: Make yas-describe-tables easier to use from lisp
Date: Wed, 26 Oct 2016 23:06:31 +0000 (UTC)

branch: master
commit c7441486db858d1c35187c3ffa6096fff064d421
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Make yas-describe-tables easier to use from lisp
    
    * yasnippet.el (yas-describe-table-by-namehash): new function.
    (yas-describe-tables): remove query for by-namehash variant, replace
    query for non-active tables with prefix arg.
---
 yasnippet.el |   91 ++++++++++++++++++++++++++--------------------------------
 1 file changed, 41 insertions(+), 50 deletions(-)

diff --git a/yasnippet.el b/yasnippet.el
index 161c996..8a6258c 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -2664,58 +2664,49 @@ and `kill-buffer' instead."
   (car (last (or (yas--template-group template)
                  (yas--template-perm-group template)))))
 
-(defun yas-describe-tables (&optional choose)
+(defun yas-describe-table-by-namehash ()
+  "Display snippet tables by NAMEHASH."
+  (interactive)
+  (with-current-buffer (get-buffer-create "*YASnippet Tables by NAMEHASH*")
+    (let ((inhibit-read-only t))
+      (erase-buffer)
+      (insert "YASnippet tables by NAMEHASH: \n")
+      (maphash
+       (lambda (_mode table)
+         (insert (format "\nSnippet table `%s':\n\n" (yas--table-name table)))
+         (maphash
+          (lambda (key _v)
+            (insert (format "   key %s maps snippets: %s\n" key
+                            (let ((names))
+                              (maphash #'(lambda (k _v)
+                                           (push k names))
+                                       (gethash key (yas--table-hash table)))
+                              names))))
+          (yas--table-hash table)))
+       yas--tables))
+    (view-mode +1)
+    (goto-char 1)
+    (display-buffer (current-buffer))))
+
+(defun yas-describe-tables (&optional with-nonactive)
   "Display snippets for each table."
   (interactive "P")
-  (let* ((by-name-hash (and choose
-                            (y-or-n-p "Show by namehash? ")))
-         (buffer (get-buffer-create "*YASnippet tables*"))
-         (active-tables (yas--get-snippet-tables))
-         (remain-tables (let ((all))
-                          (maphash #'(lambda (_k v)
-                                       (unless (find v active-tables)
-                                         (push v all)))
-                                   yas--tables)
-                          all))
-         (table-lists (list active-tables remain-tables))
-         (original-buffer (current-buffer))
-         (continue t)
-         (yas--condition-cache-timestamp (current-time)))
-    (with-current-buffer buffer
-      (setq buffer-read-only nil)
-      (erase-buffer)
-      (cond ((not by-name-hash)
-             (insert "YASnippet tables:\n")
-             (while (and table-lists
-                         continue)
-               (dolist (table (car table-lists))
-                 (yas--describe-pretty-table table original-buffer))
-               (setq table-lists (cdr table-lists))
-               (when table-lists
-                 (yas--create-snippet-xrefs)
-                 (display-buffer buffer)
-                 (setq continue (and choose (y-or-n-p "Show also non-active 
tables? ")))))
-             (yas--create-snippet-xrefs)
-             (help-mode)
-             (goto-char 1))
-            (t
-             (insert "\n\nYASnippet tables by NAMEHASH: \n")
-             (dolist (table (append active-tables remain-tables))
-               (insert (format "\nSnippet table `%s':\n\n" (yas--table-name 
table)))
-               (let ((keys))
-                 (maphash #'(lambda (k _v)
-                              (push k keys))
-                          (yas--table-hash table))
-                 (dolist (key keys)
-                   (insert (format "   key %s maps snippets: %s\n" key
-                                   (let ((names))
-                                     (maphash #'(lambda (k _v)
-                                                  (push k names))
-                                              (gethash key (yas--table-hash 
table)))
-                                     names))))))))
-      (goto-char 1)
-      (setq buffer-read-only t))
-    (display-buffer buffer)))
+  (let ((original-buffer (current-buffer))
+        (tables (yas--get-snippet-tables)))
+   (with-current-buffer (get-buffer-create "*YASnippet Tables*")
+     (let ((inhibit-read-only t))
+       (when with-nonactive
+         (maphash #'(lambda (_k v)
+                      (cl-pushnew v tables))
+                  yas--tables))
+       (erase-buffer)
+       (insert "YASnippet tables:\n")
+       (dolist (table tables)
+         (yas--describe-pretty-table table original-buffer))
+       (yas--create-snippet-xrefs))
+     (help-mode)
+     (goto-char 1)
+     (display-buffer (current-buffer)))))
 
 (defun yas--describe-pretty-table (table &optional original-buffer)
   (insert (format "\nSnippet table `%s'"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]