From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Federico Tedin Newsgroups: gmane.emacs.bugs Subject: bug#32777: 27.0.50; window-buffer gets wrong point Date: Tue, 2 Oct 2018 09:31:25 -0300 Message-ID: References: <83wor12fut.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1538483508 2655 195.159.176.226 (2 Oct 2018 12:31:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 2 Oct 2018 12:31:48 +0000 (UTC) Cc: juri@linkov.net, 32777@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 02 14:31:43 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g7Jq2-0000Wz-QR for geb-bug-gnu-emacs@m.gmane.org; Tue, 02 Oct 2018 14:31:43 +0200 Original-Received: from localhost ([::1]:43433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7Js8-0001EV-Sy for geb-bug-gnu-emacs@m.gmane.org; Tue, 02 Oct 2018 08:33:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7Jry-0001Ck-E1 for bug-gnu-emacs@gnu.org; Tue, 02 Oct 2018 08:33:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7JqN-0008RG-JE for bug-gnu-emacs@gnu.org; Tue, 02 Oct 2018 08:32:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57870) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7JqN-0008RC-D8 for bug-gnu-emacs@gnu.org; Tue, 02 Oct 2018 08:32:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1g7JqN-0004dA-8u for bug-gnu-emacs@gnu.org; Tue, 02 Oct 2018 08:32:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Federico Tedin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Oct 2018 12:32:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32777 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32777-submit@debbugs.gnu.org id=B32777.153848350417775 (code B ref 32777); Tue, 02 Oct 2018 12:32:03 +0000 Original-Received: (at 32777) by debbugs.gnu.org; 2 Oct 2018 12:31:44 +0000 Original-Received: from localhost ([127.0.0.1]:33895 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g7Jq4-0004cd-Cy for submit@debbugs.gnu.org; Tue, 02 Oct 2018 08:31:44 -0400 Original-Received: from mail-lj1-f181.google.com ([209.85.208.181]:33992) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g7Jq3-0004cP-4e for 32777@debbugs.gnu.org; Tue, 02 Oct 2018 08:31:43 -0400 Original-Received: by mail-lj1-f181.google.com with SMTP id f8-v6so1584735ljk.1 for <32777@debbugs.gnu.org>; Tue, 02 Oct 2018 05:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Kc4E8yUKGwCe2fpQEpfW/xVKdLCXHN6N1LnFF5PKhHA=; b=tE29Qn6JKToRiapo1Rc1fBC+6ElVKIBSb+pcDn5H2UkL/XkdtrSYKWdBfIZo5iIVCy 0VemgnRGhF58t6b6nFoZ+GOis+cBVg6jxjHPWO6b6zWILyD4bIFqT7hoP987pMqPxvKY bXb5r1ehYjvX4imm6Eo1svDE/F99/gqBpUbID0B62C4kCYSjik2SfFCgafIuEGEUqhGZ sabaMuAbCT87rBbmQT8odpHnk+5pfRqizQTTqAVNB0u8Axh4GCrHAXvkCrI6DzTMF9wM ybQd+E0A2PkbZsaciw5sgWbAAvjstCI8ApFnU+DzAtoavO8g4/3mrvjUaU67Pu/xntEF uDxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Kc4E8yUKGwCe2fpQEpfW/xVKdLCXHN6N1LnFF5PKhHA=; b=WujBZ0xuldsUCpZVYyCST3ElxsklZ9usBzfj7JBJ2LaGtAQ/pE0za4INa3SrfsIPQp 6szHe3jnDfw49556iuMD6KnDhZMIlPGU/ePLNOnNTQm/tlGPw6wU8huTuOoasXHaMe4s ukCp+KiDnIPkh2MeCGvQAiZJSqMgs1BmlCULZdzZ4thLQ8jj5bUDcRQmds+ZqxtWiK9Q 7V7hThXgHBHIcSQLCREw3r16RGqJx6q5ECL9r8D+1tylpauivGRW8QlwVHyA6qSiklL6 eYJlF+X5T0cmpbFoL3jGlWFio4gss7ssHwQjGqn1Mi+9zA8AnS7yqzl0xLRERnhuCNVC i4/Q== X-Gm-Message-State: ABuFfoi0ximj8cREA25z1yD6pt14wOBdzUg8SpOk0z9ZEgK3BgEyoa7R Dj8hhS8TkX4YY5ODPVNqkupldXKZvub7ylslqjQ= X-Google-Smtp-Source: ACcGV62cr4jamGoMC0v3zZ/us+ZzgSC7dC/Vr7NQ3TBNGbyvI6qgP+OZoUBb19P615w5FL3b5tlvA57zZKK3JojjXP0= X-Received: by 2002:a2e:48d:: with SMTP id a13-v6mr9360383ljf.27.1538483497045; Tue, 02 Oct 2018 05:31:37 -0700 (PDT) In-Reply-To: <83wor12fut.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:150901 Archived-At: > Can you explain the change? The minibuffer window is already the > selected window at this point (look at the implementation of > minibuffer-selected-window), so using with-selected-window, which > seems to be the only real change in the above, should be redundant. This was my reasoning: Calling "minibuffer-selected-window" returns the last selected window before switching to the minibuffer. Then, calling "window-buffer" with that window will return that window's buffer. The problem is that when "with-current-buffer" is called with the resulting buffer, it that buffer has been opened on more than one window, the active window will be set according to a criteria which I haven't figured out yet, but not necessarily to the same exact window "minibuffer-selected-window" returned. The way I tested this was the following: 1) On a frame, open three windows. On the first two, open *scratch*. On the third one, open any other buffer. 2) Insert some content into buffer *scratch* ("hello"). 3) Make sure the first window is selected, and move the point to (point-min). 4) M-x eval-expression (with-current-buffer "*scratch*" (message "%s" (point))) should yield "1". 5) Select the second window, and move the point to (point-max). 6) M-x eval-expression (with-current-buffer "*scratch*" (message "%s" (point))) should yield "7". 7) Now, select the third window. 8) M-x eval-expression (with-current-buffer "*scratch*" (message "%s" (point))) The last point yields "1" in my case. If I wanted it to yield "7", I would have to explicitly select the second window. So from this, I reasoned that using M-n when in read-extended-command, it will try to read a command from the last selected window's buffer, but the value of the point can vary if there's more than one window visiting that buffer (like in the test case originally described by Juri). Please correct me if I'm wrong. > Also, with-selected-window makes the window's buffer current, so why > did you need with-current-buffer in addition? What am I missing? This was an oversight on my part.