Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 571D9431FD0 for ; Sun, 29 May 2011 01:57:18 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5EucNL-1tpMP for ; Sun, 29 May 2011 01:57:17 -0700 (PDT) Received: from hrndva-omtalb.mail.rr.com (hrndva-omtalb.mail.rr.com [71.74.56.123]) by olra.theworths.org (Postfix) with ESMTP id B55FB431FB6 for ; Sun, 29 May 2011 01:57:17 -0700 (PDT) X-Authority-Analysis: v=1.1 cv=ou1QuR4lBR9YeJgEH9ccYmbAdaWqVVq3lOvCKJtMpGM= c=1 sm=0 a=kdBHfC_lHAEA:10 a=8YMtuzaJ5FE3wtSInqJrPg==:17 a=ncDVm-j7AAAA:8 a=170x8asiWLmGcE8pcEUA:9 a=1TAlIYiSTWAA:10 a=AeRk0RUmecrZEO0f:21 a=cBNwx19qwRruWKQi:21 a=8YMtuzaJ5FE3wtSInqJrPg==:117 X-Cloudmark-Score: 0 X-Originating-IP: 76.175.234.46 Received: from [76.175.234.46] ([76.175.234.46:57219] helo=localhost.localdomain) by hrndva-oedge02.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id 9D/B5-04598-03A02ED4; Sun, 29 May 2011 08:56:16 +0000 From: notmuch@dima.secretsauce.net To: notmuch@notmuchmail.org Subject: [PATCH] Added C-up and C-down to cycle through previous searches Date: Sun, 29 May 2011 01:56:28 -0700 Message-Id: <1306659388-21809-1-git-send-email-notmuch@dima.secretsauce.net> X-Mailer: git-send-email 1.7.5.3 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 May 2011 08:57:18 -0000 From: Dima Kogan --- Hi. I made a few improvements to the emacs UI. This patch allows the user to scroll through the most recent searches with C-up and C-down while in the search box. dima emacs/notmuch-hello.el | 49 +++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 42 insertions(+), 7 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 916cda1..56f853f 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -123,6 +123,12 @@ Typically \",\" in the US and UK and \".\" in Europe." (defvar notmuch-hello-recent-searches nil) +(defvar notmuch-hello-cyclerecent-index 0 + "The current index of the most-recent searches" ) + +(defvar notmuch-hello-search-widget nil + "The search widget") + (defun notmuch-hello-remember-search (search) (if (not (member search notmuch-hello-recent-searches)) (push search notmuch-hello-recent-searches)) @@ -148,6 +154,28 @@ Typically \",\" in the US and UK and \".\" in Europe." (match-string 1 search) search)) +(defun notmuch-hello-cyclerecent-next () + "Cycle through the most recently-searched queries, going forwards" + (interactive) + (notmuch-hello-cyclerecent 1)) + +(defun notmuch-hello-cyclerecent-prev () + "Cycle through the most recently-searched queries, going backwards" + (interactive) + (notmuch-hello-cyclerecent -1)) + +(defun notmuch-hello-cyclerecent (d) () + + (when notmuch-hello-recent-searches ; if no recent searches, do nothing + (let ((N (length notmuch-hello-recent-searches))) + (setq notmuch-hello-cyclerecent-index + (% (+ notmuch-hello-cyclerecent-index d N) N))) ; update the index + + (widget-value-set notmuch-hello-search-widget + (nth notmuch-hello-cyclerecent-index notmuch-hello-recent-searches)) + (widget-setup)) +) + (defun notmuch-hello-search (search) (let ((search (notmuch-hello-trim search))) (notmuch-hello-remember-search search) @@ -455,13 +483,19 @@ Complete list of currently available key bindings: (widget-insert "\nSearch: ") (setq notmuch-hello-search-bar-marker (point-marker)) - (widget-create 'editable-field - ;; Leave some space at the start and end of the - ;; search boxes. - :size (max 8 (- (window-width) notmuch-hello-indent - (length "Search: "))) - :action (lambda (widget &rest ignore) - (notmuch-hello-search (widget-value widget)))) + (setq notmuch-hello-search-widget + (widget-create 'editable-field + ;; Leave some space at the start and end of the + ;; search boxes. + :size (max 8 (- (window-width) notmuch-hello-indent + (length "Search: "))) + :action (lambda (widget &rest ignore) + (notmuch-hello-search (widget-value widget))) + :keymap (let ((map (make-sparse-keymap))) + (set-keymap-parent map widget-field-keymap) + (define-key map (kbd "") 'notmuch-hello-cyclerecent-prev) + (define-key map (kbd "") 'notmuch-hello-cyclerecent-next) + map))) (widget-insert "\n") (when notmuch-hello-recent-searches @@ -535,6 +569,7 @@ Complete list of currently available key bindings: (widget-insert "Type a search query and hit RET to view matching threads.\n") (when notmuch-hello-recent-searches (widget-insert "Hit RET to re-submit a previous search. Edit it first if you like.\n") + (widget-insert "In the search box, C-up/C-down cycles through the recent searches.\n") (widget-insert "Save recent searches with the `save' button.\n")) (when notmuch-saved-searches (widget-insert "Edit saved searches with the `edit' button.\n")) -- 1.7.4.4