]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Only set one variable per setq form
authorJonas Bernoulli <jonas@bernoul.li>
Sat, 8 Aug 2020 11:49:40 +0000 (13:49 +0200)
committerDavid Bremner <david@tethera.net>
Sun, 9 Aug 2020 23:50:50 +0000 (20:50 -0300)
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
emacs/notmuch-crypto.el
emacs/notmuch-lib.el
emacs/notmuch-show.el
emacs/notmuch-tree.el
emacs/notmuch.el

index 09dda247dde133868d3e7a289b39be3013bcb45c..4db7096c9b136b35ce0c1ee60b75d5e5c4c6a7f0 100644 (file)
@@ -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)))
 
index 58947a2054bc3665583bc6936252052435ea86b2..420b008f8f6e376ba6fa39904c573c2ca32a96a7 100644 (file)
@@ -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
index f8958a9116605e1c98d92cdd3aa8cb8d3a497140..886da99f542ce29f2b2614871edfcffbe554218b 100644 (file)
@@ -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)
index d088c80b3f5371c1b950e0ac7005bd72b869df58..e6d7c9ea32cd6d3b19e720b430787a2130cf5150 100644 (file)
@@ -415,8 +415,8 @@ parsing fails."
        (cond
         ;; "User <user@dom.ain>" 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)))
 
         ;; "<user@dom.ain>" 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
index b1bb40b13ac469e5adc1f7d1ba2fecdd99694eb2..827acebf7a83bf667c1d0a8f41622c43bd82df39 100644 (file)
@@ -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."
index d6e0a9d54ee48a6e074dd3f85dd561f19ae63ab8..6ce2b1f98243a47910865fd1a1d46bf237b34448 100644 (file)
@@ -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 ""))