Re: [PATCH] emacs: Use `cl-lib' instead of deprecated `cl'

2020-04-27 Thread David Bremner
Jonas Bernoulli  writes:

> I have fixed the remaining issues and added two small commits.
> See v3.  
>
Great, thanks. I've pushed the main one, and tagged the other two for
review.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Use `cl-lib' instead of deprecated `cl'

2020-04-25 Thread Jonas Bernoulli
I have fixed the remaining issues and added two small commits.
See v3.  

> Or of course you can/should get the tests running locally.

The problem was that there are incompatible changes in Emacs 27.
I am using Emacs 26 for the time being but will look into these
breaking changes later.  The first one was easy to work around,
but that just revealed a second one... 

  Jonas
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Use `cl-lib' instead of deprecated `cl'

2020-04-21 Thread David Bremner
Jonas Bernoulli  writes:

> David Bremner  writes:
>
>> A quick git grep suggests there are still cl-isms in the test-harness.
>
> I've fixed that now, see v2.
>
>> I get 3 test failures
>
> I am having issues running the tests.  Currently
> notmuch-mua-send-and-exit in emacs_deliver_message from test-lib.sh
> just hangs for me.  I haven't investigated further yet.  So I am
> afraid you'll have to run the tests for me again.

There are still 2 failures. There is a lingering 'second' in
T450-notmuch-show.sh. and a failure that I don't really understand from
T720-emacs-attachment-warnings (had to edit the embeded mml to send this
message :()

T720-emacs-attachment-warnings: Testing emacs attachment warnings
 FAIL   notmuch-test-attachment-warning part 1
Expect: t
Output: "nil <-- (lambda nil (insert \"Hello
\") (insert \"#mml type=message/rfc822 disposition=inline>
\") (insert \"X-Has-Attach:
\") (insert \"#/mml>
\"))"
Expect: t
Output: "nil <-- (lambda nil (insert \"> I sent you an attachment!
\") (sit-for 0.01))"
Expect: t
Output: "nil <-- (lambda nil (insert \"#part filename=\\\"foo\\\" />
\"))"
Expect: t
Output: "nil <-- (lambda nil (insert \"Here is an attachment:
\") (insert \"#part filename=\\\"foo\\\" />
\"))"
Expect: t
Output: "nil <-- (lambda nil (insert \"Nothing is a-tt-a-ch-ed!
\"))"
Expect: t
Output: "nil <-- nil"

I don't mind being your test runner, but I'm a bit slow for a CI
system;). We also have a travis setup, so you could use that if you
like. Of course by default we'll get IRC notifications of your failures
unless you edit .travis.yml

Or of course you can/should get the tests running locally. I don't
recognize the problem description. It might be related to missing test
prereqs. We depend on dtach which is less commonly installed.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Use `cl-lib' instead of deprecated `cl'

2020-04-17 Thread Jonas Bernoulli
David Bremner  writes:

> A quick git grep suggests there are still cl-isms in the test-harness.

I've fixed that now, see v2.

> I get 3 test failures

I am having issues running the tests.  Currently
notmuch-mua-send-and-exit in emacs_deliver_message from test-lib.sh
just hangs for me.  I haven't investigated further yet.  So I am
afraid you'll have to run the tests for me again.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Use `cl-lib' instead of deprecated `cl'

2020-04-17 Thread David Bremner
William Casarin  writes:

> From: Jonas Bernoulli 
>
> Starting with Emacs 27 the old `cl' implementation is finally
> considered obsolete.  Previously its use was strongly discouraged
> at run-time but one was still allowed to use it at compile-time.
>
> For the most part the transition is very simple and boils down to
> adding the "cl-" prefix to some symbols.  A few replacements do not
> follow that simple pattern; e.g. `first' is replaced with `car',
> even though the alias `cl-first' exists, because the latter is not
> idiomatic emacs-lisp.

I get 3 test failures

T310-emacs "Incremental parsing of search results"
   not sure what the error is here, it just reports nil
   
T450-emacs-show "Show handles subprocess errors"
  *ERROR*: Symbol’s function definition is void: second

T720-emacs-attachment-warnings: "  notmuch-test-attachment-warning part 1
  *ERROR*: Symbol’s function definition is void: loop

A quick git grep suggests there are still cl-isms in the test-harness.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: Use `cl-lib' instead of deprecated `cl'

2020-04-16 Thread William Casarin
From: Jonas Bernoulli 

