unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* `add-face'
@ 2012-09-06 15:51 Lars Ingebrigtsen
  2012-09-07  4:17 ` `add-face' Chong Yidong
  0 siblings, 1 reply; 18+ messages in thread
From: Lars Ingebrigtsen @ 2012-09-06 15:51 UTC (permalink / raw)
  To: emacs devel; +Cc: Wolfgang Jenkner

Wolfgang Jenkner has just made me aware that `face' text properties are
combining!  That is, you can have lists of them and they work like
overlays.

I've always disliked working with overlays, because they are so fiddly.
Just look (or don't!) at the code in shr.el, but I thought I had to,
since text properties didn't combine.

However, the Emacs functions for working with combining text property
faces are kinda...  weak.  You basically have to check yourself, so you
end up with code like this:

(defun gnus-combine-text-property (beg end prop val)
  "Combine PROP with text properties between BEG and END.
This combines attributes if PROP is `face' otherwise this is just
like `put-text-property', more or less.
Beware: Proof-of-concept."
  (let ((b beg))
    (while (< b end)
      (let ((oldval (get-text-property b prop)))
	(gnus-put-text-property
	 b (setq b (next-single-property-change b prop nil end))
	 prop (cond ((or (not (eq prop 'face))
			 (null oldval))
		     val)
		    ((and (consp oldval)
			  (not (keywordp (car oldval))))
		     (cons val oldval))
		    (t
		     (list val oldval))))))))

So here's my suggestion for exposing this rather nice functionality in a
more convenient form.

Add a function `add-face', that will do what you think it does.  Or
perhaps `add-face-region'?  Or `add-text-property-face'?

Anyway, this will call `add-text-properties' with a new optional
parameter NOREPLACE, that will tell `add-text-properties' to add to the
list of properties instead of replacing.  This, in turn, will then call
add_properties with a new parameter, and it will do the trivial list
manipulation stuff instead of just

	    Fsetcar (this_cdr, val1);

If this sounds like a good idea, I can implement this right away.  And
then change shr.el to use the new function, which should speed table
rendering up a bit, as well as getting rid of some uglee code.

-- 
(domestic pets only, the antidote for overdose, milk.)
  http://lars.ingebrigtsen.no  *  Lars Magne Ingebrigtsen



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2013-06-17 15:29 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-06 15:51 `add-face' Lars Ingebrigtsen
2012-09-07  4:17 ` `add-face' Chong Yidong
2012-09-07 12:41   ` `add-face' Lars Ingebrigtsen
2012-09-07 13:31     ` `add-face' Chong Yidong
2012-09-07 13:46       ` `add-face' Lars Ingebrigtsen
2012-09-07 14:13         ` `add-face' Lars Ingebrigtsen
2012-09-09  6:47         ` `add-face' Chong Yidong
2012-09-09 17:31           ` `add-face' Lars Ingebrigtsen
2012-09-10  3:07             ` `add-face' Chong Yidong
2012-09-10 12:57               ` `add-face' Stefan Monnier
2012-10-24 18:56                 ` `add-face' Lars Magne Ingebrigtsen
2013-06-17  7:54                 ` `add-face' Lars Magne Ingebrigtsen
2013-06-17  9:12                   ` `add-face' Lars Magne Ingebrigtsen
2013-06-17  9:51                     ` `add-face' Lars Magne Ingebrigtsen
2013-06-17 14:43                       ` `add-face' Stefan Monnier
2013-06-17 15:29                         ` `add-face' Lars Magne Ingebrigtsen
2012-10-24 18:54               ` `add-face' Lars Magne Ingebrigtsen
2012-09-07 20:10   ` `add-face' Johan Bockgård

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).