[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Interactive macro expansion added
From: |
Johannes Weiner |
Subject: |
Re: [PATCH] Interactive macro expansion added |
Date: |
Mon, 10 Sep 2007 02:46:32 +0200 |
User-agent: |
Mutt/1.5.16 (2007-06-11) |
Hi,
On Sun, Sep 09, 2007 at 04:06:17PM -0400, Richard Stallman wrote:
> My legal papers arrived. The browse-url patch for elinks support already
> got
> in. Can this patch get merged now too?
>
> Please send your patch and its change log entry again,
> plus NEWS entry if it needs one, and we can install it.
Alright, unified diff attached.
Hannes
diff -Naur emacs.orig/etc/NEWS emacs/etc/NEWS
--- emacs.orig/etc/NEWS 2007-09-10 02:29:43.000000000 +0200
+++ emacs/etc/NEWS 2007-09-10 02:44:36.000000000 +0200
@@ -181,6 +181,9 @@
*** The variable `fortran-line-length' can change the fixed-form line-length.
+*** The new command `pp-macroexpand-last-sexp' pretty-prints the
+macroexpansion of the s-expression before point.
+
** Miscellaneous
*** comint-mode uses `start-file-process' now (see Lisp Changes).
@@ -319,6 +322,9 @@
** The interactive-form of a function can be added post-facto via the
`interactive-form' symbol property. Mostly useful to add complex interactive
forms to subroutines.
+
+** The new function `pp-macroexpand-expression' pretty-prints the
+macroexpansion of an s-expression.
* New Packages for Lisp Programming in Emacs 23.1
diff -Naur emacs.orig/lisp/ChangeLog emacs/lisp/ChangeLog
--- emacs.orig/lisp/ChangeLog 2007-09-10 02:29:44.000000000 +0200
+++ emacs/lisp/ChangeLog 2007-09-10 02:29:15.000000000 +0200
@@ -1,3 +1,11 @@
+2007-09-10 Johannes Weiner <address@hidden>
+
+ * emacs-lisp/pp.el (pp-display-expression)
+ (pp-macroexpand-expression, pp-last-sexp)
+ (pp-macroexpand-last-sexp): New functions.
+ (pp-eval-expression): Use extracted pp-display-expression.
+ (pp-eval-last-sexp): Use extracted pp-last-sexp.
+
2007-09-05 Glenn Morris <address@hidden>
* cus-edit.el (custom-buffer-create-internal): Check tool-bar-mode
diff -Naur emacs.orig/lisp/emacs-lisp/pp.el emacs/lisp/emacs-lisp/pp.el
--- emacs.orig/lisp/emacs-lisp/pp.el 2007-09-10 02:29:44.000000000 +0200
+++ emacs/lisp/emacs-lisp/pp.el 2007-09-10 02:15:27.000000000 +0200
@@ -97,14 +97,10 @@
(princ (pp-to-string object) (or stream standard-output)))
;;;###autoload
-(defun pp-eval-expression (expression)
- "Evaluate EXPRESSION and pretty-print its value.
-Also add the value to the front of the list in the variable `values'."
- (interactive
- (list (read-from-minibuffer "Eval: " nil read-expression-map t
- 'read-expression-history)))
- (message "Evaluating...")
- (setq values (cons (eval expression) values))
+(defun pp-display-expression (expression out-buffer-name)
+ "Prettify and display EXPRESSION in an appropriate way,
+depending on its printed length. If a temporary buffer is needed
+for representation, it will be named after OUT-BUFFER-NAME."
(let* ((old-show-function temp-buffer-show-function)
;; Use this function to display the buffer.
;; This function either decides not to display it at all
@@ -128,23 +124,37 @@
(select-window window)
(run-hooks 'temp-buffer-show-hook))
(select-window old-selected)
- (message "Evaluating...done. \
-See buffer *Pp Eval Output*.")))
+ (message "See buffer %s." out-buffer-name)))
(message "%s" (buffer-substring (point-min) (point)))
))))))
- (with-output-to-temp-buffer "*Pp Eval Output*"
- (pp (car values))
+ (with-output-to-temp-buffer out-buffer-name
+ (pp expression)
(with-current-buffer standard-output
(emacs-lisp-mode)
(setq buffer-read-only nil)
(set (make-local-variable 'font-lock-verbose) nil)))))
;;;###autoload
-(defun pp-eval-last-sexp (arg)
- "Run `pp-eval-expression' on sexp before point (which see).
-With argument, pretty-print output into current buffer.
-Ignores leading comment characters."
- (interactive "P")
+(defun pp-eval-expression (expression)
+ "Evaluate EXPRESSION and pretty-print its value.
+Also add the value to the front of the list in the variable `values'."
+ (interactive
+ (list (read-from-minibuffer "Eval: " nil read-expression-map t
+ 'read-expression-history)))
+ (message "Evaluating...")
+ (setq values (cons (eval expression) values))
+ (pp-display-expression (car values) "*Pp Eval Output*"))
+
+;;;###autoload
+(defun pp-macroexpand-expression (expression)
+ "Macroexpand EXPRESSION and pretty-print its value."
+ (interactive
+ (list (read-from-minibuffer "Macroexpand: " nil read-expression-map t
+ 'read-expression-history)))
+ (pp-display-expression (macroexpand expression) "*Pp Macroexpand Output*"))
+
+(defun pp-last-sexp ()
+ "Read sexp before point. Ignores leading comment characters."
(let ((stab (syntax-table)) (pt (point)) start exp)
(set-syntax-table emacs-lisp-mode-syntax-table)
(save-excursion
@@ -160,9 +170,27 @@
(setq exp (read exp)))
(setq exp (read (current-buffer)))))
(set-syntax-table stab)
- (if arg
- (insert (pp-to-string (eval exp)))
- (pp-eval-expression exp))))
+ exp))
+
+;;;###autoload
+(defun pp-eval-last-sexp (arg)
+ "Run `pp-eval-expression' on sexp before point (which see).
+With argument, pretty-print output into current buffer.
+Ignores leading comment characters."
+ (interactive "P")
+ (if arg
+ (insert (pp-to-string (eval (pp-last-sexp))))
+ (pp-eval-expression (pp-last-sexp))))
+
+;;;###autoload
+(defun pp-macroexpand-last-sexp (arg)
+ "Run `pp-macroexpand-expression' on sexp before point (which see).
+With argument, pretty-print output into current buffer.
+Ignores leading comment characters."
+ (interactive "P")
+ (if arg
+ (insert (pp-to-string (macroexpand (pp-last-sexp))))
+ (pp-macroexpand-expression (pp-last-sexp))))
;;; Test cases for quote
;; (pp-eval-expression ''(quote quote))
signature.asc
Description: Digital signature