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 DD3FD431FAF for ; Sun, 29 Apr 2012 15:48:07 -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 vpA3CRuJJQ73 for ; Sun, 29 Apr 2012 15:48:07 -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 0E6E5431FAE for ; Sun, 29 Apr 2012 15:48:06 -0700 (PDT) Received: by wibhq7 with SMTP id hq7so1840741wib.2 for ; Sun, 29 Apr 2012 15:48:05 -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=oJXjnokV/Eho6LgbYalIC0UBmZ2myw+Gfxxu67qjuG6NMTYtaOiYiPnb+D0PBnPS6y X7rnFRlzo713cP93Bm/k7+JKYWq5Oj/Xo3qzLzF3Xzd9gaftISjQoi0Oqe9prPU8zBp0 uDmDAApA+nBEwGdM8jBvZNdE5uo/faovoQvR1sAmT2whNClOjgqKAmkzUv2bRRz1FCYw oXLGPtKX666bYCtKzwyuFI2OaqMUDAZSX/u4WKqdGHU6Wan9w62/fw/fyO7r2bz6X/aA /efUTFy3jEJTnp0RwxPFDoTUaXj3sOCv1pFCOeWDxZKprZXynq3q7TSmwtY/jyLy/cOy eaDA== Received: by 10.180.24.7 with SMTP id q7mr1545725wif.11.1335739685672; Sun, 29 Apr 2012 15:48:05 -0700 (PDT) Received: from localhost (94-192-233-223.zone6.bethere.co.uk. [94.192.233.223]) by mx.google.com with ESMTPS id fz9sm24223990wib.3.2012.04.29.15.48.04 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 29 Apr 2012 15:48:05 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [Patch v2 1/3] emacs: Move colour line from search to lib Date: Sun, 29 Apr 2012 23:48:15 +0100 Message-Id: <1335739697-8501-2-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1335739697-8501-1-git-send-email-markwalters1009@gmail.com> References: <1335739697-8501-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: Sun, 29 Apr 2012 22:48:08 -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