From: Jonas Bernoulli Date: Sat, 8 Aug 2020 11:49:40 +0000 (+0200) Subject: emacs: Only set one variable per setq form X-Git-Tag: 0.31_rc0~40 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=18d289c86309ae796e6f027c289b17ccdd38f220 emacs: Only set one variable per setq form 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. --- 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 @@ to be a saved 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 @@ by user 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 @@ for `call-process'. ARGS is as described for (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 @@ status." :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 d088c80b..e6d7c9ea 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -415,8 +415,8 @@ parsing fails." (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) @@ -1256,14 +1256,16 @@ matched." ;; 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)) @@ -1518,8 +1520,8 @@ All currently available key bindings: \\{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 @@ Complete list of currently available key bindings: \\{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 @@ BEG." (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 @@ is inactive this applies to the thread at point. 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 @@ non-authors is found, assume that all of the authors match." (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 @@ non-authors is found, assume that all of the authors match." ;; 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 @@ non-authors is found, assume that all of the authors match." (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 ""))