From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current Date: Sun, 21 Apr 2019 22:38:41 -0400 Message-ID: <87lg02sr0u.fsf@gmail.com> References: <8736mduxjh.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="181931"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: 35334@debbugs.gnu.org To: Sean McAfee Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 22 04:39:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIOrP-000lBX-RS for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Apr 2019 04:39:11 +0200 Original-Received: from localhost ([127.0.0.1]:59626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIOrO-0008Ml-Ko for geb-bug-gnu-emacs@m.gmane.org; Sun, 21 Apr 2019 22:39:10 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIOrI-0008Md-2s for bug-gnu-emacs@gnu.org; Sun, 21 Apr 2019 22:39:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIOrG-0003aK-QY for bug-gnu-emacs@gnu.org; Sun, 21 Apr 2019 22:39:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35999) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hIOrG-0003aF-NS for bug-gnu-emacs@gnu.org; Sun, 21 Apr 2019 22:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hIOrG-0000op-IC for bug-gnu-emacs@gnu.org; Sun, 21 Apr 2019 22:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Apr 2019 02:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35334 X-GNU-PR-Package: emacs Original-Received: via spool by 35334-submit@debbugs.gnu.org id=B35334.15559007313127 (code B ref 35334); Mon, 22 Apr 2019 02:39:02 +0000 Original-Received: (at 35334) by debbugs.gnu.org; 22 Apr 2019 02:38:51 +0000 Original-Received: from localhost ([127.0.0.1]:49543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIOr5-0000oN-7j for submit@debbugs.gnu.org; Sun, 21 Apr 2019 22:38:51 -0400 Original-Received: from mail-qt1-f172.google.com ([209.85.160.172]:41668) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIOr2-0000o8-NI for 35334@debbugs.gnu.org; Sun, 21 Apr 2019 22:38:49 -0400 Original-Received: by mail-qt1-f172.google.com with SMTP id f25so2017154qtc.8 for <35334@debbugs.gnu.org>; Sun, 21 Apr 2019 19:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=/aLw4vBhxTDJGTv3SWzOSq4SmBU26DDdtz9RHAY6CG4=; b=jJ+YWHdtjjCwkdb7ebpkIkb4l7QiHb9k009TfXIEHceJJkhqbXbNi92Uiw8MGsEmRB Oupq3DhjPzxPjXPvJQKnMEz3JAWV431KDKbvcYUX1ksryq3H3nyovd6uvwu0thOG7oKs YCVKXyeVGVSth6jNSXbnNVukt8A5js4mHvtPR0i8vsExQkRYCt3shmFvn/EdyDKGx1GC f3m7bq3u3scQujiUsg1dajyYAe+epC6L7aO6Xxkssc5XaW9o8AZhz3rI2OiKdvq0aYgz xvcezof0eCytkFLrigsrz2QxX8ZdYZrMCcaEYP/dqjxfcj3nLL+vmX8t7mXqWQObn38n C8pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=/aLw4vBhxTDJGTv3SWzOSq4SmBU26DDdtz9RHAY6CG4=; b=cERN6cZRA2uygVz+6vg8Vzua+j2t96ZMb+dlsZiT10Ud3IlGUJME2jy+dNTe4cwOct GjUQx0Z7ERjS/ccOIu90223X2bOGkfgidThp1odHM8a8KodUnJszn/sVx6eywcdPj+sO fV9ZowQ6aNudc3aGOQxASUolAip7JoAgdkJ+JkM4XYcsSO1ep/69MTnuot1qAHC84zlf uujV1wmIm6PuaoBucnu1Ilu5uouP6MmH6mlkdEpdx7EqbHeCFys23VjO71vhkii2gKKy RNLDbe5Agt2aBUuwe6i0hBHA7eBfy/6jD3z4elv8X4aRI4eJme/Mc8rkiNxvqpu0QLle Rzfg== X-Gm-Message-State: APjAAAXHGxpUcXK8S2BIU2U+gJ9ngEVkOZYgLTFgaGl/EQ3UsVx/2awk CUAOtQ6O2OEIdD4ZXJqu9urD8m28 X-Google-Smtp-Source: APXvYqzVTemv3PB2deMfjBv4CUnRM6Lvwj60Pmihpxy02A8aqGaz6qZc6+HCXr3pHQ5djFeppxZ4JA== X-Received: by 2002:ac8:192b:: with SMTP id t40mr13608592qtj.379.1555900723020; Sun, 21 Apr 2019 19:38:43 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id c21sm5355494qkm.8.2019.04.21.19.38.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 21 Apr 2019 19:38:42 -0700 (PDT) In-Reply-To: (Sean McAfee's message of "Sun, 21 Apr 2019 16:32:48 -0700") 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: 209.51.188.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:157979 Archived-At: Sean McAfee writes: > Starting with two windows visible, the scratch buffer and a window showing > empty buffer "a", I evaluate this expression in the scratch buffer: > > (start-process "count" "a" "bash" "-c" "for i in {1..10}; echo $i; sleep 1; done") [missing a "do" before the "echo $i", by the way] > I see the numbers 1-10 inserted into buffer "a", one second apart, as > expected. The position of point in buffer "a" follows the new lines as > they're inserted. > > Now I define the function ordinary-insertion-filter, as found on this page: > > https://www.gnu.org/software/emacs/manual/html_node/elisp/Filter-Functions.html > > That function is described as "mimicking the actions of the default > filter." However, if I erase buffer "a" and evaluate this expression in > the scratch buffer: > > (let ((proc (start-process "count" "a" "bash" "-c" "for i in {1..10}; echo $i; sleep 1; done"))) > (set-process-filter proc #'ordinary-insertion-filter)) > > ...then I see the numbers inserted as before, but now the position of point > in buffer "a" doesn't move Okay, interesting. The difference seems to be that `internal-default-process-filter' actually uses `insert-before-markers' rather than plain `insert'. I guess the window point is implemented as a marker, so inserting this way happens to move it as well. (defun ordinary-insertion-filter (proc string) (when (buffer-live-p (process-buffer proc)) (with-current-buffer (process-buffer proc) (let ((moving (= (point) (process-mark proc)))) (save-excursion ;; Insert the text, advancing the process marker. (goto-char (process-mark proc)) (insert-before-markers string) ; <------------ change here (set-marker (process-mark proc) (point))) (if moving (goto-char (process-mark proc)))))))