Re: [PATCH] devel/emacs: add devel/try-emacs-mua.sh

2015-11-12 Thread Mark Walters

> devel/try-emacs-mua.sh provides an easy way to try and experiment with
> the notmuch emacs client provided in emacs subdirectory of notmuch
> source tree.
>
> User is required to choose whether to run emacs with -q, -Q or neither
> -- and experienced ones may add other command line options, like
> '-f notmuch'.
>
> This script ensures that no .el files are newer than corresponding .elc
> files so that user (/developer!) does not accidentally experiment with
> outdated elisp files. The emacs variable to have the same effect,
> `load-prefer-newer' is not available until emacs 24.4.
>
> The *scratch* buffer is filled with some code user can execute before
> running notmuch code.

I like this -- a nice simple way to get to a working but uncustomised
test environment.

I don't know how easy the following would be but one addition that I
would find very useful would be a way to make this use the test
corpus. This would be useful for giving a completely standard
environment for interactive testing, but also for debugging what is
going on when tests fail.

Of course that is a feature request and should not delay the feature.

Finally, I think there is a bug: 


> ---
>
> Addressed David's comments in id:87d1xdtim1@maritornes.cs.unb.ca
> with 2 updates:
>  1) removed "address completion insinuate"
>  2) added code to initialize package system when using -q or -Q
>
>  devel/try-emacs-mua.sh | 92 
> ++
>  1 file changed, 92 insertions(+)
>  create mode 100755 devel/try-emacs-mua.sh
>
> diff --git a/devel/try-emacs-mua.sh b/devel/try-emacs-mua.sh
> new file mode 100755
> index ..71be152c2346
> --- /dev/null
> +++ b/devel/try-emacs-mua.sh
> @@ -0,0 +1,92 @@
> +#!/bin/sh
> +
> +# This script provides an easy way to try and experiment with the
> +# notmuch emacs client provided in notmuch/emacs directory.
> +
> +set -eu
> +
> +test $# -gt 0 || {
> + exec >&2
> + echo
> + echo "Usage: $0 '' | q | Q [other-emacs-args]"
> + echo
> + printf "  $0 %s\n" "'' starts emacs without either -q or -Q option" \
> + "q  starts emacs with -q" \
> + "Q  starts emacs with -Q"
> + echo
> + echo Note that if there are notmuch-emacs .elc files that are older than
> + echo their corresponding .el files those older .elcs will be removed.
> + echo
> + exit 1
> +}
> +
> +case $1 in '') opt=
> + ;; q | -q) opt=-q
> + ;; Q | -Q) opt=-Q
> + ;; *) echo "option '$1' not '', 'q' nor 'Q'" >&2; exit 1
> +esac
> +shift
> +
> +case $0 in
> + *\"*)   echo "'$0' contain one or more '\"'s" >&2; exit 1 ;;
> + */*)d0=${0%/*} ;;
> + *)  d0=.
> +esac
> +
> +pwd=$PWD
> +cd "$d0/.."
> +nmd=$PWD
> +emd=$PWD/emacs
> +
> +test -f "$nmd"/emacs/notmuch-lib.el || {
> + echo "Cannot find notmuch-emacs source directory"
> + exit 1
> +}
> +
> +if test -x "$nmd"/notmuch
> +then
> + nmin='
> +To use accompanied notmuch binary from the same source, evaluate
> +(setq exec-path (cons \"'"$nmd"'\" exec-path))
> +Note: Evaluating the above may be followed by unintended database
> +upgrade and getting back to old version may require dump & restore.
> +'
> +else
> + nmin=
> +fi
> +
> +if test "$opt" = '-q' || test "$opt" = '-Q'
> +then
> + pkgin='
> +If you want to use packages (like company from elpa) evaluate
> +(progn (require '\''package) (package-initialize))
> +'
> +else
> + pkgin=
> +fi

As far as I can see at this point we are in $nmd not $emd so the
following does not delete stale .elc files.

> +
> +# ensure we don't load .elc files that are older than corresponding .el file
> +# the emacs variable `load-prefer-newer' is not available until emacs 24.4
> +perl -e 'use strict; use warnings;
> +while (<*.elc>) {
> + my $elc = $_; s/elc$/el/;
> + if (-M $_ < -M $elc) {
> + warn "$_ is newer than $elc. Removing $elc\n";
> + unlink $elc or die "Failed to remove '\''$elc'\'': $!\n";
> + }
> +}'


Best wishes

Mark

