Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-15 Thread David Edmondson
On Sat, 14 Jan 2012 10:18:46 +0100, Pieter Praet  wrote:
> Does this really warrant a v2, or might we simply leave it as yet
> another victim for Tomi's uncrustify-for-elisp [1] ?

Pushing incorrectly indented code should be banned, in my opinion[1]. I'd
be tempted to have some pre-commit hooks to detect it.

Footnotes: 
[1]  Though I've done it myself.


pgpSjcYlWNUZf.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-14 Thread Pieter Praet
On Sat, 14 Jan 2012 10:14:57 +0100, Pieter Praet  wrote:
> On Fri, 13 Jan 2012 08:23:55 +, David Edmondson  wrote:
> > On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> > > Less code, same results, without sacrificing readability.
> > 
> > +1, but why not replace non-branching `if' with `when' as well?
> 
> I was planning to do that when the `unless' patch was accepted,
^^
   submit

> but after reading Xavier and Tomi's replies, I've changed my mind.
   
   I hadn't, though...

> 
> Looking at "subr.el", it's actually more efficient to use `if'
> (implemented in C) instead of `when' (a macro, which essentially
> runs "if conf (progn ...)".
> 
> The amount of non-branching "(if COND (progn ..."  statements is very
> limited though, so if inclined to "fix" them nonetheless, a patch
> follows (relative to the previous one!).
> 
> 
> Peace
> 
> -- 
> Pieter

Typsos FTW!

-- 
Pieter
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-14 Thread Pieter Praet
On Fri, 13 Jan 2012 16:06:17 +, David Edmondson  wrote:
> On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> > Less code, same results, without sacrificing readability.
> 
> Does this change correctly re-indent the line following the if/unless?

It does...

Or so I thought... I appear to have forgotten to correct the indentation
@ `notmuch-hello-insert-tags'.


Unfortunately git doesn't provide a way to diff the whitespace itself;
  (eg. "git diff --word-diff=color --word-diff-regex='[ \t]*'")

Setting "color.diff.whitespace" (and perhaps expanding the scope of
"core.whitespace") only colorizes *erroneous* whitespace...


Does this really warrant a v2, or might we simply leave it as yet
another victim for Tomi's uncrustify-for-elisp [1] ?


Peace

-- 
Pieter

[1] id:"yf639bkexs3@taco2.nixu.fi"
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-14 Thread Pieter Praet
On Fri, 13 Jan 2012 08:23:55 +, David Edmondson  wrote:
> On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> > Less code, same results, without sacrificing readability.
> 
> +1, but why not replace non-branching `if' with `when' as well?

I was planning to do that when the `unless' patch was accepted,
but after reading Xavier and Tomi's replies, I've changed my mind.

Looking at "subr.el", it's actually more efficient to use `if'
(implemented in C) instead of `when' (a macro, which essentially
runs "if conf (progn ...)".

The amount of non-branching "(if COND (progn ..."  statements is very
limited though, so if inclined to "fix" them nonetheless, a patch
follows (relative to the previous one!).


Peace

-- 
Pieter
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-13 Thread David Edmondson
On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> Less code, same results, without sacrificing readability.

Does this change correctly re-indent the line following the if/unless?


pgppn8eS1pTGG.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-13 Thread David Edmondson
On Fri, 13 Jan 2012 13:42:55 +0100, Xavier Maillard  wrote:
> On Fri, 13 Jan 2012 08:23:55 +, David Edmondson  wrote:
> > On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> > > Less code, same results, without sacrificing readability.
> > 
> > +1, but why not replace non-branching `if' with `when' as well?
> 
> I tend to use WHEN for case I need to execute multiple
> statements. For the rest, IF is ok.

Understood.


pgpKvSCUfyzJF.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-13 Thread Tomi Ollila
On Fri, 13 Jan 2012 13:42:55 +0100, Xavier Maillard  wrote:
> 
> On Fri, 13 Jan 2012 08:23:55 +, David Edmondson  wrote:
> > On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> > > Less code, same results, without sacrificing readability.
> > 
> > +1, but why not replace non-branching `if' with `when' as well?
> 
> I tend to use WHEN for case I need to execute multiple
> statements. For the rest, IF is ok.

Same here, (when ...) is (if (progn ...)) for me.

> 
> /Xavier

Tomi
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-13 Thread Xavier Maillard

On Fri, 13 Jan 2012 08:23:55 +, David Edmondson  wrote:
> On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> > Less code, same results, without sacrificing readability.
> 
> +1, but why not replace non-branching `if' with `when' as well?

I tend to use WHEN for case I need to execute multiple
statements. For the rest, IF is ok.

/Xavier
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-13 Thread David Edmondson
On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> Less code, same results, without sacrificing readability.

+1, but why not replace non-branching `if' with `when' as well?


pgpuhUlvebeLM.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-12 Thread Xavier Maillard

On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> Less code, same results, without sacrificing readability.

+1

/Xavier
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-12 Thread Dmitry Kurochkin
On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> Less code, same results, without sacrificing readability.
> 

+1

Regards,
  Dmitry

> ---
>  emacs/notmuch-address.el |6 +++---
>  emacs/notmuch-hello.el   |   20 ++--
>  emacs/notmuch-show.el|   12 ++--
>  emacs/notmuch.el |8 
>  4 files changed, 23 insertions(+), 23 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 333d4c1..dce2020 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -315,7 +315,7 @@ 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))
> +(unless (eq (% count tags-per-line) 0)
>   (widget-insert "\n"))
>  found-target-pos))
>  
> @@ -399,7 +399,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
> @@ -565,18 +565,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 5502efd..d3543f0 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -659,8 +659,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."
> @@ -740,8 +740,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))
>  
> @@ -882,8 +882,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 1e61775..ba84494 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -636,8 +636,8 @@ This function advances the next thread when finished."
>   (if notmuch-searc