Re: [PATCH] emacs: add default value to notmuch-search-line-faces
authorMark Walters <markwalters1009@gmail.com>
Sat, 28 Jan 2012 11:07:51 +0000 (11:07 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:27 +0000 (09:43 -0800)
09/9e234c455640afec49c1d8fe7144ff1687c4ac [new file with mode: 0644]

diff --git a/09/9e234c455640afec49c1d8fe7144ff1687c4ac b/09/9e234c455640afec49c1d8fe7144ff1687c4ac
new file mode 100644 (file)
index 0000000..90b6355
--- /dev/null
@@ -0,0 +1,251 @@
+Return-Path: <m.walters@qmul.ac.uk>\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 6F88C431FB6\r
+       for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 03:06:51 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+       tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+       NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\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 JztbtZz+Ihgw for <notmuch@notmuchmail.org>;\r
+       Sat, 28 Jan 2012 03:06:50 -0800 (PST)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 349AC431FAE\r
+       for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 03:06:50 -0800 (PST)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+       by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1Rr67M-0000Qt-5u; Sat, 28 Jan 2012 11:06:48 +0000\r
+Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
+       helo=localhost)\r
+       by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1Rr67L-0001XR-OF; Sat, 28 Jan 2012 11:06:48 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: David Edmondson <dme@dme.org>\r
+Subject: Re: [PATCH] emacs: add default value to notmuch-search-line-faces\r
+In-Reply-To: <cunhazhjurs.fsf@hotblack-desiato.hh.sledj.net>\r
+References: <1327605679-15213-1-git-send-email-jani@nikula.org>\r
+       <87y5st4ewt.fsf@qmul.ac.uk>\r
+       <cunhazhjurs.fsf@hotblack-desiato.hh.sledj.net>\r
+User-Agent: Notmuch/0.11+107~g185f859 (http://notmuchmail.org) Emacs/23.2.1\r
+       (i486-pc-linux-gnu)\r
+Date: Sat, 28 Jan 2012 11:07:51 +0000\r
+Message-ID: <871uqk6q60.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 94.192.233.223\r
+X-QM-SPAM-Info: Sender has good ham record.  :)\r
+X-QM-Body-MD5: 046f23133340c558ed1a97dc0491b70a (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.8\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+       determine if it is\r
+       spam. We require at least 5.0 points to mark a message as spam.\r
+       This message scored -1.8 points.\r
+       Summary of the scoring: \r
+       * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+       *      medium trust\r
+       *      [138.37.6.40 listed in list.dnswl.org]\r
+       * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+       provider *      (markwalters1009[at]gmail.com)\r
+       * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
+       *      domain\r
+       *  0.5 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\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: Sat, 28 Jan 2012 11:06:51 -0000\r
+\r
+\r
+On Fri, 27 Jan 2012 10:37:43 +0000, David Edmondson <dme@dme.org> wrote:\r
+> On Fri, 27 Jan 2012 10:29:22 +0000, Mark Walters <markwalters1009@gmail.com> wrote:\r
+> > I am not sure if this is the place\r
+> \r
+> Here or #notmuch.\r
+> \r
+> > to ask but is there a corresponding option for colouring the summary\r
+> > line in notmuch-show depending on tags/flags?\r
+> \r
+> There's id:"1325006003-27152-1-git-send-email-dme@dme.org", but it's a\r
+> bit old and may not apply cleanly any more.\r
+\r
+That's great! One hunk didn't apply but the merge was so trivial I am not sure\r
+why it did not apply. Anyway in case anyone else wants it I include the\r
+rebased version below (I also moved the defcustom under notmuch-show).\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+Subject: [PATCH] rebased id:"1325006003-27152-1-git-send-email-dme@dme.org"\r
+\r
+---\r
+ emacs/notmuch-lib.el  |   18 ++++++++++++++++++\r
+ emacs/notmuch-show.el |   33 +++++++++++++++++++++++++++++----\r
+ emacs/notmuch.el      |   17 ++---------------\r
+ 3 files changed, 49 insertions(+), 19 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index c906ca7..ab1d8e8 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -133,6 +133,24 @@ the user hasn't set this variable with the old or new value."\r
+   (interactive)\r
+   (kill-buffer (current-buffer)))\r
\r
++(defun notmuch-color-line (start end line-tag-list spec)\r
++  "Colorize a line based on tags."\r
++  ;; Create the overlay only if the message has tags which match one\r
++  ;; of those specified in `spec'.\r
++  (let (overlay)\r
++    (mapc (lambda (elem)\r
++          (let ((tag (car elem))\r
++                (attributes (cdr elem)))\r
++            (when (member tag line-tag-list)\r
++              (when (not overlay)\r
++                (setq overlay (make-overlay start end))\r
++                (overlay-put overlay 'priority 5))\r
++              ;; Merge the specified properties with any already\r
++              ;; applied from an earlier match.\r
++              (overlay-put overlay 'face\r
++                           (append (overlay-get overlay 'face) attributes)))))\r
++        spec)))\r
++\r
+ ;;\r
\r
+ (defun notmuch-common-do-stash (text)\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 84ac624..c448ab2 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -92,6 +92,24 @@ any given message."\r
+   :group 'notmuch-show\r
+   :group 'notmuch-hooks)\r
\r
++(defcustom notmuch-show-line-faces nil\r
++  "Tag to face mapping for header line highlighting in `notmuch-show-mode'.\r
++\r
++Here is an example of how to color search results based on tags.\r
++ (the following text would be placed in your ~/.emacs file):\r
++\r
++ (setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\"\r
++                                                :background \"blue\"))\r
++                                   (\"unread\" . (:foreground \"green\"))))\r
++\r
++The attributes defined for matching tags are merged, with later\r
++attributes overriding earlier. A message having both \"delete\"\r
++and \"unread\" tags with the above settings would have a green\r
++foreground and blue background."\r
++  :type '(alist :key-type (string) :value-type (custom-face-edit))\r
++  :group 'notmuch-show\r
++  :group 'notmuch-faces)\r
++\r
+ ;; Mostly useful for debugging.\r
+ (defcustom notmuch-show-all-multipart/alternative-parts t\r
+   "Should all parts of multipart/alternative parts be shown?"\r
+@@ -340,7 +358,8 @@ unchanged ADDRESS if parsing fails."\r
+ (defun notmuch-show-insert-headerline (headers date tags depth)\r
+   "Insert a notmuch style headerline based on HEADERS for a\r
+ message at DEPTH in the current thread."\r
+-  (let ((start (point)))\r
++  (let ((start (point))\r
++      overlay)\r
+     (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))\r
+           (notmuch-show-clean-address (plist-get headers :From))\r
+           " ("\r
+@@ -349,7 +368,9 @@ message at DEPTH in the current thread."\r
+           (propertize (mapconcat 'identity tags " ")\r
+                       'face 'notmuch-tag-face)\r
+           ")\n")\r
+-    (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))\r
++    (setq overlay (make-overlay start (point)))\r
++    (overlay-put overlay 'face 'notmuch-message-summary-face)\r
++    (overlay-put overlay 'priority 2)))\r
\r
+ (defun notmuch-show-insert-header (header header-value)\r
+   "Insert a single header."\r
+@@ -818,7 +839,8 @@ current buffer, if possible."\r
+        body-start body-end\r
+        (headers-invis-spec (notmuch-show-make-symbol "header"))\r
+        (message-invis-spec (notmuch-show-make-symbol "message"))\r
+-       (bare-subject (notmuch-show-strip-re (plist-get headers :Subject))))\r
++       (bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))\r
++       (tags (plist-get msg :tags)))\r
\r
+     ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise\r
+     ;; removing items from `buffer-invisibility-spec' (which is what\r
+@@ -843,10 +865,13 @@ current buffer, if possible."\r
+                                           (plist-get msg :date_relative)\r
+                                         nil)\r
+                                       (plist-get headers :Date))\r
+-                                  (plist-get msg :tags) depth)\r
++                                  tags depth)\r
\r
+     (setq content-start (point-marker))\r
\r
++    ;; Colour the header line according to the tags of the message.\r
++    (notmuch-color-line message-start content-start tags notmuch-show-line-faces)\r
++\r
+     (plist-put msg :headers-invis-spec headers-invis-spec)\r
+     (plist-put msg :message-invis-spec message-invis-spec)\r
\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 72f78ed..244fafa 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -690,7 +690,7 @@ This function advances the next thread when finished."\r
+                 (forward-line (1- notmuch-search-target-line))))))))\r
\r
+ (defcustom notmuch-search-line-faces nil\r
+-  "Tag/face mapping for line highlighting in notmuch-search.\r
++  "Tag to face mapping for line highlighting in `notmuch-search-mode'.\r
\r
+ Here is an example of how to color search results based on tags.\r
+  (the following text would be placed in your ~/.emacs file):\r
+@@ -709,20 +709,7 @@ foreground and blue background."\r
\r
+ (defun notmuch-search-color-line (start end line-tag-list)\r
+   "Colorize lines in `notmuch-show' based on tags."\r
+-  ;; Create the overlay only if the message has tags which match one\r
+-  ;; of those specified in `notmuch-search-line-faces'.\r
+-  (let (overlay)\r
+-    (mapc (lambda (elem)\r
+-          (let ((tag (car elem))\r
+-                (attributes (cdr elem)))\r
+-            (when (member tag line-tag-list)\r
+-              (when (not overlay)\r
+-                (setq overlay (make-overlay start end)))\r
+-              ;; Merge the specified properties with any already\r
+-              ;; applied from an earlier match.\r
+-              (overlay-put overlay 'face\r
+-                           (append (overlay-get overlay 'face) attributes)))))\r
+-        notmuch-search-line-faces)))\r
++  (notmuch-color-line start end line-tag-list notmuch-search-line-faces))\r
\r
+ (defun notmuch-search-author-propertize (authors)\r
+   "Split `authors' into matching and non-matching authors and\r
+-- \r
+1.7.2.3\r
+\r
+\r
+\r