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 E92A2431FCB for ; Sat, 5 May 2012 06:39: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 riJu5K8UXCsV for ; Sat, 5 May 2012 06:39:41 -0700 (PDT) Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7A79C431FB6 for ; Sat, 5 May 2012 06:39:41 -0700 (PDT) Received: by wibhr7 with SMTP id hr7so1498669wib.2 for ; Sat, 05 May 2012 06:39:40 -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=oaIUiyCRs6sL/rfiID+f7sP0GJBjAONIWuhpviQcmJo=; b=mQWbVhrJ/CIMIcRUgX3Eazl61biv8q40vIhnvPwPBtHrHTU1zKVelyRKAyInImVGL/ BNySXb8yuUKzZRSyMa5U4i/CJ3gh8W9LXAYaCKmemtRHkco07IvaWO1Lr8ieiZ6CEOtr zFj4WxciEL50nVUUMjyAmfqbGcEkW6plBP5A3gEsXKcjMiqyp0x4E1ua0MiYTVKfIxC6 58qW78rFv3osGZZKzIt2sWZnmPLh3ii6Jx6/h3JHXHHqYBaa36W3gwX7OqmKpBmj6DWt p8GVBiKUPt4/f8U8NEihixwLdcBNAcBh1rkIFqsXGO4gwyAxPwiZGYYPEcUP4igFySpg 4jGw== Received: by 10.180.24.35 with SMTP id r3mr21234054wif.7.1336225180102; Sat, 05 May 2012 06:39:40 -0700 (PDT) Received: from localhost (94-192-233-223.zone6.bethere.co.uk. [94.192.233.223]) by mx.google.com with ESMTPS id b3sm5797889wib.4.2012.05.05.06.39.38 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 05 May 2012 06:39:39 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [Patch v3 1/4] emacs: Move colour line from search to lib Date: Sat, 5 May 2012 14:39:44 +0100 Message-Id: <1336225187-8772-2-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1336225187-8772-1-git-send-email-markwalters1009@gmail.com> References: <1336225187-8772-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, 05 May 2012 13:39: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 c6236db..d5f40e2 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -612,20 +612,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