emacs: Use 'when' instead of 'if' when there is no ELSE part

This commit is contained in:
Jonas Bernoulli 2020-08-08 13:49:43 +02:00 committed by David Bremner
parent 09f6533c37
commit e1a700067a
12 changed files with 206 additions and 203 deletions

View file

@ -171,10 +171,10 @@ toggles the setting in this buffer."
(if (local-variable-p 'notmuch-address-command) (if (local-variable-p 'notmuch-address-command)
(kill-local-variable 'notmuch-address-command) (kill-local-variable 'notmuch-address-command)
(notmuch-setq-local notmuch-address-command 'internal)) (notmuch-setq-local notmuch-address-command 'internal))
(if (boundp 'company-idle-delay) (when (boundp 'company-idle-delay)
(if (local-variable-p 'company-idle-delay) (if (local-variable-p 'company-idle-delay)
(kill-local-variable 'company-idle-delay) (kill-local-variable 'company-idle-delay)
(notmuch-setq-local company-idle-delay nil)))) (notmuch-setq-local company-idle-delay nil))))
(defun notmuch-address-matching (substring) (defun notmuch-address-matching (substring)
"Returns a list of completion candidates matching SUBSTRING. "Returns a list of completion candidates matching SUBSTRING.

View file

@ -68,9 +68,9 @@ inlined."
;; This is an inlined copy of help-form-show as that ;; This is an inlined copy of help-form-show as that
;; was introduced in emacs 24 too. ;; was introduced in emacs 24 too.
(let ((msg (eval help-form))) (let ((msg (eval help-form)))
(if (stringp msg) (when (stringp msg)
(with-output-to-temp-buffer " *Char Help*" (with-output-to-temp-buffer " *Char Help*"
(princ msg)))))) (princ msg))))))
((memq char chars) ((memq char chars)
(setq done t)) (setq done t))
((and executing-kbd-macro (= char -1)) ((and executing-kbd-macro (= char -1))

View file

@ -589,8 +589,8 @@ with `notmuch-hello-query-counts'."
(mapc (lambda (elem) (mapc (lambda (elem)
;; (not elem) indicates an empty slot in the matrix. ;; (not elem) indicates an empty slot in the matrix.
(when elem (when elem
(if (> column-indent 0) (when (> column-indent 0)
(widget-insert (make-string column-indent ? ))) (widget-insert (make-string column-indent ? )))
(let* ((name (plist-get elem :name)) (let* ((name (plist-get elem :name))
(query (plist-get elem :query)) (query (plist-get elem :query))
(oldest-first (cl-case (plist-get elem :sort-order) (oldest-first (cl-case (plist-get elem :sort-order)
@ -890,8 +890,8 @@ Supports the following entries in OPTIONS as a plist:
the same values as :filter. If :filter and :filter-count are specified, this the same values as :filter. If :filter and :filter-count are specified, this
will be used instead of :filter, not in conjunction with it." will be used instead of :filter, not in conjunction with it."
(widget-insert title ": ") (widget-insert title ": ")
(if (and notmuch-hello-first-run (plist-get options :initially-hidden)) (when (and notmuch-hello-first-run (plist-get options :initially-hidden))
(add-to-list 'notmuch-hello-hidden-sections title)) (add-to-list 'notmuch-hello-hidden-sections title))
(let ((is-hidden (member title notmuch-hello-hidden-sections)) (let ((is-hidden (member title notmuch-hello-hidden-sections))
(start (point))) (start (point)))
(if is-hidden (if is-hidden

View file

@ -169,37 +169,37 @@ buffer."
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
(set-keymap-parent map notmuch-jump-minibuffer-map) (set-keymap-parent map notmuch-jump-minibuffer-map)
(pcase-dolist (`(,key ,name ,fn) action-map) (pcase-dolist (`(,key ,name ,fn) action-map)
(if (= (length key) 1) (when (= (length key) 1)
(define-key map key (define-key map key
`(lambda () (interactive) `(lambda () (interactive)
(setq notmuch-jump--action ',fn) (setq notmuch-jump--action ',fn)
(exit-minibuffer))))) (exit-minibuffer)))))
;; By doing this in two passes (and checking if we already have a ;; By doing this in two passes (and checking if we already have a
;; binding) we avoid problems if the user specifies a binding which ;; binding) we avoid problems if the user specifies a binding which
;; is a prefix of another binding. ;; is a prefix of another binding.
(pcase-dolist (`(,key ,name ,fn) action-map) (pcase-dolist (`(,key ,name ,fn) action-map)
(if (> (length key) 1) (when (> (length key) 1)
(let* ((key (elt key 0)) (let* ((key (elt key 0))
(keystr (string key)) (keystr (string key))
(new-prompt (concat prompt (format-kbd-macro keystr) " ")) (new-prompt (concat prompt (format-kbd-macro keystr) " "))
(action-submap nil)) (action-submap nil))
(unless (lookup-key map keystr) (unless (lookup-key map keystr)
(pcase-dolist (`(,k ,n ,f) action-map) (pcase-dolist (`(,k ,n ,f) action-map)
(when (= key (elt k 0)) (when (= key (elt k 0))
(push (list (substring k 1) n f) action-submap))) (push (list (substring k 1) n f) action-submap)))
;; We deal with backspace specially ;; We deal with backspace specially
(push (list (kbd "DEL") (push (list (kbd "DEL")
"Backup" "Backup"
(apply-partially #'notmuch-jump action-map prompt)) (apply-partially #'notmuch-jump action-map prompt))
action-submap) action-submap)
(setq action-submap (nreverse action-submap)) (setq action-submap (nreverse action-submap))
(define-key map keystr (define-key map keystr
`(lambda () (interactive) `(lambda () (interactive)
(setq notmuch-jump--action (setq notmuch-jump--action
',(apply-partially #'notmuch-jump ',(apply-partially #'notmuch-jump
action-submap action-submap
new-prompt)) new-prompt))
(exit-minibuffer))))))) (exit-minibuffer)))))))
map)) map))
;; ;;

View file

@ -664,11 +664,11 @@ MSG (if it isn't already)."
;; first loading gnus-art, which defines it, resulting in a ;; first loading gnus-art, which defines it, resulting in a
;; void-variable error. Hence, we advise `mm-shr' to ensure gnus-art ;; void-variable error. Hence, we advise `mm-shr' to ensure gnus-art
;; is loaded. ;; is loaded.
(if (>= emacs-major-version 24) (when (>= emacs-major-version 24)
(defadvice mm-shr (before load-gnus-arts activate) (defadvice mm-shr (before load-gnus-arts activate)
(require 'gnus-art nil t) (require 'gnus-art nil t)
(ad-disable-advice 'mm-shr 'before 'load-gnus-arts) (ad-disable-advice 'mm-shr 'before 'load-gnus-arts)
(ad-activate 'mm-shr))) (ad-activate 'mm-shr)))
(defun notmuch-mm-display-part-inline (msg part content-type process-crypto) (defun notmuch-mm-display-part-inline (msg part content-type process-crypto)
"Use the mm-decode/mm-view functions to display a part in the "Use the mm-decode/mm-view functions to display a part in the

View file

@ -275,8 +275,8 @@ Typically this is added to `notmuch-mua-send-hook'."
(narrow-to-region (point) (point-max)) (narrow-to-region (point) (point-max))
(goto-char (point-max)) (goto-char (point-max))
(if (re-search-backward message-signature-separator nil t) (if (re-search-backward message-signature-separator nil t)
(if message-signature-insert-empty-line (when message-signature-insert-empty-line
(forward-line -1)) (forward-line -1))
(goto-char (point-max)))) (goto-char (point-max))))
(let ((from (plist-get original-headers :From)) (let ((from (plist-get original-headers :From))
(date (plist-get original-headers :Date)) (date (plist-get original-headers :Date))
@ -388,7 +388,8 @@ modified. This function is notmuch addaptation of
;; https://lists.gnu.org/archive/html/emacs-devel/2011-01/msg00337.html ;; https://lists.gnu.org/archive/html/emacs-devel/2011-01/msg00337.html
;; We need to convert any string input, eg from rmail-start-mail. ;; We need to convert any string input, eg from rmail-start-mail.
(dolist (h other-headers other-headers) (dolist (h other-headers other-headers)
(if (stringp (car h)) (setcar h (intern (capitalize (car h)))))))) (when (stringp (car h))
(setcar h (intern (capitalize (car h))))))))
(args (list yank-action send-actions)) (args (list yank-action send-actions))
;; Cause `message-setup-1' to do things relevant for mail, ;; Cause `message-setup-1' to do things relevant for mail,
;; such as observe `message-default-mail-headers'. ;; such as observe `message-default-mail-headers'.
@ -428,14 +429,15 @@ the From: header is already filled in by notmuch."
;; without some explicit initialization fill freeze the operation. ;; without some explicit initialization fill freeze the operation.
;; Hence, we advice `ido-completing-read' to ensure required initialization ;; Hence, we advice `ido-completing-read' to ensure required initialization
;; is done. ;; is done.
(if (and (= emacs-major-version 23) (< emacs-minor-version 4)) (when (and (= emacs-major-version 23)
(defadvice ido-completing-read (before notmuch-ido-mode-init activate) (< emacs-minor-version 4))
(ido-init-completion-maps) (defadvice ido-completing-read (before notmuch-ido-mode-init activate)
(add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup) (ido-init-completion-maps)
(add-hook 'choose-completion-string-functions (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup)
'ido-choose-completion-string) (add-hook 'choose-completion-string-functions
(ad-disable-advice 'ido-completing-read 'before 'notmuch-ido-mode-init) 'ido-choose-completion-string)
(ad-activate 'ido-completing-read))) (ad-disable-advice 'ido-completing-read 'before 'notmuch-ido-mode-init)
(ad-activate 'ido-completing-read)))
(defun notmuch-mua-prompt-for-sender () (defun notmuch-mua-prompt-for-sender ()
"Prompt for a sender from the user's configured identities." "Prompt for a sender from the user's configured identities."

View file

@ -30,8 +30,8 @@ A thread is a forest or list of trees. A tree is a two element
list where the first element is a message, and the second element list where the first element is a message, and the second element
is a possibly empty forest of replies." is a possibly empty forest of replies."
(let ((args '("show" "--format=sexp" "--format-version=4"))) (let ((args '("show" "--format=sexp" "--format-version=4")))
(if notmuch-show-process-crypto (when notmuch-show-process-crypto
(setq args (append args '("--decrypt=true")))) (setq args (append args '("--decrypt=true"))))
(setq args (append args search-terms)) (setq args (append args search-terms))
(apply #'notmuch-call-notmuch-sexp args))) (apply #'notmuch-call-notmuch-sexp args)))

View file

@ -346,10 +346,10 @@ operation on the contents of the current buffer."
(indenting notmuch-show-indent-content)) (indenting notmuch-show-indent-content))
(with-temp-buffer (with-temp-buffer
(insert all) (insert all)
(if indenting (when indenting
(indent-rigidly (point-min) (indent-rigidly (point-min)
(point-max) (point-max)
(- (* notmuch-show-indent-messages-width depth)))) (- (* notmuch-show-indent-messages-width depth))))
;; Remove the original header. ;; Remove the original header.
(goto-char (point-min)) (goto-char (point-min))
(re-search-forward "^$" (point-max) nil) (re-search-forward "^$" (point-max) nil)
@ -392,13 +392,13 @@ operation on the contents of the current buffer."
"Update the displayed tags of the current message." "Update the displayed tags of the current message."
(save-excursion (save-excursion
(goto-char (notmuch-show-message-top)) (goto-char (notmuch-show-message-top))
(if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t) (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(replace-match (concat "(" (replace-match (concat "("
(notmuch-tag-format-tags (notmuch-tag-format-tags
tags tags
(notmuch-show-get-prop :orig-tags)) (notmuch-show-get-prop :orig-tags))
")")))))) ")"))))))
(defun notmuch-clean-address (address) (defun notmuch-clean-address (address)
"Try to clean a single email ADDRESS for display. Return a cons "Try to clean a single email ADDRESS for display. Return a cons
@ -488,9 +488,9 @@ message at DEPTH in the current thread."
(mapc (lambda (header) (mapc (lambda (header)
(let* ((header-symbol (intern (concat ":" header))) (let* ((header-symbol (intern (concat ":" header)))
(header-value (plist-get headers header-symbol))) (header-value (plist-get headers header-symbol)))
(if (and header-value (when (and header-value
(not (string-equal "" header-value))) (not (string-equal "" header-value)))
(notmuch-show-insert-header header header-value)))) (notmuch-show-insert-header header header-value))))
notmuch-message-headers) notmuch-message-headers)
(save-excursion (save-excursion
(save-restriction (save-restriction
@ -606,10 +606,10 @@ will return nil if the CID is unknown or cannot be retrieved."
(defun notmuch-show-setup-w3m () (defun notmuch-show-setup-w3m ()
"Instruct w3m how to retrieve content from a \"related\" part of a message." "Instruct w3m how to retrieve content from a \"related\" part of a message."
(interactive) (interactive)
(if (boundp 'w3m-cid-retrieve-function-alist) (when (and (boundp 'w3m-cid-retrieve-function-alist)
(unless (assq 'notmuch-show-mode w3m-cid-retrieve-function-alist) (not (assq 'notmuch-show-mode w3m-cid-retrieve-function-alist)))
(push (cons 'notmuch-show-mode #'notmuch-show--cid-w3m-retrieve) (push (cons 'notmuch-show-mode #'notmuch-show--cid-w3m-retrieve)
w3m-cid-retrieve-function-alist))) w3m-cid-retrieve-function-alist))
(setq mm-html-inhibit-images nil)) (setq mm-html-inhibit-images nil))
(defvar w3m-current-buffer) ;; From `w3m.el'. (defvar w3m-current-buffer) ;; From `w3m.el'.
@ -767,22 +767,22 @@ will return nil if the CID is unknown or cannot be retrieved."
(defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth button) (defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth button)
(notmuch-show-insert-part-text/calendar msg part content-type nth depth button)) (notmuch-show-insert-part-text/calendar msg part content-type nth depth button))
(if (version< emacs-version "25.3") (when (version< emacs-version "25.3")
;; https://bugs.gnu.org/28350 ;; https://bugs.gnu.org/28350
;; ;;
;; For newer emacs, we fall back to notmuch-show-insert-part-*/* ;; For newer emacs, we fall back to notmuch-show-insert-part-*/*
;; (see notmuch-show-handlers-for) ;; (see notmuch-show-handlers-for)
(defun notmuch-show-insert-part-text/enriched (defun notmuch-show-insert-part-text/enriched
(msg part content-type nth depth button) (msg part content-type nth depth button)
;; By requiring enriched below, we ensure that the function ;; By requiring enriched below, we ensure that the function
;; enriched-decode-display-prop is defined before it will be ;; enriched-decode-display-prop is defined before it will be
;; shadowed by the letf below. Otherwise the version in ;; shadowed by the letf below. Otherwise the version in
;; enriched.el may be loaded a bit later and used instead (for ;; enriched.el may be loaded a bit later and used instead (for
;; the first time). ;; the first time).
(require 'enriched) (require 'enriched)
(cl-letf (((symbol-function 'enriched-decode-display-prop) (cl-letf (((symbol-function 'enriched-decode-display-prop)
(lambda (start end &optional param) (list start end)))) (lambda (start end &optional param) (list start end))))
(notmuch-show-insert-part-*/* msg part content-type nth depth button)))) (notmuch-show-insert-part-*/* msg part content-type nth depth button))))
(defun notmuch-show-get-mime-type-of-application/octet-stream (part) (defun notmuch-show-get-mime-type-of-application/octet-stream (part)
;; If we can deduce a MIME type from the filename of the attachment, ;; If we can deduce a MIME type from the filename of the attachment,
@ -849,8 +849,8 @@ will return nil if the CID is unknown or cannot be retrieved."
"Return a list of content handlers for a part of type CONTENT-TYPE." "Return a list of content handlers for a part of type CONTENT-TYPE."
(let (result) (let (result)
(mapc (lambda (func) (mapc (lambda (func)
(if (functionp func) (when (functionp func)
(push func result))) (push func result)))
;; Reverse order of prefrence. ;; Reverse order of prefrence.
(list (intern (concat "notmuch-show-insert-part-*/*")) (list (intern (concat "notmuch-show-insert-part-*/*"))
(intern (concat (intern (concat
@ -1080,10 +1080,10 @@ is t, hide the part initially and show the button."
(insert "\n")) (insert "\n"))
(setq content-end (point-marker)) (setq content-end (point-marker))
;; Indent according to the depth in the thread. ;; Indent according to the depth in the thread.
(if notmuch-show-indent-content (when notmuch-show-indent-content
(indent-rigidly content-start (indent-rigidly content-start
content-end content-end
(* notmuch-show-indent-messages-width depth))) (* notmuch-show-indent-messages-width depth)))
(setq message-end (point-max-marker)) (setq message-end (point-max-marker))
;; Save the extents of this message over the whole text of the ;; Save the extents of this message over the whole text of the
;; message. ;; message.
@ -1288,7 +1288,8 @@ and THREAD. The next query is THREAD alone, and serves as a
fallback if the prior matches no messages." fallback if the prior matches no messages."
(let (queries) (let (queries)
(push (list thread) queries) (push (list thread) queries)
(if context (push (list thread "and (" context ")") queries)) (when context
(push (list thread "and (" context ")") queries))
queries)) queries))
(defun notmuch-show--build-buffer (&optional state) (defun notmuch-show--build-buffer (&optional state)
@ -1785,9 +1786,9 @@ Reshows the current thread with matches defined by the new query-string."
(let (message-ids done) (let (message-ids done)
(goto-char (point-min)) (goto-char (point-min))
(while (not done) (while (not done)
(if (notmuch-show-message-visible-p) (when (notmuch-show-message-visible-p)
(setq message-ids (setq message-ids
(append message-ids (list (notmuch-show-get-message-id))))) (append message-ids (list (notmuch-show-get-message-id)))))
(setq done (not (notmuch-show-goto-message-next)))) (setq done (not (notmuch-show-goto-message-next))))
message-ids))) message-ids)))
@ -1842,8 +1843,8 @@ archives the entire current thread, (apply changes in
thread from the search from which this thread was originally thread from the search from which this thread was originally
shown." shown."
(interactive) (interactive)
(if (notmuch-show-advance) (when (notmuch-show-advance)
(notmuch-show-archive-thread-then-next))) (notmuch-show-archive-thread-then-next)))
(defun notmuch-show-rewind () (defun notmuch-show-rewind ()
"Backup through the thread (reverse scrolling compared to \ "Backup through the thread (reverse scrolling compared to \

View file

@ -967,19 +967,19 @@ Complete list of currently available key bindings:
(never-found-target-thread nil)) (never-found-target-thread nil))
(when (memq status '(exit signal)) (when (memq status '(exit signal))
(kill-buffer (process-get proc 'parse-buf)) (kill-buffer (process-get proc 'parse-buf))
(if (buffer-live-p buffer) (when (buffer-live-p buffer)
(with-current-buffer buffer (with-current-buffer buffer
(save-excursion (save-excursion
(let ((inhibit-read-only t) (let ((inhibit-read-only t)
(atbob (bobp))) (atbob (bobp)))
(goto-char (point-max)) (goto-char (point-max))
(if (eq status 'signal) (when (eq status 'signal)
(insert "Incomplete search results (tree view process was killed).\n")) (insert "Incomplete search results (tree view process was killed).\n"))
(when (eq status 'exit) (when (eq status 'exit)
(insert "End of search results.") (insert "End of search results.")
(unless (= exit-status 0) (unless (= exit-status 0)
(insert (format " (process returned %d)" exit-status))) (insert (format " (process returned %d)" exit-status)))
(insert "\n"))))))))) (insert "\n")))))))))
(defun notmuch-tree-process-filter (proc string) (defun notmuch-tree-process-filter (proc string)
"Process and filter the output of \"notmuch show\" for tree view." "Process and filter the output of \"notmuch show\" for tree view."
@ -1023,8 +1023,8 @@ the same as for the function notmuch-tree."
(and query-context (and query-context
(concat " and (" query-context ")")))) (concat " and (" query-context ")"))))
(message-arg (if unthreaded "--unthreaded" "--entire-thread"))) (message-arg (if unthreaded "--unthreaded" "--entire-thread")))
(if (equal (car (process-lines notmuch-command "count" search-args)) "0") (when (equal (car (process-lines notmuch-command "count" search-args)) "0")
(setq search-args basic-query)) (setq search-args basic-query))
(notmuch-tag-clear-cache) (notmuch-tag-clear-cache)
(let ((proc (notmuch-start-notmuch (let ((proc (notmuch-start-notmuch
"notmuch-tree" (current-buffer) #'notmuch-tree-process-sentinel "notmuch-tree" (current-buffer) #'notmuch-tree-process-sentinel

View file

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

View file

@ -674,28 +674,28 @@ of the result."
(when (memq status '(exit signal)) (when (memq status '(exit signal))
(catch 'return (catch 'return
(kill-buffer (process-get proc 'parse-buf)) (kill-buffer (process-get proc 'parse-buf))
(if (buffer-live-p buffer) (when (buffer-live-p buffer)
(with-current-buffer buffer (with-current-buffer buffer
(save-excursion (save-excursion
(let ((inhibit-read-only t) (let ((inhibit-read-only t)
(atbob (bobp))) (atbob (bobp)))
(goto-char (point-max)) (goto-char (point-max))
(if (eq status 'signal) (when (eq status 'signal)
(insert "Incomplete search results (search process was killed).\n")) (insert "Incomplete search results (search process was killed).\n"))
(when (eq status 'exit) (when (eq status 'exit)
(insert "End of search results.\n") (insert "End of search results.\n")
;; For version mismatch, there's no point in ;; For version mismatch, there's no point in
;; showing the search buffer ;; showing the search buffer
(when (or (= exit-status 20) (= exit-status 21)) (when (or (= exit-status 20) (= exit-status 21))
(kill-buffer) (kill-buffer)
(throw 'return nil)) (throw 'return nil))
(if (and atbob (when (and atbob
(not (string= notmuch-search-target-thread "found"))) (not (string= notmuch-search-target-thread "found")))
(set 'never-found-target-thread t))))) (set 'never-found-target-thread t)))))
(when (and never-found-target-thread (when (and never-found-target-thread
notmuch-search-target-line) notmuch-search-target-line)
(goto-char (point-min)) (goto-char (point-min))
(forward-line (1- notmuch-search-target-line))))))))) (forward-line (1- notmuch-search-target-line)))))))))
(define-widget 'notmuch--custom-face-edit 'lazy (define-widget 'notmuch--custom-face-edit 'lazy
"Custom face edit with a tag Edit Face" "Custom face edit with a tag Edit Face"
@ -760,31 +760,31 @@ non-authors is found, assume that all of the authors match."
(invisible-string "") (invisible-string "")
(padding "")) (padding ""))
;; Truncate the author string to fit the specification. ;; Truncate the author string to fit the specification.
(if (> (length formatted-authors) (when (> (length formatted-authors)
(length formatted-sample)) (length formatted-sample))
(let ((visible-length (- (length formatted-sample) (let ((visible-length (- (length formatted-sample)
(length "... ")))) (length "... "))))
;; Truncate the visible string according to the width of ;; Truncate the visible string according to the width of
;; the display string. ;; the display string.
(setq visible-string (substring formatted-authors 0 visible-length)) (setq visible-string (substring formatted-authors 0 visible-length))
(setq invisible-string (substring formatted-authors visible-length)) (setq invisible-string (substring formatted-authors visible-length))
;; If possible, truncate the visible string at a natural ;; If possible, truncate the visible string at a natural
;; break (comma or pipe), as incremental search doesn't ;; break (comma or pipe), as incremental search doesn't
;; match across the visible/invisible border. ;; match across the visible/invisible border.
(when (string-match "\\(.*\\)\\([,|] \\)\\([^,|]*\\)" visible-string) (when (string-match "\\(.*\\)\\([,|] \\)\\([^,|]*\\)" visible-string)
;; Second clause is destructive on `visible-string', so ;; Second clause is destructive on `visible-string', so
;; order is important. ;; order is important.
(setq invisible-string (concat (match-string 3 visible-string) (setq invisible-string (concat (match-string 3 visible-string)
invisible-string)) invisible-string))
(setq visible-string (concat (match-string 1 visible-string) (setq visible-string (concat (match-string 1 visible-string)
(match-string 2 visible-string)))) (match-string 2 visible-string))))
;; `visible-string' may be shorter than the space allowed ;; `visible-string' may be shorter than the space allowed
;; by `format-string'. If so we must insert some padding ;; by `format-string'. If so we must insert some padding
;; after `invisible-string'. ;; after `invisible-string'.
(setq padding (make-string (- (length formatted-sample) (setq padding (make-string (- (length formatted-sample)
(length visible-string) (length visible-string)
(length "...")) (length "..."))
? )))) ? ))))
;; Use different faces to show matching and non-matching authors. ;; Use different faces to show matching and non-matching authors.
(if (string-match "\\(.*\\)|\\(.*\\)" visible-string) (if (string-match "\\(.*\\)|\\(.*\\)" visible-string)
;; The visible string contains both matching and ;; The visible string contains both matching and
@ -1006,8 +1006,8 @@ the configured default sort order."
(notmuch-tag-clear-cache) (notmuch-tag-clear-cache)
(let ((proc (get-buffer-process (current-buffer))) (let ((proc (get-buffer-process (current-buffer)))
(inhibit-read-only t)) (inhibit-read-only t))
(if proc (when proc
(error "notmuch search process already running for query `%s'" query)) (error "notmuch search process already running for query `%s'" query))
(erase-buffer) (erase-buffer)
(goto-char (point-min)) (goto-char (point-min))
(save-excursion (save-excursion
@ -1156,7 +1156,7 @@ beginning of the line."
(provide 'notmuch) (provide 'notmuch)
;; After provide to avoid loops if notmuch was require'd via notmuch-init-file. ;; After provide to avoid loops if notmuch was require'd via notmuch-init-file.
(if init-file-user ; don't load init file if the -q option was used. (when init-file-user ; don't load init file if the -q option was used.
(load notmuch-init-file t t nil t)) (load notmuch-init-file t t nil t))
;;; notmuch.el ends here ;;; notmuch.el ends here

View file

@ -36,7 +36,7 @@
;; Work around a bug in emacs 23.1 and emacs 23.2 which prevents ;; Work around a bug in emacs 23.1 and emacs 23.2 which prevents
;; noninteractive (kill-emacs) from emacsclient. ;; noninteractive (kill-emacs) from emacsclient.
(if (and (= emacs-major-version 23) (< emacs-minor-version 3)) (when (and (= emacs-major-version 23) (< emacs-minor-version 3))
(defadvice kill-emacs (before disable-yes-or-no-p activate) (defadvice kill-emacs (before disable-yes-or-no-p activate)
"Disable yes-or-no-p before executing kill-emacs" "Disable yes-or-no-p before executing kill-emacs"
(defun yes-or-no-p (prompt) t))) (defun yes-or-no-p (prompt) t)))
@ -46,7 +46,7 @@
;; seems to be present in Emacs 23.1. ;; seems to be present in Emacs 23.1.
;; Running `list-processes' after `accept-process-output' seems to work ;; Running `list-processes' after `accept-process-output' seems to work
;; around this problem. ;; around this problem.
(if (and (= emacs-major-version 23) (= emacs-minor-version 1)) (when (and (= emacs-major-version 23) (= emacs-minor-version 1))
(defadvice accept-process-output (after run-list-processes activate) (defadvice accept-process-output (after run-list-processes activate)
"run list-processes after executing accept-process-output" "run list-processes after executing accept-process-output"
(list-processes))) (list-processes)))