From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Shahid Newsgroups: gmane.emacs.help Subject: Re: call-process and incremental display of output Date: Fri, 19 Oct 2018 19:52:23 -0400 Message-ID: <87sh113360.fsf@gmail.com> References: <87y3ay2fcy.fsf@oldenburg.str.redhat.com> <87ftx5x9bv.fsf@oldenburg.str.redhat.com> <87tvlh3991.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1539993052 17841 195.159.176.226 (19 Oct 2018 23:50:52 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 19 Oct 2018 23:50:52 +0000 (UTC) User-Agent: mu4e 1.1.0; emacs 27.0.50 Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 20 01:50:48 2018 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 1gDeXY-0004Z2-1Y for geh-help-gnu-emacs@m.gmane.org; Sat, 20 Oct 2018 01:50:48 +0200 Original-Received: from localhost ([::1]:53087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDeZe-0003MK-D0 for geh-help-gnu-emacs@m.gmane.org; Fri, 19 Oct 2018 19:52:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDeZF-0003G7-0N for help-gnu-emacs@gnu.org; Fri, 19 Oct 2018 19:52:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDeZB-0005qF-OL for help-gnu-emacs@gnu.org; Fri, 19 Oct 2018 19:52:32 -0400 Original-Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:34415) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDeZB-0005pv-JN for help-gnu-emacs@gnu.org; Fri, 19 Oct 2018 19:52:29 -0400 Original-Received: by mail-qt1-x829.google.com with SMTP id o17-v6so40349386qtr.1 for ; Fri, 19 Oct 2018 16:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=wbZCnb17mdozagvp67zhmXYdRekW4XsyJi/deYe9Jhk=; b=l2yCIODXsDM3bzKAOl4y2bf20/dKFeC8rvLO8r2o3xBQOcQ0u8c//SsmPTK0EhEw1y s+JXzu8SSMklNeamf56Bmzz/wzlcpIR2R9Yr6gispQg+Qaxqv/tmbu7cRMp4CU8Z9eCA 7UCCOpuIkMFm//PpRykac49fkQMuNmktdzS7hmkWmUgha43SqdOrxtCPkj5UOreWaXnC wQG1aFr+wlizqHvtduNelKjhPtwsmdvzXkLxVBa5B/r50msRTTpXm4el3GDQLWObvUEZ 7l+c2Y1FxJHDy7UApip5B4F8NBD1/bczrbjDpaTIGdFHjigP1BT3B89r2qMkQe4U7nsP u31g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=wbZCnb17mdozagvp67zhmXYdRekW4XsyJi/deYe9Jhk=; b=eVp0e5u53ebxXmRTwGn3oXs2Vf9hGmwdrgVInblRvteDlJN1iweB8Eo+OxV3ksnmjM Dwj3tlDmcwx1RLPjdOI4OzJtKlTU80S++3CA+M8VGg8ddAnOXlr8wiujFZScsrxF1dU+ KOEdcJ/W+FkIOr0h/kBhHgigmxkjLYp31CQyvZ7W9JISXA8Uiqlxqh2Xi5OA4uXfkjIO jmV/KVgROYwFTOYo+bVaiHgxI4EGvZa8GoT60XxL3VEVrn9kSPdfB6ep0Tzh7ovYTTjb YxTdn3Q7PkH6jSc5Zfx+Qtf58QMAoQkTx/qws0DluBIjR4lklcccUj6+4rehNpx4o9lU ipBw== X-Gm-Message-State: ABuFfoiBLBmt24ZGtkyy5LWqqKHiyDo0NI/RXSDQ91+dCKg/x3v7fnGX FCUsgfRvaHjqehSQX75bIPP9YUft X-Google-Smtp-Source: ACcGV60VCuGOgVpK0gW2QL3e1yPmYrdvgWdB9U9vU7L/7YJNYg57xyw0wF9B0YTxTMUvKSfxKnzS0Q== X-Received: by 2002:a0c:b416:: with SMTP id u22mr19991634qve.97.1539993148748; Fri, 19 Oct 2018 16:52:28 -0700 (PDT) Original-Received: from amun (cpe-104-162-86-217.nyc.res.rr.com. [104.162.86.217]) by smtp.gmail.com with ESMTPSA id b5-v6sm16909343qkf.4.2018.10.19.16.52.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Oct 2018 16:52:27 -0700 (PDT) In-reply-to: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::829 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:118355 Archived-At: Stefan Monnier writes: >>> You might like to (setq-local window-point-insertion-type t) in your >>> buffer (make sure you do it before the buffer is displayed in a window). >> I'm curious why `save-excursion' doesn't respect the value of >> `window-point-insertion-type' ? I was wondering about this for some >> time now. The behavior I want is to always append the output to the end >> of the buffer but not annoy the user if they decide to move the point >> somewhere else to look at previous output. In this case the point >> should stay where it is. This sounds exactly like what markers are >> supposed to do. Unfortunately the marker created by `save-excursion' >> always has a `nil' insertion type. This means I have to maintain my own >> marker in an `unwind-protect' similar to what the compilation mode does. >> Are there any objections to changing `save-excursion' behavior ? > > I lost you: where do you save-excursion? Sorry, I should have explained a little bit what I'm trying to do. I spin up a curl process that connects to our CI server and display the log output of a build. The server stream the log output as a sequence of json messages that have to be parsed and appended to the buffer. I used to do that with the following snippet of code: (with-current-buffer log-buffer (save-excursion (goto-char (point-max)) (insert log-line))) This caused the data to be inserted at the end of the buffer, but I constantly had to scroll to the end of the buffer in order to follow the output. I was aware of this problem for a while but never got chance to tackle it. Then, I saw your earlier message about `window-point-insertion-type' and I decided to try it. That didn't work and I think the reason is `save-excursion' creates a marker with insertion type set to `nil'. In my earlier message, I was trying to propose making `save-excursion' set the marker insertion type to `t' if `window-point-insertion-type' is set to t. FYI, what I currently have is something like this: (let ((pos (copy-marker (point) t))) (ignore-errors (goto-char (point-max)) (insert payload)) (goto-char pos))