From: Austin Clements <amdragon@MIT.EDU>
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 [thread overview]
Message-ID: <1360013822-6562-3-git-send-email-amdragon@mit.edu> (raw)
In-Reply-To: <1360013822-6562-1-git-send-email-amdragon@mit.edu>
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
next prev parent reply other threads:[~2013-02-04 21:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-04 21:37 [PATCH 0/2] notmuch-combine-face-text-property improvements Austin Clements
2013-02-04 21:37 ` [PATCH 1/2] emacs: Handle all face forms when combining faces Austin Clements
2013-02-04 21:37 ` Austin Clements [this message]
2013-02-06 9:43 ` [PATCH 0/2] notmuch-combine-face-text-property improvements Damien Cassou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1360013822-6562-3-git-send-email-amdragon@mit.edu \
--to=amdragon@mit.edu \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).