From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id mOuKLeiR119ycwAA0tVLHw (envelope-from ) for ; Mon, 14 Dec 2020 16:25:12 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 8V9gKeiR119+XwAA1q6Kng (envelope-from ) for ; Mon, 14 Dec 2020 16:25:12 +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 41ADC9404C7 for ; Mon, 14 Dec 2020 16:25:12 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id D426E29CA6; Mon, 14 Dec 2020 11:24:32 -0500 (EST) Received: from mail.hostpark.net (mail.hostpark.net [212.243.197.30]) by mail.notmuchmail.org (Postfix) with ESMTPS id 9428428539 for ; Mon, 14 Dec 2020 11:24:06 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id CEF1016617 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=CLOAa5o4r5saS4p dVB/fmP4V4ZNiGkFzCCb03GYLwSA=; b=UhRw81rSaLvvHpR3wM8jIlSmbtf1fcb RSHiXrJ3PIoptJXpMYhE0q53/CpdkHF5IBLyJGiqtZ2YhDvRUyGi2G+naWTwWfjH W9L4nc74wnBxZ8ivikxBlmWuoMR3VzZTiFenb0bmSWE5hkwmCv5xdjviP7uSx2jG Ro3qEgSXfvMs= 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 b_rtVXjyaW6m 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 9016A165D6 for ; Mon, 14 Dec 2020 17:24:02 +0100 (CET) From: Jonas Bernoulli To: notmuch@notmuchmail.org Subject: [PATCH 08/32] emacs: avoid passing around some redundant information Date: Mon, 14 Dec 2020 17:23:37 +0100 Message-Id: <20201214162401.19569-9-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: 33W6RXIASLGKFQ7Y32G73KF2XD5SA3ZN X-Message-ID-Hash: 33W6RXIASLGKFQ7Y32G73KF2XD5SA3ZN 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=UhRw81rS; 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: 41ADC9404C7 X-Spam-Score: 1.42 X-Migadu-Scanner: scn0.migadu.com X-TUID: 7e+xK7F4M+XR When running "notmuch" we use its full path but when displaying the command to the user we show just its name for readability reasons. Avoid passing around both representations because it is very easy to get the name from the path. Notmuch itself uses the involved functions just for "notmuch" but there might be extensions that use them for other executable so we forgo other potential simplifications. --- emacs/notmuch-lib.el | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index be15af5e..e09912d3 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -800,20 +800,27 @@ (defun notmuch-check-exit-status (exit-status command &optional output err) Emacs requested a newer output format than supported by the notmuch CLI. You may need to restart Emacs or upgrade your notmuch package.")) (t - (let* ((command-string - (mapconcat (lambda (arg) - (shell-quote-argument - (cond ((stringp arg) arg) - ((symbolp arg) (symbol-name arg)) - (t "*UNKNOWN ARGUMENT*")))) - command " ")) - (extra - (concat "command: " command-string "\n" - (if (integerp exit-status) - (format "exit status: %s\n" exit-status) - (format "exit signal: %s\n" exit-status)) - (and err (concat "stderr:\n" err)) - (and output (concat "stdout:\n" output))))) + (pcase-let* + ((`(,command . ,args) command) + (command (if (equal (file-name-nondirectory command) + notmuch-command) + notmuch-command + command)) + (command-string + (mapconcat (lambda (arg) + (shell-quote-argument + (cond ((stringp arg) arg) + ((symbolp arg) (symbol-name arg)) + (t "*UNKNOWN ARGUMENT*")))) + (cons command args) + " ")) + (extra + (concat "command: " command-string "\n" + (if (integerp exit-status) + (format "exit status: %s\n" exit-status) + (format "exit signal: %s\n" exit-status)) + (and err (concat "stderr:\n" err)) + (and output (concat "stdout:\n" output))))) (if err ;; We have an error message straight from the CLI. (notmuch-logged-error @@ -821,7 +828,7 @@ (defun notmuch-check-exit-status (exit-status command &optional output err) ;; We only have combined output from the CLI; don't inundate ;; the user with it. Mimic `process-lines'. (notmuch-logged-error (format "%s exited with status %s" - (car command) exit-status) + command exit-status) extra)) ;; `notmuch-logged-error' does not return. )))) @@ -908,7 +915,6 @@ (defun notmuch-start-notmuch (name buffer sentinel &rest args) (err-proc (get-buffer-process err-buffer))) (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) (set-process-sentinel err-proc #'notmuch-start-notmuch-error-sentinel) proc)) @@ -919,8 +925,7 @@ (defun notmuch-start-notmuch-sentinel (proc event) (err (and (buffer-live-p err-buffer) (not (zerop (buffer-size err-buffer))) (with-current-buffer err-buffer (buffer-string)))) - (sub-sentinel (process-get proc 'sub-sentinel)) - (real-command (process-get proc 'real-command))) + (sub-sentinel (process-get proc 'sub-sentinel))) (condition-case err (progn ;; Invoke the sub-sentinel, if any @@ -932,7 +937,7 @@ (defun notmuch-start-notmuch-sentinel (proc event) ;; and there's no point in telling the user that (but we ;; still check for and report stderr output below). (when (buffer-live-p (process-buffer proc)) - (notmuch-check-async-exit-status proc event real-command err)) + (notmuch-check-async-exit-status proc event nil err)) ;; If that didn't signal an error, then any error output was ;; really warning output. Show warnings, if any. (let ((warnings -- 2.29.1