Re: [PATCH 07/23] emacs: Use 'and' instead of 'when' when the return value matters

2020-07-27 Thread Jonas Bernoulli
Sean Whitton  writes:

> Hello,
>
> On Mon 27 Jul 2020 at 12:02AM +02, Jonas Bernoulli wrote:
>
>> Sean Whitton  writes:
>>
>>> On Sun 26 Jul 2020 at 06:58PM +02, Jonas Bernoulli wrote:
>>>
 Also do so for some 'if' forms that lack an ELSE part.
 Even go as far as using 'and' and 'not' instead of 'unless'.
>>>
>>> I don't follow "when the return value matters", could you explain?
>>
>> As in "when the caller consumes the returned value".  The alternative
>> would be for the caller to not care about the value returned by the
>> callee and to instead call it for the side-effects only.
>>
>> By using `and' we can signal that care about the return value and by
>> using `when' that we care about the side-effects instead.
>
> Thank you for your reply.  Just to confirm, this is just a convention,
> right?  I hadn't come across it yet.

Yes, just a convention.

Here's one place that talks about this convention:
https://emacs.stackexchange.com/questions/14195/and-vs-when-for-conditionals
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 07/23] emacs: Use 'and' instead of 'when' when the return value matters

2020-07-27 Thread Sean Whitton
Hello,

On Mon 27 Jul 2020 at 12:02AM +02, Jonas Bernoulli wrote:

> Sean Whitton  writes:
>
>> On Sun 26 Jul 2020 at 06:58PM +02, Jonas Bernoulli wrote:
>>
>>> Also do so for some 'if' forms that lack an ELSE part.
>>> Even go as far as using 'and' and 'not' instead of 'unless'.
>>
>> I don't follow "when the return value matters", could you explain?
>
> As in "when the caller consumes the returned value".  The alternative
> would be for the caller to not care about the value returned by the
> callee and to instead call it for the side-effects only.
>
> By using `and' we can signal that care about the return value and by
> using `when' that we care about the side-effects instead.

Thank you for your reply.  Just to confirm, this is just a convention,
right?  I hadn't come across it yet.

-- 
Sean Whitton
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 07/23] emacs: Use 'and' instead of 'when' when the return value matters

2020-07-26 Thread Jonas Bernoulli
Sean Whitton  writes:

> On Sun 26 Jul 2020 at 06:58PM +02, Jonas Bernoulli wrote:
>
>> Also do so for some 'if' forms that lack an ELSE part.
>> Even go as far as using 'and' and 'not' instead of 'unless'.
>
> I don't follow "when the return value matters", could you explain?

As in "when the caller consumes the returned value".  The alternative
would be for the caller to not care about the value returned by the
callee and to instead call it for the side-effects only.

By using `and' we can signal that care about the return value and by
using `when' that we care about the side-effects instead.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 07/23] emacs: Use 'and' instead of 'when' when the return value matters

2020-07-26 Thread Sean Whitton
Hello,

On Sun 26 Jul 2020 at 06:58PM +02, Jonas Bernoulli wrote:

> Also do so for some 'if' forms that lack an ELSE part.
> Even go as far as using 'and' and 'not' instead of 'unless'.

I don't follow "when the return value matters", could you explain?

Thanks.

-- 
Sean Whitton
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 07/23] emacs: Use 'and' instead of 'when' when the return value matters

2020-07-26 Thread Jonas Bernoulli
Also do so for some 'if' forms that lack an ELSE part.
Even go as far as using 'and' and 'not' instead of 'unless'.
---
 emacs/coolj.el   | 12 +++---
 emacs/notmuch-address.el | 72 ++--
 emacs/notmuch-crypto.el  |  2 +-
 emacs/notmuch-draft.el   |  2 +-
 emacs/notmuch-lib.el | 37 +-
 emacs/notmuch-maildir-fcc.el |  4 +-
 emacs/notmuch-mua.el | 13 +++
 emacs/notmuch-show.el| 45 +++---
 emacs/notmuch-tree.el|  4 +-
 emacs/notmuch-wash.el|  8 ++--
 emacs/notmuch.el | 28 --
 11 files changed, 114 insertions(+), 113 deletions(-)

