From 95a83384a278b1c3321faf67380cc89f5e8124b2 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 14 Apr 2012 20:21:39 +0100 Subject: [PATCH] [PATCH 1/3] emacs: Move colour line from search to lib --- 2a/84f96ad568a07c0afb2bb686e8d3f069c5923b | 130 ++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 2a/84f96ad568a07c0afb2bb686e8d3f069c5923b diff --git a/2a/84f96ad568a07c0afb2bb686e8d3f069c5923b b/2a/84f96ad568a07c0afb2bb686e8d3f069c5923b new file mode 100644 index 000000000..bc4375a0f --- /dev/null +++ b/2a/84f96ad568a07c0afb2bb686e8d3f069c5923b @@ -0,0 +1,130 @@ +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 AD84C431FC2 + for ; Sat, 14 Apr 2012 12:21:42 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=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 eEopK5ZF17UI for ; + Sat, 14 Apr 2012 12:21:41 -0700 (PDT) +Received: from mail-we0-f181.google.com (mail-we0-f181.google.com + [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id F1C28431FAF + for ; Sat, 14 Apr 2012 12:21:40 -0700 (PDT) +Received: by werm13 with SMTP id m13so3020360wer.26 + for ; Sat, 14 Apr 2012 12:21:39 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=y0hdnGd29PSJx+eMW5RDnHZNH17Jv6GTzMVLCfLdID4=; + b=kQMgCgwXogN0Ed6oPe+vSiEQVUgN92r3tIVPaYk8H/vzeStFnexZfPPyTHiCvqx/7e + cuE4RHYB6gcFO3c5giapDNokeQRfe/iNmjGo9AsNyLaoVPhUrG7S/0kMlsNAZtd8cMxl + jqujyis2i33qmcMFJgwrpM+M+A3b13wW4/rcgwbV7RfjvsFOZpsIPT7WDpCE4qfLjvSp + fNCNtrOiI0Y5dMNGrNBKLvRTXzGrxDg2YMxzS+To8ewLhuK4WdeLHW+djt8hWr9NwHSH + zx7TWotRhgAA0TxvSBdWjaM2tBPNNLnl0rs3kUAuAPHMQTc4nUYv2Z8feYNdS6hzaFyC + ABPQ== +Received: by 10.216.208.21 with SMTP id p21mr3543264weo.12.1334431299625; + Sat, 14 Apr 2012 12:21:39 -0700 (PDT) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + h8sm10637596wix.4.2012.04.14.12.21.38 (version=TLSv1/SSLv3 cipher=OTHER); + Sat, 14 Apr 2012 12:21:39 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH 1/3] emacs: Move colour line from search to lib +Date: Sat, 14 Apr 2012 20:21:39 +0100 +Message-Id: <1334431301-27303-2-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1334431301-27303-1-git-send-email-markwalters1009@gmail.com> +References: <1334431301-27303-1-git-send-email-markwalters1009@gmail.com> +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: Sat, 14 Apr 2012 19:21:43 -0000 + +This patch moves the overlay/colouring from notmuch.el to +notmuch-lib.el. This is in preparation for its use by notmuch-show in +the next patch. This is just a rebased version of the emacs/notmuch.el +and emacs/notmuch-lib.el parts of David Edmondson's patch (see +id:"1325006003-27152-1-git-send-email-dme@dme.org") +--- + emacs/notmuch-lib.el | 18 ++++++++++++++++++ + emacs/notmuch.el | 15 +-------------- + 2 files changed, 19 insertions(+), 14 deletions(-) + +diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +index 6907a5f..c8a9351 100644 +--- a/emacs/notmuch-lib.el ++++ b/emacs/notmuch-lib.el +@@ -148,6 +148,24 @@ the user hasn't set this variable with the old or new value." + "Return a query that matches the message with id ID." + (concat "id:\"" (replace-regexp-in-string "\"" "\"\"" id t t) "\"")) + ++(defun notmuch-color-line (start end line-tag-list spec) ++ "Colorize a line based on tags." ++ ;; Create the overlay only if the message has tags which match one ++ ;; of those specified in `spec'. ++ (let (overlay) ++ (mapc (lambda (elem) ++ (let ((tag (car elem)) ++ (attributes (cdr elem))) ++ (when (member tag line-tag-list) ++ (when (not overlay) ++ (setq overlay (make-overlay start end)) ++ (overlay-put overlay 'priority 5)) ++ ;; Merge the specified properties with any already ++ ;; applied from an earlier match. ++ (overlay-put overlay 'face ++ (append (overlay-get overlay 'face) attributes))))) ++ spec))) ++ + ;; + + (defun notmuch-common-do-stash (text) +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index ba833e6..09f6c50 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -728,20 +728,7 @@ foreground and blue background." + + (defun notmuch-search-color-line (start end line-tag-list) + "Colorize lines in `notmuch-show' based on tags." +- ;; Create the overlay only if the message has tags which match one +- ;; of those specified in `notmuch-search-line-faces'. +- (let (overlay) +- (mapc (lambda (elem) +- (let ((tag (car elem)) +- (attributes (cdr elem))) +- (when (member tag line-tag-list) +- (when (not overlay) +- (setq overlay (make-overlay start end))) +- ;; Merge the specified properties with any already +- ;; applied from an earlier match. +- (overlay-put overlay 'face +- (append (overlay-get overlay 'face) attributes))))) +- notmuch-search-line-faces))) ++ (notmuch-color-line start end line-tag-list notmuch-search-line-faces)) + + (defun notmuch-search-author-propertize (authors) + "Split `authors' into matching and non-matching authors and +-- +1.7.9.1 + -- 2.26.2