[PATCH 1/1] devel/release-checks.sh: check NOTMUCH_(MAJOR|MINOR|MICRO)_VERSION

2013-11-08 Thread David Bremner
Tomi Ollila  writes:

> New defines NOTMUCH_MAJOR_VERSION, NOTMUCH_MINOR_VERSION and
> NOTMUCH_MICRO_VERSION were added to lib/notmuch.h.
> Check that these match the current value defined in ./version.

This seems OK to me. And in worse case it can't break anything too
important.

d


[PATCH v2 00/11] Fix search tagging races

2013-11-08 Thread David Bremner
Austin Clements  writes:

> This is v2 of id:1381185201-25197-1-git-send-email-amdragon at mit.edu.
> It fixes several comments from Mark and Jani.  This has been rebased
> on top of the tag completion changes, so doing * from a large search
> buffer will no longer crash.  Hence, this series depends on the
> (currently pending) series in
> id:1382487721-31776-1-git-send-email-amdragon at mit.edu.
>

pushed.

d


[PATCH 1/1] devel/release-checks.sh: check NOTMUCH_(MAJOR|MINOR|MICRO)_VERSION

2013-11-08 Thread Tomi Ollila
New defines NOTMUCH_MAJOR_VERSION, NOTMUCH_MINOR_VERSION and
NOTMUCH_MICRO_VERSION were added to lib/notmuch.h.
Check that these match the current value defined in ./version.
---
 devel/release-checks.sh | 36 
 1 file changed, 36 insertions(+)

diff --git a/devel/release-checks.sh b/devel/release-checks.sh
index 4eff1a7..d6410ad 100755
--- a/devel/release-checks.sh
+++ b/devel/release-checks.sh
@@ -13,6 +13,8 @@ fi
 set -o posix
 set -o pipefail # bash feature

+readonly DEFAULT_IFS="$IFS" # Note: In this particular case quotes are needed.
+
 # Avoid locale-specific differences in output of executed commands
 LANG=C LC_ALL=C; export LANG LC_ALL

@@ -20,8 +22,10 @@ readonly PV_FILE='bindings/python/notmuch/version.py'

 # Using array here turned out to be unnecessarily complicated
 emsgs=''
+emsg_count=0
 append_emsg ()
 {
+   emsg_count=$((emsg_count + 1))
emsgs="${emsgs:+$emsgs\n}  $1"
 }

@@ -73,6 +77,38 @@ case $VERSION in
*)  verfail "'$VERSION' is a single number" ;;
 esac

+_set_version_components ()
+{
+   VERSION_MAJOR=$1
+   VERSION_MINOR=$2
+   VERSION_MICRO=${3:-0} # set to 0 in case $3 is unset or "null" (string)
+}
+
+IFS=.
+_set_version_components $VERSION
+IFS=$DEFAULT_IFS
+
+echo -n "Checking that libnotmuch version macros match $VERSION... "
+NOTMUCH_MAJOR_VERSION=broken
+NOTMUCH_MINOR_VERSION=broken
+NOTMUCH_MICRO_VERSION=broken
+eval `awk 'NF == 3 && $1 == "#define" && $2 ~ /^NOTMUCH_[A-Z]+_VERSION$/ \
+   && $3 ~ /^[0-9]+$/ { print $2 "=" $3 }' lib/notmuch.h`
+
+check_version_component ()
+{
+   eval local v1=\$VERSION_$1
+   eval local v2=\$NOTMUCH_$1_VERSION
+   if [ $v1 != $v2 ]
+   thenappend_emsg "NOTMUCH_$1_VERSION is defined as '$v2' in 
lib/notmuch.h instead of '$v1'"
+   fi
+}
+
+old_emsg_count=$emsg_count
+check_version_component MAJOR
+check_version_component MINOR
+check_version_component MICRO
+[ $old_emsg_count = $emsg_count ] && echo Yes. || echo No.

 echo -n "Checking that this is Debian package for notmuch... "
 read deb_notmuch deb_version rest < debian/changelog
-- 
1.8.0



[PATCH v3 7/7] emacs: help: base-keymap-test-help

2013-11-08 Thread Mark Walters
Add an argument to notmuch-help for the mode to display help for.
This aids testing of the base-keymap case in remapping in emacs help.

It is only intended for testing, ie not for master (but it does no harm)
---
 emacs/notmuch-lib.el |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 4b3a86e..7b8acb3 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -316,7 +316,7 @@ prefix argument.  PREFIX and TAIL are used internally."
   (setq beg (match-end 0)))
 doc))