diff --git a/emacs/coolj.el b/emacs/coolj.el
index 961db606..39a8de2b 100644
--- a/emacs/coolj.el
+++ b/emacs/coolj.el
@@ -107,12 +107,12 @@ (defun coolj-set-breakpoint (prefix)
 If the line should not be broken, return nil; point remains on the
 line."
   (move-to-column fill-column)
-  (if (and (re-search-forward "[^ ]" (line-end-position) 1)
-  (> (current-column) fill-column))
-  ;; This line is too long.  Can we break it?
-  (or (coolj-find-break-backward prefix)
- (progn (move-to-column fill-column)
-(coolj-find-break-forward)
+  (and (re-search-forward "[^ ]" (line-end-position) 1)
+   (> (current-column) fill-column)
+   ;; This line is too long.  Can we break it?
+   (or (coolj-find-break-backward prefix)
+  (progn (move-to-column fill-column)
+ (coolj-find-break-forward)
 
 (defun coolj-find-break-backward (prefix)
   "Move point backward to the first available breakpoint and return t.
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 4db7096c..2dd08661 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -252,20 +252,20 @@ (defun notmuch-address-expand-name ()
 (defun notmuch-address-locate-command (command)
   "Return non-nil if `command' is an executable either on
 `exec-path' or an absolute pathname."
-  (when (stringp command)
-(if (and (file-name-absolute-p command)
-(file-executable-p command))
-   command
-  (setq command (file-name-nondirectory command))
-  (catch 'found-command
-   (let (bin)
- (dolist (dir exec-path)
-   (setq bin (expand-file-name command dir))
-   (when (or (and (file-executable-p bin)
-  (not (file-directory-p bin)))
- (and (file-executable-p (setq bin (concat bin ".exe")))
-  (not (file-directory-p bin
- (throw 'found-command bin
+  (and (stringp command)
+   (if (and (file-name-absolute-p command)
+   (file-executable-p command))
+  command
+(setq command (file-name-nondirectory command))
+(catch 'found-command
+  (let (bin)
+(dolist (dir exec-path)
+  (setq bin (expand-file-name command dir))
+  (when (or (and (file-executable-p bin)
+ (not (file-directory-p bin)))
+(and (file-executable-p (setq bin (concat bin ".exe")))
+ (not (file-directory-p bin
+(throw 'found-command bin
 
 (defun notmuch-address-harvest-addr (result)
   (let ((name-addr (plist-get result :name-addr)))
@@ -304,18 +304,20 @@ (defun notmuch-address-harvest (&optional addr-prefix 
synchronous callback)
 execution, CALLBACK is called when harvesting finishes."
   (let* ((sent (eq (car notmuch-address-internal-completion) 'sent))
 (config-query (cadr notmuch-address-internal-completion))
-(prefix-query (when addr-prefix
-(format "%s:%s*" (if sent "to" "from") addr-prefix)))
+(prefix-query (and addr-prefix
+   (format "%s:%s*"
+   (if sent "to" "from")
+   addr-prefix)))
 (from-or-to-me-query
  (mapconcat (lambda (x)
   (concat (if sent "from:" "to:") x))
 (notmuch-user-emails) " or "))
 (query (if (or prefix-query config-query)
(concat (format "(%s)" from-or-to-me-query)
-   (when prefix-query
- (format " and (%s)" prefix-query))
-   (when config-query
- (format " and (%s)" config-query)))
+   (and prefix-query
+(format " and (%s)" prefix-query))
+   (and config-query
+(format " and (%s)" config-query)))
  from-or-to-me-query))
 (args `("address" "--format=sexp" "--format-version=4"
 ,(if sent "--output=recipients" "--output=sender")
@@ -354,21 +356,21 @@ (defun notmuch-address--get-address-hash ()