]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-wash.el
emacs: Use 'when' instead of 'if' when there is no ELSE part
[notmuch] / emacs / notmuch-wash.el
index 31fda61f96428d136233367d883a6a71a0cf4580..ce4b963727696986405ad59d387994ba1f7c1a94 100644 (file)
@@ -216,8 +216,8 @@ that PREFIX should not include a newline."
     (goto-char (1+ end))
     (save-excursion
       (goto-char beg)
     (goto-char (1+ end))
     (save-excursion
       (goto-char beg)
-      (if prefix
-         (insert-before-markers prefix))
+      (when prefix
+       (insert-before-markers prefix))
       (let ((button-beg (point)))
        (insert-before-markers (notmuch-wash-button-label overlay) "\n")
        (let ((button (make-button button-beg (1- (point))
       (let ((button-beg (point)))
        (insert-before-markers (notmuch-wash-button-label overlay) "\n")
        (let ((button (make-button button-beg (1- (point))
@@ -229,13 +229,13 @@ that PREFIX should not include a newline."
   "Excerpt citations and up to one signature."
   (goto-char (point-min))
   (beginning-of-line)
   "Excerpt citations and up to one signature."
   (goto-char (point-min))
   (beginning-of-line)
-  (if (and (< (point) (point-max))
-          (re-search-forward notmuch-wash-original-regexp nil t))
-      (let* ((msg-start (match-beginning 0))
-            (msg-end (point-max))
-            (msg-lines (count-lines msg-start msg-end)))
-       (notmuch-wash-region-to-button
-        msg msg-start msg-end "original")))
+  (when (and (< (point) (point-max))
+            (re-search-forward notmuch-wash-original-regexp nil t))
+    (let* ((msg-start (match-beginning 0))
+          (msg-end (point-max))
+          (msg-lines (count-lines msg-start msg-end)))
+      (notmuch-wash-region-to-button
+       msg msg-start msg-end "original")))
   (while (and (< (point) (point-max))
              (re-search-forward notmuch-wash-citation-regexp nil t))
     (let* ((cite-start (match-beginning 0))
   (while (and (< (point) (point-max))
              (re-search-forward notmuch-wash-citation-regexp nil t))
     (let* ((cite-start (match-beginning 0))
@@ -254,21 +254,21 @@ that PREFIX should not include a newline."
          (notmuch-wash-region-to-button
           msg hidden-start (point-marker)
           "citation")))))
          (notmuch-wash-region-to-button
           msg hidden-start (point-marker)
           "citation")))))
-  (if (and (not (eobp))
-          (re-search-forward notmuch-wash-signature-regexp nil t))
-      (let* ((sig-start (match-beginning 0))
-            (sig-end (match-end 0))
-            (sig-lines (count-lines sig-start (point-max))))
-       (if (<= sig-lines notmuch-wash-signature-lines-max)
-           (let ((sig-start-marker (make-marker))
-                 (sig-end-marker (make-marker)))
-             (set-marker sig-start-marker sig-start)
-             (set-marker sig-end-marker (point-max))
-             (overlay-put (make-overlay sig-start-marker sig-end-marker)
-                          'face 'message-cited-text)
-             (notmuch-wash-region-to-button
-              msg sig-start-marker sig-end-marker
-              "signature"))))))
+  (when (and (not (eobp))
+            (re-search-forward notmuch-wash-signature-regexp nil t))
+    (let* ((sig-start (match-beginning 0))
+          (sig-end (match-end 0))
+          (sig-lines (count-lines sig-start (point-max))))
+      (when (<= sig-lines notmuch-wash-signature-lines-max)
+       (let ((sig-start-marker (make-marker))
+             (sig-end-marker (make-marker)))
+         (set-marker sig-start-marker sig-start)
+         (set-marker sig-end-marker (point-max))
+         (overlay-put (make-overlay sig-start-marker sig-end-marker)
+                      'face 'message-cited-text)
+         (notmuch-wash-region-to-button
+          msg sig-start-marker sig-end-marker
+          "signature"))))))
 
 ;;
 
 
 ;;
 
@@ -286,12 +286,12 @@ that PREFIX should not include a newline."
     (delete-region (match-beginning 1) (match-end 1)))
   ;; Remove a leading blank line.
   (goto-char (point-min))
     (delete-region (match-beginning 1) (match-end 1)))
   ;; Remove a leading blank line.
   (goto-char (point-min))
-  (if (looking-at "\n")
-      (delete-region (match-beginning 0) (match-end 0)))
+  (when (looking-at "\n")
+    (delete-region (match-beginning 0) (match-end 0)))
   ;; Remove a trailing blank line.
   (goto-char (point-max))
   ;; Remove a trailing blank line.
   (goto-char (point-max))
-  (if (looking-at "\n")
-      (delete-region (match-beginning 0) (match-end 0))))
+  (when (looking-at "\n")
+    (delete-region (match-beginning 0) (match-end 0))))
 
 ;;
 
 
 ;;
 
@@ -399,12 +399,12 @@ for error."
          (patch-end (point-max))
          part)
       (goto-char patch-start)
          (patch-end (point-max))
          part)
       (goto-char patch-start)
-      (if (or
-          ;; Patch ends with signature.
-          (re-search-forward notmuch-wash-signature-regexp nil t)
-          ;; Patch ends with bugtraq comment.
-          (re-search-forward "^\\*\\*\\* " nil t))
-         (setq patch-end (match-beginning 0)))
+      (when (or
+            ;; Patch ends with signature.
+            (re-search-forward notmuch-wash-signature-regexp nil t)
+            ;; Patch ends with bugtraq comment.
+            (re-search-forward "^\\*\\*\\* " nil t))
+       (setq patch-end (match-beginning 0)))
       (save-restriction
        (narrow-to-region patch-start patch-end)
        (setq part (plist-put part :content-type "inline patch"))
       (save-restriction
        (narrow-to-region patch-start patch-end)
        (setq part (plist-put part :content-type "inline patch"))