[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: pp-eval-expression broken
From: |
Drew Adams |
Subject: |
RE: pp-eval-expression broken |
Date: |
Fri, 5 Jan 2007 19:24:10 -0800 |
> The reason for the change in pp-eval-expression
> is so that it will use read-expression-map and
> read-expression-history. There is no clean way to make
> (interactive "x") use them.
>
> If this change causes trouble, we could create a new command with the
> new meaning of pp-eval-expression, and document that for users; then
> we could put pp-eval-expression back the old way, just for Lisp
> callers.
It was I who suggested using `read-expression-history' and
`read-expression-map' (thread "pp-eval-expression should use
read-expression-history" in Emacs-Pretest-Bug, 2006-10-14).
That's what I do in my own redefined `pp-eval-expression'. But I don't use
(interactive "X") or (interactive "x"). I just use this:
(interactive
(list (read-from-minibuffer "Eval: " nil read-expression-map t
'read-expression-history))
Is there a problem with using that?
I'm not necessarily suggesting the following changes, but I also:
1. inhibit `emacs-lisp-mode-hook'.
2. call `font-lock-fontify-buffer'.
3. add a progress message ("Evaluating...").
Here's the code, FWIW (updated today, to deal with the recent non-eval for
Emacs 22):
(defun pp-eval-expression (expression)
"Evaluate EXPRESSION and pretty-print value into a new display buffer.
If the pretty-printed value fits on one line, the message line is used
instead. The value is also consed onto 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...")
(unless (or (interactive-p) (> emacs-major-version 21)) ; Emacs 22 fix.
(setq expression (eval expression)))
(setq values (cons expression values))
(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 or displays it in the usual way.
(temp-buffer-show-function
(function
(lambda (buf)
(save-excursion
(set-buffer buf)
(goto-char (point-min))
(end-of-line 1)
(if (or (< (1+ (point)) (point-max))
(>= (- (point) (point-min))
(frame-width)))
(let ((temp-buffer-show-function
old-show-function)
(old-selected (selected-window))
(window (display-buffer buf)))
(goto-char (point-min))
(make-frame-visible
(window-frame window))
(unwind-protect
(progn
(select-window window)
(run-hooks
'temp-buffer-show-hook))
(select-window old-selected)
(message
"Evaluating...done. \
See buffer *Pp Eval Output*.")))
(message "%s"
(buffer-substring (point-min)
(point)))))))))
(with-output-to-temp-buffer "*Pp Eval Output*"
(pp (car values)))
(save-excursion
(set-buffer "*Pp Eval Output*")
(setq buffer-read-only nil)
(let ((emacs-lisp-mode-hook nil)
(change-major-mode-hook nil))
(emacs-lisp-mode))
(make-local-variable 'font-lock-verbose)
(setq font-lock-verbose nil)
(font-lock-fontify-buffer))))
- pp-eval-expression broken, Drew Adams, 2007/01/05
- RE: pp-eval-expression broken, Drew Adams, 2007/01/05
- Re: pp-eval-expression broken, Richard Stallman, 2007/01/05
- RE: pp-eval-expression broken,
Drew Adams <=
- RE: pp-eval-expression broken, Drew Adams, 2007/01/06
- Re: pp-eval-expression broken, Richard Stallman, 2007/01/06
- RE: pp-eval-expression broken, Drew Adams, 2007/01/09
- RE: pp-eval-expression broken, Drew Adams, 2007/01/13
- Re: pp-eval-expression broken, Richard Stallman, 2007/01/14