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

2014-08-04 Thread David Bremner
Austin Clements  writes:

> This introduces notmuch-jump, which is like a user-friendly,
> user-configurable global prefix map for saved searches.  This provi

Unfortunately this patch doesn't apply anymore.

> @@ -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 \

Why the extra \ ?

> +(defun notmuch-jump--plist-delete (plist property)
> +  (let* ((xplist (cons nil plist))
> +  (pred xplist))
> +(while (cdr pred)
> +  (when (eq (cadr pred) property)
> + (setcdr pred (cdddr pred)))
> +  (setq pred (cddr pred)))
> +(cdr xplist)))

Should this function maybe be somewhere more generic?



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

2014-08-04 Thread Austin Clements
Quoth David Bremner on Aug 04 at  8:00 pm:
 Austin Clements amdra...@mit.edu writes:
 
  This introduces notmuch-jump, which is like a user-friendly,
  user-configurable global prefix map for saved searches.  This provi
 
 Unfortunately this patch doesn't apply anymore.

Drat.  Thwarted by my own other patch!

Rebased series coming shortly (the resolution wasn't anything
interesting).

  @@ -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 \
 
 Why the extra \ ?

It means we can add more lines to this list without having the modify
an existing line, which cleans up future diffs and simplifies future
rebasing and handling of merge conflicts.

  +(defun notmuch-jump--plist-delete (plist property)
  +  (let* ((xplist (cons nil plist))
  +(pred xplist))
  +(while (cdr pred)
  +  (when (eq (cadr pred) property)
  +   (setcdr pred (cdddr pred)))
  +  (setq pred (cddr pred)))
  +(cdr xplist)))
 
 Should this function maybe be somewhere more generic?

Good idea.  I've moved it to notmuch-lib.  The diff from v2 is below:

diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 9cb1e6a..05bbce5 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -22,6 +22,7 @@
 
 (eval-when-compile (require 'cl))
 
+(require 'notmuch-lib)
 (require 'notmuch-hello)
 
 ;;;###autoload
@@ -90,7 +91,7 @@ (defun notmuch-jump (action-map prompt)
 ;; ourselves) from their labels, so disable the minibuffer's
 ;; own re-face-ing.
 (minibuffer-prompt-properties
- (notmuch-jump--plist-delete
+ (notmuch-plist-delete
   (copy-sequence minibuffer-prompt-properties)
   'face))
 ;; Build the keymap with our bindings
@@ -165,15 +166,6 @@ (defun notmuch-jump--make-keymap (action-map)
   (exit-minibuffer
 map))
 
-(defun notmuch-jump--plist-delete (plist property)
-  (let* ((xplist (cons nil plist))
-(pred xplist))
-(while (cdr pred)
-  (when (eq (cadr pred) property)
-   (setcdr pred (cdddr pred)))
-  (setq pred (cddr pred)))
-(cdr xplist)))
-
 (unless (fboundp 'window-body-width)
   ;; Compatibility for Emacs pre-24
   (defun window-body-width (optional window)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index a23c85d..19269e3 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -476,6 +476,15 @@ (defun notmuch-remove-if-not (predicate list)
   (setq list (cdr list)))
 (nreverse out)))
 
+(defun notmuch-plist-delete (plist property)
+  (let* ((xplist (cons nil plist))
+(pred xplist))
+(while (cdr pred)
+  (when (eq (cadr pred) property)
+   (setcdr pred (cdddr pred)))
+  (setq pred (cddr pred)))
+(cdr xplist)))
+
 (defun notmuch-split-content-type (content-type)
   Split content/type into 'content' and 'type'
   (split-string content-type /))

___
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 .
+;;
+;; 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 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)