Starting with Emacs 27 the old `cl' implementation is finally
considered obsolete.  Previously its use was strongly discouraged
at run-time but one was still allowed to use it at compile-time.

For the most part the transition is very simple and boils down to
adding the "cl-" prefix to some symbols.  A few replacements do not
follow that simple pattern; e.g. `first' is replaced with `car',
even though the alias `cl-first' exists, because the latter is not
idiomatic emacs-lisp.

In a few cases we start using `pcase-let' or `pcase-lambda' instead
of renaming e.g. `first' to `car'.  That way we can remind the reader
of the meaning of the various parts of the data that is being
deconstructed.

An obsolete `lexical-let' and a `lexical-let*' are replaced with their
regular variants `let' and `let*' even though we do not at the same
time enable `lexical-binding' for that file.  That is the right thing
to do because it does not actually make a difference in those cases
whether lexical bindings are used or not, and because this should be
enabled in a separate commit.

We need to explicitly depend on the `cl-lib' package because Emacs
24.1 and 24.2 lack that library.  When using these releases we end
up using the backport from GNU Elpa.

We need to explicitly require the `pcase' library because
`pcase-dolist' was not autoloaded until Emacs 25.1.
---

Thanks Jonas!

I couldn't get this patch to cleanly apply, so I've rebased it on master
for anyone who wants to test.

Cheers,
Will

 emacs/notmuch-company.el |   5 +-
 emacs/notmuch-draft.el   |   2 +-
 emacs/notmuch-hello.el   | 147 ++-
 emacs/notmuch-jump.el|  45 +--
 emacs/notmuch-lib.el |  18 ++---
 emacs/notmuch-maildir-fcc.el |  35 +
 emacs/notmuch-mua.el |  76 +-
 emacs/notmuch-parser.el  |  18 ++---
 emacs/notmuch-pkg.el.tmpl|   3 +-
 emacs/notmuch-show.el| 103 
 emacs/notmuch-tag.el |  45 ++-
 emacs/notmuch-tree.el|  20 ++---
 emacs/notmuch.el |  62 +++
 test/test-lib.el |   2 +-
 14 files changed, 292 insertions(+), 289 deletions(-)

diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index 3e12e7a9..ac998f9b 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -27,7 +27,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
+
 (require 'notmuch-lib)
 
 (defvar notmuch-company-last-prefix nil)
@@ -65,7 +66,7 @@
   (require 'company)
   (let ((case-fold-search t)
(completion-ignore-case t))
-(case command
+(cl-case command
   (interactive (company-begin-backend 'notmuch-company))
   (prefix (and (derived-mode-p 'message-mode)
   (looking-back (concat 
notmuch-address-completion-headers-regexp ".*")
diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index e22e0d16..504b33be 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -152,7 +152,7 @@ Used when a new version is saved, or the message is sent."
   "Checks if we should save a message that should be encrypted.
 
 `notmuch-draft-save-plaintext' controls the behaviour."
-  (case notmuch-draft-save-plaintext
+  (cl-case notmuch-draft-save-plaintext
((ask)
 (unless (yes-or-no-p "(Customize `notmuch-draft-save-plaintext' to 
avoid this warning)
 This message contains mml tags that suggest it is intended to be encrypted.
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index ab6ee798..bdf584e6 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -21,7 +21,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
+
 (require 'widget)
 (require 'wid-edit) ; For `widget-forward'.
 
@@ -47,17 +48,19 @@ lists (NAME QUERY COUNT-QUERY)."
((keywordp (car saved-search))
 (plist-get saved-search field))
;; It is not a plist so it is an old-style entry.
-   ((consp (cdr saved-search)) ;; It is a list (NAME QUERY COUNT-QUERY)
-(case field
-  (:name (first saved-search))
-  (:query (second saved-search))
-  (:count-query (third saved-search))
-  (t nil)))
-   (t  ;; It is a cons-cell (NAME . QUERY)
-(case field
-  (:name (car saved-search))
-  (:query (cdr saved-search))
-  (t nil)
+   ((consp (cdr saved-search))
+(pcase-let ((`(,name ,query ,count-query) saved-search))
+  (cl-case field
+   (:name name)
+   (:query query)
+   (:count-query count-query)
+   (t nil
+   (t
+(pcase-let ((`(,name . ,query) saved-search))
+  (cl-case field
+   (:name name)
+   (:query query)
+   (t nil))
 
 (defun notmuch-hello-saved-search-to-plist (saved-search)
   "Return a copy of SAVED-SEARCH in plist form.
@@ -66,7 +69,7 @@ If saved search is a plist then just return a copy. In other
 cases, for backwards