]> code.delx.au - gnu-emacs-elpa/commitdiff
New names-pprint command, to pretty-print entire namespace
authorArtur Malabarba <bruce.connor.am@gmail.com>
Wed, 17 Jun 2015 09:01:23 +0000 (10:01 +0100)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Wed, 17 Jun 2015 10:04:05 +0000 (11:04 +0100)
Affects #17

names-dev.el

index 4efc12e3569a8e36b4fbc4020657be80336b5423..87a6d58c24392f6ed736ea9a499be293d813df8b 100644 (file)
 (defmacro names-print (name &rest forms)
   "Return the expanded results of (namespace NAME :global :verbose FORMS).
 Ideal for determining why a specific form isn't being parsed
-correctly."
+correctly. You may need to set `eval-expression-print-level' and
+`eval-expression-print-length' to nil in order to see your full
+expansion."
   (declare (indent (lambda (&rest x) 0)) (debug 0))
-  `(let ((eval-expression-print-level (max eval-expression-print-level 300))
-         (eval-expression-print-length (max eval-expression-print-length 300)))
-     (macroexpand '(define-namespace ,name :global :verbose ,@forms))))
+  `(define-namespace ,name :global :verbose ,@forms))
 
 (defvar names-font-lock
   '(("^:autoload\\_>" 0 'font-lock-warning-face prepend)
@@ -156,8 +156,8 @@ If KILL is non-nil, kill the temp buffer afterwards."
   (progn
     (beginning-of-defun)
     (ignore-errors
-      (backward-up-list)
-      (names--looking-at-namespace))))
+      (backward-up-list))
+    (names--looking-at-namespace)))
 
 (defun names-eval-defun (edebug-it)
   "Identical to `eval-defun', except it works for forms inside namespaces.
@@ -204,6 +204,15 @@ Argument EVAL-LAST-SEXP-ARG-INTERNAL is the same as `eval-print-last-sexp'."
 
 ;; (pp (symbol-function 'names--preceding-sexp-original) (current-buffer))
 
+(defun names-pprint ()
+  "Pretty-print an expansion of the namespace around point."
+  (interactive)
+  (let ((ns (save-excursion
+              (names--top-of-namespace)
+              (cdr-safe (read (current-buffer))))))
+    (pp-macroexpand-expression
+     (macroexpand (cons 'names-print ns)))))
+
 \f
 ;;; Find stuff
 (require 'find-func nil t)