Re: [notmuch] [PATCH -v4] notmuch.el: Add face support to search and show mode
authorAlexander Botero-Lowry <alex.boterolowry@gmail.com>
Wed, 25 Nov 2009 05:24:07 +0000 (21:24 +1600)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:35:42 +0000 (09:35 -0800)
10/00a4aeb9d4ef704cefbfc6ce0ea42064450fdf [new file with mode: 0644]

diff --git a/10/00a4aeb9d4ef704cefbfc6ce0ea42064450fdf b/10/00a4aeb9d4ef704cefbfc6ce0ea42064450fdf
new file mode 100644 (file)
index 0000000..136a2bf
--- /dev/null
@@ -0,0 +1,136 @@
+Return-Path: <alex.boterolowry@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 44228431FBC\r
+       for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 21:24:12 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id IiFj36NLLJAG for <notmuch@notmuchmail.org>;\r
+       Tue, 24 Nov 2009 21:24:11 -0800 (PST)\r
+Received: from mail-yw0-f200.google.com (mail-yw0-f200.google.com\r
+       [209.85.211.200])\r
+       by olra.theworths.org (Postfix) with ESMTP id 83ED0431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 21:24:11 -0800 (PST)\r
+Received: by ywh38 with SMTP id 38so6685448ywh.6\r
+       for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 21:24:11 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=domainkey-signature:received:received:received:from:to:subject\r
+       :in-reply-to:references:date:message-id:mime-version:content-type;\r
+       bh=EVgPASpy/G7L2S8T/Pcyx12L6l8s7Si9ZGlKwM9b/zA=;\r
+       b=JrawpXxaaKSu4TUx5aWdQkCn4q6J6YYBM1iVvboYPcjscxNoPF8VcUz+RT2a5PFD5L\r
+       aXePKm75leYppqoXKhg0JSd0/InNn1Uzkt+r6ittQL764DZ7QclJKCpx4MwDIUmajC1U\r
+       ycaZINUqJ7tsTjyIUZTHtjeGcphwGr3XeHcLM=\r
+DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
+       h=from:to:subject:in-reply-to:references:date:message-id:mime-version\r
+       :content-type;\r
+       b=eY+n/+IR88yykPTFzG0ZUtsBIhiHimOjC+rse/Ii5KRGBRPa59MwjKAZWvxNlBQ+iI\r
+       rrrUSoYAhuHM/F4HYpbvlY2XzEkQNPh0Ae5c05T8XxIA0julS1kFqsCTsaelVyOOmpJI\r
+       DFpp4IvVpJxEI0Op/2vONkYXnivl6fPUn8f9o=\r
+Received: by 10.150.172.38 with SMTP id u38mr12673360ybe.328.1259126644847;\r
+       Tue, 24 Nov 2009 21:24:04 -0800 (PST)\r
+Received: from fortitudo (70-36-144-85.dsl.dynamic.sonic.net [70.36.144.85])\r
+       by mx.google.com with ESMTPS id 15sm2944590gxk.4.2009.11.24.21.24.03\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Tue, 24 Nov 2009 21:24:03 -0800 (PST)\r
+Received: from alexbl (uid 1001) (envelope-from\r
+       alexbl@fortitudo.i-did-not-set--mail-host-address--so-tickle-me)\r
+       id 7037 by fortitudo (DragonFly Mail Agent)\r
+       Tue, 24 Nov 2009 21:24:08 -0800\r
+From: Alexander Botero-Lowry <alex.boterolowry@gmail.com>\r
+To: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,\r
+       notmuch@notmuchmail.org\r
+In-Reply-To:\r
+ <1259125080-18708-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>\r
+References:\r
+ <1259125080-18708-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>\r
+Date: Tue, 24 Nov 2009 21:24:07 -0800\r
+Message-ID:\r
+ <86fx83qirs.fsf@fortitudo.i-did-not-set--mail-host-address--so-tickle-me>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Subject: Re: [notmuch] [PATCH -v4] notmuch.el: Add face support to search\r
+ and show mode\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 25 Nov 2009 05:24:12 -0000\r
+\r
+On Wed, 25 Nov 2009 10:28:00 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:\r
+> This add two faces, notmuch-show-subject-face and\r
+> notmuch-tag-face. The first face is used to show the subject\r
+> line in the notmuch-show-mode and the second one to show tags\r
+> in the notmuch-search-mode.\r
+> \r
+First, I definetly think fontification is the way to go instead of\r
+the adhoc/crappy way that cworth and I have been doing this in the\r
+past.\r
+\r
+[snip]\r
+\r
+> +(defvar notmuch-show-font-lock-keywords\r
+> +  (list ;; header in font-lock-type-face\r
+> +   (list "\\(Subject:.*$\\)"\r
+> +     '(1  'notmuch-show-subject-face)))\r
+> +  "Additonal expression to hightlight in notmuch-show-mode")\r
+> +\r
+So what happens if I have Subject: xxxx in my message? We already ran\r
+into a problem where a patch sent the list that included notmuch control\r
+character caused it to go into an infinite loop, I'd prefer our\r
+fontification code be a bit more resilient. At the very least this\r
+should use the font-lock syntax tables stuff to only do header\r
+fontification when inside the header block. This would probably require\r
+that fontification occur before the message is post-processed by \r
+notmuch-show to remove the section markers etc.\r
+\r
+Also +1 for more subduded colors than red. :) Possibly consider copying\r
+the message-mode colors, so that there is a bit of consistency between\r
+sending and viewing mail? Might even be able to steal the message-mode\r
+faces by importing their symbols.\r
+\r
+[snip]\r
+\r
+>  (defun notmuch-search-mode ()\r
+>    "Major mode for searching mail with notmuch.\r
+> @@ -865,7 +888,18 @@ global search.\r
+>    (setq truncate-lines t)\r
+>    (setq major-mode 'notmuch-search-mode\r
+>      mode-name "notmuch-search")\r
+> -  (setq buffer-read-only t))\r
+> +  (setq buffer-read-only t)\r
+> +  (if (not notmuch-tag-face-alist)\r
+> +      (add-to-list 'notmuch-search-font-lock-keywords (list\r
+> +            "\\(([^)]*)$\\)" '(1  'notmuch-tag-face)))\r
+This way of detecting the tags seems ok, but I think it would be nicer\r
+if it could be done even more deterministically. :) One idea that be\r
+neat is to have a --format=sexp for notmuch search, which exports sexps\r
+(probably alists, but could be some other format) for the search results\r
+that can just be eval'd and processed in a cleaner way (and would also\r
+make for nicer APIs in emacs for querying notmuch itself). Actually I\r
+really like the idea of a sexp output mode for show too, instead of the\r
+markers.... *plots*\r
+\r
+> +    (progn\r
+> +  (setq notmuch-search-tags (mapcar 'car notmuch-tag-face-alist))\r
+> +  (loop for notmuch-search-tag  in notmuch-search-tags\r
+> +    do (add-to-list 'notmuch-search-font-lock-keywords (list\r
+> +                            (concat "\\(" notmuch-search-tag "\\)")\r
+> +                `(1  ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))\r
+> +  (set (make-local-variable 'font-lock-defaults)\r
+> +         '(notmuch-search-font-lock-keywords t)))\r
+>  \r
+I don't really see the point of fontifying all tags the same way if no\r
+tag-faces have been set, especially if none of the rest of the search\r
+results are fontified.\r
+\r
+Alex\r