From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Update point in visible but non-selected buffer/window Date: Fri, 21 Oct 2016 10:39:37 +0200 Message-ID: <87shrqdrjq.fsf@fastmail.fm> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-Trace: blaine.gmane.org 1477061359 8100 195.159.176.226 (21 Oct 2016 14:49:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 21 Oct 2016 14:49:19 +0000 (UTC) User-Agent: mu4e 0.9.17; emacs 25.1.2 To: Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 21 16:49:16 2016 Return-path: Envelope-to: geh-help-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 1bxb89-0000yK-P4 for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Oct 2016 16:49:09 +0200 Original-Received: from localhost ([::1]:32844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxb8C-0000PR-2u for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Oct 2016 10:49:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxVMd-00040J-CA for help-gnu-emacs@gnu.org; Fri, 21 Oct 2016 04:39:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxVMa-0007kv-7f for help-gnu-emacs@gnu.org; Fri, 21 Oct 2016 04:39:43 -0400 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:47199) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bxVMa-0007kX-1p for help-gnu-emacs@gnu.org; Fri, 21 Oct 2016 04:39:40 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 9795E2073D for ; Fri, 21 Oct 2016 04:39:39 -0400 (EDT) Original-Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Fri, 21 Oct 2016 04:39:39 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.fm; h= content-type:date:from:message-id:mime-version:subject:to :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=IgBY9xqt04v6bUNZDDd8URXmsdY =; b=d5v+31ZctMeHrr4yoDaIvdl7xd5jj9ItQzzIZz4/b3N3G/VBGFzDcgSsgeY wG/0m70NCm9KnvSEL4eEPo0sT7g4qnnnKE6MmZ5K3uarpvukpypm6AWeahccGRpM SuQbNsqT8wy3NgSUZnkm6nnawEptDxXvMrFGpLGQes8Pu7UI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=Ig BY9xqt04v6bUNZDDd8URXmsdY=; b=pouwQA7dgWs9P5ULaj1dFybS5B3Nc9+yCH LPni7QWKxF4Al2C/SEnCvNgya6sQp0S8ON3m75xYKvv2etck87MEdk3tIxf/cF23 cDskJ5AQcZdM00hZJqZHPw4dAjvt7IlmIUpU9+aA3xAxazt6gb7wYBIOhzC9x9Dp b5bmje/ug= X-Sasl-enc: hDIASdlHOoqv1e9OKq4KCzCsoRfMF4H+BmogwO1LSbvc 1477039179 Original-Received: from IdeaPad.messagingengine.com (x4d0ac05f.dyn.telefonica.de [77.10.192.95]) by mail.messagingengine.com (Postfix) with ESMTPA id 094DAF2D2D for ; Fri, 21 Oct 2016 04:39:38 -0400 (EDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 X-Mailman-Approved-At: Fri, 21 Oct 2016 10:39:20 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111584 Archived-At: Hi all, I just found out the hard way that changing point programmatically (i.e., from within an Elisp program) in a buffer that is visible in a non-selected window doesn't (necessarily?) update the position of the cursor, and when the window is selected again, point is reset to the cursor position. To be more explicit: Suppose I have two buffers, A and B, being displayed in two windows, W_a and W_b. W_a is selected, point is at the beginning of the buffer. Now I select W_b. In W_a, the cursor is still visible as a hollow box. In W_b, I execute some command that moves point in buffer A (specifically, by using `re-search-forward' inside a `with-current-buffer'). The cursor in W_a does not move, however. Still, as long as I do not select W_a, point is where `re-search-forward' left it (and thus does not correspond to the visible cursor position). For example, when I do something like: (with-current-buffer "A" (point)) I get the result I expect, which is not the position where I see the (hollow) cursor. However, if I then select window W_a, the hollow cursor is changed back into a box, but it remains at the position where it was all the time, i.e., at the beginning of the buffer, and point is adjusted accordingly. I can see why this behaviour makes sense from a user's perspective, and I figured out that I can call `select-window' inside `with-current-buffer' to force the cursor position to change as well as point. But I haven't been able to find any info on this behaviour in the Elisp manual, so I was wondering if this has been described somewhere and whether the solution I stumbled upon (using `select-window') is the best way to achieve the effect I want, or whether there is a better, more canonical way. TIA Joost -- Joost Kremers Life has its moments