From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 033D7431FB6 for ; Wed, 25 May 2011 10:57:03 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, 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 K94P4d2C7jBn for ; Wed, 25 May 2011 10:57:03 -0700 (PDT) Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id E630A431FD0 for ; Wed, 25 May 2011 10:57:02 -0700 (PDT) Received: by bwg12 with SMTP id 12so7308818bwg.26 for ; Wed, 25 May 2011 10:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=YxN5HWEE9xCS6uCdclVmVAC5sPdZqDhPcL6ImBVXxLQ=; b=opGxSrmyyjMeYJBtfyD/uYYZ98McAwX6d833am5cXurOUOG5O5GFRRYZ33Jc0EKtpx Wp1SG9prr4cRRq3dxWOczVqzJyHaaQ8ovoG4idaFtBfHwgfkwGQsBYTiWDvc+sw3+5PN +ivRiKLo8Q+z/4AaJCHCnkHClqKIaJxxr5VDo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; b=ni1CHHg3ciE5olPsBl+VjlaefGs3sNtraBT1l2Y9A2ZMGTXy2rCEtijHFKBeQXfzCE JVsCTOz7fGJg0Q4kLa5k2HECMHIJ72gGW52Xs31V5XpPpajt6hK8519NlSWdWPke7i6F 3gndQ3In43JzvaupxtFxRNPg4l47l9gqhy3zo= Received: by 10.204.136.217 with SMTP id s25mr221968bkt.13.1306346220917; Wed, 25 May 2011 10:57:00 -0700 (PDT) Received: from localhost (dslb-178-004-026-109.pools.arcor-ip.net [178.4.26.109]) by mx.google.com with ESMTPS id d25sm5371083bkd.17.2011.05.25.10.56.58 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2011 10:56:59 -0700 (PDT) From: Daniel Schoepe To: Austin Clements , Carl Worth Subject: Re: [PATCH] emacs: Make the queries used in the all-tags section In-Reply-To: <874o4iwwp5.fsf@gilead.invalid> References: <87fwoath2s.fsf@gilead.home.box> <871uznqeox.fsf@tredergarh.home.box> <874o4iwwp5.fsf@gilead.invalid> User-Agent: Notmuch/0.5-210-g1acc997 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Wed, 25 May 2011 19:56:51 +0200 Message-ID: <871uzmwtng.fsf@gilead.invalid> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Cc: notmuch@notmuchmail.org 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: Wed, 25 May 2011 17:57:04 -0000 --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain I accidentally used `filter' in the previous patch which isn't defined by default during runtime, updated version in the attachment. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-emacs-Make-queries-used-in-the-all-tags-section-conf.patch Content-Transfer-Encoding: quoted-printable From=20e8f5e997b7082a50f75d7329a69fccc126a21e5e Mon Sep 17 00:00:00 2001 From: Daniel Schoepe Date: Fri, 20 May 2011 00:53:50 +0200 Subject: [PATCH] emacs: Make queries used in the all-tags section configurable This patch adds a customization variable that controls what queries are used to construct the all-tags section in notmuch-hello. It allows the user to specify a function to construct the query given a tag or a string that is used as a filter for each tag. It also adds a variable to hide various tags from the all-tags section. Signed-off-by: Daniel Schoepe =2D-- emacs/notmuch-hello.el | 38 +++++++++++++++++++++++++++++++++++--- emacs/notmuch-lib.el | 12 ++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index e58dd24..b3f133c 100644 =2D-- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -55,6 +55,24 @@ :type 'boolean :group 'notmuch) =20 +(defcustom notmuch-hello-tag-list-make-query nil + "Function or string to generate queries for the all tags list. + +This variable controls which query results are shown for each tag +in the \"all tags\" list. It can be nil (for default behaviour, +displaying all messages for a tag), a string that is used as a +filter for messages having that tag (equivalent to \"tag:TAG +and (THIS-VARIABLE)\", or a function that is given a tag and +should return the query that is to be used for the tag. If it +returns nil, the corresponding tag will be hidden." + :type '(choice (const nil :tag "tag:TAG") string function) + :group 'notmuch) + +(defcustom notmuch-hello-hide-tags nil + "List of tags to be hidden in the \"all tags\"-section." + :type '(repeat string) + :group 'notmuch) + (defface notmuch-hello-logo-background '((((class color) (background dark)) @@ -318,6 +336,22 @@ Complete list of currently available key bindings: ;;(setq buffer-read-only t) ) =20 +(defun notmuch-hello-generate-tag-alist () + "Return an alist from tags to queries to display in the all-tags section= ." + (notmuch-filter + 'cdr + (mapcar '(lambda (tag) + (cons tag + (cond + ((functionp notmuch-hello-tag-list-make-query) + (funcall notmuch-hello-tag-list-make-query tag)) + ((stringp notmuch-hello-tag-list-make-query) + (concat "tag:" tag " and (" + notmuch-hello-tag-list-make-query ")")) + (t (concat "tag:" tag))))) + (notmuch-filter (lambda (tag) (not (member tag notmuch-hello-hide-tags= ))) + (process-lines notmuch-command "search-tags"))))) + ;;;###autoload (defun notmuch-hello (&optional no-display) "Run notmuch and display saved searches, known tags, etc." @@ -396,9 +430,7 @@ Complete list of currently available key bindings: if (> (string-to-number (notmuch-saved-search-count (cdr elem))) 0) collect elem))) (saved-widest (notmuch-hello-longest-label saved-alist)) =2D (alltags-alist (if notmuch-show-all-tags-list =2D (mapcar '(lambda (tag) (cons tag (concat "tag:" tag))) =2D (process-lines notmuch-command "search-tags")))) + (alltags-alist (if notmuch-show-all-tags-list (notmuch-hello-generat= e-tag-alist))) (alltags-widest (notmuch-hello-longest-label alltags-alist)) (widest (max saved-widest alltags-widest))) =20 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index cc80fb2..a3195ff 100644 =2D-- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -120,6 +120,18 @@ within the current window." (or (memq prop buffer-invisibility-spec) (assq prop buffer-invisibility-spec))))) =20 +;; notmuch- prefix to avoid clashes with user-defined filter-functions: +;; For instance, the filter-function suggested in the elisp cookbook +;; on the emacswiki always filters out elements that are nil +;; even if the predicate returns t for nil; hence this has slightly +;; different semantics than what some users have defined for themselves. +(defun notmuch-filter (pred lst) + "Return a list containing all elements from LST that satisfy PRED." + (and lst + (if (funcall pred (car lst)) + (cons (car lst) (notmuch-filter pred (cdr lst))) + (notmuch-filter pred (cdr lst))))) + ; This lets us avoid compiling these replacement functions when emacs ; is sufficiently new enough to supply them alone. We do the macro ; treatment rather than just wrapping our defun calls in a when form =2D-=20 1.7.5.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBAgAGBQJN3ULkAAoJEIaTAtce+Z+JBmAP/jsYuQch+U1Eag4gONSQK5Bq Wigvd/Nl3jPaiC/xOZqsD6hNBtuDquv56Viu/ODhSGeeQkUkN948isWc43m2SQEW hSgd7GSXur/ZEXaNpHuu9Ai4Pf5IIxJcPKsj1npnLGHccjUTZxiYWnKijdm6vR1p S+LTtaP1LY4+bDHSf8Lzi496cBptbZkPUdYXY8/nebcPRvpakw1qEaVh47LFXwzK H9uiyzbj8cBMfSXgFwqVN6507bffp5kZNrbP3qAfua18lsI8vVu0RNpg9PO/ChkZ 2933HN27i+EcVM86DpK5EAfgObQ+xamFLmfKlJpb1sXPa2btbz90rcKxdBockNYD W3FvekAmyz/577e52K6roXMKC7h9UqTFxchH8Uaa5EsEzoY7IMfFdWggN6+FhPZx 2GH1Yo8Veudb8rJ/0fJHLB93plOuZq3Fuqdvlh0I58Og908m5Wag3prZbRLT753G Y1/5c1KoSDDCVQ5k9c9GAAUipJquH3vpowJdyLjmnaG7sshfaNNwlzPutMD7x7Xq ottzQ8/XjJMX2kkTSymWv7ut9RotJQM6SnXh2YSz4ZL2ZOZA8db9hmvSxqdkvTLI 1zKHgOCZNyMm1Z0lhqDpOCRnngVXFR6y8Imgm5vRGRiMYFdrC9RgDkCtyadnyuHI xX9Q+q3EyIMh3HpZd1sO =Jr/h -----END PGP SIGNATURE----- --==-=-=--