From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KFmzNMKR118DcwAA0tVLHw (envelope-from ) for ; Mon, 14 Dec 2020 16:24:34 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 8Gt9MMKR11+4HQAAbx9fmQ (envelope-from ) for ; Mon, 14 Dec 2020 16:24:34 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 20F1D9404FD for ; Mon, 14 Dec 2020 16:24:33 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 3B36F29BE5; Mon, 14 Dec 2020 11:24:16 -0500 (EST) Received: from mail.hostpark.net (mail.hostpark.net [212.243.197.30]) by mail.notmuchmail.org (Postfix) with ESMTPS id 4F8A728538 for ; Mon, 14 Dec 2020 11:24:05 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id A34321660C for ; Mon, 14 Dec 2020 17:24:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bernoul.li; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=sel2011a; t=1607963042; bh=nqzzAuVvPNuJOUp N3XzPCDcpopj6jZ/sonfBq+ZBxOw=; b=PqLmXKtw3IGyEutLGcFiOaMd63M1rZC qHt+Tu/XJ6IfSYuASXZxbAycNLVdjvedu9c8Xyeua1rSljIP+aYFGuJqlERQJeXA 5/nZhQSnPWLiMRqIjy+FBSQvO9A2PhyNpsZ1dJQmXSxDLYXZVKesoI6zOiea2U+7 EmeUjQq7D/wY= X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail0.hostpark.net [127.0.0.1]) (amavisd-new, port 10224) with ESMTP id 13hyA9FGyu5L for ; Mon, 14 Dec 2020 17:24:02 +0100 (CET) Received: from customer (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id 563D4165E2 for ; Mon, 14 Dec 2020 17:24:02 +0100 (CET) From: Jonas Bernoulli To: notmuch@notmuchmail.org Subject: [PATCH 04/32] emacs: notmuch-start-notmuch: remove backward compatibility code Date: Mon, 14 Dec 2020 17:23:33 +0100 Message-Id: <20201214162401.19569-5-jonas@bernoul.li> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201214162401.19569-1-jonas@bernoul.li> References: <20201214162401.19569-1-jonas@bernoul.li> MIME-Version: 1.0 Message-ID-Hash: JSKL32HEFRRLXD3XGIDVZ6UB55FRHUJW X-Message-ID-Hash: JSKL32HEFRRLXD3XGIDVZ6UB55FRHUJW X-MailFrom: jonas@bernoul.li X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 1.42 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=bernoul.li header.s=sel2011a header.b=PqLmXKtw; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 20F1D9404FD X-Spam-Score: 1.42 X-Migadu-Scanner: scn0.migadu.com X-TUID: cGygC3QLwVw8 We no longer support Emacs releases before version 25.1. Also adjust the sentinels which only had to deal with an error file when using an older Emacs release was used. --- emacs/notmuch-lib.el | 64 ++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 47 deletions(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index e23999ad..76387779 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -896,42 +896,19 @@ (defun notmuch-start-notmuch (name buffer sentinel &rest args) 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 err-proc - ;; Find notmuch using Emacs' `exec-path' - (command (or (executable-find notmuch-command) - (error "Command not found: %s" notmuch-command)))) - (if (fboundp 'make-process) - (progn - (setq err-buffer (generate-new-buffer " *notmuch-stderr*")) - ;; Emacs 25 and newer has `make-process', which allows - ;; redirecting stderr independently from stdout to a - ;; separate buffer. As this allows us to avoid using a - ;; temporary file and shell invocation, use it when - ;; available. - (setq proc (make-process - :name name - :buffer buffer - :command (cons command args) - :connection-type 'pipe - :stderr err-buffer)) - (setq err-proc (get-buffer-process err-buffer)) - (process-put proc 'err-buffer err-buffer) - - (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 - ;; even to redirect stderr to a file, so we use a trivial shell - ;; wrapper to send stderr to a temporary file and clean things - ;; up in the sentinel. - (setq err-file (make-temp-file "nmerr")) - (let ((process-connection-type nil)) ;; Use a pipe - (setq proc (apply #'start-process name buffer - "/bin/sh" "-c" - "exec 2>\"$1\"; shift; exec \"$0\" \"$@\"" - command err-file args))) - (process-put proc 'err-file err-file)) + (let* ((command (or (executable-find notmuch-command) + (error "Command not found: %s" notmuch-command))) + (err-buffer (generate-new-buffer " *notmuch-stderr*")) + (proc (make-process + :name name + :buffer buffer + :command (cons command args) + :connection-type 'pipe + :stderr err-buffer)) + (err-proc (get-buffer-process err-buffer))) + (process-put err-proc 'err-buffer err-buffer) + (set-process-sentinel err-proc #'notmuch-start-notmuch-error-sentinel) + (process-put proc 'err-buffer err-buffer) (process-put proc 'sub-sentinel sentinel) (process-put proc 'real-command (cons notmuch-command args)) (set-process-sentinel proc #'notmuch-start-notmuch-sentinel) @@ -939,9 +916,7 @@ (defun notmuch-start-notmuch (name buffer sentinel &rest args) (defun notmuch-start-notmuch-sentinel (proc event) "Process sentinel function used by `notmuch-start-notmuch'." - (let* ((err-file (process-get proc 'err-file)) - (err-buffer (or (process-get proc 'err-buffer) - (find-file-noselect err-file))) + (let* ((err-buffer (process-get proc 'err-buffer)) (err (and (not (zerop (buffer-size err-buffer))) (with-current-buffer err-buffer (buffer-string)))) (sub-sentinel (process-get proc 'sub-sentinel)) @@ -977,16 +952,11 @@ (defun notmuch-start-notmuch-sentinel (proc event) (error ;; Emacs behaves strangely if an error escapes from a sentinel, ;; so turn errors into messages. - (message "%s" (error-message-string err)))) - (when err-file (ignore-errors (delete-file err-file))))) + (message "%s" (error-message-string err)))))) (defun notmuch-start-notmuch-error-sentinel (proc event) - (let* ((err-file (process-get proc 'err-file)) - ;; When `make-process' is available, use the error buffer - ;; associated with the process, otherwise the error file. - (err-buffer (or (process-get proc 'err-buffer) - (find-file-noselect err-file)))) - (when err-buffer (kill-buffer err-buffer)))) + (let ((buffer (process-get proc 'err-buffer))) + (kill-buffer buffer))) (defvar-local notmuch-show-process-crypto nil) -- 2.29.1