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 67873431FAF for ; Fri, 26 Oct 2012 06:21:23 -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 Eu45Rm-wbuh1 for ; Fri, 26 Oct 2012 06:21:22 -0700 (PDT) Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 576EB431FAE for ; Fri, 26 Oct 2012 06:21:22 -0700 (PDT) Received: by mail-ee0-f53.google.com with SMTP id e51so1268128eek.26 for ; Fri, 26 Oct 2012 06:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:in-reply-to:organization:references :user-agent:x-face:face:x-pgp:x-pgp-fp:date:message-id:mime-version :content-type; bh=oGN1xr1IbgEryGEzrGlpIeamzifYo1ceA/pYqdqIPuc=; b=PQMpRogwUqydsFsmJRd+krzp1Elh8kc8DCF5sq1n3gz64yndVmPfx4BMJmRdjmlglF uOAfQ2XIM1bXm0DxTiNfEOv8lLLtZOn+J2t5rOiGYx0VGGJ0XIEB27RL9Xzo06YWOEsR Y5X3LD7vfrBXGQ6kXacZJDVTMqEvqN25AjNJhb143wcrOeN+QZQmHL46y/sTKFxqm2HW ELX3Xa3kWgx3+b303VA3ZoMrn34L4TnakuHVCewhzS2N+ORXkRlf8WROJRUc8XCy5tSA IrduF9bxM23QsLBOWgGR1nOV/AT9LCAbrli7c/1ms9RDo6TeOEMWvSCNDRoNVdTOH5/u rX+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:in-reply-to:organization:references :user-agent:x-face:face:x-pgp:x-pgp-fp:date:message-id:mime-version :content-type:x-gm-message-state; bh=oGN1xr1IbgEryGEzrGlpIeamzifYo1ceA/pYqdqIPuc=; b=d3+QgbByElngodsrEsN3QM3zU9aX2/CYi/Z5HgLA/YEawttcySgJoFbyAQAsEKQ/qF sLSEHGtXk2bhZfwt4R3hVR54oni+m1V7SvvMNrldBpxgtxGCgq1e14oKyPDiVChfnjDH RWLgZklfvdY7ngukHefxA3XjQEBlixEgauM5K0KVkxqF2PZGC7w7fwpQV+SYiZ81DK2t TRkry8aA128do9fsyYf+rXe3WH6jpGDaUGmv/P9SSswZhfGXwWZWfZYzf8kKuuYcH8Ba PpJUCMJAP89Ny1bUvzBXrMR4Rzacnd4s+QZlC1cuJrpNNwKC/apdtelYt2knU6hRsrm7 cVVQ== Received: by 10.14.179.69 with SMTP id g45mr22800605eem.42.1351257679452; Fri, 26 Oct 2012 06:21:19 -0700 (PDT) Received: from mpn-glaptop (77-253-124-192.adsl.inetia.pl. [77.253.124.192]) by mx.google.com with ESMTPS id g47sm2626538eeo.6.2012.10.26.06.21.15 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 26 Oct 2012 06:21:17 -0700 (PDT) Sender: Michal Nazarewicz From: Michal Nazarewicz To: Taesoo Kim , notmuch@notmuchmail.org Subject: Re: [PATCH 1/2] Automatic tagging based on maildir In-Reply-To: <1351208039-32293-2-git-send-email-taesoo@mit.edu> Organization: http://mina86.com/ References: <1351208039-32293-1-git-send-email-taesoo@mit.edu> <1351208039-32293-2-git-send-email-taesoo@mit.edu> User-Agent: Notmuch/0.14+22~g8bdc16b (http://notmuchmail.org) Emacs/24.2.50.1 (x86_64-unknown-linux-gnu) X-Face: PbkBB1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HnMAAAAAElFTkSuQmCC X-PGP: 50751FF4 X-PGP-FP: AC1F 5F5C D418 88F8 CC84 5858 2060 4012 5075 1FF4 Date: Fri, 26 Oct 2012 15:19:54 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Gm-Message-State: ALoCoQlsEpkNCVT/vl5Py5IlPZPCRn8woVn6Ysw/fK1Vnah+wQMv8MDgVagco9Bouwq2H5ITpb81ZsEjGf11l4HVK0vjNa1JYtOFW0xrlkUsM3UECdpZ/DwTnkFUAAOyGeP3epZYPAsNI44DvUnbY1NQCyQFZ8MiOQJqlRPNceG03Ar+z7iYSpLa8x7bssGV42Zmb+gAGpyh Cc: Taesoo Kim 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: Fri, 26 Oct 2012 13:21:23 -0000 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, Oct 26 2012, Taesoo Kim wrote: > @@ -240,6 +242,32 @@ _entry_in_ignore_list (const char *entry, add_files_= state_t *state) > return FALSE; > } >=20=20 > +static void > +_add_maildir_as_tag(notmuch_database_t *notmuch, > + notmuch_message_t *msg, const char *path)=20 > +{ > + char *tok =3D talloc_strdup (notmuch, path); > + int len =3D strlen(tok); > +=20=20=20=20 > + /* asserts path ends with /cur|/tmp|/new */ It actually does not assert that. It just checks =E2=80=9C/=E2=80=9D. > + if (len > 4 && tok[len - 4] =3D=3D '/') { > + char *iter =3D tok + len - 4; > + *iter =3D '\0'; > + while (-- iter && iter >=3D tok) { > + char c =3D *iter; > + if (c =3D=3D '/' || c =3D=3D '.') { > + *iter =3D '\0'; > + notmuch_message_add_tag (msg, iter + 1); > + if (c =3D=3D '/') { > + break; > + } > + } > + *iter =3D tolower(*iter); > + } strtok() would make it easier. > + } > + talloc_free (tok); > +} How about (not tested): static void _add_maildir_as_tag(notmuch_database_t *notmuch, notmuch_message_t *msg, const char *path) { const char *a =3D NULL, *b =3D NULL; char *dir, *tag, *saveptr; while ((path =3D strchr(path, '/'))) { a =3D b; b =3D path; } if (!a || ++a >=3D b || (strcmp(b, "/cur") && strcmp(b, "/new") && strcmp(b, "/tmp"))) return; dir =3D talloc_strndup(notmuch, a, b - a); while ((tag =3D strtok_r(dir, ".", &saveptr))) notmuch_message_add_tag(msg, tag); talloc_free(dir); } --=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-- --=-=-= Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: text/plain --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJQio36AAoJECBgQBJQdR/0E+8P/1nGvBlGhqQpcbqen2TBT0AI kkg9qZua/QI+l9DcpFAP3P979Ux+2QgJagIuiC5QE68pJ9zyYUft8WVau252ycl+ pEMhk4y8cT2ttsJJzSEWA2kd1+Bknkn0/jdWSgKd3hoJ47XIEF8MpeJZ5QY0W+eG pjcqCKk5So118v7UAMSkhX5UOzT7IvUYcHuPKns8eaGv9D0TcmYPJRCvQdWoyXUB auo8ktTe8MqL1ZdKMFmKcGvI257J8F5bccHLUFSKKw+oO6RzCR5Sb+v4ejmwKlPs o5UIyaSJFHTOndTdxAyw8C1bE2dy+ryStN1gFpu92/f68j/Qr2NYnRbMVUOqTMVt +1T35voXdmGvhzQAAAqBipgzSDNGZMMnBy4fl9sBFGIrE3ZjzixXe5XXcrVTWnhd V6gwHOZ+KDP/CYQEOySrftIs3TxDGZq7p7ViHRpfq0FJ/v7/sEhSUv4P76O0xvJi k+kvNGpOcbp64IhhoCKS3EqLRqJ990iuzrNKGx6eSesgjxRVoUvwRt/bcU+/StY/ x0rZRRe6rlZ2v1+OIx1FtSOc6mGNzlyVeAHsE44/hKayxmt6cQ1I0u8FeCO8G4ok LMbHyknpnp9NdTIG1E5x2cX0nUnZ38Sh+zckBbZjbjGAXi9Qna35W3iETLoBh8ch C5SwGi23JNMnRQw0qCjz =ug1A -----END PGP SIGNATURE----- --==-=-=-- --=-=-=--