-(defun notmuch-help ()
+(defun notmuch-help ( mode)
   "Display help for the current notmuch mode.

 This is similar to `describe-function' for the current major
@@ -328,7 +328,7 @@ A command that supports a prefix argument can explicitly 
document
 its prefixed behavior by setting the 'notmuch-prefix-doc property
 of its command symbol."
   (interactive)
-  (let* ((mode major-mode)
+  (let* ((mode (or mode major-mode))
 (doc (substitute-command-keys (notmuch-substitute-command-keys 
(documentation mode t)
 (with-current-buffer (generate-new-buffer "*notmuch-help*")
   (insert doc)
-- 
1.7.9.1



[PATCH v3 6/7] emacs: tree: use remap for the over-ridden global bindings

2013-11-08 Thread Mark Walters
Following a suggestion by Austin in id:20130915153642.GY1426 at mit.edu
we use remap for the over-riding bindings in pick. This means that if
the user modifies the global keymap these modifications will happen in
the tree-view versions of them too.

[tree-view overrides these to do things like close the message pane
before doing the action, so the functionality is very close to the
original common keymap function.]
---
 emacs/notmuch-tree.el |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index f13b41f..8d59e65 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -220,13 +220,13 @@ FUNC."
 (set-keymap-parent map notmuch-common-keymap)
 ;; The following override the global keymap.
 ;; Override because we want to close message pane first.
-(define-key map "?" (notmuch-tree-close-message-pane-and #'notmuch-help))
+(define-key map [remap notmuch-help] (notmuch-tree-close-message-pane-and 
#'notmuch-help))
 ;; Override because we first close message pane and then close tree buffer.
-(define-key map "q" 'notmuch-tree-quit)
+(define-key map [remap notmuch-kill-this-buffer] 'notmuch-tree-quit)
 ;; Override because we close message pane after the search query is 
entered.
-(define-key map "s" 'notmuch-tree-to-search)
+(define-key map [remap notmuch-search] 'notmuch-tree-to-search)
 ;; Override because we want to close message pane first.
-(define-key map "m" (notmuch-tree-close-message-pane-and 
#'notmuch-mua-new-mail))
+(define-key map [remap notmuch-mua-new-mail] 
(notmuch-tree-close-message-pane-and #'notmuch-mua-new-mail))

 ;; these use notmuch-show functions directly
 (define-key map "|" 'notmuch-show-pipe-message)
-- 
1.7.9.1



[PATCH v3 5/7] emacs: help: add a special function to deal with remaps

2013-11-08 Thread Mark Walters
remaps are a rather unusual keymap consisting of "first key" 'remap
and then "second-key" the remapped-function. Thus we do the
documentation for it separately.
---
 emacs/notmuch-lib.el |   22 --
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index a4f481b..4b3a86e 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -261,6 +261,21 @@ It does not prepend if ACTUAL-KEY is already listed in 
TAIL."
tail)))
 tail)

+(defun notmuch-describe-remaps (remap-keymap ua-keys base-keymap prefix tail)
+  ;; Remappings are represented as a binding whose first "event" is
+  ;; 'remap.  Hence, if the keymap has any remappings, it will have a
+  ;; binding whose "key" is 'remap, and whose "binding" is itself a
+  ;; keymap that maps not from keys to commands, but from old (remapped)
+  ;; functions to the commands to use in their stead.
+  (map-keymap
+   (lambda (command binding)
+ (mapc
+  (lambda (actual-key)
+   (setq tail (notmuch-describe-key actual-key binding prefix ua-keys 
tail)))
+  (where-is-internal command base-keymap)))
+   remap-keymap)
+  tail)
+
 (defun notmuch-describe-keymap (keymap ua-keys base-keymap  prefix 
tail)
   "Return a list of cons cells, each describing one binding in KEYMAP.

@@ -277,8 +292,11 @@ prefix argument.  PREFIX and TAIL are used internally."
  (cond ((mouse-event-p key) nil)
   ((keymapp binding)
(setq tail
- (notmuch-describe-keymap
-  binding ua-keys base-keymap (notmuch-prefix-key-description 
key) tail)))
+ (if (eq key 'remap)
+ (notmuch-describe-remaps
+  binding ua-keys base-keymap prefix tail)
+   (notmuch-describe-keymap
+binding ua-keys base-keymap 
(notmuch-prefix-key-description key) tail
   (binding
(setq tail (notmuch-describe-key (vector key) binding prefix 
ua-keys tail)
keymap)
-- 
1.7.9.1



[PATCH v3 4/7] emacs: help: add base-keymap

2013-11-08 Thread Mark Walters
To support key remapping in emacs help we need to know the base keymap
when looking at the remapping. keep track of this while we recurse
down the sub-keymaps in help.
---
 emacs/notmuch-lib.el |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 8852703..a4f481b 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -261,7 +261,7 @@ It does not prepend if ACTUAL-KEY is already listed in 
TAIL."
tail)))
 tail)

-(defun notmuch-describe-keymap (keymap ua-keys  prefix tail)
+(defun notmuch-describe-keymap (keymap ua-keys base-keymap  prefix 
tail)
   "Return a list of cons cells, each describing one binding in KEYMAP.

 Each cons cell consists of a string giving a human-readable
@@ -278,7 +278,7 @@ prefix argument.  PREFIX and TAIL are used internally."
   ((keymapp binding)
(setq tail
  (notmuch-describe-keymap
-  binding ua-keys (notmuch-prefix-key-description key) tail)))
+  binding ua-keys base-keymap (notmuch-prefix-key-description 
key) tail)))
   (binding
(setq tail (notmuch-describe-key (vector key) binding prefix 
ua-keys tail)
keymap)
@@ -291,7 +291,7 @@ prefix argument.  PREFIX and TAIL are used internally."
   (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
 (keymap (symbol-value (intern keymap-name)))
 (ua-keys (where-is-internal 'universal-argument keymap t))
-(desc-alist (notmuch-describe-keymap keymap ua-keys))
+(desc-alist (notmuch-describe-keymap keymap ua-keys keymap))
 (desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr 
arg))) desc-alist))
 (desc (mapconcat #'identity desc-list "\n")))
(setq doc (replace-match desc 1 1 doc)))
-- 
1.7.9.1



[PATCH v3 3/7] emacs: help: split out notmuch-describe-key as a function

2013-11-08 Thread Mark Walters
The actual documentation function notmuch-describe-keymap was getting
rather complicated so split out the code for a single key into its own
function notmuch-describe-key.
---
 emacs/notmuch-lib.el |   42 +-
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 2195166..8852703 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -237,6 +237,30 @@ This is basically just `format-kbd-macro' but we also 
convert ESC to M-."
"M-"
   (concat desc " "

+
+(defun notmuch-describe-key (actual-key binding prefix ua-keys tail)
+  "Prepend cons cells describing prefix-arg ACTUAL-KEY and ACTUAL-KEY to TAIL
+
+It does not prepend if ACTUAL-KEY is already listed in TAIL."
+  (let ((key-string (concat prefix (format-kbd-macro actual-key
+;; We don't include documentation if the key-binding is
+;; over-ridden. Note, over-riding a binding automatically hides the
+;; prefixed version too.
+(unless (assoc key-string tail)
+  (when (and ua-keys (symbolp binding)
+(get binding 'notmuch-prefix-doc))
+   ;; Documentation for prefixed command
+   (let ((ua-desc (key-description ua-keys)))
+ (push (cons (concat ua-desc " " prefix (format-kbd-macro actual-key))
+ (get binding 'notmuch-prefix-doc))
+   tail)))
+  ;; Documentation for command
+  (push (cons key-string
+ (or (and (symbolp binding) (get binding 'notmuch-doc))
+ (notmuch-documentation-first-line binding)))
+   tail)))
+tail)
+
 (defun notmuch-describe-keymap (keymap ua-keys  prefix tail)
   "Return a list of cons cells, each describing one binding in KEYMAP.

@@ -256,23 +280,7 @@ prefix argument.  PREFIX and TAIL are used internally."
  (notmuch-describe-keymap
   binding ua-keys (notmuch-prefix-key-description key) tail)))
   (binding
-   (let ((key-string (concat prefix (format-kbd-macro (vector key)
- ;; We don't include documentation if the key-binding is
- ;; over-ridden. Note, over-riding a binding
- ;; automatically hides the prefixed version too.
- (unless (assoc key-string tail)
-   (when (and ua-keys (symbolp binding)
-  (get binding 'notmuch-prefix-doc))
- ;; Documentation for prefixed command
- (let ((ua-desc (key-description ua-keys)))
-   (push (cons (concat ua-desc " " prefix (format-kbd-macro 
(vector key)))
-   (get binding 'notmuch-prefix-doc))
- tail)))
-   ;; Documentation for command
-   (push (cons key-string
-   (or (and (symbolp binding) (get binding 
'notmuch-doc))
-   (notmuch-documentation-first-line binding)))
- tail))
+   (setq tail (notmuch-describe-key (vector key) binding prefix 
ua-keys tail)
keymap)
   tail)

-- 
1.7.9.1



[PATCH v3 2/7] emacs: help: remove duplicate bindings

2013-11-08 Thread Mark Walters
If the user (or a mode) overrides a keybinding from the common keymap
in one of the modes then both help lines appear in the help screen
even though only one of them is applicable.

Fix this by checking if we already have that key binding. We do this
by constructing an list of (key . docstring) pairs so it is easy to
check if we have already had that binding. Then the actual print help
routine changes these pairs into strings "key \t docstring"
---
 emacs/notmuch-lib.el |   41 -
 1 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index ec5a2cb..2195166 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -238,11 +238,12 @@ This is basically just `format-kbd-macro' but we also 
convert ESC to M-."
   (concat desc " "

 (defun notmuch-describe-keymap (keymap ua-keys  prefix tail)
-  "Return a list of strings, each describing one binding in KEYMAP.
+  "Return a list of cons cells, each describing one binding in KEYMAP.

-Each string gives a human-readable description of the key and a
-one-line description of the bound function.  See `notmuch-help'
-for an overview of how this documentation is extracted.
+Each cons cell consists of a string giving a human-readable
+description of the key, and a one-line description of the bound
+function.  See `notmuch-help' for an overview of how this
+documentation is extracted.

 UA-KEYS should be a key sequence bound to `universal-argument'.
 It will be used to describe bindings of commands that support a
@@ -255,18 +256,23 @@ prefix argument.  PREFIX and TAIL are used internally."
  (notmuch-describe-keymap
   binding ua-keys (notmuch-prefix-key-description key) tail)))
   (binding
-   (when (and ua-keys (symbolp binding)
-  (get binding 'notmuch-prefix-doc))
- ;; Documentation for prefixed command
- (let ((ua-desc (key-description ua-keys)))
-   (push (concat ua-desc " " prefix (format-kbd-macro (vector key))
- "\t" (get binding 'notmuch-prefix-doc))
- tail)))
-   ;; Documentation for command
-   (push (concat prefix (format-kbd-macro (vector key)) "\t"
- (or (and (symbolp binding) (get binding 'notmuch-doc))
- (notmuch-documentation-first-line binding)))
- tail
+   (let ((key-string (concat prefix (format-kbd-macro (vector key)
+ ;; We don't include documentation if the key-binding is
+ ;; over-ridden. Note, over-riding a binding
+ ;; automatically hides the prefixed version too.
+ (unless (assoc key-string tail)
+   (when (and ua-keys (symbolp binding)
+  (get binding 'notmuch-prefix-doc))
+ ;; Documentation for prefixed command
+ (let ((ua-desc (key-description ua-keys)))
+   (push (cons (concat ua-desc " " prefix (format-kbd-macro 
(vector key)))
+   (get binding 'notmuch-prefix-doc))
+ tail)))
+   ;; Documentation for command
+   (push (cons key-string
+   (or (and (symbolp binding) (get binding 
'notmuch-doc))
+   (notmuch-documentation-first-line binding)))
+ tail))
keymap)
   tail)

@@ -277,7 +283,8 @@ prefix argument.  PREFIX and TAIL are used internally."
   (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
 (keymap (symbol-value (intern keymap-name)))
 (ua-keys (where-is-internal 'universal-argument keymap t))
-(desc-list (notmuch-describe-keymap keymap ua-keys))
+(desc-alist (notmuch-describe-keymap keymap ua-keys))
+(desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr 
arg))) desc-alist))
 (desc (mapconcat #'identity desc-list "\n")))
(setq doc (replace-match desc 1 1 doc)))
   (setq beg (match-end 0)))
-- 
1.7.9.1



[PATCH v3 1/7] emacs: help: check for nil key binding

2013-11-08 Thread Mark Walters
A standard way to unset a key binding is local-unset-key which is equivalent to
  (define-key (current-local-map) key nil)

Currently notmuch-help gives an error and fails if a user has done this.

To fix this we only add a help line if the binding is non-nil.
---
 emacs/notmuch-lib.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 921ed20..ec5a2cb 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -254,7 +254,7 @@ prefix argument.  PREFIX and TAIL are used internally."
(setq tail
  (notmuch-describe-keymap
   binding ua-keys (notmuch-prefix-key-description key) tail)))
-  (t
+  (binding
(when (and ua-keys (symbolp binding)
   (get binding 'notmuch-prefix-doc))
  ;; Documentation for prefixed command
-- 
1.7.9.1



[PATCH v3 0/7] emacs: help: remap keybindings

2013-11-08 Thread Mark Walters
This is version 3 of the series. v2 is at
id:1383870096-14627-1-git-send-email-markwalters1009 at gmail.com

The changes are in response to Austin's review of v2. I have not
changed notmuch-describe-key.

The other change is to add a base-keymap to look up the remapped
commands in (since notmuch-substitute-command-keys could refer to
something other than the current keymap). Currently this never happens
but this makes the code more robust.

The final patch of the series is (probably) just for testing
purposes. It lets you call notmuch-help and specify which mode you
want to display help for. This means you can call it without having
the mode as current-mode and hence test the base-keymap code.

Finally the diff from v2 below (with the testing patch omitted) is below.

Best wishes

Mark

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index ef616d5..4b3a86e 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -261,7 +261,7 @@ It does not prepend if ACTUAL-KEY is already listed in 
TAIL."
tail)))
 tail)

-(defun notmuch-describe-remaps (remap-keymap ua-keys prefix tail)
+(defun notmuch-describe-remaps (remap-keymap ua-keys base-keymap prefix tail)
   ;; Remappings are represented as a binding whose first "event" is
   ;; 'remap.  Hence, if the keymap has any remappings, it will have a
   ;; binding whose "key" is 'remap, and whose "binding" is itself a
@@ -272,11 +272,11 @@ It does not prepend if ACTUAL-KEY is already listed in 
TAIL."
  (mapc
   (lambda (actual-key)
(setq tail (notmuch-describe-key actual-key binding prefix ua-keys 
tail)))
-  (where-is-internal command)))
+  (where-is-internal command base-keymap)))
remap-keymap)
   tail)

-(defun notmuch-describe-keymap (keymap ua-keys  prefix tail)
+(defun notmuch-describe-keymap (keymap ua-keys base-keymap  prefix 
tail)
   "Return a list of cons cells, each describing one binding in KEYMAP.

 Each cons cell consists of a string giving a human-readable
@@ -291,13 +291,12 @@ prefix argument.  PREFIX and TAIL are used internally."
(lambda (key binding)
  (cond ((mouse-event-p key) nil)
   ((keymapp binding)
-   (if (eq key 'remap)
-   (setq tail
+   (setq tail
+ (if (eq key 'remap)
  (notmuch-describe-remaps
-  binding ua-keys prefix tail))
- (setq tail
+  binding ua-keys base-keymap prefix tail)
(notmuch-describe-keymap
-binding ua-keys (notmuch-prefix-key-description key) 
tail
+binding ua-keys base-keymap 
(notmuch-prefix-key-description key) tail
   (binding
(setq tail (notmuch-describe-key (vector key) binding prefix 
ua-keys tail)
keymap)
@@ -310,7 +309,7 @@ prefix argument.  PREFIX and TAIL are used internally."
   (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
 (keymap (symbol-value (intern keymap-name)))
 (ua-keys (where-is-internal 'universal-argument keymap t))
-(desc-alist (notmuch-describe-keymap keymap ua-keys))
+(desc-alist (notmuch-describe-keymap keymap ua-keys keymap))
 (desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr 
arg))) desc-alist))
 (desc (mapconcat #'identity desc-list "\n")))
(setq doc (replace-match desc 1 1 doc)))



Mark Walters (7):
  emacs: help: check for nil key binding
  emacs: help: remove duplicate bindings
  emacs: help: split out notmuch-describe-key as a function
  emacs: help: add base-keymap
  emacs: help: add a special function to deal with remaps
  emacs: tree: use remap for the over-ridden global bindings
  emacs: help: base-keymap-test-help

 emacs/notmuch-lib.el  |   79 ++--
 emacs/notmuch-tree.el |8 ++--
 2 files changed, 60 insertions(+), 27 deletions(-)




-- 
1.7.9.1



[PATCH v3 0/7] emacs: help: remap keybindings

2013-11-08 Thread Austin Clements
LGTM.

Quoth Mark Walters on Nov 08 at  5:40 pm:
> This is version 3 of the series. v2 is at
> id:1383870096-14627-1-git-send-email-markwalters1009 at gmail.com
> 
> The changes are in response to Austin's review of v2. I have not
> changed notmuch-describe-key.
> 
> The other change is to add a base-keymap to look up the remapped
> commands in (since notmuch-substitute-command-keys could refer to
> something other than the current keymap). Currently this never happens
> but this makes the code more robust.
> 
> The final patch of the series is (probably) just for testing
> purposes. It lets you call notmuch-help and specify which mode you
> want to display help for. This means you can call it without having
> the mode as current-mode and hence test the base-keymap code.
> 
> Finally the diff from v2 below (with the testing patch omitted) is below.
> 
> Best wishes
> 
> Mark
> 
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index ef616d5..4b3a86e 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -261,7 +261,7 @@ It does not prepend if ACTUAL-KEY is already listed in 
> TAIL."
>   tail)))
>  tail)
>  
> -(defun notmuch-describe-remaps (remap-keymap ua-keys prefix tail)
> +(defun notmuch-describe-remaps (remap-keymap ua-keys base-keymap prefix tail)
>;; Remappings are represented as a binding whose first "event" is
>;; 'remap.  Hence, if the keymap has any remappings, it will have a
>;; binding whose "key" is 'remap, and whose "binding" is itself a
> @@ -272,11 +272,11 @@ It does not prepend if ACTUAL-KEY is already listed in 
> TAIL."
>   (mapc
>(lambda (actual-key)
>   (setq tail (notmuch-describe-key actual-key binding prefix ua-keys 
> tail)))
> -  (where-is-internal command)))
> +  (where-is-internal command base-keymap)))
> remap-keymap)
>tail)
>  
> -(defun notmuch-describe-keymap (keymap ua-keys  prefix tail)
> +(defun notmuch-describe-keymap (keymap ua-keys base-keymap  prefix 
> tail)
>"Return a list of cons cells, each describing one binding in KEYMAP.
>  
>  Each cons cell consists of a string giving a human-readable
> @@ -291,13 +291,12 @@ prefix argument.  PREFIX and TAIL are used internally."
> (lambda (key binding)
>   (cond ((mouse-event-p key) nil)
>  ((keymapp binding)
> - (if (eq key 'remap)
> - (setq tail
> + (setq tail
> +   (if (eq key 'remap)
> (notmuch-describe-remaps
> -binding ua-keys prefix tail))
> -   (setq tail
> +binding ua-keys base-keymap prefix tail)
>   (notmuch-describe-keymap
> -  binding ua-keys (notmuch-prefix-key-description key) 
> tail
> +  binding ua-keys base-keymap 
> (notmuch-prefix-key-description key) tail
>  (binding
>   (setq tail (notmuch-describe-key (vector key) binding prefix 
> ua-keys tail)
> keymap)
> @@ -310,7 +309,7 @@ prefix argument.  PREFIX and TAIL are used internally."
>(let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
>(keymap (symbol-value (intern keymap-name)))
>(ua-keys (where-is-internal 'universal-argument keymap t))
> -  (desc-alist (notmuch-describe-keymap keymap ua-keys))
> +  (desc-alist (notmuch-describe-keymap keymap ua-keys keymap))
>(desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr 
> arg))) desc-alist))
>(desc (mapconcat #'identity desc-list "\n")))
>   (setq doc (replace-match desc 1 1 doc)))
> 
> 
> 
> Mark Walters (7):
>   emacs: help: check for nil key binding
>   emacs: help: remove duplicate bindings
>   emacs: help: split out notmuch-describe-key as a function
>   emacs: help: add base-keymap
>   emacs: help: add a special function to deal with remaps
>   emacs: tree: use remap for the over-ridden global bindings
>   emacs: help: base-keymap-test-help
> 
>  emacs/notmuch-lib.el  |   79 ++--
>  emacs/notmuch-tree.el |8 ++--
>  2 files changed, 60 insertions(+), 27 deletions(-)


[PATCH 21/21] vim: add help file

2013-11-08 Thread David Bremner
Felipe Contreras  writes:
>
> You can probably check that it's working with this:
> % vim -c ":h notmuch"

It turns I needed to re-run 

   "vim-addon-manager install notmuch"

This might be a bit debian specific, but it's already documented as
needed for the initial install. It would probably be worth updating
debian/notmuch-vim.README.Debian to suggest running this on upgrade as
well.

Otherwise running :helptags wants write into /usr/share/vim/addons/doc,
which is naturally a bit tricky for a non-root user.



[PATCH 21/21] vim: add help file

2013-11-08 Thread Felipe Contreras
On Fri, Nov 8, 2013 at 12:03 PM, David Bremner  wrote:
> Felipe Contreras  writes:
>>
>> You can probably check that it's working with this:
>> % vim -c ":h notmuch"
>
> It turns I needed to re-run
>
>"vim-addon-manager install notmuch"
>
> This might be a bit debian specific, but it's already documented as
> needed for the initial install. It would probably be worth updating
> debian/notmuch-vim.README.Debian to suggest running this on upgrade as
> well.

Shouldn't this happen on a post update script or something?

-- 
Felipe Contreras


[PATCH 21/21] vim: add help file

2013-11-08 Thread David Bremner
Felipe Contreras  writes:

> Signed-off-by: Felipe Contreras 
> ---
>  debian/notmuch-vim.dirs|   1 +
>  debian/notmuch-vim.install |   1 +
>  vim/Makefile   |   1 +
>  vim/notmuch.txt| 153 
> +
>  vim/notmuch.yaml   |   1 +

I verified that these changes don't break the debian build.  FWIW, I
didn't manage to invoke the notmuch help within vim, but that's probably
just invimcompetence on my part.  Let me know if there is something
you'd like me to verify on the debian packages.

d


[PATCH 21/21] vim: add help file

2013-11-08 Thread Felipe Contreras
On Fri, Nov 8, 2013 at 6:43 AM, David Bremner  wrote:
> Felipe Contreras  writes:
>
>> Signed-off-by: Felipe Contreras 
>> ---
>>  debian/notmuch-vim.dirs|   1 +
>>  debian/notmuch-vim.install |   1 +
>>  vim/Makefile   |   1 +
>>  vim/notmuch.txt| 153 
>> +
>>  vim/notmuch.yaml   |   1 +
>
> I verified that these changes don't break the debian build.  FWIW, I
> didn't manage to invoke the notmuch help within vim, but that's probably
> just invimcompetence on my part.  Let me know if there is something
> you'd like me to verify on the debian packages.

You can probably check that it's working with this:
% vim -c ":h notmuch"

If that doesn't work, you might need to do this first:
% vim -c ':helptags /usr/share/vim/addons/doc' -c q

-- 
Felipe Contreras


[PATCH v2 5/5] emacs: tree: use remap for the over-ridden global bindings

2013-11-08 Thread Mark Walters
Following a suggestion by Austin in id:20130915153642.GY1426 at mit.edu
we use remap for the over-riding bindings in pick. This means that if
the user modifies the global keymap these modifications will happen in
the tree-view versions of them too.

[tree-view overrides these to do things like close the message pane
before doing the action, so the functionality is very close to the
original common keymap function.]
---
 emacs/notmuch-tree.el |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index f13b41f..8d59e65 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -220,13 +220,13 @@ FUNC."
 (set-keymap-parent map notmuch-common-keymap)
 ;; The following override the global keymap.
 ;; Override because we want to close message pane first.
-(define-key map "?" (notmuch-tree-close-message-pane-and #'notmuch-help))
+(define-key map [remap notmuch-help] (notmuch-tree-close-message-pane-and 
#'notmuch-help))
 ;; Override because we first close message pane and then close tree buffer.
-(define-key map "q" 'notmuch-tree-quit)
+(define-key map [remap notmuch-kill-this-buffer] 'notmuch-tree-quit)
 ;; Override because we close message pane after the search query is 
entered.
-(define-key map "s" 'notmuch-tree-to-search)
+(define-key map [remap notmuch-search] 'notmuch-tree-to-search)
 ;; Override because we want to close message pane first.
-(define-key map "m" (notmuch-tree-close-message-pane-and 
#'notmuch-mua-new-mail))
+(define-key map [remap notmuch-mua-new-mail] 
(notmuch-tree-close-message-pane-and #'notmuch-mua-new-mail))

 ;; these use notmuch-show functions directly
 (define-key map "|" 'notmuch-show-pipe-message)
-- 
1.7.9.1



[PATCH v2 4/5] emacs: help: add a special function to deal with remaps

2013-11-08 Thread Mark Walters
remaps are a rather unusual keymap consisting of "first key" 'remap
and then "second-key" the remapped-function. Thus we do the
documentation for it separately.
---
 emacs/notmuch-lib.el |   25 ++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 8852703..ef616d5 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -261,6 +261,21 @@ It does not prepend if ACTUAL-KEY is already listed in 
TAIL."
tail)))
 tail)

+(defun notmuch-describe-remaps (remap-keymap ua-keys prefix tail)
+  ;; Remappings are represented as a binding whose first "event" is
+  ;; 'remap.  Hence, if the keymap has any remappings, it will have a
+  ;; binding whose "key" is 'remap, and whose "binding" is itself a
+  ;; keymap that maps not from keys to commands, but from old (remapped)
+  ;; functions to the commands to use in their stead.
+  (map-keymap
+   (lambda (command binding)
+ (mapc
+  (lambda (actual-key)
+   (setq tail (notmuch-describe-key actual-key binding prefix ua-keys 
tail)))
+  (where-is-internal command)))
+   remap-keymap)
+  tail)
+
 (defun notmuch-describe-keymap (keymap ua-keys  prefix tail)
   "Return a list of cons cells, each describing one binding in KEYMAP.

@@ -276,9 +291,13 @@ prefix argument.  PREFIX and TAIL are used internally."
(lambda (key binding)
  (cond ((mouse-event-p key) nil)
   ((keymapp binding)
-   (setq tail
- (notmuch-describe-keymap
-  binding ua-keys (notmuch-prefix-key-description key) tail)))
+   (if (eq key 'remap)
+   (setq tail
+ (notmuch-describe-remaps
+  binding ua-keys prefix tail))
+ (setq tail
+   (notmuch-describe-keymap
+binding ua-keys (notmuch-prefix-key-description key) 
tail
   (binding
(setq tail (notmuch-describe-key (vector key) binding prefix 
ua-keys tail)
keymap)
-- 
1.7.9.1



[PATCH v2 3/5] emacs: help: split out notmuch-describe-key as a function

2013-11-08 Thread Mark Walters
The actual documentation function notmuch-describe-keymap was getting
rather complicated so split out the code for a single key into its own
function notmuch-describe-key.
---
 emacs/notmuch-lib.el |   42 +-
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 2195166..8852703 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -237,6 +237,30 @@ This is basically just `format-kbd-macro' but we also 
convert ESC to M-."
"M-"
   (concat desc " "

+
+(defun notmuch-describe-key (actual-key binding prefix ua-keys tail)
+  "Prepend cons cells describing prefix-arg ACTUAL-KEY and ACTUAL-KEY to TAIL
+
+It does not prepend if ACTUAL-KEY is already listed in TAIL."
+  (let ((key-string (concat prefix (format-kbd-macro actual-key
+;; We don't include documentation if the key-binding is
+;; over-ridden. Note, over-riding a binding automatically hides the
+;; prefixed version too.
+(unless (assoc key-string tail)
+  (when (and ua-keys (symbolp binding)
+(get binding 'notmuch-prefix-doc))
+   ;; Documentation for prefixed command
+   (let ((ua-desc (key-description ua-keys)))
+ (push (cons (concat ua-desc " " prefix (format-kbd-macro actual-key))
+ (get binding 'notmuch-prefix-doc))
+   tail)))
+  ;; Documentation for command
+  (push (cons key-string
+ (or (and (symbolp binding) (get binding 'notmuch-doc))
+ (notmuch-documentation-first-line binding)))
+   tail)))
+tail)
+
 (defun notmuch-describe-keymap (keymap ua-keys  prefix tail)
   "Return a list of cons cells, each describing one binding in KEYMAP.

@@ -256,23 +280,7 @@ prefix argument.  PREFIX and TAIL are used internally."
  (notmuch-describe-keymap
   binding ua-keys (notmuch-prefix-key-description key) tail)))
   (binding
-   (let ((key-string (concat prefix (format-kbd-macro (vector key)
- ;; We don't include documentation if the key-binding is
- ;; over-ridden. Note, over-riding a binding
- ;; automatically hides the prefixed version too.
- (unless (assoc key-string tail)
-   (when (and ua-keys (symbolp binding)
-  (get binding 'notmuch-prefix-doc))
- ;; Documentation for prefixed command
- (let ((ua-desc (key-description ua-keys)))
-   (push (cons (concat ua-desc " " prefix (format-kbd-macro 
(vector key)))
-   (get binding 'notmuch-prefix-doc))
- tail)))
-   ;; Documentation for command
-   (push (cons key-string
-   (or (and (symbolp binding) (get binding 
'notmuch-doc))
-   (notmuch-documentation-first-line binding)))
- tail))
+   (setq tail (notmuch-describe-key (vector key) binding prefix 
ua-keys tail)
keymap)
   tail)

-- 
1.7.9.1



[PATCH v2 2/5] emacs: help: remove duplicate bindings

2013-11-08 Thread Mark Walters
If the user (or a mode) overrides a keybinding from the common keymap
in one of the modes then both help lines appear in the help screen
even though only one of the is applicable.

Fix this by checking if we already have that key binding. We do this
by constructing an list of (key . docstring) pairs so it is easy to
check if we have already had that binding. Then the actual print help
routine changes these pairs into strings "key \t docstring"
---
 emacs/notmuch-lib.el |   41 -
 1 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index ec5a2cb..2195166 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -238,11 +238,12 @@ This is basically just `format-kbd-macro' but we also 
convert ESC to M-."
   (concat desc " "

 (defun notmuch-describe-keymap (keymap ua-keys  prefix tail)
-  "Return a list of strings, each describing one binding in KEYMAP.
+  "Return a list of cons cells, each describing one binding in KEYMAP.

-Each string gives a human-readable description of the key and a
-one-line description of the bound function.  See `notmuch-help'
-for an overview of how this documentation is extracted.
+Each cons cell consists of a string giving a human-readable
+description of the key, and a one-line description of the bound
+function.  See `notmuch-help' for an overview of how this
+documentation is extracted.

 UA-KEYS should be a key sequence bound to `universal-argument'.
 It will be used to describe bindings of commands that support a
@@ -255,18 +256,23 @@ prefix argument.  PREFIX and TAIL are used internally."
  (notmuch-describe-keymap
   binding ua-keys (notmuch-prefix-key-description key) tail)))
   (binding
-   (when (and ua-keys (symbolp binding)
-  (get binding 'notmuch-prefix-doc))
- ;; Documentation for prefixed command
- (let ((ua-desc (key-description ua-keys)))
-   (push (concat ua-desc " " prefix (format-kbd-macro (vector key))
- "\t" (get binding 'notmuch-prefix-doc))
- tail)))
-   ;; Documentation for command
-   (push (concat prefix (format-kbd-macro (vector key)) "\t"
- (or (and (symbolp binding) (get binding 'notmuch-doc))
- (notmuch-documentation-first-line binding)))
- tail
+   (let ((key-string (concat prefix (format-kbd-macro (vector key)
+ ;; We don't include documentation if the key-binding is
+ ;; over-ridden. Note, over-riding a binding
+ ;; automatically hides the prefixed version too.
+ (unless (assoc key-string tail)
+   (when (and ua-keys (symbolp binding)
+  (get binding 'notmuch-prefix-doc))
+ ;; Documentation for prefixed command
+ (let ((ua-desc (key-description ua-keys)))
+   (push (cons (concat ua-desc " " prefix (format-kbd-macro 
(vector key)))
+   (get binding 'notmuch-prefix-doc))
+ tail)))
+   ;; Documentation for command
+   (push (cons key-string
+   (or (and (symbolp binding) (get binding 
'notmuch-doc))
+   (notmuch-documentation-first-line binding)))
+ tail))
keymap)
   tail)

@@ -277,7 +283,8 @@ prefix argument.  PREFIX and TAIL are used internally."
   (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
 (keymap (symbol-value (intern keymap-name)))
 (ua-keys (where-is-internal 'universal-argument keymap t))
-(desc-list (notmuch-describe-keymap keymap ua-keys))
+(desc-alist (notmuch-describe-keymap keymap ua-keys))
+(desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr 
arg))) desc-alist))
 (desc (mapconcat #'identity desc-list "\n")))
(setq doc (replace-match desc 1 1 doc)))
   (setq beg (match-end 0)))
-- 
1.7.9.1



[PATCH v2 1/5] emacs: help: check for nil key binding

2013-11-08 Thread Mark Walters
A standard way to unset a key binding is local-unset-key which is equivalent to
  (define-key (current-local-map) key nil)

Currently notmuch-help gives an error and fails if a user has done this.

To fix this we only add a help line if the binding is non-nil.
---
 emacs/notmuch-lib.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 921ed20..ec5a2cb 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -254,7 +254,7 @@ prefix argument.  PREFIX and TAIL are used internally."
(setq tail
  (notmuch-describe-keymap
   binding ua-keys (notmuch-prefix-key-description key) tail)))
-  (t
+  (binding
(when (and ua-keys (symbolp binding)
   (get binding 'notmuch-prefix-doc))
  ;; Documentation for prefixed command
-- 
1.7.9.1



[PATCH v2 0/5] emacs: help: and remap keybindings

2013-11-08 Thread Mark Walters
This is version 2 of the series 
id:1382821479-23384-1-git-send-email-markwalters1009 at gmail.com

It fixes most of the comments Austin raised in his review. 

The first patch is now trivial and fixes a bug with unset keys in
help. (This is Austin's solution which is obviously better than mine
was)

The second patch is unchanged. The third patch is new and just
separates out a helper function. This will make the remapping help
code clearer, but is probably good in its own right.

The fourth patch deals with help for the remapping case. It is
completely separate from the main help so does not clutter it up like
it did before. The logic is slightly different from before: it now
puts all remapped bindings in rather than just the first (if the
command being remapped was bound to multiple keys).

The fifth patch adds remappings to tree and is unchanged.

It does not address Austin's query about passing down the base keymap
for the remapping.

Best wishes

Mark


Mark Walters (5):
  emacs: help: check for nil key binding
  emacs: help: remove duplicate bindings
  emacs: help: split out notmuch-describe-key as a function
  emacs: help: add a special function to deal with remaps
  emacs: tree: use remap for the over-ridden global bindings

 emacs/notmuch-lib.el  |   76 +++-
 emacs/notmuch-tree.el |8 ++--
 2 files changed, 59 insertions(+), 25 deletions(-)

-- 
1.7.9.1



Re: [PATCH 21/21] vim: add help file

2013-11-08 Thread David Bremner
Felipe Contreras felipe.contre...@gmail.com writes:

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
  debian/notmuch-vim.dirs|   1 +
  debian/notmuch-vim.install |   1 +
  vim/Makefile   |   1 +
  vim/notmuch.txt| 153 
 +
  vim/notmuch.yaml   |   1 +

I verified that these changes don't break the debian build.  FWIW, I
didn't manage to invoke the notmuch help within vim, but that's probably
just invimcompetence on my part.  Let me know if there is something
you'd like me to verify on the debian packages.

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


Re: [PATCH 21/21] vim: add help file

2013-11-08 Thread Felipe Contreras
On Fri, Nov 8, 2013 at 6:43 AM, David Bremner da...@tethera.net wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
  debian/notmuch-vim.dirs|   1 +
  debian/notmuch-vim.install |   1 +
  vim/Makefile   |   1 +
  vim/notmuch.txt| 153 
 +
  vim/notmuch.yaml   |   1 +

 I verified that these changes don't break the debian build.  FWIW, I
 didn't manage to invoke the notmuch help within vim, but that's probably
 just invimcompetence on my part.  Let me know if there is something
 you'd like me to verify on the debian packages.

You can probably check that it's working with this:
% vim -c :h notmuch

If that doesn't work, you might need to do this first:
% vim -c ':helptags /usr/share/vim/addons/doc' -c q

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


[PATCH 1/1] devel/release-checks.sh: check NOTMUCH_(MAJOR|MINOR|MICRO)_VERSION

2013-11-08 Thread Tomi Ollila
New defines NOTMUCH_MAJOR_VERSION, NOTMUCH_MINOR_VERSION and
NOTMUCH_MICRO_VERSION were added to lib/notmuch.h.
Check that these match the current value defined in ./version.
---
 devel/release-checks.sh | 36 
 1 file changed, 36 insertions(+)

diff --git a/devel/release-checks.sh b/devel/release-checks.sh
index 4eff1a7..d6410ad 100755
--- a/devel/release-checks.sh
+++ b/devel/release-checks.sh
@@ -13,6 +13,8 @@ fi
 set -o posix
 set -o pipefail # bash feature
 
+readonly DEFAULT_IFS=$IFS # Note: In this particular case quotes are needed.
+
 # Avoid locale-specific differences in output of executed commands
 LANG=C LC_ALL=C; export LANG LC_ALL
 
@@ -20,8 +22,10 @@ readonly PV_FILE='bindings/python/notmuch/version.py'
 
 # Using array here turned out to be unnecessarily complicated
 emsgs=''
+emsg_count=0
 append_emsg ()
 {
+   emsg_count=$((emsg_count + 1))
emsgs=${emsgs:+$emsgs\n}  $1
 }
 
@@ -73,6 +77,38 @@ case $VERSION in
*)  verfail '$VERSION' is a single number ;;
 esac
 
+_set_version_components ()
+{
+   VERSION_MAJOR=$1
+   VERSION_MINOR=$2
+   VERSION_MICRO=${3:-0} # set to 0 in case $3 is unset or null (string)
+}
+
+IFS=.
+_set_version_components $VERSION
+IFS=$DEFAULT_IFS
+
+echo -n Checking that libnotmuch version macros match $VERSION... 
+NOTMUCH_MAJOR_VERSION=broken
+NOTMUCH_MINOR_VERSION=broken
+NOTMUCH_MICRO_VERSION=broken
+eval `awk 'NF == 3  $1 == #define  $2 ~ /^NOTMUCH_[A-Z]+_VERSION$/ \
+$3 ~ /^[0-9]+$/ { print $2 = $3 }' lib/notmuch.h`
+
+check_version_component ()
+{
+   eval local v1=\$VERSION_$1
+   eval local v2=\$NOTMUCH_$1_VERSION
+   if [ $v1 != $v2 ]
+   thenappend_emsg NOTMUCH_$1_VERSION is defined as '$v2' in 
lib/notmuch.h instead of '$v1'
+   fi
+}
+
+old_emsg_count=$emsg_count
+check_version_component MAJOR
+check_version_component MINOR
+check_version_component MICRO
+[ $old_emsg_count = $emsg_count ]  echo Yes. || echo No.
 
 echo -n Checking that this is Debian package for notmuch... 
 read deb_notmuch deb_version rest  debian/changelog
-- 
1.8.0

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


[PATCH v3 3/7] emacs: help: split out notmuch-describe-key as a function

2013-11-08 Thread Mark Walters
The actual documentation function notmuch-describe-keymap was getting
rather complicated so split out the code for a single key into its own
function notmuch-describe-key.
---
 emacs/notmuch-lib.el |   42 +-
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 2195166..8852703 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -237,6 +237,30 @@ This is basically just `format-kbd-macro' but we also 
convert ESC to M-.
M-
   (concat desc  
 
+
+(defun notmuch-describe-key (actual-key binding prefix ua-keys tail)
+  Prepend cons cells describing prefix-arg ACTUAL-KEY and ACTUAL-KEY to TAIL
+
+It does not prepend if ACTUAL-KEY is already listed in TAIL.
+  (let ((key-string (concat prefix (format-kbd-macro actual-key
+;; We don't include documentation if the key-binding is
+;; over-ridden. Note, over-riding a binding automatically hides the
+;; prefixed version too.
+(unless (assoc key-string tail)
+  (when (and ua-keys (symbolp binding)
+(get binding 'notmuch-prefix-doc))
+   ;; Documentation for prefixed command
+   (let ((ua-desc (key-description ua-keys)))
+ (push (cons (concat ua-desc   prefix (format-kbd-macro actual-key))
+ (get binding 'notmuch-prefix-doc))
+   tail)))
+  ;; Documentation for command
+  (push (cons key-string
+ (or (and (symbolp binding) (get binding 'notmuch-doc))
+ (notmuch-documentation-first-line binding)))
+   tail)))
+tail)
+
 (defun notmuch-describe-keymap (keymap ua-keys optional prefix tail)
   Return a list of cons cells, each describing one binding in KEYMAP.
 
@@ -256,23 +280,7 @@ prefix argument.  PREFIX and TAIL are used internally.
  (notmuch-describe-keymap
   binding ua-keys (notmuch-prefix-key-description key) tail)))
   (binding
-   (let ((key-string (concat prefix (format-kbd-macro (vector key)
- ;; We don't include documentation if the key-binding is
- ;; over-ridden. Note, over-riding a binding
- ;; automatically hides the prefixed version too.
- (unless (assoc key-string tail)
-   (when (and ua-keys (symbolp binding)
-  (get binding 'notmuch-prefix-doc))
- ;; Documentation for prefixed command
- (let ((ua-desc (key-description ua-keys)))
-   (push (cons (concat ua-desc   prefix (format-kbd-macro 
(vector key)))
-   (get binding 'notmuch-prefix-doc))
- tail)))
-   ;; Documentation for command
-   (push (cons key-string
-   (or (and (symbolp binding) (get binding 
'notmuch-doc))
-   (notmuch-documentation-first-line binding)))
- tail))
+   (setq tail (notmuch-describe-key (vector key) binding prefix 
ua-keys tail)
keymap)
   tail)
 
-- 
1.7.9.1

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


[PATCH v3 1/7] emacs: help: check for nil key binding

2013-11-08 Thread Mark Walters
A standard way to unset a key binding is local-unset-key which is equivalent to
  (define-key (current-local-map) key nil)

Currently notmuch-help gives an error and fails if a user has done this.

To fix this we only add a help line if the binding is non-nil.
---
 emacs/notmuch-lib.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 921ed20..ec5a2cb 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -254,7 +254,7 @@ prefix argument.  PREFIX and TAIL are used internally.
(setq tail
  (notmuch-describe-keymap
   binding ua-keys (notmuch-prefix-key-description key) tail)))
-  (t
+  (binding
(when (and ua-keys (symbolp binding)
   (get binding 'notmuch-prefix-doc))
  ;; Documentation for prefixed command
-- 
1.7.9.1

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


[PATCH v3 2/7] emacs: help: remove duplicate bindings

2013-11-08 Thread Mark Walters
If the user (or a mode) overrides a keybinding from the common keymap
in one of the modes then both help lines appear in the help screen
even though only one of them is applicable.

Fix this by checking if we already have that key binding. We do this
by constructing an list of (key . docstring) pairs so it is easy to
check if we have already had that binding. Then the actual print help
routine changes these pairs into strings key \t docstring
---
 emacs/notmuch-lib.el |   41 -
 1 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index ec5a2cb..2195166 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -238,11 +238,12 @@ This is basically just `format-kbd-macro' but we also 
convert ESC to M-.
   (concat desc  
 
 (defun notmuch-describe-keymap (keymap ua-keys optional prefix tail)
-  Return a list of strings, each describing one binding in KEYMAP.
+  Return a list of cons cells, each describing one binding in KEYMAP.
 
-Each string gives a human-readable description of the key and a
-one-line description of the bound function.  See `notmuch-help'
-for an overview of how this documentation is extracted.
+Each cons cell consists of a string giving a human-readable
+description of the key, and a one-line description of the bound
+function.  See `notmuch-help' for an overview of how this
+documentation is extracted.
 
 UA-KEYS should be a key sequence bound to `universal-argument'.
 It will be used to describe bindings of commands that support a
@@ -255,18 +256,23 @@ prefix argument.  PREFIX and TAIL are used internally.
  (notmuch-describe-keymap
   binding ua-keys (notmuch-prefix-key-description key) tail)))
   (binding
-   (when (and ua-keys (symbolp binding)
-  (get binding 'notmuch-prefix-doc))
- ;; Documentation for prefixed command
- (let ((ua-desc (key-description ua-keys)))
-   (push (concat ua-desc   prefix (format-kbd-macro (vector key))
- \t (get binding 'notmuch-prefix-doc))
- tail)))
-   ;; Documentation for command
-   (push (concat prefix (format-kbd-macro (vector key)) \t
- (or (and (symbolp binding) (get binding 'notmuch-doc))
- (notmuch-documentation-first-line binding)))
- tail
+   (let ((key-string (concat prefix (format-kbd-macro (vector key)
+ ;; We don't include documentation if the key-binding is
+ ;; over-ridden. Note, over-riding a binding
+ ;; automatically hides the prefixed version too.
+ (unless (assoc key-string tail)
+   (when (and ua-keys (symbolp binding)
+  (get binding 'notmuch-prefix-doc))
+ ;; Documentation for prefixed command
+ (let ((ua-desc (key-description ua-keys)))
+   (push (cons (concat ua-desc   prefix (format-kbd-macro 
(vector key)))
+   (get binding 'notmuch-prefix-doc))
+ tail)))
+   ;; Documentation for command
+   (push (cons key-string
+   (or (and (symbolp binding) (get binding 
'notmuch-doc))
+   (notmuch-documentation-first-line binding)))
+ tail))
keymap)
   tail)
 
@@ -277,7 +283,8 @@ prefix argument.  PREFIX and TAIL are used internally.
   (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
 (keymap (symbol-value (intern keymap-name)))
 (ua-keys (where-is-internal 'universal-argument keymap t))
-(desc-list (notmuch-describe-keymap keymap ua-keys))
+(desc-alist (notmuch-describe-keymap keymap ua-keys))
+(desc-list (mapcar (lambda (arg) (concat (car arg) \t (cdr 
arg))) desc-alist))
 (desc (mapconcat #'identity desc-list \n)))
(setq doc (replace-match desc 1 1 doc)))
   (setq beg (match-end 0)))
-- 
1.7.9.1

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


[PATCH v3 4/7] emacs: help: add base-keymap

2013-11-08 Thread Mark Walters
To support key remapping in emacs help we need to know the base keymap
when looking at the remapping. keep track of this while we recurse
down the sub-keymaps in help.
---
 emacs/notmuch-lib.el |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 8852703..a4f481b 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -261,7 +261,7 @@ It does not prepend if ACTUAL-KEY is already listed in 
TAIL.
tail)))
 tail)
 
-(defun notmuch-describe-keymap (keymap ua-keys optional prefix tail)
+(defun notmuch-describe-keymap (keymap ua-keys base-keymap optional prefix 
tail)
   Return a list of cons cells, each describing one binding in KEYMAP.
 
 Each cons cell consists of a string giving a human-readable
@@ -278,7 +278,7 @@ prefix argument.  PREFIX and TAIL are used internally.
   ((keymapp binding)
(setq tail
  (notmuch-describe-keymap
-  binding ua-keys (notmuch-prefix-key-description key) tail)))
+  binding ua-keys base-keymap (notmuch-prefix-key-description 
key) tail)))
   (binding
(setq tail (notmuch-describe-key (vector key) binding prefix 
ua-keys tail)
keymap)
@@ -291,7 +291,7 @@ prefix argument.  PREFIX and TAIL are used internally.
   (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
 (keymap (symbol-value (intern keymap-name)))
 (ua-keys (where-is-internal 'universal-argument keymap t))
-(desc-alist (notmuch-describe-keymap keymap ua-keys))
+(desc-alist (notmuch-describe-keymap keymap ua-keys keymap))
 (desc-list (mapcar (lambda (arg) (concat (car arg) \t (cdr 
arg))) desc-alist))
 (desc (mapconcat #'identity desc-list \n)))
(setq doc (replace-match desc 1 1 doc)))
-- 
1.7.9.1

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


[PATCH v3 7/7] emacs: help: base-keymap-test-help

2013-11-08 Thread Mark Walters
Add an argument to notmuch-help for the mode to display help for.
This aids testing of the base-keymap case in remapping in emacs help.

It is only intended for testing, ie not for master (but it does no harm)
---
 emacs/notmuch-lib.el |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 4b3a86e..7b8acb3 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -316,7 +316,7 @@ prefix argument.  PREFIX and TAIL are used internally.
   (setq beg (match-end 0)))
 doc))
 
-(defun notmuch-help ()
+(defun notmuch-help (optional mode)
   Display help for the current notmuch mode.
 
 This is similar to `describe-function' for the current major
@@ -328,7 +328,7 @@ A command that supports a prefix argument can explicitly 
document
 its prefixed behavior by setting the 'notmuch-prefix-doc property
 of its command symbol.
   (interactive)
-  (let* ((mode major-mode)
+  (let* ((mode (or mode major-mode))
 (doc (substitute-command-keys (notmuch-substitute-command-keys 
(documentation mode t)
 (with-current-buffer (generate-new-buffer *notmuch-help*)
   (insert doc)
-- 
1.7.9.1

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


[PATCH v3 5/7] emacs: help: add a special function to deal with remaps

2013-11-08 Thread Mark Walters
remaps are a rather unusual keymap consisting of first key 'remap
and then second-key the remapped-function. Thus we do the
documentation for it separately.
---
 emacs/notmuch-lib.el |   22 --
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index a4f481b..4b3a86e 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -261,6 +261,21 @@ It does not prepend if ACTUAL-KEY is already listed in 
TAIL.
tail)))
 tail)
 
+(defun notmuch-describe-remaps (remap-keymap ua-keys base-keymap prefix tail)
+  ;; Remappings are represented as a binding whose first event is
+  ;; 'remap.  Hence, if the keymap has any remappings, it will have a
+  ;; binding whose key is 'remap, and whose binding is itself a
+  ;; keymap that maps not from keys to commands, but from old (remapped)
+  ;; functions to the commands to use in their stead.
+  (map-keymap
+   (lambda (command binding)
+ (mapc
+  (lambda (actual-key)
+   (setq tail (notmuch-describe-key actual-key binding prefix ua-keys 
tail)))
+  (where-is-internal command base-keymap)))
+   remap-keymap)
+  tail)
+
 (defun notmuch-describe-keymap (keymap ua-keys base-keymap optional prefix 
tail)
   Return a list of cons cells, each describing one binding in KEYMAP.
 
@@ -277,8 +292,11 @@ prefix argument.  PREFIX and TAIL are used internally.
  (cond ((mouse-event-p key) nil)
   ((keymapp binding)
(setq tail
- (notmuch-describe-keymap
-  binding ua-keys base-keymap (notmuch-prefix-key-description 
key) tail)))
+ (if (eq key 'remap)
+ (notmuch-describe-remaps
+  binding ua-keys base-keymap prefix tail)
+   (notmuch-describe-keymap
+binding ua-keys base-keymap 
(notmuch-prefix-key-description key) tail
   (binding
(setq tail (notmuch-describe-key (vector key) binding prefix 
ua-keys tail)
keymap)
-- 
1.7.9.1

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


Re: [PATCH 21/21] vim: add help file

2013-11-08 Thread David Bremner
Felipe Contreras felipe.contre...@gmail.com writes:

 You can probably check that it's working with this:
 % vim -c :h notmuch

It turns I needed to re-run 

   vim-addon-manager install notmuch

This might be a bit debian specific, but it's already documented as
needed for the initial install. It would probably be worth updating
debian/notmuch-vim.README.Debian to suggest running this on upgrade as
well.

Otherwise running :helptags wants write into /usr/share/vim/addons/doc,
which is naturally a bit tricky for a non-root user.

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


Re: [PATCH 21/21] vim: add help file

2013-11-08 Thread Felipe Contreras
On Fri, Nov 8, 2013 at 12:03 PM, David Bremner da...@tethera.net wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 You can probably check that it's working with this:
 % vim -c :h notmuch

 It turns I needed to re-run

vim-addon-manager install notmuch

 This might be a bit debian specific, but it's already documented as
 needed for the initial install. It would probably be worth updating
 debian/notmuch-vim.README.Debian to suggest running this on upgrade as
 well.

Shouldn't this happen on a post update script or something?

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


Re: [PATCH v3 0/7] emacs: help: remap keybindings

2013-11-08 Thread Austin Clements
LGTM.

Quoth Mark Walters on Nov 08 at  5:40 pm:
 This is version 3 of the series. v2 is at
 id:1383870096-14627-1-git-send-email-markwalters1...@gmail.com
 
 The changes are in response to Austin's review of v2. I have not
 changed notmuch-describe-key.
 
 The other change is to add a base-keymap to look up the remapped
 commands in (since notmuch-substitute-command-keys could refer to
 something other than the current keymap). Currently this never happens
 but this makes the code more robust.
 
 The final patch of the series is (probably) just for testing
 purposes. It lets you call notmuch-help and specify which mode you
 want to display help for. This means you can call it without having
 the mode as current-mode and hence test the base-keymap code.
 
 Finally the diff from v2 below (with the testing patch omitted) is below.
 
 Best wishes
 
 Mark
 
 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
 index ef616d5..4b3a86e 100644
 --- a/emacs/notmuch-lib.el
 +++ b/emacs/notmuch-lib.el
 @@ -261,7 +261,7 @@ It does not prepend if ACTUAL-KEY is already listed in 
 TAIL.
   tail)))
  tail)
  
 -(defun notmuch-describe-remaps (remap-keymap ua-keys prefix tail)
 +(defun notmuch-describe-remaps (remap-keymap ua-keys base-keymap prefix tail)
;; Remappings are represented as a binding whose first event is
;; 'remap.  Hence, if the keymap has any remappings, it will have a
;; binding whose key is 'remap, and whose binding is itself a
 @@ -272,11 +272,11 @@ It does not prepend if ACTUAL-KEY is already listed in 
 TAIL.
   (mapc
(lambda (actual-key)
   (setq tail (notmuch-describe-key actual-key binding prefix ua-keys 
 tail)))
 -  (where-is-internal command)))
 +  (where-is-internal command base-keymap)))
 remap-keymap)
tail)
  
 -(defun notmuch-describe-keymap (keymap ua-keys optional prefix tail)
 +(defun notmuch-describe-keymap (keymap ua-keys base-keymap optional prefix 
 tail)
Return a list of cons cells, each describing one binding in KEYMAP.
  
  Each cons cell consists of a string giving a human-readable
 @@ -291,13 +291,12 @@ prefix argument.  PREFIX and TAIL are used internally.
 (lambda (key binding)
   (cond ((mouse-event-p key) nil)
  ((keymapp binding)
 - (if (eq key 'remap)
 - (setq tail
 + (setq tail
 +   (if (eq key 'remap)
 (notmuch-describe-remaps
 -binding ua-keys prefix tail))
 -   (setq tail
 +binding ua-keys base-keymap prefix tail)
   (notmuch-describe-keymap
 -  binding ua-keys (notmuch-prefix-key-description key) 
 tail
 +  binding ua-keys base-keymap 
 (notmuch-prefix-key-description key) tail
  (binding
   (setq tail (notmuch-describe-key (vector key) binding prefix 
 ua-keys tail)
 keymap)
 @@ -310,7 +309,7 @@ prefix argument.  PREFIX and TAIL are used internally.
(let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
(keymap (symbol-value (intern keymap-name)))
(ua-keys (where-is-internal 'universal-argument keymap t))
 -  (desc-alist (notmuch-describe-keymap keymap ua-keys))
 +  (desc-alist (notmuch-describe-keymap keymap ua-keys keymap))
(desc-list (mapcar (lambda (arg) (concat (car arg) \t (cdr 
 arg))) desc-alist))
(desc (mapconcat #'identity desc-list \n)))
   (setq doc (replace-match desc 1 1 doc)))
 
 
 
 Mark Walters (7):
   emacs: help: check for nil key binding
   emacs: help: remove duplicate bindings
   emacs: help: split out notmuch-describe-key as a function
   emacs: help: add base-keymap
   emacs: help: add a special function to deal with remaps
   emacs: tree: use remap for the over-ridden global bindings
   emacs: help: base-keymap-test-help
 
  emacs/notmuch-lib.el  |   79 ++--
  emacs/notmuch-tree.el |8 ++--
  2 files changed, 60 insertions(+), 27 deletions(-)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 21/21] vim: add help file

2013-11-08 Thread David Bremner
Felipe Contreras felipe.contre...@gmail.com writes:

 On Fri, Nov 8, 2013 at 12:03 PM, David Bremner da...@tethera.net wrote:

 This might be a bit debian specific, but it's already documented as
 needed for the initial install. It would probably be worth updating
 debian/notmuch-vim.README.Debian to suggest running this on upgrade as
 well.

 Shouldn't this happen on a post update script or something?


Yeah, I talked to the Debian vim maintainer, and apparently that is a
design flaw with the current way vim addons are managed. So the best we
can do for the moment is put a note in debian/notmuch-vim.NEWS (in the
same format as debian/NEWS.Debian. The format is a bit fussy, so I can
take care of that.

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


RPM repository for Fedora on copr

2013-11-08 Thread Suvayu Ali
Hi,

The notmuch packages available for Fedora are rather old.  So I have
been building my own packages for a while.  Today I discovered copr[1],
so I thought others might be interested in the packages.  I have based
the spec on the version used for Fedora with some changes.  I update the
package from time to time when I see interesting changes in the Git
repository.  You can find the repository information here:

  http://copr-fe.cloud.fedoraproject.org/coprs/fatka/notmuch/

I also have a repo for the mutt fork, mutt-kz.

  http://copr-fe.cloud.fedoraproject.org/coprs/fatka/mutt-kz/

Hope people like it :).

Cheers,


Footnotes:

[1] https://fedorahosted.org/copr/wiki/UserDocs#FAQ

-- 
Suvayu

Open source is the future. It sets us free.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 00/11] Fix search tagging races

2013-11-08 Thread David Bremner
Austin Clements amdra...@mit.edu writes:

 This is v2 of id:1381185201-25197-1-git-send-email-amdra...@mit.edu.
 It fixes several comments from Mark and Jani.  This has been rebased
 on top of the tag completion changes, so doing * from a large search
 buffer will no longer crash.  Hence, this series depends on the
 (currently pending) series in
 id:1382487721-31776-1-git-send-email-amdra...@mit.edu.


pushed.

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


Re: [PATCH 1/1] devel/release-checks.sh: check NOTMUCH_(MAJOR|MINOR|MICRO)_VERSION

2013-11-08 Thread David Bremner
Tomi Ollila tomi.oll...@iki.fi writes:

 New defines NOTMUCH_MAJOR_VERSION, NOTMUCH_MINOR_VERSION and
 NOTMUCH_MICRO_VERSION were added to lib/notmuch.h.
 Check that these match the current value defined in ./version.

This seems OK to me. And in worse case it can't break anything too
important.

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