[PATCH v2 0/2] emacs: Shortcut keys to saved searches

2014-07-15 Thread Mark Walters

On Tue, 15 Jul 2014, Austin Clements  wrote:
> This is version 2 of
> id:1405353735-26244-1-git-send-email-amdragon at mit.edu and addresses
> Mark's comments in id:87egxnd4aq.fsf at qmul.ac.uk.
>
> The diff from v1 is below.

This version gets a +1 from me. I would have a slight preference for
making the prompt "Jump to search: " rather than "Search: " to emphasise
that you can't type an actual search, but am definitely happy with this
version.

Best wishes

Mark




>
> diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
> index cb1ae10..9cb1e6a 100644
> --- a/emacs/notmuch-jump.el
> +++ b/emacs/notmuch-jump.el
> @@ -53,20 +53,19 @@ (defun notmuch-jump-search ()
>  (setq action-map (nreverse action-map))
>  
>  (if action-map
> - (notmuch-jump action-map "Search ")
> -  (error "No shortcut keys for saved searches.  Please customize 
> notmuch-saved-searches."
> + (notmuch-jump action-map "Search: ")
> +  (error "To use notmuch-jump, please customize shortcut keys in 
> notmuch-saved-searches."
>  
>  (defvar notmuch-jump--action nil)
>  
>  (defun notmuch-jump (action-map prompt)
>"Interactively prompt for one of the keys in ACTION-MAP.
>  
> -Displays a pop-up temporary buffer with a summary of all bindings
> -in ACTION-MAP, reads a key from the minibuffer, and performs the
> -corresponding action.  The prompt can be canceled with C-g.
> -PROMPT must be a string to use for the prompt if this command was
> -not invoked directly by a key binding (e.g., it was invoked
> -through M-x).  PROMPT should include a space at the end.
> +Displays a summary of all bindings in ACTION-MAP in the
> +minibuffer, reads a key from the minibuffer, and performs the
> +corresponding action.  The prompt can be canceled with C-g or
> +RET.  PROMPT must be a string to use for the prompt.  PROMPT
> +should include a space at the end.
>  
>  ACTION-MAP must be a list of triples of the form
>(KEY LABEL ACTION)
> @@ -82,16 +81,9 @@ (defun notmuch-jump (action-map prompt)
> (with-temp-buffer
>   (notmuch-jump--insert-items (window-body-width) items)
>   (buffer-string)))
> -  (prompt-text
> -   (if (eq this-original-command this-command)
> -   ;; Make it look like we're just part of any regular
> -   ;; submap prompt (like C-x, C-c, etc.)
> -   (concat (format-kbd-macro (this-command-keys)) "-")
> - ;; We were invoked through something like M-x
> - prompt))
>(full-prompt
> (concat table "\n\n"
> -   (propertize prompt-text 'face 'minibuffer-prompt)))
> +   (propertize prompt 'face 'minibuffer-prompt)))
>;; By default, the minibuffer applies the minibuffer face to
>;; the entire prompt.  However, we want to clearly
>;; distinguish bindings (which we put in the prompt face
> @@ -121,14 +113,14 @@ (defun notmuch-jump--format-actions (action-map)
>  
>;; Compute the maximum key description width
>(let ((key-width 1))
> -(dolist (action action-map)
> +(dolist (entry action-map)
>(setq key-width
>   (max key-width
> -  (string-width (format-kbd-macro (first action))
> +  (string-width (format-kbd-macro (first entry))
>  ;; Format each action
> -(mapcar (lambda (action)
> -   (let ((key (format-kbd-macro (first action)))
> - (desc (second action)))
> +(mapcar (lambda (entry)
> +   (let ((key (format-kbd-macro (first entry)))
> + (desc (second entry)))
>   (concat
>(propertize key 'face 'minibuffer-prompt)
>(make-string (- key-width (length key)) ? )
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 135422d..b338aaa 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -25,6 +25,9 @@
>  (require 'mm-decode)
>  (require 'cl)
>  
> +(autoload 'notmuch-jump-search "notmuch-jump"
> +  "Jump to a saved search by shortcut key." t)
> +
>  (defvar notmuch-command "notmuch"
>"Command to run the notmuch binary.")
>  
> @@ -134,8 +137,6 @@ (defvar notmuch-common-keymap
>  map)
>"Keymap shared by all notmuch modes.")
>  
> -(autoload 'notmuch-jump-search "notmuch-jump" "Jump to a saved search by 
> shortcut key." t)
> -
>  ;; By default clicking on a button does not select the window
>  ;; containing the button (as opposed to clicking on a widget which
>  ;; does). This means that the button action is then executed in the


[PATCH 4/4] nmbug: Add an 'init' command

2014-07-15 Thread David Bremner
"W. Trevor King"  writes:

> +sub do_init {
> +  my $tempwork = tempdir ('/tmp/nmbug-init.XX', CLEANUP => 1);
> +  system ('git', 'init', '--separate-git-dir', $NMBGIT, $tempwork) == 0
> +or die "'git init' exited with nonzero value\n";
> +  git ('config', '--unset', 'core.worktree');
> +  git ('config', 'core.bare', 'true');
> +  # create an empty blob (e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)
> +  git ('hash-object', '-w', '--stdin');
> +  git ( { GIT_WORK_TREE => $tempwork }, 'commit', '--allow-empty',
> +'-m', 'Start a new nmbug repository' );
> +}
> +


Shouldn't this empty blob already be created by the following line:

my $EMPTYBLOB = git (qw{hash-object -t blob /dev/null});

Or is the key point to write it into the database?  Anyway I like my
hack slightly better than yours ;).

d





[PATCH 3/4] nmbug: Catch stderr in is_unmerged

2014-07-15 Thread David Bremner
"W. Trevor King"  writes:

> +  if ($dir eq '-2|') {
> +$dir = '-|';
> +  }
> +

I think I'd prefer an extra flag, rather than making new syntax.
The existing syntax is not pretty, but it is standard perl



[PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-15 Thread David Bremner
"W. Trevor King"  writes:

> -  my $fetch_head = git ('rev-parse', $commit);
> +  my ($fetch_head, $status) = git_with_status ('rev-parse', $commit);
> +  if ($status) {
> +return 0;
> +  }

Could there be other errors here, other than @{upstream} not existing?
At first glance it seems like there is potential to hide errors here.

d



[PATCH] emacs: tree/show remove duplicate function

2014-07-15 Thread David Bremner
Mark Walters  writes:

> On Tue, 15 Jul 2014, David Bremner  wrote:
>> Mark Walters  writes:
>>> +  (cond ((eq major-mode 'notmuch-show-mode)
>>> + (notmuch-show-get-message-properties))
>>> +((eq major-mode 'notmuch-tree-mode)
>>> + (notmuch-tree-get-message-properties
>>
>> I see this already existed, but it looks weird to me to have a two test
>> cond with no else. Is it intentional to have the code drop through and
>> do nothing if neither case matches?  It seems like it might be better to
>> signal an error.
>
> I can definitely do that. But as a comparison
> notmuch-search-get-result and notmuch-search-find-thread-id "work" in
> any buffer in the sense of returning nil but not complaining so perhaps
> the current version is more consistent. 
>

It occurs to me that we can fix all 3 places in a followup patch,
so I'll push this for now.

d


[PATCH v2 0/6] nmbug-status fixups from notmuch-to-html

2014-07-15 Thread David Bremner
"W. Trevor King"  writes:

> Changes from v1 [1]
>
> * Tweaked the license commit message (1/6) [2] with Carl's permission
>   [3].
> * Squashed v1's footer commits (old 2/5, 3/5, and 6/5, now 3/6) [4].
> * Squashed v1's description commits (old 4/5 and 5/5, now 2/6) [4].
> * Added commits 4/6, 5/6, and 6/6 to optionally load templates from
>   the config file.

Series pushed.

> Carl Worth (3):
>   Add explicit license information
>   Add a docstring describing the program
>   Move the generated date from the top of the page to the footer.

Yay, patches from Carl ;).



[PATCH] emacs: search archive tweak

2014-07-15 Thread David Bremner
Mark Walters  writes:

> notmuch-search-archive-thread moves to the next line after tagging. In
> the normal case this makes sense, but if the region is active, it tags
> the whole region and then it doesn't really. Thus only move to the
> next line if region is not active.
> ---

pushed to master.

d


[PATCH v2 2/2] emacs: Expand default saved searches and add shortcut keys

2014-07-15 Thread David Bremner
Austin Clements  writes:

> This should help new users off to a better start with the addition of
> more sensible saved searches and default shortcut keys.  Most existing
> users have probably customized this variable and won't be affected.

I didn't have a chance to review the code, but I like the interface.

d


notmuch-reply date format

2014-07-15 Thread Sime Ramov
Hi,

* Austin Clements  [2014-07-15 16:14 +0200]:
> Close. For whatever reason, localtime takes a pointer to a time_t,
> not a time_t (even though time_t is just a number). You'll need
> something like
>
> [...]

Thank you *so much*, everything is in order now! Finally a nice
attribution line :)


[PATCH 3/4] nmbug: Catch stderr in is_unmerged

2014-07-15 Thread W. Trevor King
On Tue, Jul 15, 2014 at 08:49:58PM -0300, David Bremner wrote:
> "W. Trevor King"  writes:
> 
> > +  if ($dir eq '-2|') {
> > +$dir = '-|';
> > +  }
> > +
> 
> I think I'd prefer an extra flag, rather than making new syntax.
> The existing syntax is not pretty, but it is standard perl

There should be standard Perl syntax for capturing both streams ;).  I
can add a separate parameter instead, but Perl doesn't seem to have
keyword-arguments.  At least, nmbug relies on assumptions about
argument values:

  sub git_pipe {
my $envref = (ref $_[0] eq 'HASH') ? shift : {};
my $ioref  = (ref $_[0] eq 'ARRAY') ? shift : undef;
my $dir = ($_[0] eq '-|' or $_[0] eq '|-') ? shift : undef;
?
  }

to map positional arguments back into particular semantic meanings.
That seemed ugly enough (can we only have a single boolean argument
with this pattern?) that I'd prefer piggy-backing on Perl's
stream-direction syntax.  But let me know what you like best, and I'll
go that way with v2.  I'd be happy to rewrite nmbug in Python too,
which has (to my eyes) much saner kwargs and subprocess handling.

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20140715/5641a03a/attachment.pgp>


[PATCH 4/4] nmbug: Add an 'init' command

2014-07-15 Thread W. Trevor King
On Tue, Jul 15, 2014 at 08:54:28PM -0300, David Bremner wrote:
> "W. Trevor King"  writes:
> 
> > +sub do_init {
> > +  my $tempwork = tempdir ('/tmp/nmbug-init.XX', CLEANUP => 1);
> > +  system ('git', 'init', '--separate-git-dir', $NMBGIT, $tempwork) == 0
> > +or die "'git init' exited with nonzero value\n";
> > +  git ('config', '--unset', 'core.worktree');
> > +  git ('config', 'core.bare', 'true');
> > +  # create an empty blob (e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)
> > +  git ('hash-object', '-w', '--stdin');
> > +  git ( { GIT_WORK_TREE => $tempwork }, 'commit', '--allow-empty',
> > +'-m', 'Start a new nmbug repository' );
> > +}
> > +
> 
> 
> Shouldn't this empty blob already be created by the following line:
> 
> my $EMPTYBLOB = git (qw{hash-object -t blob /dev/null});
> 
> Or is the key point to write it into the database?  Anyway I like my
> hack slightly better than yours ;).

We need to write it to the database.  I'll use /dev/null in v2,
though.

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20140715/c652b5c9/attachment.pgp>


[PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-15 Thread W. Trevor King
On Tue, Jul 15, 2014 at 08:44:53PM -0300, David Bremner wrote:
> W. Trevor King writes:
> > -  my $fetch_head = git ('rev-parse', $commit);
> > +  my ($fetch_head, $status) = git_with_status ('rev-parse', $commit);
> > +  if ($status) {
> > +return 0;
> > +  }
> 
> Could there be other errors here, other than @{upstream} not
> existing?  At first glance it seems like there is potential to hide
> errors here.

Possible errors that I can find:

* fatal: Not a git repository: ? (with a poor GIT_DIR config)
* fatal: ambiguous argument ? (with an invalid/missing revision name)
* fatal: No upstream configured for branch ? (when
  branch..remote or branch..merge aren't set)

All of which return 128 as of Git v1.9.1.  We're only interested in
the last.  I'm fine looking for ?No upstream configured for branch?
after we capture stderr with ?nmbug: Catch stderr in is_unmerged? [1],
but I don't expect the other two error cases to happen very often.  At
least, I doubt you could get this far into do_status with a broken
GIT_DIR, and we're hard-coding '@{upstream}' here.

Cheers,
Trevor

[1]: id:d55cf02465c5f2d83f2dd0bc666831ee524b0fb7.1404678709.git.wking at 
tremily.us
 http://article.gmane.org/gmane.mail.notmuch.general/18627

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20140715/023b1ed3/attachment-0001.pgp>


[PATCH v2 2/2] emacs: Expand default saved searches and add shortcut keys

2014-07-15 Thread Austin Clements
This should help new users off to a better start with the addition of
more sensible saved searches and default shortcut keys.  Most existing
users have probably customized this variable and won't be affected.
---
 emacs/notmuch-hello.el  | 9 +++--
 test/emacs.expected-output/notmuch-hello| 2 +-
 test/emacs.expected-output/notmuch-hello-long-names | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 061b27d..65d0627 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -93,8 +93,13 @@ (define-widget 'notmuch-saved-search-plist 'list
(const :tag "Oldest-first" oldest-first)
(const :tag "Newest-first" 
newest-first))

-(defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")
-   (:name "unread" :query "tag:unread"))
+(defcustom notmuch-saved-searches
+  `((:name "inbox" :query "tag:inbox" :key ,(kbd "i"))
+(:name "unread" :query "tag:unread" :key ,(kbd "u"))
+(:name "flagged" :query "tag:flagged" :key ,(kbd "f"))
+(:name "sent" :query "tag:sent" :key ,(kbd "t"))
+(:name "drafts" :query "tag:draft" :key ,(kbd "d"))
+(:name "all mail" :query "*" :key ,(kbd "a")))
   "A list of saved searches to display.

 The saved search can be given in 3 forms. The preferred way is as
diff --git a/test/emacs.expected-output/notmuch-hello 
b/test/emacs.expected-output/notmuch-hello
index 2d69891..9ba4cfc 100644
--- a/test/emacs.expected-output/notmuch-hello
+++ b/test/emacs.expected-output/notmuch-hello
@@ -2,7 +2,7 @@

 Saved searches: [edit]

- 52 inbox   52 unread
+ 52 inbox   52 unread  52 all mail

 Search: .

diff --git a/test/emacs.expected-output/notmuch-hello-long-names 
b/test/emacs.expected-output/notmuch-hello-long-names
index 486d0d9..1c8d6eb 100644
--- a/test/emacs.expected-output/notmuch-hello-long-names
+++ b/test/emacs.expected-output/notmuch-hello-long-names
@@ -2,7 +2,7 @@

 Saved searches: [edit]

- 52 inbox   52 unread
+ 52 inbox   52 unread  52 all mail

 Search: .

-- 
2.0.0



[PATCH v2 1/2] emacs: Introduce notmuch-jump: shortcut keys to saved searches

2014-07-15 Thread Austin Clements
This introduces notmuch-jump, which is like a user-friendly,
user-configurable global prefix map for saved searches.  This provides
a non-modal and much faster way to access saved searches than
notmuch-hello.

A user configures shortcut keys in notmuch-saved-searches, which are
immediately accessible from anywhere in Notmuch under the "j" key (for
"jump").  When the user hits "j", the minibuffer immediately shows a
helpful table of bindings reminiscent of a completions buffer.

This code is a combination of work from myself (originally,
"notmuch-go"), David Edmondson, and modifications from Mark Walters.
---
 emacs/Makefile.local   |   3 +-
 emacs/notmuch-hello.el |   2 +
 emacs/notmuch-jump.el  | 181 +
 emacs/notmuch-lib.el   |   4 ++
 4 files changed, 189 insertions(+), 1 deletion(-)
 create mode 100644 emacs/notmuch-jump.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index c0d6b19..1109cfa 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -18,7 +18,8 @@ emacs_sources := \
$(dir)/notmuch-tag.el \
$(dir)/coolj.el \
$(dir)/notmuch-print.el \
-   $(dir)/notmuch-version.el
+   $(dir)/notmuch-version.el \
+   $(dir)/notmuch-jump.el \

 $(dir)/notmuch-version.el: $(dir)/Makefile.local version.stamp
 $(dir)/notmuch-version.el: $(srcdir)/$(dir)/notmuch-version.el.tmpl
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 3de5238..061b27d 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -85,6 +85,7 @@ (define-widget 'notmuch-saved-search-plist 'list
(group :format "%v" :inline t (const :format "  Query: " 
:query) (string :format "%v")))
  (checklist :inline t
 :format "%v"
+(group :format "%v" :inline t (const :format "Shortcut 
key: " :key) (key-sequence :format "%v"))
 (group :format "%v" :inline t (const :format "Count-Query: 
" :count-query) (string :format "%v"))
 (group :format "%v" :inline t (const :format "" 
:sort-order)
(choice :tag " Sort Order"
@@ -101,6 +102,7 @@ (defcustom notmuch-saved-searches '((:name "inbox" :query 
"tag:inbox")

   :nameName of the search (required).
   :query   Search to run (required).
+  :key Optional shortcut key for `notmuch-jump-search'.
   :count-query Optional extra query to generate the count
shown. If not present then the :query property
is used.
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
new file mode 100644
index 000..9cb1e6a
--- /dev/null
+++ b/emacs/notmuch-jump.el
@@ -0,0 +1,181 @@
+;; notmuch-jump.el --- User-friendly shortcut keys
+;;
+;; Copyright ? Austin Clements
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with Notmuch.  If not, see .
+;;
+;; Authors: Austin Clements 
+;;  David Edmondson 
+
+(eval-when-compile (require 'cl))
+
+(require 'notmuch-hello)
+
+;;;###autoload
+(defun notmuch-jump-search ()
+  "Jump to a saved search by shortcut key.
+
+This prompts for and performs a saved search using the shortcut
+keys configured in the :key property of `notmuch-saved-searches'.
+Typically these shortcuts are a single key long, so this is a
+fast way to jump to a saved search from anywhere in Notmuch."
+  (interactive)
+
+  ;; Build the action map
+  (let (action-map)
+(dolist (saved-search notmuch-saved-searches)
+  (let* ((saved-search (notmuch-hello-saved-search-to-plist saved-search))
+(key (plist-get saved-search :key)))
+   (when key
+ (let ((name (plist-get saved-search :name))
+   (query (plist-get saved-search :query))
+   (oldest-first
+(case (plist-get saved-search :sort-order)
+  (newest-first nil)
+  (oldest-first t)
+  (otherwise (default-value notmuch-search-oldest-first)
+   (push (list key name
+   `(lambda () (notmuch-search ',query ',oldest-first)))
+ action-map)
+(setq action-map (nreverse action-map))
+
+(if action-map
+   (notmuch-jump action-map "Search: ")
+  (error "To use notmuch-jump, please customize shortcut keys in 
notmuch-saved-searches."
+
+(defvar 

[PATCH v2 0/2] emacs: Shortcut keys to saved searches

2014-07-15 Thread Austin Clements
This is version 2 of
id:1405353735-26244-1-git-send-email-amdragon at mit.edu and addresses
Mark's comments in id:87egxnd4aq.fsf at qmul.ac.uk.

The diff from v1 is below.

diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index cb1ae10..9cb1e6a 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -53,20 +53,19 @@ (defun notmuch-jump-search ()
 (setq action-map (nreverse action-map))

 (if action-map
-   (notmuch-jump action-map "Search ")
-  (error "No shortcut keys for saved searches.  Please customize 
notmuch-saved-searches."
+   (notmuch-jump action-map "Search: ")
+  (error "To use notmuch-jump, please customize shortcut keys in 
notmuch-saved-searches."

 (defvar notmuch-jump--action nil)

 (defun notmuch-jump (action-map prompt)
   "Interactively prompt for one of the keys in ACTION-MAP.

-Displays a pop-up temporary buffer with a summary of all bindings
-in ACTION-MAP, reads a key from the minibuffer, and performs the
-corresponding action.  The prompt can be canceled with C-g.
-PROMPT must be a string to use for the prompt if this command was
-not invoked directly by a key binding (e.g., it was invoked
-through M-x).  PROMPT should include a space at the end.
+Displays a summary of all bindings in ACTION-MAP in the
+minibuffer, reads a key from the minibuffer, and performs the
+corresponding action.  The prompt can be canceled with C-g or
+RET.  PROMPT must be a string to use for the prompt.  PROMPT
+should include a space at the end.

 ACTION-MAP must be a list of triples of the form
   (KEY LABEL ACTION)
@@ -82,16 +81,9 @@ (defun notmuch-jump (action-map prompt)
  (with-temp-buffer
(notmuch-jump--insert-items (window-body-width) items)
(buffer-string)))
-(prompt-text
- (if (eq this-original-command this-command)
- ;; Make it look like we're just part of any regular
- ;; submap prompt (like C-x, C-c, etc.)
- (concat (format-kbd-macro (this-command-keys)) "-")
-   ;; We were invoked through something like M-x
-   prompt))
 (full-prompt
  (concat table "\n\n"
- (propertize prompt-text 'face 'minibuffer-prompt)))
+ (propertize prompt 'face 'minibuffer-prompt)))
 ;; By default, the minibuffer applies the minibuffer face to
 ;; the entire prompt.  However, we want to clearly
 ;; distinguish bindings (which we put in the prompt face
@@ -121,14 +113,14 @@ (defun notmuch-jump--format-actions (action-map)

   ;; Compute the maximum key description width
   (let ((key-width 1))
-(dolist (action action-map)
+(dolist (entry action-map)
   (setq key-width
(max key-width
-(string-width (format-kbd-macro (first action))
+(string-width (format-kbd-macro (first entry))
 ;; Format each action
-(mapcar (lambda (action)
- (let ((key (format-kbd-macro (first action)))
-   (desc (second action)))
+(mapcar (lambda (entry)
+ (let ((key (format-kbd-macro (first entry)))
+   (desc (second entry)))
(concat
 (propertize key 'face 'minibuffer-prompt)
 (make-string (- key-width (length key)) ? )
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 135422d..b338aaa 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -25,6 +25,9 @@
 (require 'mm-decode)
 (require 'cl)

+(autoload 'notmuch-jump-search "notmuch-jump"
+  "Jump to a saved search by shortcut key." t)
+
 (defvar notmuch-command "notmuch"
   "Command to run the notmuch binary.")

@@ -134,8 +137,6 @@ (defvar notmuch-common-keymap
 map)
   "Keymap shared by all notmuch modes.")

-(autoload 'notmuch-jump-search "notmuch-jump" "Jump to a saved search by 
shortcut key." t)
-
 ;; By default clicking on a button does not select the window
 ;; containing the button (as opposed to clicking on a widget which
 ;; does). This means that the button action is then executed in the




notmuch-reply date format

2014-07-15 Thread Sime Ramov
Hello,

* Austin Clements  [Mon, 14 Jul 2014 09:04:31 -0400]:
> Assuming the CLI is the right place for you to change this, you
> probably want to call notmuch_message_get_date, then localtime, then
> strftime.

Tried to get this working to no avail. Not a programmer obviously :) I
cobbled this together from various online sources:

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 7c1c809..16cf19c 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -44,9 +44,15 @@ format_part_reply (mime_node_t *node)
 int i;

 if (node->envelope_file) {
-   printf ("On %s, %s wrote:\n",
-   notmuch_message_get_header (node->envelope_file, "date"),
-   notmuch_message_get_header (node->envelope_file, "from"));
+   struct tm *info;
+   char dbuf[30];
+
+   info = localtime(notmuch_message_get_date(node->envelope_file));
+
+   strftime(dbuf, sizeof(dbuf), "%F %R %z", info);
+   printf ("* %s [%s]:\n",
+   notmuch_message_get_header(node->envelope_file, "from"), dbuf);
+
 } else if (GMIME_IS_MESSAGE (node->part)) {
GMimeMessage *message = GMIME_MESSAGE (node->part);
InternetAddressList *recipients;

When compiling I get this warning:

notmuch-reply.c: In function 'format_part_reply':
notmuch-reply.c:50: warning: passing argument 1 of 'localtime' makes pointer 
from integer without a cast

And a core dump when notmuch reply is invoked on a message. Am I even
close? :) Thanks


[PATCH] emacs: tree/show remove duplicate function

2014-07-15 Thread Mark Walters
On Tue, 15 Jul 2014, David Bremner  wrote:
> Mark Walters  writes:
>> +   (cond ((eq major-mode 'notmuch-show-mode)
>> +  (notmuch-show-get-message-properties))
>> + ((eq major-mode 'notmuch-tree-mode)
>> +  (notmuch-tree-get-message-properties
>
> I see this already existed, but it looks weird to me to have a two test
> cond with no else. Is it intentional to have the code drop through and
> do nothing if neither case matches?  It seems like it might be better to
> signal an error.

I can definitely do that. But as a comparison
notmuch-search-get-result and notmuch-search-find-thread-id "work" in
any buffer in the sense of returning nil but not complaining so perhaps
the current version is more consistent. 

Plausibly a comment and an explicit nil case would be clearer for the other 
modes.

Best wishes

Mark





[PATCH 1/2] emacs: Introduce notmuch-jump: shortcut keys to saved searches

2014-07-15 Thread Mark Walters
On Tue, 15 Jul 2014, Austin Clements  wrote:
> Quoth Mark Walters on Jul 14 at 10:22 pm:
>> 
>> On Mon, 14 Jul 2014, Austin Clements  wrote:
>> > This introduces notmuch-jump, which is like a user-friendly,
>> > user-configurable global prefix map for saved searches.  This provides
>> > a non-modal and much faster way to access saved searches than
>> > notmuch-hello.
>> >
>> > A user configures shortcut keys in notmuch-saved-searches, which are
>> > immediately accessible from anywhere in Notmuch under the "j" key (for
>> > "jump").  When the user hits "j", the minibuffer immediately shows a
>> > helpful table of bindings reminiscent of a completions buffer.
>> 
>> I am basically happy with this: the only downside compared to dme's
>> patch is that this is quite substantially bigger. However, since this is
>> all in it's own file that is not really a problem.
>> 
>> I have a few comments below. In all cases I am happy to go with the
>> current code if you think it's better than my suggestion.
>> 
>> > This code is a combination of work from myself (originally,
>> > "notmuch-go"), David Edmondson, and modifications from Mark Walters.
>> > ---
>> >  emacs/Makefile.local   |   3 +-
>> >  emacs/notmuch-hello.el |   2 +
>> >  emacs/notmuch-jump.el  | 189 
>> > +
>> >  emacs/notmuch-lib.el   |   3 +
>> >  4 files changed, 196 insertions(+), 1 deletion(-)
>> >  create mode 100644 emacs/notmuch-jump.el
>> >
>> > diff --git a/emacs/Makefile.local b/emacs/Makefile.local
>> > index c0d6b19..1109cfa 100644
>> > --- a/emacs/Makefile.local
>> > +++ b/emacs/Makefile.local
>> > @@ -18,7 +18,8 @@ emacs_sources := \
>> >$(dir)/notmuch-tag.el \
>> >$(dir)/coolj.el \
>> >$(dir)/notmuch-print.el \
>> > -  $(dir)/notmuch-version.el
>> > +  $(dir)/notmuch-version.el \
>> > +  $(dir)/notmuch-jump.el \
>> >  
>> >  $(dir)/notmuch-version.el: $(dir)/Makefile.local version.stamp
>> >  $(dir)/notmuch-version.el: $(srcdir)/$(dir)/notmuch-version.el.tmpl
>> > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
>> > index 3de5238..061b27d 100644
>> > --- a/emacs/notmuch-hello.el
>> > +++ b/emacs/notmuch-hello.el
>> > @@ -85,6 +85,7 @@ (define-widget 'notmuch-saved-search-plist 'list
>> >(group :format "%v" :inline t (const :format "  Query: " 
>> > :query) (string :format "%v")))
>> >  (checklist :inline t
>> > :format "%v"
>> > +   (group :format "%v" :inline t (const :format "Shortcut 
>> > key: " :key) (key-sequence :format "%v"))
>> > (group :format "%v" :inline t (const :format "Count-Query: 
>> > " :count-query) (string :format "%v"))
>> > (group :format "%v" :inline t (const :format "" 
>> > :sort-order)
>> >(choice :tag " Sort Order"
>> > @@ -101,6 +102,7 @@ (defcustom notmuch-saved-searches '((:name "inbox" 
>> > :query "tag:inbox")
>> >  
>> >:nameName of the search (required).
>> >:query   Search to run (required).
>> > +  :key Optional shortcut key for `notmuch-jump-search'.
>> >:count-query Optional extra query to generate the count
>> > shown. If not present then the :query property
>> > is used.
>> > diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
>> > new file mode 100644
>> > index 000..cb1ae10
>> > --- /dev/null
>> > +++ b/emacs/notmuch-jump.el
>> > @@ -0,0 +1,189 @@
>> > +;; notmuch-jump.el --- User-friendly shortcut keys
>> > +;;
>> > +;; Copyright ? Austin Clements
>> > +;;
>> > +;; This file is part of Notmuch.
>> > +;;
>> > +;; Notmuch is free software: you can redistribute it and/or modify it
>> > +;; under the terms of the GNU General Public License as published by
>> > +;; the Free Software Foundation, either version 3 of the License, or
>> > +;; (at your option) any later version.
>> > +;;
>> > +;; Notmuch is distributed in the hope that it will be useful, but
>> > +;; WITHOUT ANY WARRANTY; without even the implied warranty of
>> > +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> > +;; General Public License for more details.
>> > +;;
>> > +;; You should have received a copy of the GNU General Public License
>> > +;; along with Notmuch.  If not, see .
>> > +;;
>> > +;; Authors: Austin Clements 
>> > +;;  David Edmondson 
>> > +
>> > +(eval-when-compile (require 'cl))
>> > +
>> > +(require 'notmuch-hello)
>> > +
>> > +;;;###autoload
>> > +(defun notmuch-jump-search ()
>> > +  "Jump to a saved search by shortcut key.
>> > +
>> > +This prompts for and performs a saved search using the shortcut
>> > +keys configured in the :key property of `notmuch-saved-searches'.
>> > +Typically these shortcuts are a single key long, so this is a
>> > +fast way to jump to a saved search from anywhere in Notmuch."
>> > +  (interactive)
>> > +
>> > +  ;; Build the action map
>> > +  (let (action-map)

nevermore

2014-07-15 Thread David Bremner
Trevor Jim  writes:

> Nevermore is an experimental emacs email interface for Notmuch.
> It provides:
>
> * Interactive search
> * Snooze
> * Tag editing with autocompletion
> * Mail address completion (via company-mode)
> * Junk mail filtering (via bogofilter)

At least the interactive search and the completion are both quite nice,
and it would be great to borrow that code for the default emacs
interface.  A minor usability feature I liked was that the second pane
updated as I moved between message headers in the nevermore
equivalent of tree view.

d


[PATCH] emacs: tree/show remove duplicate function

2014-07-15 Thread David Bremner
Mark Walters  writes:

>
> Plausibly a comment and an explicit nil case would be clearer for the other 
> modes.
>

Your call. 

d


[PATCH 1/2] emacs: Introduce notmuch-jump: shortcut keys to saved searches

2014-07-15 Thread Austin Clements
Quoth Mark Walters on Jul 14 at 10:22 pm:
> 
> On Mon, 14 Jul 2014, Austin Clements  wrote:
> > This introduces notmuch-jump, which is like a user-friendly,
> > user-configurable global prefix map for saved searches.  This provides
> > a non-modal and much faster way to access saved searches than
> > notmuch-hello.
> >
> > A user configures shortcut keys in notmuch-saved-searches, which are
> > immediately accessible from anywhere in Notmuch under the "j" key (for
> > "jump").  When the user hits "j", the minibuffer immediately shows a
> > helpful table of bindings reminiscent of a completions buffer.
> 
> I am basically happy with this: the only downside compared to dme's
> patch is that this is quite substantially bigger. However, since this is
> all in it's own file that is not really a problem.
> 
> I have a few comments below. In all cases I am happy to go with the
> current code if you think it's better than my suggestion.
> 
> > This code is a combination of work from myself (originally,
> > "notmuch-go"), David Edmondson, and modifications from Mark Walters.
> > ---
> >  emacs/Makefile.local   |   3 +-
> >  emacs/notmuch-hello.el |   2 +
> >  emacs/notmuch-jump.el  | 189 
> > +
> >  emacs/notmuch-lib.el   |   3 +
> >  4 files changed, 196 insertions(+), 1 deletion(-)
> >  create mode 100644 emacs/notmuch-jump.el
> >
> > diff --git a/emacs/Makefile.local b/emacs/Makefile.local
> > index c0d6b19..1109cfa 100644
> > --- a/emacs/Makefile.local
> > +++ b/emacs/Makefile.local
> > @@ -18,7 +18,8 @@ emacs_sources := \
> > $(dir)/notmuch-tag.el \
> > $(dir)/coolj.el \
> > $(dir)/notmuch-print.el \
> > -   $(dir)/notmuch-version.el
> > +   $(dir)/notmuch-version.el \
> > +   $(dir)/notmuch-jump.el \
> >  
> >  $(dir)/notmuch-version.el: $(dir)/Makefile.local version.stamp
> >  $(dir)/notmuch-version.el: $(srcdir)/$(dir)/notmuch-version.el.tmpl
> > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> > index 3de5238..061b27d 100644
> > --- a/emacs/notmuch-hello.el
> > +++ b/emacs/notmuch-hello.el
> > @@ -85,6 +85,7 @@ (define-widget 'notmuch-saved-search-plist 'list
> > (group :format "%v" :inline t (const :format "  Query: " 
> > :query) (string :format "%v")))
> >   (checklist :inline t
> >  :format "%v"
> > +(group :format "%v" :inline t (const :format "Shortcut 
> > key: " :key) (key-sequence :format "%v"))
> >  (group :format "%v" :inline t (const :format "Count-Query: 
> > " :count-query) (string :format "%v"))
> >  (group :format "%v" :inline t (const :format "" 
> > :sort-order)
> > (choice :tag " Sort Order"
> > @@ -101,6 +102,7 @@ (defcustom notmuch-saved-searches '((:name "inbox" 
> > :query "tag:inbox")
> >  
> >:nameName of the search (required).
> >:query   Search to run (required).
> > +  :key Optional shortcut key for `notmuch-jump-search'.
> >:count-query Optional extra query to generate the count
> > shown. If not present then the :query property
> > is used.
> > diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
> > new file mode 100644
> > index 000..cb1ae10
> > --- /dev/null
> > +++ b/emacs/notmuch-jump.el
> > @@ -0,0 +1,189 @@
> > +;; notmuch-jump.el --- User-friendly shortcut keys
> > +;;
> > +;; Copyright ? Austin Clements
> > +;;
> > +;; This file is part of Notmuch.
> > +;;
> > +;; Notmuch is free software: you can redistribute it and/or modify it
> > +;; under the terms of the GNU General Public License as published by
> > +;; the Free Software Foundation, either version 3 of the License, or
> > +;; (at your option) any later version.
> > +;;
> > +;; Notmuch is distributed in the hope that it will be useful, but
> > +;; WITHOUT ANY WARRANTY; without even the implied warranty of
> > +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > +;; General Public License for more details.
> > +;;
> > +;; You should have received a copy of the GNU General Public License
> > +;; along with Notmuch.  If not, see .
> > +;;
> > +;; Authors: Austin Clements 
> > +;;  David Edmondson 
> > +
> > +(eval-when-compile (require 'cl))
> > +
> > +(require 'notmuch-hello)
> > +
> > +;;;###autoload
> > +(defun notmuch-jump-search ()
> > +  "Jump to a saved search by shortcut key.
> > +
> > +This prompts for and performs a saved search using the shortcut
> > +keys configured in the :key property of `notmuch-saved-searches'.
> > +Typically these shortcuts are a single key long, so this is a
> > +fast way to jump to a saved search from anywhere in Notmuch."
> > +  (interactive)
> > +
> > +  ;; Build the action map
> > +  (let (action-map)
> > +(dolist (saved-search notmuch-saved-searches)
> > +  (let* ((saved-search (notmuch-hello-saved-search-to-plist 
> > saved-search))
> > 

Re: [PATCH 1/2] emacs: Introduce notmuch-jump: shortcut keys to saved searches

2014-07-15 Thread Mark Walters
On Tue, 15 Jul 2014, Austin Clements amdra...@mit.edu wrote:
 Quoth Mark Walters on Jul 14 at 10:22 pm:
 
 On Mon, 14 Jul 2014, Austin Clements amdra...@mit.edu wrote:
  This introduces notmuch-jump, which is like a user-friendly,
  user-configurable global prefix map for saved searches.  This provides
  a non-modal and much faster way to access saved searches than
  notmuch-hello.
 
  A user configures shortcut keys in notmuch-saved-searches, which are
  immediately accessible from anywhere in Notmuch under the j key (for
  jump).  When the user hits j, the minibuffer immediately shows a
  helpful table of bindings reminiscent of a completions buffer.
 
 I am basically happy with this: the only downside compared to dme's
 patch is that this is quite substantially bigger. However, since this is
 all in it's own file that is not really a problem.
 
 I have a few comments below. In all cases I am happy to go with the
 current code if you think it's better than my suggestion.
 
  This code is a combination of work from myself (originally,
  notmuch-go), David Edmondson, and modifications from Mark Walters.
  ---
   emacs/Makefile.local   |   3 +-
   emacs/notmuch-hello.el |   2 +
   emacs/notmuch-jump.el  | 189 
  +
   emacs/notmuch-lib.el   |   3 +
   4 files changed, 196 insertions(+), 1 deletion(-)
   create mode 100644 emacs/notmuch-jump.el
 
  diff --git a/emacs/Makefile.local b/emacs/Makefile.local
  index c0d6b19..1109cfa 100644
  --- a/emacs/Makefile.local
  +++ b/emacs/Makefile.local
  @@ -18,7 +18,8 @@ emacs_sources := \
 $(dir)/notmuch-tag.el \
 $(dir)/coolj.el \
 $(dir)/notmuch-print.el \
  -  $(dir)/notmuch-version.el
  +  $(dir)/notmuch-version.el \
  +  $(dir)/notmuch-jump.el \
   
   $(dir)/notmuch-version.el: $(dir)/Makefile.local version.stamp
   $(dir)/notmuch-version.el: $(srcdir)/$(dir)/notmuch-version.el.tmpl
  diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
  index 3de5238..061b27d 100644
  --- a/emacs/notmuch-hello.el
  +++ b/emacs/notmuch-hello.el
  @@ -85,6 +85,7 @@ (define-widget 'notmuch-saved-search-plist 'list
 (group :format %v :inline t (const :format   Query:  
  :query) (string :format %v)))
   (checklist :inline t
  :format %v
  +   (group :format %v :inline t (const :format Shortcut 
  key:  :key) (key-sequence :format %v))
  (group :format %v :inline t (const :format Count-Query: 
   :count-query) (string :format %v))
  (group :format %v :inline t (const :format  
  :sort-order)
 (choice :tag  Sort Order
  @@ -101,6 +102,7 @@ (defcustom notmuch-saved-searches '((:name inbox 
  :query tag:inbox)
   
 :nameName of the search (required).
 :query   Search to run (required).
  +  :key Optional shortcut key for `notmuch-jump-search'.
 :count-query Optional extra query to generate the count
  shown. If not present then the :query property
  is used.
  diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
  new file mode 100644
  index 000..cb1ae10
  --- /dev/null
  +++ b/emacs/notmuch-jump.el
  @@ -0,0 +1,189 @@
  +;; notmuch-jump.el --- User-friendly shortcut keys
  +;;
  +;; Copyright © Austin Clements
  +;;
  +;; This file is part of Notmuch.
  +;;
  +;; Notmuch is free software: you can redistribute it and/or modify it
  +;; under the terms of the GNU General Public License as published by
  +;; the Free Software Foundation, either version 3 of the License, or
  +;; (at your option) any later version.
  +;;
  +;; Notmuch is distributed in the hope that it will be useful, but
  +;; WITHOUT ANY WARRANTY; without even the implied warranty of
  +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  +;; General Public License for more details.
  +;;
  +;; You should have received a copy of the GNU General Public License
  +;; along with Notmuch.  If not, see http://www.gnu.org/licenses/.
  +;;
  +;; Authors: Austin Clements acleme...@csail.mit.edu
  +;;  David Edmondson d...@dme.org
  +
  +(eval-when-compile (require 'cl))
  +
  +(require 'notmuch-hello)
  +
  +;;;###autoload
  +(defun notmuch-jump-search ()
  +  Jump to a saved search by shortcut key.
  +
  +This prompts for and performs a saved search using the shortcut
  +keys configured in the :key property of `notmuch-saved-searches'.
  +Typically these shortcuts are a single key long, so this is a
  +fast way to jump to a saved search from anywhere in Notmuch.
  +  (interactive)
  +
  +  ;; Build the action map
  +  (let (action-map)
  +(dolist (saved-search notmuch-saved-searches)
  +  (let* ((saved-search (notmuch-hello-saved-search-to-plist 
  saved-search))
  +   (key (plist-get saved-search :key)))
  +  (when key
  +(let ((name (plist-get saved-search :name))
  +  (query (plist-get saved-search :query))
  

Re: [PATCH] emacs: tree/show remove duplicate function

2014-07-15 Thread Mark Walters
On Tue, 15 Jul 2014, David Bremner da...@tethera.net wrote:
 Mark Walters markwalters1...@gmail.com writes:
 +   (cond ((eq major-mode 'notmuch-show-mode)
 +  (notmuch-show-get-message-properties))
 + ((eq major-mode 'notmuch-tree-mode)
 +  (notmuch-tree-get-message-properties

 I see this already existed, but it looks weird to me to have a two test
 cond with no else. Is it intentional to have the code drop through and
 do nothing if neither case matches?  It seems like it might be better to
 signal an error.

I can definitely do that. But as a comparison
notmuch-search-get-result and notmuch-search-find-thread-id work in
any buffer in the sense of returning nil but not complaining so perhaps
the current version is more consistent. 

Plausibly a comment and an explicit nil case would be clearer for the other 
modes.

Best wishes

Mark



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


Re: notmuch-reply date format

2014-07-15 Thread Sime Ramov
Hello,

* Austin Clements amdra...@mit.edu [Mon, 14 Jul 2014 09:04:31 -0400]:
 Assuming the CLI is the right place for you to change this, you
 probably want to call notmuch_message_get_date, then localtime, then
 strftime.

Tried to get this working to no avail. Not a programmer obviously :) I
cobbled this together from various online sources:

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 7c1c809..16cf19c 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -44,9 +44,15 @@ format_part_reply (mime_node_t *node)
 int i;
 
 if (node-envelope_file) {
-   printf (On %s, %s wrote:\n,
-   notmuch_message_get_header (node-envelope_file, date),
-   notmuch_message_get_header (node-envelope_file, from));
+   struct tm *info;
+   char dbuf[30];
+
+   info = localtime(notmuch_message_get_date(node-envelope_file));
+
+   strftime(dbuf, sizeof(dbuf), %F %R %z, info);
+   printf (* %s [%s]:\n,
+   notmuch_message_get_header(node-envelope_file, from), dbuf);
+
 } else if (GMIME_IS_MESSAGE (node-part)) {
GMimeMessage *message = GMIME_MESSAGE (node-part);
InternetAddressList *recipients;

When compiling I get this warning:

notmuch-reply.c: In function 'format_part_reply':
notmuch-reply.c:50: warning: passing argument 1 of 'localtime' makes pointer 
from integer without a cast

And a core dump when notmuch reply is invoked on a message. Am I even
close? :) Thanks
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: tree/show remove duplicate function

2014-07-15 Thread David Bremner
Mark Walters markwalters1...@gmail.com writes:


 Plausibly a comment and an explicit nil case would be clearer for the other 
 modes.


Your call. 

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


Re: nevermore

2014-07-15 Thread David Bremner
Trevor Jim t...@mac.com writes:

 Nevermore is an experimental emacs email interface for Notmuch.
 It provides:

 * Interactive search
 * Snooze
 * Tag editing with autocompletion
 * Mail address completion (via company-mode)
 * Junk mail filtering (via bogofilter)

At least the interactive search and the completion are both quite nice,
and it would be great to borrow that code for the default emacs
interface.  A minor usability feature I liked was that the second pane
updated as I moved between message headers in the nevermore
equivalent of tree view.

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


[PATCH v2 2/2] emacs: Expand default saved searches and add shortcut keys

2014-07-15 Thread Austin Clements
This should help new users off to a better start with the addition of
more sensible saved searches and default shortcut keys.  Most existing
users have probably customized this variable and won't be affected.
---
 emacs/notmuch-hello.el  | 9 +++--
 test/emacs.expected-output/notmuch-hello| 2 +-
 test/emacs.expected-output/notmuch-hello-long-names | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 061b27d..65d0627 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -93,8 +93,13 @@ (define-widget 'notmuch-saved-search-plist 'list
(const :tag Oldest-first oldest-first)
(const :tag Newest-first 
newest-first))
 
-(defcustom notmuch-saved-searches '((:name inbox :query tag:inbox)
-   (:name unread :query tag:unread))
+(defcustom notmuch-saved-searches
+  `((:name inbox :query tag:inbox :key ,(kbd i))
+(:name unread :query tag:unread :key ,(kbd u))
+(:name flagged :query tag:flagged :key ,(kbd f))
+(:name sent :query tag:sent :key ,(kbd t))
+(:name drafts :query tag:draft :key ,(kbd d))
+(:name all mail :query * :key ,(kbd a)))
   A list of saved searches to display.
 
 The saved search can be given in 3 forms. The preferred way is as
diff --git a/test/emacs.expected-output/notmuch-hello 
b/test/emacs.expected-output/notmuch-hello
index 2d69891..9ba4cfc 100644
--- a/test/emacs.expected-output/notmuch-hello
+++ b/test/emacs.expected-output/notmuch-hello
@@ -2,7 +2,7 @@
 
 Saved searches: [edit]
 
- 52 inbox   52 unread
+ 52 inbox   52 unread  52 all mail
 
 Search: .
 
diff --git a/test/emacs.expected-output/notmuch-hello-long-names 
b/test/emacs.expected-output/notmuch-hello-long-names
index 486d0d9..1c8d6eb 100644
--- a/test/emacs.expected-output/notmuch-hello-long-names
+++ b/test/emacs.expected-output/notmuch-hello-long-names
@@ -2,7 +2,7 @@
 
 Saved searches: [edit]
 
- 52 inbox   52 unread
+ 52 inbox   52 unread  52 all mail
 
 Search: .
 
-- 
2.0.0

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


[PATCH v2 1/2] emacs: Introduce notmuch-jump: shortcut keys to saved searches

2014-07-15 Thread Austin Clements
This introduces notmuch-jump, which is like a user-friendly,
user-configurable global prefix map for saved searches.  This provides
a non-modal and much faster way to access saved searches than
notmuch-hello.

A user configures shortcut keys in notmuch-saved-searches, which are
immediately accessible from anywhere in Notmuch under the j key (for
jump).  When the user hits j, the minibuffer immediately shows a
helpful table of bindings reminiscent of a completions buffer.

This code is a combination of work from myself (originally,
notmuch-go), David Edmondson, and modifications from Mark Walters.
---
 emacs/Makefile.local   |   3 +-
 emacs/notmuch-hello.el |   2 +
 emacs/notmuch-jump.el  | 181 +
 emacs/notmuch-lib.el   |   4 ++
 4 files changed, 189 insertions(+), 1 deletion(-)
 create mode 100644 emacs/notmuch-jump.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index c0d6b19..1109cfa 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -18,7 +18,8 @@ emacs_sources := \
$(dir)/notmuch-tag.el \
$(dir)/coolj.el \
$(dir)/notmuch-print.el \
-   $(dir)/notmuch-version.el
+   $(dir)/notmuch-version.el \
+   $(dir)/notmuch-jump.el \
 
 $(dir)/notmuch-version.el: $(dir)/Makefile.local version.stamp
 $(dir)/notmuch-version.el: $(srcdir)/$(dir)/notmuch-version.el.tmpl
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 3de5238..061b27d 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -85,6 +85,7 @@ (define-widget 'notmuch-saved-search-plist 'list
(group :format %v :inline t (const :format   Query:  
:query) (string :format %v)))
  (checklist :inline t
 :format %v
+(group :format %v :inline t (const :format Shortcut 
key:  :key) (key-sequence :format %v))
 (group :format %v :inline t (const :format Count-Query: 
 :count-query) (string :format %v))
 (group :format %v :inline t (const :format  
:sort-order)
(choice :tag  Sort Order
@@ -101,6 +102,7 @@ (defcustom notmuch-saved-searches '((:name inbox :query 
tag:inbox)
 
   :nameName of the search (required).
   :query   Search to run (required).
+  :key Optional shortcut key for `notmuch-jump-search'.
   :count-query Optional extra query to generate the count
shown. If not present then the :query property
is used.
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
new file mode 100644
index 000..9cb1e6a
--- /dev/null
+++ b/emacs/notmuch-jump.el
@@ -0,0 +1,181 @@
+;; notmuch-jump.el --- User-friendly shortcut keys
+;;
+;; Copyright © Austin Clements
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with Notmuch.  If not, see http://www.gnu.org/licenses/.
+;;
+;; Authors: Austin Clements acleme...@csail.mit.edu
+;;  David Edmondson d...@dme.org
+
+(eval-when-compile (require 'cl))
+
+(require 'notmuch-hello)
+
+;;;###autoload
+(defun notmuch-jump-search ()
+  Jump to a saved search by shortcut key.
+
+This prompts for and performs a saved search using the shortcut
+keys configured in the :key property of `notmuch-saved-searches'.
+Typically these shortcuts are a single key long, so this is a
+fast way to jump to a saved search from anywhere in Notmuch.
+  (interactive)
+
+  ;; Build the action map
+  (let (action-map)
+(dolist (saved-search notmuch-saved-searches)
+  (let* ((saved-search (notmuch-hello-saved-search-to-plist saved-search))
+(key (plist-get saved-search :key)))
+   (when key
+ (let ((name (plist-get saved-search :name))
+   (query (plist-get saved-search :query))
+   (oldest-first
+(case (plist-get saved-search :sort-order)
+  (newest-first nil)
+  (oldest-first t)
+  (otherwise (default-value notmuch-search-oldest-first)
+   (push (list key name
+   `(lambda () (notmuch-search ',query ',oldest-first)))
+ action-map)
+(setq action-map (nreverse action-map))
+
+(if action-map
+   (notmuch-jump action-map Search: )
+  (error To use notmuch-jump, please customize shortcut keys in 
notmuch-saved-searches.
+
+(defvar notmuch-jump--action nil)

Re: [PATCH] dump: make dump take Xapian write lock

2014-07-15 Thread David Bremner
Mark Walters markwalters1...@gmail.com writes:


 Discussion with Olly on irc indicates that this is currently the best
 solution: in xapian trunk there may be better possibilities using
 snapshots but they need to make it to a release and propogate out to
 users before we can switch approach.

I agree that this seems to be the only feasible approach to make dump
atomic.  I'm a little unsure about the benefits to the end user though.
Currently, the user has to check the return code of dump to ensure it
completed correctly.  With this change, the user will still have to
check that dump did not error out when trying to acquire a write lock.
The following ticket

  http://trac.xapian.org/ticket/275

suggests that if we wanted to a blocking open, we'd be on our own.

Did I miss something here about the benefits? I agree that failing
earlier is nicer, but is that it?

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


Re: notmuch-reply date format

2014-07-15 Thread Austin Clements
Quoth Sime Ramov on Jul 15 at  9:35 am:
 Hello,
 
 * Austin Clements amdra...@mit.edu [Mon, 14 Jul 2014 09:04:31 -0400]:
  Assuming the CLI is the right place for you to change this, you
  probably want to call notmuch_message_get_date, then localtime, then
  strftime.
 
 Tried to get this working to no avail. Not a programmer obviously :) I
 cobbled this together from various online sources:
 
 diff --git a/notmuch-reply.c b/notmuch-reply.c
 index 7c1c809..16cf19c 100644
 --- a/notmuch-reply.c
 +++ b/notmuch-reply.c
 @@ -44,9 +44,15 @@ format_part_reply (mime_node_t *node)
  int i;
  
  if (node-envelope_file) {
 - printf (On %s, %s wrote:\n,
 - notmuch_message_get_header (node-envelope_file, date),
 - notmuch_message_get_header (node-envelope_file, from));
 + struct tm *info;
 + char dbuf[30];
 +
 + info = localtime(notmuch_message_get_date(node-envelope_file));

Close.  For whatever reason, localtime takes a pointer to a time_t,
not a time_t (even though time_t is just a number).  You'll need
something like

time_t date;

date = notmuch_message_get_date(node-envelope_file);
info = localtime(date);

 +
 + strftime(dbuf, sizeof(dbuf), %F %R %z, info);
 + printf (* %s [%s]:\n,
 + notmuch_message_get_header(node-envelope_file, from), dbuf);
 +
  } else if (GMIME_IS_MESSAGE (node-part)) {
   GMimeMessage *message = GMIME_MESSAGE (node-part);
   InternetAddressList *recipients;
 
 When compiling I get this warning:
 
 notmuch-reply.c: In function 'format_part_reply':
 notmuch-reply.c:50: warning: passing argument 1 of 'localtime' makes pointer 
 from integer without a cast

Ah, C.  I'm sure they meant for that number that looks nothing like a
pointer to actually be a pointer that could corrupt memory, disclose
private information, or crash the program.  I'll just convert it for
them real quick...

 And a core dump when notmuch reply is invoked on a message. Am I even
 close? :) Thanks
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 0/2] emacs: Shortcut keys to saved searches

2014-07-15 Thread Austin Clements
This is version 2 of
id:1405353735-26244-1-git-send-email-amdra...@mit.edu and addresses
Mark's comments in id:87egxnd4aq@qmul.ac.uk.

The diff from v1 is below.

diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index cb1ae10..9cb1e6a 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -53,20 +53,19 @@ (defun notmuch-jump-search ()
 (setq action-map (nreverse action-map))
 
 (if action-map
-   (notmuch-jump action-map Search )
-  (error No shortcut keys for saved searches.  Please customize 
notmuch-saved-searches.
+   (notmuch-jump action-map Search: )
+  (error To use notmuch-jump, please customize shortcut keys in 
notmuch-saved-searches.
 
 (defvar notmuch-jump--action nil)
 
 (defun notmuch-jump (action-map prompt)
   Interactively prompt for one of the keys in ACTION-MAP.
 
-Displays a pop-up temporary buffer with a summary of all bindings
-in ACTION-MAP, reads a key from the minibuffer, and performs the
-corresponding action.  The prompt can be canceled with C-g.
-PROMPT must be a string to use for the prompt if this command was
-not invoked directly by a key binding (e.g., it was invoked
-through M-x).  PROMPT should include a space at the end.
+Displays a summary of all bindings in ACTION-MAP in the
+minibuffer, reads a key from the minibuffer, and performs the
+corresponding action.  The prompt can be canceled with C-g or
+RET.  PROMPT must be a string to use for the prompt.  PROMPT
+should include a space at the end.
 
 ACTION-MAP must be a list of triples of the form
   (KEY LABEL ACTION)
@@ -82,16 +81,9 @@ (defun notmuch-jump (action-map prompt)
  (with-temp-buffer
(notmuch-jump--insert-items (window-body-width) items)
(buffer-string)))
-(prompt-text
- (if (eq this-original-command this-command)
- ;; Make it look like we're just part of any regular
- ;; submap prompt (like C-x, C-c, etc.)
- (concat (format-kbd-macro (this-command-keys)) -)
-   ;; We were invoked through something like M-x
-   prompt))
 (full-prompt
  (concat table \n\n
- (propertize prompt-text 'face 'minibuffer-prompt)))
+ (propertize prompt 'face 'minibuffer-prompt)))
 ;; By default, the minibuffer applies the minibuffer face to
 ;; the entire prompt.  However, we want to clearly
 ;; distinguish bindings (which we put in the prompt face
@@ -121,14 +113,14 @@ (defun notmuch-jump--format-actions (action-map)
 
   ;; Compute the maximum key description width
   (let ((key-width 1))
-(dolist (action action-map)
+(dolist (entry action-map)
   (setq key-width
(max key-width
-(string-width (format-kbd-macro (first action))
+(string-width (format-kbd-macro (first entry))
 ;; Format each action
-(mapcar (lambda (action)
- (let ((key (format-kbd-macro (first action)))
-   (desc (second action)))
+(mapcar (lambda (entry)
+ (let ((key (format-kbd-macro (first entry)))
+   (desc (second entry)))
(concat
 (propertize key 'face 'minibuffer-prompt)
 (make-string (- key-width (length key)) ? )
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 135422d..b338aaa 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -25,6 +25,9 @@
 (require 'mm-decode)
 (require 'cl)
 
+(autoload 'notmuch-jump-search notmuch-jump
+  Jump to a saved search by shortcut key. t)
+
 (defvar notmuch-command notmuch
   Command to run the notmuch binary.)
 
@@ -134,8 +137,6 @@ (defvar notmuch-common-keymap
 map)
   Keymap shared by all notmuch modes.)
 
-(autoload 'notmuch-jump-search notmuch-jump Jump to a saved search by 
shortcut key. t)
-
 ;; By default clicking on a button does not select the window
 ;; containing the button (as opposed to clicking on a widget which
 ;; does). This means that the button action is then executed in the


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


Re: notmuch-reply date format

2014-07-15 Thread Sime Ramov
Hi,

* Austin Clements amdra...@mit.edu [2014-07-15 16:14 +0200]:
 Close. For whatever reason, localtime takes a pointer to a time_t,
 not a time_t (even though time_t is just a number). You'll need
 something like

 [...]

Thank you *so much*, everything is in order now! Finally a nice
attribution line :)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 0/2] emacs: Shortcut keys to saved searches

2014-07-15 Thread Mark Walters

On Tue, 15 Jul 2014, Austin Clements amdra...@mit.edu wrote:
 This is version 2 of
 id:1405353735-26244-1-git-send-email-amdra...@mit.edu and addresses
 Mark's comments in id:87egxnd4aq@qmul.ac.uk.

 The diff from v1 is below.

This version gets a +1 from me. I would have a slight preference for
making the prompt Jump to search:  rather than Search:  to emphasise
that you can't type an actual search, but am definitely happy with this
version.

Best wishes

Mark





 diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
 index cb1ae10..9cb1e6a 100644
 --- a/emacs/notmuch-jump.el
 +++ b/emacs/notmuch-jump.el
 @@ -53,20 +53,19 @@ (defun notmuch-jump-search ()
  (setq action-map (nreverse action-map))
  
  (if action-map
 - (notmuch-jump action-map Search )
 -  (error No shortcut keys for saved searches.  Please customize 
 notmuch-saved-searches.
 + (notmuch-jump action-map Search: )
 +  (error To use notmuch-jump, please customize shortcut keys in 
 notmuch-saved-searches.
  
  (defvar notmuch-jump--action nil)
  
  (defun notmuch-jump (action-map prompt)
Interactively prompt for one of the keys in ACTION-MAP.
  
 -Displays a pop-up temporary buffer with a summary of all bindings
 -in ACTION-MAP, reads a key from the minibuffer, and performs the
 -corresponding action.  The prompt can be canceled with C-g.
 -PROMPT must be a string to use for the prompt if this command was
 -not invoked directly by a key binding (e.g., it was invoked
 -through M-x).  PROMPT should include a space at the end.
 +Displays a summary of all bindings in ACTION-MAP in the
 +minibuffer, reads a key from the minibuffer, and performs the
 +corresponding action.  The prompt can be canceled with C-g or
 +RET.  PROMPT must be a string to use for the prompt.  PROMPT
 +should include a space at the end.
  
  ACTION-MAP must be a list of triples of the form
(KEY LABEL ACTION)
 @@ -82,16 +81,9 @@ (defun notmuch-jump (action-map prompt)
 (with-temp-buffer
   (notmuch-jump--insert-items (window-body-width) items)
   (buffer-string)))
 -  (prompt-text
 -   (if (eq this-original-command this-command)
 -   ;; Make it look like we're just part of any regular
 -   ;; submap prompt (like C-x, C-c, etc.)
 -   (concat (format-kbd-macro (this-command-keys)) -)
 - ;; We were invoked through something like M-x
 - prompt))
(full-prompt
 (concat table \n\n
 -   (propertize prompt-text 'face 'minibuffer-prompt)))
 +   (propertize prompt 'face 'minibuffer-prompt)))
;; By default, the minibuffer applies the minibuffer face to
;; the entire prompt.  However, we want to clearly
;; distinguish bindings (which we put in the prompt face
 @@ -121,14 +113,14 @@ (defun notmuch-jump--format-actions (action-map)
  
;; Compute the maximum key description width
(let ((key-width 1))
 -(dolist (action action-map)
 +(dolist (entry action-map)
(setq key-width
   (max key-width
 -  (string-width (format-kbd-macro (first action))
 +  (string-width (format-kbd-macro (first entry))
  ;; Format each action
 -(mapcar (lambda (action)
 -   (let ((key (format-kbd-macro (first action)))
 - (desc (second action)))
 +(mapcar (lambda (entry)
 +   (let ((key (format-kbd-macro (first entry)))
 + (desc (second entry)))
   (concat
(propertize key 'face 'minibuffer-prompt)
(make-string (- key-width (length key)) ? )
 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
 index 135422d..b338aaa 100644
 --- a/emacs/notmuch-lib.el
 +++ b/emacs/notmuch-lib.el
 @@ -25,6 +25,9 @@
  (require 'mm-decode)
  (require 'cl)
  
 +(autoload 'notmuch-jump-search notmuch-jump
 +  Jump to a saved search by shortcut key. t)
 +
  (defvar notmuch-command notmuch
Command to run the notmuch binary.)
  
 @@ -134,8 +137,6 @@ (defvar notmuch-common-keymap
  map)
Keymap shared by all notmuch modes.)
  
 -(autoload 'notmuch-jump-search notmuch-jump Jump to a saved search by 
 shortcut key. t)
 -
  ;; By default clicking on a button does not select the window
  ;; containing the button (as opposed to clicking on a widget which
  ;; does). This means that the button action is then executed in the
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 2/2] emacs: Expand default saved searches and add shortcut keys

2014-07-15 Thread David Bremner
Austin Clements amdra...@mit.edu writes:

 This should help new users off to a better start with the addition of
 more sensible saved searches and default shortcut keys.  Most existing
 users have probably customized this variable and won't be affected.

I didn't have a chance to review the code, but I like the interface.

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


Re: [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html

2014-07-15 Thread David Bremner
W. Trevor King wk...@tremily.us writes:

 Changes from v1 [1]

 * Tweaked the license commit message (1/6) [2] with Carl's permission
   [3].
 * Squashed v1's footer commits (old 2/5, 3/5, and 6/5, now 3/6) [4].
 * Squashed v1's description commits (old 4/5 and 5/5, now 2/6) [4].
 * Added commits 4/6, 5/6, and 6/6 to optionally load templates from
   the config file.

Series pushed.

 Carl Worth (3):
   Add explicit license information
   Add a docstring describing the program
   Move the generated date from the top of the page to the footer.

Yay, patches from Carl ;).

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


Re: [PATCH] emacs: tree/show remove duplicate function

2014-07-15 Thread David Bremner
Mark Walters markwalters1...@gmail.com writes:

 On Tue, 15 Jul 2014, David Bremner da...@tethera.net wrote:
 Mark Walters markwalters1...@gmail.com writes:
 +  (cond ((eq major-mode 'notmuch-show-mode)
 + (notmuch-show-get-message-properties))
 +((eq major-mode 'notmuch-tree-mode)
 + (notmuch-tree-get-message-properties

 I see this already existed, but it looks weird to me to have a two test
 cond with no else. Is it intentional to have the code drop through and
 do nothing if neither case matches?  It seems like it might be better to
 signal an error.

 I can definitely do that. But as a comparison
 notmuch-search-get-result and notmuch-search-find-thread-id work in
 any buffer in the sense of returning nil but not complaining so perhaps
 the current version is more consistent. 


It occurs to me that we can fix all 3 places in a followup patch,
so I'll push this for now.

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


Re: [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-15 Thread David Bremner
W. Trevor King wk...@tremily.us writes:

 -  my $fetch_head = git ('rev-parse', $commit);
 +  my ($fetch_head, $status) = git_with_status ('rev-parse', $commit);
 +  if ($status) {
 +return 0;
 +  }

Could there be other errors here, other than @{upstream} not existing?
At first glance it seems like there is potential to hide errors here.

d

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


Re: [PATCH 3/4] nmbug: Catch stderr in is_unmerged

2014-07-15 Thread David Bremner
W. Trevor King wk...@tremily.us writes:

 +  if ($dir eq '-2|') {
 +$dir = '-|';
 +  }
 +

I think I'd prefer an extra flag, rather than making new syntax.
The existing syntax is not pretty, but it is standard perl

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


Re: [PATCH 4/4] nmbug: Add an 'init' command

2014-07-15 Thread David Bremner
W. Trevor King wk...@tremily.us writes:

 +sub do_init {
 +  my $tempwork = tempdir ('/tmp/nmbug-init.XX', CLEANUP = 1);
 +  system ('git', 'init', '--separate-git-dir', $NMBGIT, $tempwork) == 0
 +or die 'git init' exited with nonzero value\n;
 +  git ('config', '--unset', 'core.worktree');
 +  git ('config', 'core.bare', 'true');
 +  # create an empty blob (e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)
 +  git ('hash-object', '-w', '--stdin');
 +  git ( { GIT_WORK_TREE = $tempwork }, 'commit', '--allow-empty',
 +'-m', 'Start a new nmbug repository' );
 +}
 +


Shouldn't this empty blob already be created by the following line:

my $EMPTYBLOB = git (qw{hash-object -t blob /dev/null});

Or is the key point to write it into the database?  Anyway I like my
hack slightly better than yours ;).

d


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


Re: [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-15 Thread W. Trevor King
On Tue, Jul 15, 2014 at 08:44:53PM -0300, David Bremner wrote:
 W. Trevor King writes:
  -  my $fetch_head = git ('rev-parse', $commit);
  +  my ($fetch_head, $status) = git_with_status ('rev-parse', $commit);
  +  if ($status) {
  +return 0;
  +  }
 
 Could there be other errors here, other than @{upstream} not
 existing?  At first glance it seems like there is potential to hide
 errors here.

Possible errors that I can find:

* fatal: Not a git repository: … (with a poor GIT_DIR config)
* fatal: ambiguous argument … (with an invalid/missing revision name)
* fatal: No upstream configured for branch … (when
  branch.name.remote or branch.name.merge aren't set)

All of which return 128 as of Git v1.9.1.  We're only interested in
the last.  I'm fine looking for “No upstream configured for branch”
after we capture stderr with “nmbug: Catch stderr in is_unmerged” [1],
but I don't expect the other two error cases to happen very often.  At
least, I doubt you could get this far into do_status with a broken
GIT_DIR, and we're hard-coding '@{upstream}' here.

Cheers,
Trevor

[1]: id:d55cf02465c5f2d83f2dd0bc666831ee524b0fb7.1404678709.git.wk...@tremily.us
 http://article.gmane.org/gmane.mail.notmuch.general/18627

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 4/4] nmbug: Add an 'init' command

2014-07-15 Thread W. Trevor King
On Tue, Jul 15, 2014 at 08:54:28PM -0300, David Bremner wrote:
 W. Trevor King wk...@tremily.us writes:
 
  +sub do_init {
  +  my $tempwork = tempdir ('/tmp/nmbug-init.XX', CLEANUP = 1);
  +  system ('git', 'init', '--separate-git-dir', $NMBGIT, $tempwork) == 0
  +or die 'git init' exited with nonzero value\n;
  +  git ('config', '--unset', 'core.worktree');
  +  git ('config', 'core.bare', 'true');
  +  # create an empty blob (e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)
  +  git ('hash-object', '-w', '--stdin');
  +  git ( { GIT_WORK_TREE = $tempwork }, 'commit', '--allow-empty',
  +'-m', 'Start a new nmbug repository' );
  +}
  +
 
 
 Shouldn't this empty blob already be created by the following line:
 
 my $EMPTYBLOB = git (qw{hash-object -t blob /dev/null});
 
 Or is the key point to write it into the database?  Anyway I like my
 hack slightly better than yours ;).

We need to write it to the database.  I'll use /dev/null in v2,
though.

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 3/4] nmbug: Catch stderr in is_unmerged

2014-07-15 Thread W. Trevor King
On Tue, Jul 15, 2014 at 08:49:58PM -0300, David Bremner wrote:
 W. Trevor King wk...@tremily.us writes:
 
  +  if ($dir eq '-2|') {
  +$dir = '-|';
  +  }
  +
 
 I think I'd prefer an extra flag, rather than making new syntax.
 The existing syntax is not pretty, but it is standard perl

There should be standard Perl syntax for capturing both streams ;).  I
can add a separate parameter instead, but Perl doesn't seem to have
keyword-arguments.  At least, nmbug relies on assumptions about
argument values:

  sub git_pipe {
my $envref = (ref $_[0] eq 'HASH') ? shift : {};
my $ioref  = (ref $_[0] eq 'ARRAY') ? shift : undef;
my $dir = ($_[0] eq '-|' or $_[0] eq '|-') ? shift : undef;
…
  }

to map positional arguments back into particular semantic meanings.
That seemed ugly enough (can we only have a single boolean argument
with this pattern?) that I'd prefer piggy-backing on Perl's
stream-direction syntax.  But let me know what you like best, and I'll
go that way with v2.  I'd be happy to rewrite nmbug in Python too,
which has (to my eyes) much saner kwargs and subprocess handling.

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch