From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id AA97C6DE0230 for ; Thu, 9 Aug 2018 13:54:40 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.333 X-Spam-Level: X-Spam-Status: No, score=0.333 tagged_above=-999 required=5 tests=[AWL=-0.109, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.211, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SlSi84iix3aj for ; Thu, 9 Aug 2018 13:54:39 -0700 (PDT) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by arlo.cworth.org (Postfix) with ESMTPS id 8C0336DE01E1 for ; Thu, 9 Aug 2018 13:54:38 -0700 (PDT) Received: by mail-wr1-f48.google.com with SMTP id v14-v6so6314103wro.5 for ; Thu, 09 Aug 2018 13:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=31RP50atbIHCAsaU1iPCo09RyFS/8xmKgsDKJEHC+/Y=; b=HWDkzn4uw3n/DK19t51H4mF2YHQllbAVvw0gW08kCNf0bEvFGI2n7oDsO1vvhJ991+ qWbTTOoFC4o08Mp1gp4PRrBNCgoTzSL4WPfSWzM/fZAdTxqv5OUhxRr/CtPeAr/dwcL6 fIHqOvX4euqqHNEVE9tgmfW9YVqGy2Oik3zJyRnA+jdr4jc7PvuJhFb0m2+9uzH3RyrJ fAUAWmdrfdBJj+i4Wx5pE7wR02W0wGjGR2POdjkf8ZzCRxMD5IchZK1MUZBSLTIGczbx kSMfExpQUJ6L4bw7OInXAxaUjoL8qGgdfy+PpfWiueti4wsrsBSnIxMF6mLuzwzLtcBT /w9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=31RP50atbIHCAsaU1iPCo09RyFS/8xmKgsDKJEHC+/Y=; b=t75UkKOFXRTPmgk8i7Yhn0R4Ky6F+8B4BmNWMOnbGZF5ZPqaHKRzLvwRBMLvzhWqbD rtd2fClG/lm6KHxh+mhQHL/PbXgOO+vvIU9UrR+ONwnJk2IDkClshTN+3y/PVq/chJW5 op8EsfZSkqKUBFgb/hiq1/8irSF7iKHMd3dfygtrUR97QimaFCx/dYmHTqMWTDMLUFfw DXKtycexSpDeVns/Y20FRCFZ6Z7CR6dCDxouKsh+Z4QMzmWPdMcDztUKG3lZNxsDvnT1 9kdJwhTvexzFnarWhXHpqiSaTySdeQWrMbjdrp3Ys4qHSlS37QYYkhWl+o0YxnZDqb8M CZhA== X-Gm-Message-State: AOUpUlE4cqrt4wx+ANRTTqLe5orUnFOhigFe11s4kfQHQm1UT8MyfcCa F5UAKAOTzq4kHzjvrE9OgHdI3f8qJ9M4GA== X-Google-Smtp-Source: AA+uWPyL3msuHTlRJBTBXRsQHA5+adlvNVyZ0dFzsjC/70Cef7MdAnk3j6R7QTZk7In4rUFhleyHEA== X-Received: by 2002:adf:8bd4:: with SMTP id w20-v6mr2392167wra.110.1533848076632; Thu, 09 Aug 2018 13:54:36 -0700 (PDT) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [81.149.164.25]) by smtp.gmail.com with ESMTPSA id m35-v6sm8872338wrf.41.2018.08.09.13.54.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 13:54:35 -0700 (PDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 9ff74d7c for ; Thu, 9 Aug 2018 20:54:34 +0000 (UTC) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH v1 1/1] emacs: Kill the stderr buffer when an async process completes Date: Thu, 9 Aug 2018 21:54:34 +0100 Message-Id: <20180809205434.34404-1-dme@dme.org> X-Mailer: git-send-email 2.17.1 (Apple Git-112) In-Reply-To: References: X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Aug 2018 20:54:40 -0000 On some platforms (e.g. macOS), it is necessary to add a real sentinel process for the error buffer used by `notmuch-start-notmuch' rather than a no-op sentinel. --- emacs/notmuch-lib.el | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index a7e02710..03c966b7 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -909,7 +909,7 @@ invoke `set-process-sentinel' directly on the returned process, as that will interfere with the handling of stderr and the exit status." - (let (err-file err-buffer proc + (let (err-file err-buffer proc err-proc ;; Find notmuch using Emacs' `exec-path' (command (or (executable-find notmuch-command) (error "Command not found: %s" notmuch-command)))) @@ -926,11 +926,13 @@ status." :buffer buffer :command (cons command args) :connection-type 'pipe - :stderr err-buffer)) + :stderr err-buffer) + err-proc (get-buffer-process err-buffer)) (process-put proc 'err-buffer err-buffer) - ;; Silence "Process NAME stderr finished" in stderr by adding a - ;; no-op sentinel to the fake stderr process object - (set-process-sentinel (get-buffer-process err-buffer) #'ignore)) + + (process-put err-proc 'err-file err-file) + (process-put err-proc 'err-buffer err-buffer) + (set-process-sentinel err-proc #'notmuch-start-notmuch-error-sentinel)) ;; On Emacs versions before 25, there is no way to capture ;; stdout and stderr separately for asynchronous processes, or @@ -990,9 +992,14 @@ status." ;; Emacs behaves strangely if an error escapes from a sentinel, ;; so turn errors into messages. (message "%s" (error-message-string err)))) - (when err-buffer (kill-buffer err-buffer)) (when err-file (ignore-errors (delete-file err-file))))) +(defun notmuch-start-notmuch-error-sentinel (proc event) + (let* ((err-file (process-get proc 'err-file)) + (err-buffer (or (process-get proc 'err-buffer) + (find-file-noselect err-file)))) + (when err-buffer (kill-buffer err-buffer)))) + ;; This variable is used only buffer local, but it needs to be ;; declared globally first to avoid compiler warnings. (defvar notmuch-show-process-crypto nil) -- 2.17.1 (Apple Git-112)