From: "Drew Adams" <drew.adams@oracle.com>
Subject: RE: pp-eval-expression broken
Date: Fri, 5 Jan 2007 19:24:10 -0800 [thread overview]
Message-ID: <EIENLHALHGIMHGDOLMIMKEBKCOAA.drew.adams@oracle.com> (raw)
In-Reply-To: <E1H31iF-0000Oo-IH@fencepost.gnu.org>
> 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))))
next prev parent reply other threads:[~2007-01-06 3:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-05 15:51 pp-eval-expression broken Drew Adams
2007-01-05 17:52 ` Drew Adams
2007-01-05 18:58 ` Randal L. Schwartz
2007-01-05 19:14 ` Drew Adams
2007-01-06 2:55 ` Richard Stallman
2007-01-06 3:24 ` Drew Adams [this message]
2007-01-06 6:28 ` Drew Adams
2007-01-07 3:46 ` Richard Stallman
2007-01-09 22:56 ` Drew Adams
2007-01-13 22:27 ` Drew Adams
2007-01-14 14:45 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=EIENLHALHGIMHGDOLMIMKEBKCOAA.drew.adams@oracle.com \
--to=drew.adams@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.