From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kelly Dean Newsgroups: gmane.emacs.bugs Subject: bug#12985: eval-last-sexp looks broken when executed twice Date: Tue, 27 Nov 2012 04:41:44 -0800 (PST) Message-ID: <1354020104.37554.YahooMailClassic@web141102.mail.bf1.yahoo.com> References: <1353808326.42897.YahooMailClassic@web141103.mail.bf1.yahoo.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1354020150 1348 80.91.229.3 (27 Nov 2012 12:42:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 27 Nov 2012 12:42:30 +0000 (UTC) Cc: 12985@debbugs.gnu.org To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 27 13:42:42 2012 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 1TdKUp-0006Fy-2K for geb-bug-gnu-emacs@m.gmane.org; Tue, 27 Nov 2012 13:42:39 +0100 Original-Received: from localhost ([::1]:41637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdKUd-0003b5-DD for geb-bug-gnu-emacs@m.gmane.org; Tue, 27 Nov 2012 07:42:27 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:55854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdKUW-0003ak-Cx for bug-gnu-emacs@gnu.org; Tue, 27 Nov 2012 07:42:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TdKUQ-0007wM-HV for bug-gnu-emacs@gnu.org; Tue, 27 Nov 2012 07:42:20 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59252) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdKUQ-0007wI-Dv for bug-gnu-emacs@gnu.org; Tue, 27 Nov 2012 07:42:14 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TdKWA-0000XL-4T for bug-gnu-emacs@gnu.org; Tue, 27 Nov 2012 07:44:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Kelly Dean Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 27 Nov 2012 12:44: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.13540202152020 (code B ref 12985); Tue, 27 Nov 2012 12:44:02 +0000 Original-Received: (at 12985) by debbugs.gnu.org; 27 Nov 2012 12:43:35 +0000 Original-Received: from localhost ([127.0.0.1]:41270 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TdKVj-0000WX-Dd for submit@debbugs.gnu.org; Tue, 27 Nov 2012 07:43:35 -0500 Original-Received: from nm13.bullet.mail.bf1.yahoo.com ([98.139.212.172]:27404) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TdKVh-0000WN-Iy for 12985@debbugs.gnu.org; Tue, 27 Nov 2012 07:43:34 -0500 Original-Received: from [98.139.215.142] by nm13.bullet.mail.bf1.yahoo.com with NNFMP; 27 Nov 2012 12:41:44 -0000 Original-Received: from [98.139.212.238] by tm13.bullet.mail.bf1.yahoo.com with NNFMP; 27 Nov 2012 12:41:44 -0000 Original-Received: from [127.0.0.1] by omp1047.mail.bf1.yahoo.com with NNFMP; 27 Nov 2012 12:41:44 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 845206.3766.bm@omp1047.mail.bf1.yahoo.com Original-Received: (qmail 50224 invoked by uid 60001); 27 Nov 2012 12:41:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1354020104; bh=d8DrF8VvX2n6IqJyLhcst4cBFingITDTNO06oGmgl/g=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=UZit59YICVI4SxtwQOoYwCgjajQWcApCan710xSkiwOHD3QzhYzpMKRAOewrVP+lKxlNffD05ix+kriAOkDNBsFM3R+aDse4ws8jpmvsCuWm6bYBl+sNmX79Sun5+2uXZ72/MilYYmPQBP63h59ziPuYFPkmp5ohxgrHnHb/3Dc= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=h7PKR47L7A2wQSaaJXP+WfGYurfqashK3njDsXDzYHbOu1R4G1TdZAsytvTQzxttIVqemcPW7AsOgZe+ql4Wb7yWZUgbY/ruR4Wo/I3VMtBgLZFIcpdpmObMLrGWJBJhYF0Z7ndUmOLUOog9FL6Wqt5UVYnqWBaJq8iG3+y+0Pg=; X-YMail-OSG: E0sbhI0VM1nbsXNI5unLOMqE7x07CoiXzivfN8jih0vnxd_ mO79vyKQKmeaRt_U5OJRl4IBUu.GJKjAR.O5hqbpGJwrqVK2CIK1xn8YBdn4 BPIcaWgd.WaF_l1pxqoxHTXp9IDf0p_FMBOpMoxQCWGFfTpxkt.5CSrtcyQ0 t8JZsv1cb6w4rTl8xoAvVlxcH5HNI083gNmycWBEowVq4NHEdVBTtv7suhS3 nLSwkhpxF1hZydUxcuKtyyXB5Dl4o.cMYWzHR2KQ3bfkaqLSx.xTAXZ7n026 z7dafqCPHZh2n.Vo3pbpsS2LfjXfOATe_VowmgF4_h9EJmciCtqvCEuT4YtN WJHuiUdSyLjgFf8KlNlYdhKF4Ry6BE2lRfnrPtoQCV7NhWo6l5triIx01Fmh p_m5fY_p3ig83i7txW18.KA.TCa72G615.54ndAHzlAcQLh0JH5ZilCTeJeB _dNAsPTNOPfJG6Wo- Original-Received: from [96.47.226.21] by web141102.mail.bf1.yahoo.com via HTTP; Tue, 27 Nov 2012 04:41:44 PST X-Rocket-MIMEInfo: 001.001, PiBJdCdzIG5vdCBhIGJ1ZywgaXQncyBhIGZlYXR1cmUgb2YKPiBldmFsLWV4cHJlc3Npb24tcHJpbnQtZm9ybWF0LgpTb3JyeSBmb3IgdGhlIG1pc3Rha2VuIGJ1ZyByZXBvcnQuIEkgc2hvdWxkIGhhdmUgcmVhZCB0aGUgc291cmNlIGNvZGUsIGFuZCByZXBvcnRlZCB0aGlzIGJ1ZyBhcyBhIGRvY3VtZW50YXRpb24gZGVmaWNpZW5jeSBpbnN0ZWFkLCBzaW5jZSB0aGUgaGVscCBwYWdlcyBmb3IgZXZhbC1sYXN0LXNleHAgYW5kIGV2YWwtcHJpbnQtbGFzdC1zZXhwIHNheSBub3RoaW5nIGFib3V0IGV2YWwtZXgBMAEBAQE- X-Mailer: YahooMailClassic/15.0.8 YahooMailWebService/0.8.127.475 In-Reply-To: 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:67505 Archived-At: > It's not a bug, it's a feature of > eval-expression-print-format. Sorry for the mistaken bug report. I should have read the source code, and reported this bug as a documentation deficiency instead, since the help pages for eval-last-sexp and eval-print-last-sexp say nothing about eval-expression-print-format or about behaving differently when called twice. I propose adding to the doc strings for eval-last-sexp and eval-print-last-sexp, "If the value is an integer, and this command is called twice in succession, then in addition to printing the decimal representation, also print the octal and hex representations and char interpretation of the value." BTW the doc string for eval-last-sexp says "print value in minibuffer." which should be "print value into echo area." Also, eval-expression-print-format omits the char if the invoking command name is not eval-last-sexp or eval-print-last-sexp. Why? For example, if I do M-x eval-expression [ret] 5 [ret] I only get 5 (#o5, #x5) I don't see why not simplify it to: (defun eval-expression-print-format (value) "Format VALUE as a result of evaluated expression if invoked twice, invoked as a name other than eval-last-sexp or eval-print-last-sexp, or if in debug mode. Return a formatted string that is displayed in the echo area in addition to the value printed by prin1 in functions which display the result of expression evaluation." (if (and (integerp value) (or (not (memq this-command '(eval-last-sexp eval-print-last-sexp))) (eq this-command last-command) (if (boundp 'edebug-active) edebug-active))) (let ((char-string (prin1-char value))) (if char-string (format " (#o%o, #x%x, %s)" value value char-string) (format " (#o%o, #x%x)" value value))))) Even then the design seems wrong. It's designed to avoid producing the string the first time eval-last-sexp or eval-print-last-sexp is called, regardless of whether the result will be displayed in the echo area (in which case I don't see any reason to avoid it) or printed into the buffer (in which case avoiding it is good since the user probably wants just the decimal representation). And it makes one of my custom functions fail to work the same as eval-last-sexp when intended, which is what brought all this to my attention in the first place: (defun eval-region-or-last-sexp () "Eval region if active; otherwise, eval last sexp and print value into echo area or, with prefix argument, into current buffer. See `eval-region' and `eval-last-sexp' for details." (interactive) (if mark-active (call-interactively 'eval-region) (call-interactively 'eval-last-sexp))) I can fix my function using (setq this-command 'eval-last-sexp), but that's a kludge. 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. Regarding lack of hard word wrap in the doc strings above, it's because I propose (add-hook 'help-mode-hook (lambda () (toggle-word-wrap 1)))