From: Pieter Praet <pieter@praet.org>
To: David Edmondson <dme@dme.org>, Jani Nikula <jani@nikula.org>
Cc: Notmuch Mail <notmuch@notmuchmail.org>
Subject: [PATCH v2] emacs: globally replace non-branching "(if (not ..." with "(unless ..."
Date: Mon, 16 Jan 2012 11:56:40 +0100 [thread overview]
Message-ID: <1326711400-28002-1-git-send-email-pieter@praet.org> (raw)
In-Reply-To: <cuny5t95gfe.fsf@hotblack-desiato.hh.sledj.net>
Less code, same results, without sacrificing readability.
---
v2: Fixed indentation oversight @ `notmuch-hello-insert-tags'.
emacs/notmuch-address.el | 6 +++---
emacs/notmuch-hello.el | 22 +++++++++++-----------
emacs/notmuch-show.el | 12 ++++++------
emacs/notmuch.el | 8 ++++----
4 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 8eba7a0..d72b169 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -37,9 +37,9 @@ line."
(defvar notmuch-address-history nil)
(defun notmuch-address-message-insinuate ()
- (if (not (memq notmuch-address-message-alist-member message-completion-alist))
- (setq message-completion-alist
- (push notmuch-address-message-alist-member message-completion-alist))))
+ (unless (memq notmuch-address-message-alist-member message-completion-alist)
+ (setq message-completion-alist
+ (push notmuch-address-message-alist-member message-completion-alist))))
(defun notmuch-address-options (original)
(process-lines notmuch-address-command original))
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 02017ce..8aa2ad5 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -317,8 +317,8 @@ should be. Returns a cons cell `(tags-per-line width)'."
;; If the last line was not full (and hence did not include a
;; carriage return), insert one now.
- (if (not (eq (% count tags-per-line) 0))
- (widget-insert "\n"))
+ (unless (eq (% count tags-per-line) 0)
+ (widget-insert "\n"))
found-target-pos))
(defun notmuch-hello-goto-search ()
@@ -401,7 +401,7 @@ Complete list of currently available key bindings:
; Jump through a hoop to get this value from the deprecated variable
; name (`notmuch-folders') or from the default value.
- (if (not notmuch-saved-searches)
+ (unless notmuch-saved-searches
(setq notmuch-saved-searches (notmuch-saved-searches)))
(if no-display
@@ -567,18 +567,18 @@ Complete list of currently available key bindings:
(widget-insert "\n\n")
(let ((start (point)))
(setq found-target-pos (notmuch-hello-insert-tags alltags-alist widest target))
- (if (not final-target-pos)
- (setq final-target-pos found-target-pos))
+ (unless final-target-pos
+ (setq final-target-pos found-target-pos))
(indent-rigidly start (point) notmuch-hello-indent)))
(widget-insert "\n")
- (if (not notmuch-show-all-tags-list)
- (widget-create 'push-button
- :notify (lambda (widget &rest ignore)
- (setq notmuch-show-all-tags-list t)
- (notmuch-hello-update))
- "Show all tags")))
+ (unless notmuch-show-all-tags-list
+ (widget-create 'push-button
+ :notify (lambda (widget &rest ignore)
+ (setq notmuch-show-all-tags-list t)
+ (notmuch-hello-update))
+ "Show all tags")))
(let ((start (point)))
(widget-insert "\n\n")
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1a250a3..72bf888 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -656,8 +656,8 @@ current buffer, if possible."
;; part, so we make sure that we're down at the end.
(goto-char (point-max))
;; Ensure that the part ends with a carriage return.
- (if (not (bolp))
- (insert "\n")))
+ (unless (bolp)
+ (insert "\n")))
(defun notmuch-show-insert-body (msg body depth)
"Insert the body BODY at depth DEPTH in the current thread."
@@ -737,8 +737,8 @@ current buffer, if possible."
(setq body-start (point-marker))
(notmuch-show-insert-body msg (plist-get msg :body) depth)
;; Ensure that the body ends with a newline.
- (if (not (bolp))
- (insert "\n"))
+ (unless (bolp)
+ (insert "\n"))
(setq body-end (point-marker))
(setq content-end (point-marker))
@@ -879,8 +879,8 @@ buffer."
(run-hooks 'notmuch-show-hook))
;; Move straight to the first open message
- (if (not (notmuch-show-message-visible-p))
- (notmuch-show-next-open-message))
+ (unless (notmuch-show-message-visible-p)
+ (notmuch-show-next-open-message))
;; Set the header line to the subject of the first open message.
(setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ef4dcc7..c5fcc80 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -643,8 +643,8 @@ This function advances the next thread when finished."
(if notmuch-search-process-filter-data
(insert (concat "Error: Unexpected output from notmuch search:\n" notmuch-search-process-filter-data)))
(insert "End of search results.")
- (if (not (= exit-status 0))
- (insert (format " (process returned %d)" exit-status)))
+ (unless (= exit-status 0)
+ (insert (format " (process returned %d)" exit-status)))
(insert "\n")
(if (and atbob
(not (string= notmuch-search-target-thread "found")))
@@ -1013,8 +1013,8 @@ Invokes `notmuch-poll-script', \"notmuch new\", or does nothing
depending on the value of `notmuch-poll-script'."
(interactive)
(if (stringp notmuch-poll-script)
- (if (not (string= notmuch-poll-script ""))
- (call-process notmuch-poll-script nil nil))
+ (unless (string= notmuch-poll-script "")
+ (call-process notmuch-poll-script nil nil))
(call-process notmuch-command nil nil nil "new")))
(defun notmuch-search-poll-and-refresh-view ()
--
1.7.8.1
next prev parent reply other threads:[~2012-01-16 10:58 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-11 21:48 [PATCH] emacs: support "notmuch new" as a notmuch-poll-script Jani Nikula
2011-12-11 22:00 ` Dmitry Kurochkin
2011-12-11 22:19 ` Jani Nikula
2011-12-11 22:39 ` Dmitry Kurochkin
2011-12-11 22:58 ` Austin Clements
2011-12-11 23:10 ` Jani Nikula
2011-12-12 0:31 ` Austin Clements
2011-12-12 0:39 ` Dmitry Kurochkin
2011-12-12 10:15 ` Tomi Ollila
2011-12-12 10:21 ` Dmitry Kurochkin
2011-12-12 11:38 ` Tomi Ollila
2011-12-12 15:42 ` Austin Clements
2011-12-12 19:57 ` [PATCH v2] " Jani Nikula
2011-12-12 20:12 ` Dmitry Kurochkin
2011-12-12 20:24 ` Austin Clements
2011-12-12 20:50 ` [PATCH v3] " Jani Nikula
2011-12-12 20:53 ` Dmitry Kurochkin
2011-12-12 21:13 ` Jani Nikula
2011-12-12 21:24 ` Austin Clements
2011-12-12 21:34 ` Dmitry Kurochkin
2011-12-12 21:01 ` Austin Clements
2011-12-15 4:24 ` David Bremner
2012-01-12 17:31 ` Pieter Praet
2012-01-12 17:33 ` [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..." Pieter Praet
2012-01-12 17:40 ` Dmitry Kurochkin
2012-01-12 22:10 ` Xavier Maillard
2012-01-13 8:23 ` David Edmondson
2012-01-13 12:42 ` Xavier Maillard
2012-01-13 12:37 ` Tomi Ollila
2012-01-13 13:01 ` David Edmondson
2012-01-14 9:14 ` Pieter Praet
2012-01-14 9:17 ` [PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..." Pieter Praet
2012-01-28 12:41 ` David Bremner
2012-01-28 12:55 ` Jani Nikula
2012-01-28 17:14 ` David Bremner
2012-01-30 9:23 ` David Edmondson
2012-02-01 13:46 ` Pieter Praet
2012-02-01 14:21 ` Dmitry Kurochkin
2012-01-30 7:03 ` Pieter Praet
2012-01-30 7:59 ` Tomi Ollila
2012-02-01 13:46 ` Pieter Praet
2012-01-31 3:34 ` David Bremner
2012-02-01 13:47 ` Pieter Praet
2012-02-01 13:50 ` [PATCH v2] " Pieter Praet
2012-02-01 14:05 ` David Edmondson
2012-02-02 1:31 ` David Bremner
2012-01-14 9:52 ` [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..." Pieter Praet
2012-01-13 16:06 ` David Edmondson
2012-01-14 9:18 ` Pieter Praet
2012-01-15 11:55 ` David Edmondson
2012-01-16 10:56 ` Pieter Praet [this message]
2012-01-16 11:06 ` [PATCH v2] " David Edmondson
2012-01-16 12:39 ` Tomi Ollila
2012-01-21 12:21 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1326711400-28002-1-git-send-email-pieter@praet.org \
--to=pieter@praet.org \
--cc=dme@dme.org \
--cc=jani@nikula.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).