unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How to add a display property when a char appear in a buffer.
@ 2021-11-29  3:20 Feng Shu
  2021-11-29 12:37 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Feng Shu @ 2021-11-29  3:20 UTC (permalink / raw)
  To: emacs-devel


Hi:

I want to auto add display property :min-width '(2.0), when a char
*appear* into a buffer. this char maybe inserted by user command, maybe
inserted in elisp.

any good way? I have try to use post-command, but seem to be not a good
idea for low performance.

thanks.


-- 




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

* Re: How to add a display property when a char appear in a buffer.
  2021-11-29  3:20 How to add a display property when a char appear in a buffer Feng Shu
@ 2021-11-29 12:37 ` Eli Zaretskii
  2021-11-29 12:52   ` Feng Shu
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2021-11-29 12:37 UTC (permalink / raw)
  To: Feng Shu; +Cc: emacs-devel

> From: "Feng Shu" <tumashu@163.com>
> Date: Mon, 29 Nov 2021 11:20:34 +0800
> 
> I want to auto add display property :min-width '(2.0), when a char
> *appear* into a buffer. this char maybe inserted by user command, maybe
> inserted in elisp.

If it's inserted by a user command, you can write a slightly different
command that puts the property.  If you want to cover also insertions
from Lisp, I think the only good mechanism is to register a jit-lock
function.

But IMNSHO, it is not a good idea to put this property on individual
characters, not at all.  You will end up with buffers that have many
display properties, and that slows down redisplay, makes the Emacs
memory larger, etc.  Don't do that!

The right way of making double-width character occupy exactly 2
columns on GUI frames is to tweak their pixel_width on the level of
the display code, under the control of some variable, similar to what
I did with height (which you didn't like, but here we are talking
about width, not height)).  We are discussing such a feature on this
list, so I suggest that you follow that discussion and provide input
and feedback where you see fit.



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

* Re: How to add a display property when a char appear in a buffer.
  2021-11-29 12:37 ` Eli Zaretskii
@ 2021-11-29 12:52   ` Feng Shu
  0 siblings, 0 replies; 3+ messages in thread
From: Feng Shu @ 2021-11-29 12:52 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: "Feng Shu" <tumashu@163.com>
>> Date: Mon, 29 Nov 2021 11:20:34 +0800
>> 
>> I want to auto add display property :min-width '(2.0), when a char
>> *appear* into a buffer. this char maybe inserted by user command, maybe
>> inserted in elisp.
>
> If it's inserted by a user command, you can write a slightly different
> command that puts the property.  If you want to cover also insertions
> from Lisp, I think the only good mechanism is to register a jit-lock
> function.
>
> But IMNSHO, it is not a good idea to put this property on individual
> characters, not at all.  You will end up with buffers that have many
> display properties, and that slows down redisplay, makes the Emacs
> memory larger, etc.  Don't do that!
>
> The right way of making double-width character occupy exactly 2
> columns on GUI frames is to tweak their pixel_width on the level of
> the display code, under the control of some variable, similar to what
> I did with height (which you didn't like, but here we are talking
> about width, not height)).  We are discussing such a feature on this

wow, good news :-)


> list, so I suggest that you follow that discussion and provide input
> and feedback where you see fit.

-- 




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

end of thread, other threads:[~2021-11-29 12:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29  3:20 How to add a display property when a char appear in a buffer Feng Shu
2021-11-29 12:37 ` Eli Zaretskii
2021-11-29 12:52   ` Feng Shu

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).