From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: pp-eval-expression broken Date: Fri, 5 Jan 2007 19:24:10 -0800 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1168053903 5576 80.91.229.12 (6 Jan 2007 03:25:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 6 Jan 2007 03:25:03 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 06 04:25:01 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1H32B1-0005ZO-GJ for ged-emacs-devel@m.gmane.org; Sat, 06 Jan 2007 04:24:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H32B0-0001sV-QZ for ged-emacs-devel@m.gmane.org; Fri, 05 Jan 2007 22:24:58 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H32An-0001pN-8R for emacs-devel@gnu.org; Fri, 05 Jan 2007 22:24:45 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H32Al-0001lW-BJ for emacs-devel@gnu.org; Fri, 05 Jan 2007 22:24:43 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H32Al-0001lR-0n for emacs-devel@gnu.org; Fri, 05 Jan 2007 22:24:43 -0500 Original-Received: from [148.87.113.118] (helo=rgminet01.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1H32Ak-0001vt-JX for emacs-devel@gnu.org; Fri, 05 Jan 2007 22:24:42 -0500 Original-Received: from rgmgw1.us.oracle.com (rgmgw1.us.oracle.com [138.1.186.110]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id l063Oe7w021698 for ; Fri, 5 Jan 2007 20:24:40 -0700 Original-Received: from rcsmt250.oracle.com (rcsmt250.oracle.com [148.87.90.195]) by rgmgw1.us.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id l05MnpwT009004 for ; Fri, 5 Jan 2007 20:24:40 -0700 Original-Received: from dhcp-amer-rmdc-csvpn-gw4-141-144-102-221.vpn.oracle.com by rcsmt251.oracle.com with ESMTP id 2342932341168053856; Fri, 05 Jan 2007 20:24:16 -0700 Original-To: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 In-Reply-To: Importance: Normal X-Whitelist: TRUE X-Whitelist: TRUE X-Brightmail-Tracker: AAAAAQAAAAI= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:64862 Archived-At: > 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))))