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 37A2C429E25 for ; Mon, 6 Jun 2011 23:26:14 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7] 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 wlsI-vjzXz2j for ; Mon, 6 Jun 2011 23:26:13 -0700 (PDT) Received: from new1.smtp.messagingengine.com (new1.smtp.messagingengine.com [66.111.4.221]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 5F72B431FB6 for ; Mon, 6 Jun 2011 23:26:13 -0700 (PDT) Received: from compute6.internal (compute6.nyi.mail.srv.osa [10.202.2.46]) by gateway1.messagingengine.com (Postfix) with ESMTP id 66CBB20247 for ; Tue, 7 Jun 2011 02:26:12 -0400 (EDT) Received: from frontend1.messagingengine.com ([10.202.2.160]) by compute6.internal (MEProxy); Tue, 07 Jun 2011 02:26:12 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=date:from:to:subject:message-id:in-reply-to:references:mime-version:content-type; s=smtpout; bh=tglnvRQ+XlHaEOUgJ3QZ5sNSxTU=; b=LoM15Vh30JGUk6xAwdM4tcdPoBEi6Qw2SV26lVqweyjQzET/wGXSAs7BBNzT3nmMD+SaZSNMzxdllEHZ3PG4IGiMUJsg+vOEjYIPU7IAX1f2d8Bgd7EsUbLYBWs9HutOh1zvwDfwjMmsWZtNlZOmvWnLCd7wl2NjMKBYUdmEhb4= X-Sasl-enc: z1eFREclrWg5EpLaxiwxA8OM9gPzYmcJInRfGsBuGLus 1307427971 Received: from smart (cpe-76-175-234-46.socal.res.rr.com [76.175.234.46]) by mail.messagingengine.com (Postfix) with ESMTPSA id 28718406830 for ; Tue, 7 Jun 2011 02:26:10 -0400 (EDT) Date: Mon, 6 Jun 2011 23:26:20 -0700 From: Dima Kogan To: notmuch@notmuchmail.org Subject: Re: [PATCH] Added C-up and C-down to cycle through previous searches Message-ID: <20110606232620.049fa55f@smart> In-Reply-To: <87fwnopwhw.fsf@gmail.com> References: <1306659388-21809-1-git-send-email-notmuch@dima.secretsauce.net> <87vcwto5n3.fsf@gmail.com> <20110604130732.5d28fb68@smart> <87fwnopwhw.fsf@gmail.com> X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.4; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/GUBy1g+ec3F+vRYS1FEBbzi" 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: Tue, 07 Jun 2011 06:26:14 -0000 --MP_/GUBy1g+ec3F+vRYS1FEBbzi Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline > Notmuch uses a mix of 8 char width tabs and spaces. First go tabs, > then, if you need indenting with more precision, spaces. Look at the > lines your patch removes for an example. > > Also, .dir-locals.el sets some variables to configure Emacs for > Notmuch coding style but only for c-mode. You may set it by hand for > lisp. Hi again. Here's the new patch, with M-n/M-p and tabbed indentation dima --MP_/GUBy1g+ec3F+vRYS1FEBbzi Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-Added-M-n-and-M-p-to-cycle-through-previous-searches.patch >From 70193e0a9f7451033fd0843d46ac40e5524b000b Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Mon, 6 Jun 2011 23:15:26 -0700 Subject: [PATCH] Added M-n and M-p to cycle through previous searches --- emacs/notmuch-hello.el | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 40 insertions(+), 7 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 916cda1..035e551 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,26 @@ 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 +481,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 "M-p") 'notmuch-hello-cyclerecent-prev) + (define-key map (kbd "M-n") 'notmuch-hello-cyclerecent-next) + map))) (widget-insert "\n") (when notmuch-hello-recent-searches @@ -535,6 +567,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, M-n/M-p 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.5.3 --MP_/GUBy1g+ec3F+vRYS1FEBbzi--