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 61CA9431FC7 for ; Mon, 4 Feb 2013 13:37:12 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 FTOv7KL7J96V for ; Mon, 4 Feb 2013 13:37:11 -0800 (PST) Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU [18.7.68.34]) by olra.theworths.org (Postfix) with ESMTP id BCD5C431FBC for ; Mon, 4 Feb 2013 13:37:10 -0800 (PST) X-AuditID: 12074422-b7f5c6d000000545-46-51102a06bd23 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP id C5.EF.01349.60A20115; Mon, 4 Feb 2013 16:37:10 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r14Lb8tA003239; Mon, 4 Feb 2013 16:37:08 -0500 Received: from drake.dyndns.org (26-4-172.dynamic.csail.mit.edu [18.26.4.172]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r14Lb6Q7016772 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 4 Feb 2013 16:37:07 -0500 Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1U2Tis-0001mw-5k; Mon, 04 Feb 2013 16:37:06 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 2/2] emacs: Combine string faces and combine under existing faces Date: Mon, 4 Feb 2013 16:37:02 -0500 Message-Id: <1360013822-6562-3-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360013822-6562-1-git-send-email-amdragon@mit.edu> References: <1360013822-6562-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBIsWRmVeSWpSXmKPExsUixG6nrsumJRBoMPciv8Wuu1uZLK7fnMns wOSxc9Zddo9nq24xBzBFcdmkpOZklqUW6dslcGVsn32SrWCzUMXiJ1YNjA/5uhg5OSQETCTm Te1lg7DFJC7cWw9kc3EICexjlPg2dw8zhLOBUWLK8o+MEM5hJom+Z9PZIZy5jBJtc2ezg/Sz CWhIbNu/nBHEFhGQlth5dzYriM0sYC+xcdZrsBphgUCJBdd+MYPYLAKqEt/6V4PZvEA1bW8m QN2hKNH9DMTm4OAUcJC4u4oHJCwEVPLu4nzGCYz8CxgZVjHKpuRW6eYmZuYUpybrFicn5uWl Fuma6uVmluilppRuYgQHkovSDsafB5UOMQpwMCrx8AZe4w8UYk0sK67MPcQoycGkJMpbpCQQ KMSXlJ9SmZFYnBFfVJqTWnyIUYKDWUmE9+MNoHLelMTKqtSifJiUNAeLkjjvtZSb/kIC6Ykl qdmpqQWpRTBZGQ4OJQleH02goYJFqempFWmZOSUIaSYOTpDhPEDDDUFqeIsLEnOLM9Mh8qcY dTn2P2l/zijEkpeflyolzisOUiQAUpRRmgc3B5YAXjGKA70lzGsEUsUDTB5wk14BLWECWqKU A/JBcUkiQkqqgVHvVorPgZANApWyTxN7KmJefSzhkywubrydU1zm8t5+uXNUVE7fgvlFOtIf tZ2sfV9zl57oyZ7jt9YmT8RQ/mH9oe4vGnFvTneeNfHdHpedmHA/9fuVpfrbIzgtfXyfWe8N OjXvZnjMe44Xuk49K/pPfT08822ksf7eY5Z+874VWF2Jfj8tWYmlOCPRUIu5qDgRACO7GLzb AgAA 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: Mon, 04 Feb 2013 21:37:13 -0000 This improves notmuch-combine-face-text-property to support both applying faces to strings and to support combining the given face under existing faces, rather than over. --- emacs/notmuch-lib.el | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index ad2816d..7c8816d 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -311,13 +311,16 @@ single element face list." face (list face))) -(defun notmuch-combine-face-text-property (start end face) +(defun notmuch-combine-face-text-property (start end face &optional below object) "Combine FACE into the 'face text property between START and END. This function combines FACE with any existing faces between START -and END. Attributes specified by FACE take precedence over -existing attributes. FACE must be a face name (a symbol or -string), a property list of face attributes, or a list of these." +and END in OBJECT (which defaults to the current buffer). +Attributes specified by FACE take precedence over existing +attributes unless BELOW is non-nil. FACE must be a face name (a +symbol or string), a property list of face attributes, or a list +of these. For convenience when applied to strings, this returns +OBJECT." ;; A face property can have three forms: a face name (a string or ;; symbol), a property list, or a list of these two forms. In the @@ -327,13 +330,15 @@ string), a property list of face attributes, or a list of these." (let ((pos start) (face-list (notmuch-face-ensure-list-form face))) (while (< pos end) - (let* ((cur (get-text-property pos 'face)) + (let* ((cur (get-text-property pos 'face object)) (cur-list (notmuch-face-ensure-list-form cur)) (new (cond ((null cur-list) face) + (below (append cur-list face-list)) (t (append face-list cur-list)))) - (next (next-single-property-change pos 'face nil end))) - (put-text-property pos next 'face new) - (setq pos next))))) + (next (next-single-property-change pos 'face object end))) + (put-text-property pos next 'face new object) + (setq pos next)))) + object) (defun notmuch-logged-error (msg &optional extra) "Log MSG and EXTRA to *Notmuch errors* and signal MSG. -- 1.7.10.4