From 7731a4c02ea1b8d5b8cf05b5a8db5387a3bdfbce Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Thu, 6 Sep 2012 17:30:56 +0300 Subject: [PATCH] Re: [PATCH 1/6] emacs: add helper for tag change list manipulation --- be/a70a3b6f5d2dd4010a3eff86b580f9bface2cf | 115 ++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 be/a70a3b6f5d2dd4010a3eff86b580f9bface2cf diff --git a/be/a70a3b6f5d2dd4010a3eff86b580f9bface2cf b/be/a70a3b6f5d2dd4010a3eff86b580f9bface2cf new file mode 100644 index 000000000..2ed82e215 --- /dev/null +++ b/be/a70a3b6f5d2dd4010a3eff86b580f9bface2cf @@ -0,0 +1,115 @@ +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 38000431FAF + for ; Thu, 6 Sep 2012 07:30:50 -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=[none] + 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 I4tFRUlP-Don for ; + Thu, 6 Sep 2012 07:30:49 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 8B840431FAE + for ; Thu, 6 Sep 2012 07:30:49 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 0F8A51000E5; + Thu, 6 Sep 2012 17:30:57 +0300 (EEST) +From: Tomi Ollila +To: Jani Nikula , Michal Nazarewicz , + notmuch@notmuchmail.org +Subject: Re: [PATCH 1/6] emacs: add helper for tag change list manipulation +In-Reply-To: <87txvf8g5b.fsf@nikula.org> +References: + <9dbf16fb95f40812ad246f95b954681bc895ceb2.1346614915.git.jani@nikula.org> + <87txvf8g5b.fsf@nikula.org> +User-Agent: Notmuch/0.14+11~gd9bf007 (http://notmuchmail.org) Emacs/24.2.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable +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: Thu, 06 Sep 2012 14:30:50 -0000 + +On Mon, Sep 03 2012, Jani Nikula wrote: + +> On Mon, 03 Sep 2012, Michal Nazarewicz wrote: +>> Jani Nikula writes: +>>> Add a helper to create (and optionally reverse) a list of tag changes. +>>> --- +>>> emacs/notmuch-tag.el | 17 +++++++++++++++++ +>>> 1 file changed, 17 insertions(+) +>>> +>>> diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el +>>> index 0c0fc87..c1aeb99 100644 +>>> --- a/emacs/notmuch-tag.el +>>> +++ b/emacs/notmuch-tag.el +>>> @@ -140,6 +140,23 @@ notmuch-after-tag-hook will be run." +>>> ;; in all cases we return tag-changes as a list +>>> tag-changes) +>>>=20=20 +>>> +(defun notmuch-tag-change-list (tags &optional reverse) +>>> + "Convert TAGS into a list of tag changes. +>>> + +>>> +Add a \"+\" prefix to any tag in TAGS list that doesn't already +>>> +begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all +>>> +\"+\" prefixes with \"-\" and vice versa in the result." +>>> + (mapcar (lambda (str) +>>> + (let ((s (if (not (string-match "^[+-]" str)) +>>> + (concat "+" str) +>>> + str))) +>> +>> (if (string-match "^[-+]" str) str (concat "+" str)) +>> +>> Negation only makes things less readable IMO. +> +> Agreed. + +The whole series LGTM -- but are you still going to do=20 +changes here ? + +> Jani. + +Tomi + + +> +>> +>>> + (if reverse +>>> + (concat (if (=3D (string-to-char s) ?-) "+" "-") +>>> + (substring s 1)) +>>> + s))) +>>> + tags)) +>>> + +>>> + +>>> ;; +>>>=20=20 +>>> (provide 'notmuch-tag) +>> +>> --=20 +>> Best regards, _ _ +>> .o. | Liege of Serenely Enlightened Majesty of o' \,=3D./ `o +>> ..o | Computer Science, Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz= + (o o) +>> ooo +------------------ooO--(_)--Ooo-- -- 2.26.2