From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#12208: yes-or-no-p escapes with-current-buffer Date: Thu, 16 Aug 2012 11:38:10 +0200 Message-ID: <502CBF82.3080601@gmx.at> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1345109900 10376 80.91.229.3 (16 Aug 2012 09:38:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 16 Aug 2012 09:38:20 +0000 (UTC) Cc: 12208@debbugs.gnu.org To: Steve Hafner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 16 11:38:19 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 1T1wWw-00071N-0f for geb-bug-gnu-emacs@m.gmane.org; Thu, 16 Aug 2012 11:38:18 +0200 Original-Received: from localhost ([::1]:36720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1wWu-0004z1-W8 for geb-bug-gnu-emacs@m.gmane.org; Thu, 16 Aug 2012 05:38:16 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1wWt-0004yw-6t for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2012 05:38:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T1wWs-0002sc-4p for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2012 05:38:15 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1wWs-0002sV-1P for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2012 05:38:14 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1T1wfO-0000Lx-5e for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2012 05:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Aug 2012 09:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12208 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12208-submit@debbugs.gnu.org id=B12208.13451104121341 (code B ref 12208); Thu, 16 Aug 2012 09:47:02 +0000 Original-Received: (at 12208) by debbugs.gnu.org; 16 Aug 2012 09:46:52 +0000 Original-Received: from localhost ([127.0.0.1]:60537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T1wfC-0000LZ-W9 for submit@debbugs.gnu.org; Thu, 16 Aug 2012 05:46:52 -0400 Original-Received: from mailout-de.gmx.net ([213.165.64.23]:58298) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1T1wfB-0000LS-Jy for 12208@debbugs.gnu.org; Thu, 16 Aug 2012 05:46:50 -0400 Original-Received: (qmail invoked by alias); 16 Aug 2012 09:38:00 -0000 Original-Received: from 62-47-56-184.adsl.highway.telekom.at (EHLO [62.47.56.184]) [62.47.56.184] by mail.gmx.net (mp029) with SMTP; 16 Aug 2012 11:38:00 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/bUE1Dt6fbsFmzeudzkmOddM1By9ROgoMeoq7ulg xgPqOEjQSrF8gj In-Reply-To: X-Y-GMX-Trusted: 0 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 (newer, 2) 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:63226 > Open two buffers "buffer1" and "buffer2" so that both are visible. > > Place the following in each buffer > > (with-current-buffer "buffer1" > (goto-char (point-min)) > (yes-or-no-p "") > (insert "X")) > > C-xC-e from buffer1 places "X" at the beginning of the file, while > C-xC-e from buffer2 places an "X" wherever the point was before moving > from buffer1. This doesn't happen if only one buffer is visible; Nor > does it happen if we replace "yes-or-no-p" with "y-or-n-p". > This happens on both 23.3.1 and 24.1. Indeed. What you see is `save-window-excursion' at work. Let's remove `yes-or-no-p' from the example. With emacs -Q in *scratch* evaluate the following form: (let ((form "(with-current-buffer \"*buffer1*\" (goto-char (point-min)) (save-window-excursion nil) (setq x (1+ x)) (insert (format \"%s\" x)))")) (setq x 0) (switch-to-buffer (get-buffer-create "*buffer1*")) (insert form) (split-window) (other-window 1) (switch-to-buffer (get-buffer-create "*buffer2*")) (insert form) (other-window 1)) Now in any of the two windows go to the end of the buffer and evaluate the preceding form. From the *buffer1* window the number is inserted at position 1, from the *buffer2* window at the position of *buffer1* before evaluating the form. If, instead, you used the slightly different form (let ((form "(with-selected-window (get-buffer-window \"*buffer1*\") (goto-char (point-min)) (save-window-excursion nil) (setq x (1+ x)) (insert (format \"%s\" x)))")) (setq x 0) (switch-to-buffer (get-buffer-create "*buffer1*")) (insert form) (split-window) (other-window 1) (switch-to-buffer (get-buffer-create "*buffer2*")) (insert form) (other-window 1)) both insertions happen at position 1. martin