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 AE6FOx2vK1/8RwAA0tVLHw (envelope-from ) for ; Thu, 06 Aug 2020 07:19:57 +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 eGBtNx2vK1/ZQgAA1q6Kng (envelope-from ) for ; Thu, 06 Aug 2020 07:19:57 +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 827DE9403EC for ; Thu, 6 Aug 2020 07:19:57 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 5BFA829AB0; Thu, 6 Aug 2020 03:19:30 -0400 (EDT) Received: from mail.hostpark.net (mail.hostpark.net [212.243.197.30]) by mail.notmuchmail.org (Postfix) with ESMTPS id 6768329A96 for ; Thu, 6 Aug 2020 03:19:14 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id DE237B7D56 for ; Thu, 6 Aug 2020 09:19:11 +0200 (CEST) X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10124) with ESMTP id l2gkTrmgSktj for ; Thu, 6 Aug 2020 09:19:11 +0200 (CEST) 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 8DF26B7D4C for ; Thu, 6 Aug 2020 09:19:11 +0200 (CEST) From: Jonas Bernoulli To: notmuch@notmuchmail.org Subject: [PATCH v2 05/23] emacs: Only set one variable per setq form Date: Thu, 6 Aug 2020 09:18:52 +0200 Message-Id: <20200806071910.10369-6-jonas@bernoul.li> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200806071910.10369-1-jonas@bernoul.li> References: <20200726165818.400-1-jonas@bernoul.li> <20200806071910.10369-1-jonas@bernoul.li> MIME-Version: 1.0 Message-ID-Hash: QFSUUHZV423664WWXLEK3W2ZSZZ6JLEP X-Message-ID-Hash: QFSUUHZV423664WWXLEK3W2ZSZZ6JLEP 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-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; 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-Spam-Score: 0.03 X-TUID: cujQpNcuja0R It's a bit weird to avoid having to write the "(setq ... )" more than once, just because we can. In a language that uses '=' for the same purpose we also happily use that once per assignment. While there are no benefit to using just one 'setq' there are some drawbacks. It is not always clear on first what is a key and what a value and as a result it is easy to make a mistake. Also it becomes harder to comment out just one assignment. --- emacs/notmuch-address.el | 6 +++--- emacs/notmuch-crypto.el | 23 ++++++++++++----------- emacs/notmuch-lib.el | 8 ++++---- emacs/notmuch-show.el | 26 ++++++++++++++------------ emacs/notmuch-tree.el | 4 ++-- emacs/notmuch.el | 35 ++++++++++++++++++----------------- 6 files changed, 53 insertions(+), 49 deletions(-) diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index 09dda247..4db7096c 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -381,9 +381,9 @@ (defun notmuch-address--load-address-hash () notmuch-address-internal-completion) (equal (plist-get load-plist :version) notmuch-address--save-hash-version)) - (setq notmuch-address-last-harvest (plist-get load-plist :last-harvest) - notmuch-address-completions (plist-get load-plist :completions) - notmuch-address-full-harvest-finished t) + (setq notmuch-address-last-harvest (plist-get load-plist :last-harvest)) + (setq notmuch-address-completions (plist-get load-plist :completions)) + (setq notmuch-address-full-harvest-finished t) ;; Return t to say load was successful. t))) diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el index 58947a20..420b008f 100644 --- a/emacs/notmuch-crypto.el +++ b/emacs/notmuch-crypto.el @@ -117,20 +117,21 @@ (defun notmuch-crypto-insert-sigstatus-button (sigstatus from) (userid (plist-get sigstatus :userid))) ;; If userid is present it has full or greater validity. (if userid - (setq label (concat "Good signature by: " userid) - face 'notmuch-crypto-signature-good) - (setq label (concat "Good signature by key: " fingerprint) - face 'notmuch-crypto-signature-good-key)) - (setq button-action 'notmuch-crypto-sigstatus-good-callback - help-msg (concat "Click to list key ID 0x" fingerprint ".")))) + (progn + (setq label (concat "Good signature by: " userid)) + (setq face 'notmuch-crypto-signature-good)) + (setq label (concat "Good signature by key: " fingerprint)) + (setq face 'notmuch-crypto-signature-good-key)) + (setq button-action 'notmuch-crypto-sigstatus-good-callback) + (setq help-msg (concat "Click to list key ID 0x" fingerprint ".")))) ((string= status "error") - (setq label (concat "Unknown key ID " keyid " or unsupported algorithm") - button-action 'notmuch-crypto-sigstatus-error-callback - help-msg (concat "Click to retrieve key ID " keyid + (setq label (concat "Unknown key ID " keyid " or unsupported algorithm")) + (setq button-action 'notmuch-crypto-sigstatus-error-callback) + (setq help-msg (concat "Click to retrieve key ID " keyid " from keyserver."))) ((string= status "bad") - (setq label (concat "Bad signature (claimed key ID " keyid ")") - face 'notmuch-crypto-signature-bad)) + (setq label (concat "Bad signature (claimed key ID " keyid ")")) + (setq face 'notmuch-crypto-signature-bad)) (status (setq label (concat "Unknown signature status: " status))) (t diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index f8958a91..886da99f 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -861,8 +861,8 @@ (defun notmuch-call-notmuch--helper (destination args) (let (stdin-string) (while (keywordp (car args)) (cl-case (car args) - (:stdin-string (setq stdin-string (cadr args) - args (cddr args))) + (:stdin-string (setq stdin-string (cadr args)) + (setq args (cddr args))) (otherwise (error "Unknown keyword argument: %s" (car args))))) (if (null stdin-string) @@ -939,8 +939,8 @@ (defun notmuch-start-notmuch (name buffer sentinel &rest args) :buffer buffer :command (cons command args) :connection-type 'pipe - :stderr err-buffer) - err-proc (get-buffer-process err-buffer)) + :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) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 8592936f..a0a6c09d 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -415,8 +415,8 @@ (defun notmuch-clean-address (address) (cond ;; "User " style. ((string-match "\\(.*\\) <\\(.*\\)>" address) - (setq p-name (match-string 1 address) - p-address (match-string 2 address))) + (setq p-name (match-string 1 address)) + (setq p-address (match-string 2 address))) ;; "" style. ((string-match "<\\(.*\\)>" address) @@ -1250,14 +1250,16 @@ (defun notmuch-show (thread-id &optional elide-toggle parent-buffer query-contex ;; Set various buffer local variables to their appropriate initial ;; state. Do this after enabling `notmuch-show-mode' so that they ;; aren't wiped out. - (setq notmuch-show-thread-id thread-id - notmuch-show-parent-buffer parent-buffer - notmuch-show-query-context (if (or (string= query-context "") - (string= query-context "*")) - nil query-context) - notmuch-show-process-crypto notmuch-crypto-process-mime - ;; If `elide-toggle', invert the default value. - notmuch-show-elide-non-matching-messages + (setq notmuch-show-thread-id thread-id) + (setq notmuch-show-parent-buffer parent-buffer) + (setq notmuch-show-query-context + (if (or (string= query-context "") + (string= query-context "*")) + nil + query-context)) + (setq notmuch-show-process-crypto notmuch-crypto-process-mime) + ;; If `elide-toggle', invert the default value. + (setq notmuch-show-elide-non-matching-messages (if elide-toggle (not notmuch-show-only-matching-messages) notmuch-show-only-matching-messages)) @@ -1512,8 +1514,8 @@ (define-derived-mode notmuch-show-mode fundamental-mode "notmuch-show" \\{notmuch-show-mode-map}" (setq notmuch-buffer-refresh-function #'notmuch-show-refresh-view) - (setq buffer-read-only t - truncate-lines t) + (setq buffer-read-only t) + (setq truncate-lines t) (setq imenu-prev-index-position-function #'notmuch-show-imenu-prev-index-position-function) (setq imenu-extract-index-name-function diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index b1bb40b1..827acebf 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -956,8 +956,8 @@ (define-derived-mode notmuch-tree-mode fundamental-mode "notmuch-tree" \\{notmuch-tree-mode-map}" (setq notmuch-buffer-refresh-function #'notmuch-tree-refresh-view) (hl-line-mode 1) - (setq buffer-read-only t - truncate-lines t)) + (setq buffer-read-only t) + (setq truncate-lines t)) (defun notmuch-tree-process-sentinel (proc msg) "Add a message to let user know when \"notmuch tree\" exits." diff --git a/emacs/notmuch.el b/emacs/notmuch.el index d6e0a9d5..6ce2b1f9 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -443,8 +443,8 @@ (defun notmuch-search-foreach-result (beg end fn) (while (and pos (or (< pos end) first)) (when (notmuch-search-get-result pos) (funcall fn pos)) - (setq pos (notmuch-search-result-end pos) - first nil)))) + (setq pos (notmuch-search-result-end pos)) + (setq first nil)))) ;; Unindent the function argument of notmuch-search-foreach-result so ;; the indentation of callers doesn't get out of hand. (put 'notmuch-search-foreach-result 'lisp-indent-function 2) @@ -589,8 +589,8 @@ (defun notmuch-search-tag (tag-changes &optional beg end only-matched) If ONLY-MATCHED is non-nil, only tag matched messages." (interactive (notmuch-search-interactive-tag-changes)) (unless (and beg end) - (setq beg (car (notmuch-interactive-region)) - end (cadr (notmuch-interactive-region)))) + (setq beg (car (notmuch-interactive-region))) + (setq end (cadr (notmuch-interactive-region)))) (let ((search-string (notmuch-search-find-stable-query-region beg end only-matched))) (notmuch-tag search-string tag-changes) @@ -762,8 +762,8 @@ (defun notmuch-search-insert-authors (format-string authors) (length "... ")))) ;; Truncate the visible string according to the width of ;; the display string. - (setq visible-string (substring formatted-authors 0 visible-length) - invisible-string (substring formatted-authors visible-length)) + (setq visible-string (substring formatted-authors 0 visible-length)) + (setq invisible-string (substring formatted-authors visible-length)) ;; If possible, truncate the visible string at a natural ;; break (comma or pipe), as incremental search doesn't ;; match across the visible/invisible border. @@ -771,8 +771,8 @@ (defun notmuch-search-insert-authors (format-string authors) ;; Second clause is destructive on `visible-string', so ;; order is important. (setq invisible-string (concat (match-string 3 visible-string) - invisible-string) - visible-string (concat (match-string 1 visible-string) + invisible-string)) + (setq visible-string (concat (match-string 1 visible-string) (match-string 2 visible-string)))) ;; `visible-string' may be shorter than the space allowed ;; by `format-string'. If so we must insert some padding @@ -785,17 +785,18 @@ (defun notmuch-search-insert-authors (format-string authors) (if (string-match "\\(.*\\)|\\(.*\\)" visible-string) ;; The visible string contains both matching and ;; non-matching authors. - (setq visible-string (notmuch-search-author-propertize visible-string) - ;; The invisible string must contain only non-matching - ;; authors, as the visible-string contains both. - invisible-string (propertize invisible-string - 'face 'notmuch-search-non-matching-authors)) + (progn + (setq visible-string (notmuch-search-author-propertize visible-string)) + ;; The invisible string must contain only non-matching + ;; authors, as the visible-string contains both. + (setq invisible-string (propertize invisible-string + 'face 'notmuch-search-non-matching-authors))) ;; The visible string contains only matching authors. (setq visible-string (propertize visible-string - 'face 'notmuch-search-matching-authors) - ;; The invisible string may contain both matching and - ;; non-matching authors. - invisible-string (notmuch-search-author-propertize invisible-string))) + 'face 'notmuch-search-matching-authors)) + ;; The invisible string may contain both matching and + ;; non-matching authors. + (setq invisible-string (notmuch-search-author-propertize invisible-string))) ;; If there is any invisible text, add it as a tooltip to the ;; visible text. (when (not (string= invisible-string "")) -- 2.28.0