> +
> +cd "$pwd"
> +
> +# note: whitespace in $EMACS splits to command and args
> +exec ${EMACS:-emacs} $opt -L "$emd" -l "$emd"/notmuch.el "$@" --eval '
> +(with-current-buffer "*scratch*"
> +  (insert "
> +Go to the end of the following lines and type C-x C-e to evaluate
> +(or C-j which is shorter but inserts evaluation results into buffer)
> +
> +To \"disable\" mail sending, evaluate
> +(setq message-send-mail-function (lambda () t))
> +'"$nmin$pkgin"'
> +To start notmuch (hello) screen, evaluate
> +(notmuch-hello)") (set-buffer-modified-p nil))'
> -- 
> 2.0.0
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] devel/emacs: add devel/try-emacs-mua.sh

2015-11-12 Thread Tomi Ollila
On Thu, Nov 12 2015, Mark Walters  wrote:

>> devel/try-emacs-mua.sh provides an easy way to try and experiment with
>> the notmuch emacs client provided in emacs subdirectory of notmuch
>> source tree.
>>
>> User is required to choose whether to run emacs with -q, -Q or neither
>> -- and experienced ones may add other command line options, like
>> '-f notmuch'.
>>
>> This script ensures that no .el files are newer than corresponding .elc
>> files so that user (/developer!) does not accidentally experiment with
>> outdated elisp files. The emacs variable to have the same effect,
>> `load-prefer-newer' is not available until emacs 24.4.
>>
>> The *scratch* buffer is filled with some code user can execute before
>> running notmuch code.
>
> I like this -- a nice simple way to get to a working but uncustomised
> test environment.
>
> I don't know how easy the following would be but one addition that I
> would find very useful would be a way to make this use the test
> corpus. This would be useful for giving a completely standard
> environment for interactive testing, but also for debugging what is
> going on when tests fail.
>
> Of course that is a feature request and should not delay the feature.
>
> Finally, I think there is a bug: 
>
>
>> ---
>>
>> Addressed David's comments in id:87d1xdtim1@maritornes.cs.unb.ca
>> with 2 updates:
>>  1) removed "address completion insinuate"
>>  2) added code to initialize package system when using -q or -Q
>>
>>  devel/try-emacs-mua.sh | 92 
>> ++
>>  1 file changed, 92 insertions(+)
>>  create mode 100755 devel/try-emacs-mua.sh
>>
>> diff --git a/devel/try-emacs-mua.sh b/devel/try-emacs-mua.sh
>> new file mode 100755
>> index ..71be152c2346
>> --- /dev/null
>> +++ b/devel/try-emacs-mua.sh
>> @@ -0,0 +1,92 @@
>> +#!/bin/sh
>> +
>> +# This script provides an easy way to try and experiment with the
>> +# notmuch emacs client provided in notmuch/emacs directory.
>> +
>> +set -eu
>> +
>> +test $# -gt 0 || {
>> +exec >&2
>> +echo
>> +echo "Usage: $0 '' | q | Q [other-emacs-args]"
>> +echo
>> +printf "  $0 %s\n" "'' starts emacs without either -q or -Q option" \
>> +"q  starts emacs with -q" \
>> +"Q  starts emacs with -Q"
>> +echo
>> +echo Note that if there are notmuch-emacs .elc files that are older than
>> +echo their corresponding .el files those older .elcs will be removed.
>> +echo
>> +exit 1
>> +}
>> +
>> +case $1 in '') opt=
>> +;; q | -q) opt=-q
>> +;; Q | -Q) opt=-Q
>> +;; *) echo "option '$1' not '', 'q' nor 'Q'" >&2; exit 1
>> +esac
>> +shift
>> +
>> +case $0 in
>> +*\"*)   echo "'$0' contain one or more '\"'s" >&2; exit 1 ;;
>> +*/*)d0=${0%/*} ;;
>> +*)  d0=.
>> +esac
>> +
>> +pwd=$PWD
>> +cd "$d0/.."
>> +nmd=$PWD
>> +emd=$PWD/emacs
>> +
>> +test -f "$nmd"/emacs/notmuch-lib.el || {
>> +echo "Cannot find notmuch-emacs source directory"
>> +exit 1
>> +}
>> +
>> +if test -x "$nmd"/notmuch
>> +then
>> +nmin='
>> +To use accompanied notmuch binary from the same source, evaluate
>> +(setq exec-path (cons \"'"$nmd"'\" exec-path))
>> +Note: Evaluating the above may be followed by unintended database
>> +upgrade and getting back to old version may require dump & restore.
>> +'
>> +else
>> +nmin=
>> +fi
>> +
>> +if test "$opt" = '-q' || test "$opt" = '-Q'
>> +then
>> +pkgin='
>> +If you want to use packages (like company from elpa) evaluate
>> +(progn (require '\''package) (package-initialize))
>> +'
>> +else
>> +pkgin=
>> +fi
>
> As far as I can see at this point we are in $nmd not $emd so the
> following does not delete stale .elc files.

It sure doesn't! Thanks for the review.

Tomi


>
>> +
>> +# ensure we don't load .elc files that are older than corresponding .el file
>> +# the emacs variable `load-prefer-newer' is not available until emacs 24.4
>> +perl -e 'use strict; use warnings;
>> +while (<*.elc>) {
>> +my $elc = $_; s/elc$/el/;
>> +if (-M $_ < -M $elc) {
>> +warn "$_ is newer than $elc. Removing $elc\n";
>> +unlink $elc or die "Failed to remove '\''$elc'\'': $!\n";
>> +}
>> +}'
>
>
> Best wishes
>
> Mark
>
>> +
>> +cd "$pwd"
>> +
>> +# note: whitespace in $EMACS splits to command and args
>> +exec ${EMACS:-emacs} $opt -L "$emd" -l "$emd"/notmuch.el "$@" --eval '
>> +(with-current-buffer "*scratch*"
>> +  (insert "
>> +Go to the end of the following lines and type C-x C-e to evaluate
>> +(or C-j which is shorter but inserts evaluation results into buffer)
>> +
>> +To \"disable\" mail sending, evaluate
>> +(setq message-send-mail-function (lambda () t))
>> +'"$nmin$pkgin"'
>> +To start notmuch (hello) screen, evaluate
>> +(notmuch-hello)") (set-buffer-modified-p nil))'
>> -- 
>> 2.0.0
>>
>> ___
>> notmuch mailing list
>> notmuch@notmuchmail.org
>> 

[PATCH] emacs: hello: fix accidental modification of widget-keymap

2015-11-12 Thread Mark Walters
In emacs24 we use make-composed-keymap. It seems that if only a single
map is specified then emacs just resuses it rather than creating a
copy of it. Thus use make-sparse-keymap to force a copy.
---

pseudomyne and the diredful author thamer found that we modify
widget-keymap in notmuch. We clearly don't want to, and I think we
tried not to, but emacs was being clever and reused the old keymap
rather than creating a new one.

Anyway the following patch seems to work, and if the user modifies
widget-keymap deliberately then it does get inherited by notmuch-hello
(which was the point of make-composed-keymap rather than just
copy-keymap in the first place).

The bug only occurs in emacs24. I essentially only use emacs23 so it
has not been tested much.

Best wishes

Mark




 emacs/notmuch-hello.el | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 8bde808..b42e0f2 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -652,8 +652,12 @@ with `notmuch-hello-query-counts'."
 
 (defvar notmuch-hello-mode-map
   (let ((map (if (fboundp 'make-composed-keymap)
-;; Inherit both widget-keymap and notmuch-common-keymap
-(make-composed-keymap widget-keymap)
+;; Inherit both widget-keymap and
+;; notmuch-common-keymap. We have to use
+;; make-sparse-keymap to force this to be a new
+;; keymap (so that when we modify map it does not
+;; modify widget-keymap).
+(make-composed-keymap (list (make-sparse-keymap) 
widget-keymap))
   ;; Before Emacs 24, keymaps didn't support multiple
   ;; inheritance,, so just copy the widget keymap since
   ;; it's unlikely to change.
-- 
2.1.4

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


Re: weird paths in notmuch database

2015-11-12 Thread Davide Mancusi
2015-11-06 16:37 GMT+01:00 Davide Mancusi :
> 2015-11-06 16:34 GMT+01:00 Tomi Ollila :
>> Ah, so path 
>> /export/home/username/mail//home/username/local/mail/archive/cur/1446805732.2711_9.hostname:2,S
>>
>> does not exist? It probably used to be (?) (via some long-gone symlink?)
>> and now it is just garbage in the database (that does not go away)...?
>
> No, it never existed. I'm positive about that.
>
> ...however, I just noticed that my muttrc config contains
>
> set folder="/home/username/local/mail"
>
> Maybe mutt-kz is screwing up things when it calls notmuch internally?

For the record, I ended up dumping and restoring the database. That
got me rid of the non-existing paths.

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