From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#12985: eval-last-sexp looks broken when executed twice Date: Thu, 09 May 2013 00:19:09 +0300 Organization: JURTA Message-ID: <874nedmaok.fsf@mail.jurta.org> References: <1353808326.42897.YahooMailClassic@web141103.mail.bf1.yahoo.com> <1354020104.37554.YahooMailClassic@web141102.mail.bf1.yahoo.com> <87ehdjlw3x.fsf@mail.jurta.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1368048550 15727 80.91.229.3 (8 May 2013 21:29:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 May 2013 21:29:10 +0000 (UTC) Cc: 12985@debbugs.gnu.org To: Kelly Dean Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 08 23:29:08 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UaBvA-00063V-E4 for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 May 2013 23:29:08 +0200 Original-Received: from localhost ([::1]:36903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UaBvA-0002Jo-1p for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 May 2013 17:29:08 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UaBv5-0002JW-Me for bug-gnu-emacs@gnu.org; Wed, 08 May 2013 17:29:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UaBv4-0001Ig-9Y for bug-gnu-emacs@gnu.org; Wed, 08 May 2013 17:29:03 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58305) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UaBv4-0001Ic-6P for bug-gnu-emacs@gnu.org; Wed, 08 May 2013 17:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UaBv4-0004Op-Fw for bug-gnu-emacs@gnu.org; Wed, 08 May 2013 17:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 May 2013 21:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12985 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 12985-submit@debbugs.gnu.org id=B12985.136804849216823 (code B ref 12985); Wed, 08 May 2013 21:29:02 +0000 Original-Received: (at 12985) by debbugs.gnu.org; 8 May 2013 21:28:12 +0000 Original-Received: from localhost ([127.0.0.1]:34181 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UaBuG-0004NG-4X for submit@debbugs.gnu.org; Wed, 08 May 2013 17:28:12 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:53176 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UaBuE-0004NA-GO for 12985@debbugs.gnu.org; Wed, 08 May 2013 17:28:11 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 7E937258B9E91C; Wed, 8 May 2013 14:28:08 -0700 (PDT) In-Reply-To: <87ehdjlw3x.fsf@mail.jurta.org> (Juri Linkov's message of "Mon, 06 May 2013 22:57:38 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:74090 Archived-At: >> It seems a better design would be to always include the string, even >> the first time, when displaying in the echo area, and never include >> the string when printing into the buffer, regardless of the invoking >> command name. This is simpler, and it's how eval-expression already works. > > Thank you for suggesting a new design. I agree it is better > than the current design. The patch below implements it and > removes the feature of behaving differently when called twice. Since this feature will use a better design now, more commands could benefit from this feature: `C-M-x' (`eval-defun' and `edebug-eval-defun') and `ielm-send-input'. === modified file 'lisp/emacs-lisp/lisp-mode.el' --- lisp/emacs-lisp/lisp-mode.el 2013-05-06 20:23:40 +0000 +++ lisp/emacs-lisp/lisp-mode.el 2013-05-08 21:12:52 +0000 @@ -928,6 +928,8 @@ (defun eval-defun-2 () ;; will make eval-region return. (goto-char ,end) ',form)))))) + (let ((str (eval-expression-print-format (car values)))) + (if str (princ str))) ;; The result of evaluation has been put onto VALUES. So return it. (car values)) === modified file 'lisp/emacs-lisp/edebug.el' --- lisp/emacs-lisp/edebug.el 2013-04-08 02:21:59 +0000 +++ lisp/emacs-lisp/edebug.el 2013-05-08 21:17:06 +0000 @@ -528,7 +528,10 @@ (defun edebug-eval-defun (edebug-it) (put (nth 1 form) 'saved-face nil))))) (setq edebug-result (eval (eval-sexp-add-defvars form) lexical-binding)) (if (not edebugging) - (princ edebug-result) + (prog1 + (princ edebug-result) + (let ((str (eval-expression-print-format edebug-result))) + (if str (princ str)))) edebug-result))) === modified file 'lisp/ielm.el' --- lisp/ielm.el 2013-01-01 09:11:05 +0000 +++ lisp/ielm.el 2013-05-08 21:10:23 +0000 @@ -408,7 +408,8 @@ (defun ielm-eval-input (input-string) (condition-case nil ;; Self-referential objects cause loops in the printer, so ;; trap quits here. May as well do errors, too - (setq ielm-output (concat ielm-output (pp-to-string ielm-result))) + (setq ielm-output (concat ielm-output (pp-to-string ielm-result) + (eval-expression-print-format ielm-result))) (error (setq ielm-error-type "IELM Error") (setq ielm-result "Error during pretty-printing (bug in pp)")) (quit (setq ielm-error-type "IELM Error")