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

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

Date: Mon, 4 Aug 2014 21:44:03 -0400

To: David Bremner

Cc: notmuch@notmuchmail.org

From: Austin Clements


Quoth David Bremner on Aug 04 at  8:00 pm:
> Austin Clements <amdragon@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 "/"))


Thread: