all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#42521: 28.0.50; Can't include an image in a display string
@ 2020-07-24 19:40 Dmitry Gutov
  2020-07-25  5:54 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2020-07-24 19:40 UTC (permalink / raw)
  To: 42521

(progn
   (erase-buffer)
   (insert " ")
   (setq o (make-overlay (point-min) (point)))
   (overlay-put o 'display
                (concat (propertize " " 'display
                                    (create-image "splash.svg" nil nil 
:max-height
                                                  (default-font-height)))
                        " text after image")))

The script above will end with a blank space instead of an image being 
displayed.

To compare: replace the first 'display symbol with 'after-string, and
the image is displayed.

Why do we need this: if this worked, we would implement icons display in
the default completion popup in company-mode. It's a feature that has 
been requested for a while. See the discussion here:

https://github.com/company-mode/company-mode/pull/996#issuecomment-662743347

Unfortunately, as we seem to have concluded in

   https://debbugs.gnu.org/cgi/bugreport.cgi?bug=18285
   and
   https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20847,

I have to use the `display' overlay property in most of the cases.

P.S. This is not a regression, Emacs 26.3 is the same.

In GNU Emacs 28.0.50 (build 25, x86_64-pc-linux-gnu, GTK+ Version 
3.24.20, cairo version 1.16.0)
  of 2020-07-20 built on potemkin
Repository revision: 4c08c2f45b9bb0265f6d7c3529011dee1b18e843
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Ubuntu 20.04 LTS





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

* bug#42521: 28.0.50; Can't include an image in a display string
  2020-07-24 19:40 bug#42521: 28.0.50; Can't include an image in a display string Dmitry Gutov
@ 2020-07-25  5:54 ` Eli Zaretskii
  2020-07-25 10:26   ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2020-07-25  5:54 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 42521

severity 42521 wishlist
thanks

> From: Dmitry Gutov <dgutov@yandex.ru>
> Date: Fri, 24 Jul 2020 22:40:02 +0300
> 
> (progn
>    (erase-buffer)
>    (insert " ")
>    (setq o (make-overlay (point-min) (point)))
>    (overlay-put o 'display
>                 (concat (propertize " " 'display
>                                     (create-image "splash.svg" nil nil 
> :max-height
>                                                   (default-font-height)))
>                         " text after image")))
> 
> The script above will end with a blank space instead of an image being 
> displayed.

This is a documented limitation of the current design and
implementation of the 'display' property.  The ELisp manual says:

  ‘STRING’
       Display STRING instead of the text that has this property.

       Recursive display specifications are not supported—STRING’s
       ‘display’ properties, if any, are not used.

I never looked into lifting this restriction, so I don't know what
would that entail.  There are probably some complications with faces,
at least.  If someone wants to study the issue, that'd be welcome, I
think.





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

* bug#42521: 28.0.50; Can't include an image in a display string
  2020-07-25  5:54 ` Eli Zaretskii
@ 2020-07-25 10:26   ` Dmitry Gutov
  2020-07-25 10:56     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2020-07-25 10:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 42521

On 25.07.2020 08:54, Eli Zaretskii wrote:
>         Recursive display specifications are not supported—STRING’s
>         ‘display’ properties, if any, are not used.

I see, thank you.

But what about other ways to reach the same goal?

Like supporting image spec placed on 'before-string' instead of 'display':

(progn
   (erase-buffer)
   (insert " ")
   (setq o (make-overlay (point-min) (point)))
   (overlay-put o 'display
                (propertize " text after image"
                            'before-string
                            (create-image "splash.svg" nil nil
                                          :max-height
                                          (default-font-height)))))

If this worked, I would actually prefer it.





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

* bug#42521: 28.0.50; Can't include an image in a display string
  2020-07-25 10:26   ` Dmitry Gutov
@ 2020-07-25 10:56     ` Eli Zaretskii
  2020-07-25 11:34       ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2020-07-25 10:56 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 42521

> Cc: 42521@debbugs.gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> Date: Sat, 25 Jul 2020 13:26:19 +0300
> 
> Like supporting image spec placed on 'before-string' instead of 'display':
> 
> (progn
>    (erase-buffer)
>    (insert " ")
>    (setq o (make-overlay (point-min) (point)))
>    (overlay-put o 'display
>                 (propertize " text after image"
>                             'before-string
>                             (create-image "splash.svg" nil nil
>                                           :max-height
>                                           (default-font-height)))))
> 
> If this worked, I would actually prefer it.

This puts a 'before-string' property on a display string.  But
'before-string' is an overlay property, not a text property, so it
cannot be put on a string, only on buffer text.





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

* bug#42521: 28.0.50; Can't include an image in a display string
  2020-07-25 10:56     ` Eli Zaretskii
@ 2020-07-25 11:34       ` Dmitry Gutov
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Gutov @ 2020-07-25 11:34 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 42521

On 25.07.2020 13:56, Eli Zaretskii wrote:
> This puts a 'before-string' property on a display string.  But
> 'before-string' is an overlay property, not a text property, so it
> cannot be put on a string, only on buffer text.

Ah, yes. Thank you for the reminder.





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

end of thread, other threads:[~2020-07-25 11:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-24 19:40 bug#42521: 28.0.50; Can't include an image in a display string Dmitry Gutov
2020-07-25  5:54 ` Eli Zaretskii
2020-07-25 10:26   ` Dmitry Gutov
2020-07-25 10:56     ` Eli Zaretskii
2020-07-25 11:34       ` Dmitry Gutov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.