emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using glyphs by default in perl-mode


From: Ted Zlatanov
Subject: Re: using glyphs by default in perl-mode
Date: Fri, 07 Jun 2013 11:39:21 -0400
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux)

On Fri, 07 Jun 2013 17:52:10 +0300 Eli Zaretskii <address@hidden> wrote: 

>> From: Ted Zlatanov <address@hidden>
>> Date: Fri, 07 Jun 2013 08:48:48 -0400
>> 
>> OK, but read that sentence again.  Can you really make sense of it?

EZ> Yes, definitely.  I wonder what makes it illegible for you.  (No, I
EZ> didn't write that doc string.)

The way it's written makes it hard to read, not illegible.

You and others who know how text composition works are a terrible use
case for this docstring.  I'll propose a revised version.

>> Currently, AFAIK Emacs treats images as a text property.

EZ> More accurately, you display images by creating text properties with
EZ> images as their values.

Yes, exactly.

>> This is convenient but there are many cases where I'd rather have
>> images behave like typed characters: one image == one character ==
>> one glyph.

EZ> Then create a font.  That's what you want.  Emacs cannot display text
EZ> as something else except via text properties or overlays.

Yes!  But I don't want to create the font, I want Emacs to do it for me.

>> (make-char 'image "/tmp/gnus.png")
>> 
>> will produce something that respects font size, can be scaled, and looks
>> like a character to all Emacs functions but like an image visually.  In
>> text mode or without image support it would be treated like a character
>> that can't be rendered.

EZ> This doesn't make sense to me: a character has many properties and
EZ> attributes that the above doesn't provide.

They will have to be faked, simulated, or ignored.

EZ> Displaying an image as a character means that you will need to
EZ> implement a font library, or something close.

It's a feature request based on my experience with images in Emacs
today.  If it goes on my queue, it may never get done because I have no
knowledge of the font and image internals.  But obviously that's what
will happen if no one else thinks it's worth implementing... so this is
my proposal, to gather interest.

EZ> Why can't you generate a set of strings with display properties, and
EZ> then insert them into a buffer?  After all, a single-character string
EZ> should do what you want, no?

It doesn't.  It doesn't respect font size, most importantly.  It needs
to scale so I can insert 20 images at size 15 and have them look good.
And when I change to size 25, I want the images to flow like text.  I
don't want to treat images in a special way in some cases.

The origin of this was that I'd like to extend `prog-prettify-symbols'
to support images as well.  It would be so much easier to say

("eli" . ,(make-char 'image "eli.png"))

and pass the character to be inserted, not a special extension to this
simple format to support images.  BTW, SVG would be great here too.

Fundamentally, I'm talking about treating images as characters because
Emacs is good at dealing with characters.  Text properties are useful
and I think the image support there is great, but text properties are
not first-class citizens of a buffer.

For instance, to come back to the first part of this post, it would be
very nice to compose characters with image glyphs or SVG glyphs
(gradients and vector graphics).  It would make some pretty amazing
visuals possible.  I've done this with Java Swing, and you can see some
examples at http://filthyrichclients.org/ (I highly recommend the
book).

HTML is a very good analogy.  It has images as a text property through
CSS and it has images as an <img> element, which ends up as an actual
DOM node (IIUC the terminology, I hope you'll know what I mean).  They
both have their place.  Emacs only has the former.

Ted




reply via email to

[Prev in Thread] Current Thread [Next in Thread]