GNU bug report logs - #46177
27.1; Display problem with minibuffer overlay when using display property

Previous Next

Package: emacs;

Reported by: Clemens <clemens.radermacher <at> posteo.de>

Date: Fri, 29 Jan 2021 18:00:01 UTC

Severity: normal

Found in version 27.1

Done: Clemens <clemens.radermacher <at> posteo.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 46177 in the body.
You can then email your comments to 46177 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#46177; Package emacs. (Fri, 29 Jan 2021 18:00:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Clemens <clemens.radermacher <at> posteo.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 29 Jan 2021 18:00:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Clemens <clemens.radermacher <at> posteo.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; Display problem with minibuffer overlay when using display
 property
Date: Fri, 29 Jan 2021 18:58:46 +0100
When using an overlay with an `after-string` which uses `display`
the prompt background bleeds into the after string:


(set-face-attribute 'minibuffer-prompt nil :background "purple")

(minibuffer-with-setup-hook
    (lambda ()
      (overlay-put
       (make-overlay (point-max) (point-max) nil t t)
       'after-string (propertize " world"
                                 'display
				 " minibuffer")))
  (read-string "Hello"))


While I would expect it to be displayed like when using:


(minibuffer-with-setup-hook
    (lambda ()
      (overlay-put
       (make-overlay (point-max) (point-max) nil t t)
       'after-string " minibuffer"))
  (read-string "Hello"))






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46177; Package emacs. (Fri, 29 Jan 2021 18:38:02 GMT) Full text and rfc822 format available.

Message #8 received at 46177 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Clemens <clemens.radermacher <at> posteo.de>
Cc: 46177 <at> debbugs.gnu.org
Subject: Re: bug#46177: 27.1;
 Display problem with minibuffer overlay when using display property
Date: Fri, 29 Jan 2021 20:37:12 +0200
> From: Clemens <clemens.radermacher <at> posteo.de>
> Date: Fri, 29 Jan 2021 18:58:46 +0100
> 
> When using an overlay with an `after-string` which uses `display`
> the prompt background bleeds into the after string:

That's a feature: Emacs treats display strings and overlay strings
differently for the purposes of face merging.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46177; Package emacs. (Fri, 29 Jan 2021 20:27:01 GMT) Full text and rfc822 format available.

Message #11 received at 46177 <at> debbugs.gnu.org (full text, mbox):

From: Clemens <clemens.radermacher <at> posteo.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 46177 <at> debbugs.gnu.org
Subject: Re: bug#46177: 27.1; Display problem with minibuffer overlay when
 using display property
Date: Fri, 29 Jan 2021 21:26:26 +0100
> That's a feature: Emacs treats display strings and overlay strings
> differently for the purposes of face merging.


Okay, thanks. I have a problem with this when displaying completion 
candidates in the minibuffer. The candidates are displayed via 
`after-string` overlay. The candidates are provided by the caller and 
can contain the `display` property. Right now I "inline" any parts of 
the string that use `display` to avoid this:


(defun selectrum--display-string (str)
  "Return display string of STR."
  (let ((len (length str))
        (display "")
        (start 0)
        (end 0))
    (while (not (eq len end))
      (setq end (next-single-property-change start 'display str len))
      (let ((val  (get-text-property start 'display str)))
        (if (and val (stringp val))
            (setq display (concat display val))
          (setq display (concat display (substring str start end)))))
      (setq start end))
    display))


Is there a better way?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46177; Package emacs. (Sat, 30 Jan 2021 08:27:02 GMT) Full text and rfc822 format available.

Message #14 received at 46177 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Clemens <clemens.radermacher <at> posteo.de>
Cc: 46177 <at> debbugs.gnu.org
Subject: Re: bug#46177: 27.1; Display problem with minibuffer overlay when
 using display property
Date: Sat, 30 Jan 2021 10:26:47 +0200
> Cc: 46177 <at> debbugs.gnu.org
> From: Clemens <clemens.radermacher <at> posteo.de>
> Date: Fri, 29 Jan 2021 21:26:26 +0100
> 
> > That's a feature: Emacs treats display strings and overlay strings
> > differently for the purposes of face merging.
> 
> Okay, thanks. I have a problem with this when displaying completion 
> candidates in the minibuffer. The candidates are displayed via 
> `after-string` overlay. The candidates are provided by the caller and 
> can contain the `display` property. Right now I "inline" any parts of 
> the string that use `display` to avoid this:
> 
> 
> (defun selectrum--display-string (str)
>    "Return display string of STR."
>    (let ((len (length str))
>          (display "")
>          (start 0)
>          (end 0))
>      (while (not (eq len end))
>        (setq end (next-single-property-change start 'display str len))
>        (let ((val  (get-text-property start 'display str)))
>          (if (and val (stringp val))
>              (setq display (concat display val))
>            (setq display (concat display (substring str start end)))))
>        (setq start end))
>      display))
> 
> 
> Is there a better way?

Better in what sense?

If you mean a way that prevents the background of the prompt from
being applied to the text you display via the overlay, I think the
best/only way is for the overlay string or display string to specify
the background color.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46177; Package emacs. (Sat, 30 Jan 2021 09:31:02 GMT) Full text and rfc822 format available.

Message #17 received at 46177 <at> debbugs.gnu.org (full text, mbox):

From: Clemens <clemens.radermacher <at> posteo.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 46177 <at> debbugs.gnu.org
Subject: Re: bug#46177: 27.1; Display problem with minibuffer overlay when
 using display property
Date: Sat, 30 Jan 2021 10:30:21 +0100
> Better in what sense?
> 
> If you mean a way that prevents the background of the prompt from
> being applied to the text you display via the overlay, I think the
> best/only way is for the overlay string or display string to specify
> the background color.

Yes, I meant to avoid the issue that the minibuffer prompt face gets
applied to strings defined in the display property. The code I posted
simply removes any strings in the display spec and inlines them, which
seems to work well, too. The problem is not only the background color it 
seems, I would need to completely undo the effects of the minibuffer 
prompt face and I don't know how to do that. But what I'm doing now 
works and if there isn't a better solution I'm fine with using it.

I don't understand the reasons for the current behaviour but please
check out the following which seems not appropriate to me:


(set-face-attribute 'minibuffer-prompt nil :foreground "purple")
(minibuffer-with-setup-hook
    (lambda ()
      (overlay-put
       (make-overlay (point-max) (point-max) nil t t)
       'after-string
       (concat " from"
	           (propertize " world"
			       'display
			       " minibuffer"))))
  (read-string "Hello"))


Even with the " from" string between the string defined in the display 
property gets the prompt face applied.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46177; Package emacs. (Sat, 30 Jan 2021 10:46:02 GMT) Full text and rfc822 format available.

Message #20 received at 46177 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Clemens <clemens.radermacher <at> posteo.de>
Cc: 46177 <at> debbugs.gnu.org
Subject: Re: bug#46177: 27.1; Display problem with minibuffer overlay when
 using display property
Date: Sat, 30 Jan 2021 12:46:11 +0200
> Cc: 46177 <at> debbugs.gnu.org
> From: Clemens <clemens.radermacher <at> posteo.de>
> Date: Sat, 30 Jan 2021 10:30:21 +0100
> 
> The problem is not only the background color it seems, I would need
> to completely undo the effects of the minibuffer prompt face and I
> don't know how to do that.

Use a face which explicitly overrides every attribute of minibuffer
prompt face, I guess?

> (set-face-attribute 'minibuffer-prompt nil :foreground "purple")
> (minibuffer-with-setup-hook
>      (lambda ()
>        (overlay-put
>         (make-overlay (point-max) (point-max) nil t t)
>         'after-string
>         (concat " from"
> 	           (propertize " world"
> 			       'display
> 			       " minibuffer"))))
>    (read-string "Hello"))
> 
> 
> Even with the " from" string between the string defined in the display 
> property gets the prompt face applied.

Because " minibuffer" is a display string, and its buffer position is
still EOB.  That it has the " from " string in the overlay property
before it doesn't change the buffer position whose face affects the
display string.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46177; Package emacs. (Sat, 30 Jan 2021 11:11:01 GMT) Full text and rfc822 format available.

Message #23 received at 46177 <at> debbugs.gnu.org (full text, mbox):

From: Clemens <clemens.radermacher <at> posteo.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 46177 <at> debbugs.gnu.org
Subject: Re: bug#46177: 27.1; Display problem with minibuffer overlay when
 using display property
Date: Sat, 30 Jan 2021 12:09:57 +0100
> Use a face which explicitly overrides every attribute of minibuffer
> prompt face, I guess?

As far as I understand I would have to loop through the overlay string, 
too and apply those face adjustments to every of those display property 
strings. I think then I can also just inline them like in my shown 
example which avoid this issue in the first place.

> 
>> (set-face-attribute 'minibuffer-prompt nil :foreground "purple")
>> (minibuffer-with-setup-hook
>>       (lambda ()
>>         (overlay-put
>>          (make-overlay (point-max) (point-max) nil t t)
>>          'after-string
>>          (concat " from"
>> 	           (propertize " world"
>> 			       'display
>> 			       " minibuffer"))))
>>     (read-string "Hello"))
>>
>>
>> Even with the " from" string between the string defined in the display
>> property gets the prompt face applied.
> 
> Because " minibuffer" is a display string, and its buffer position is
> still EOB.  That it has the " from " string in the overlay property
> before it doesn't change the buffer position whose face affects the
> display string.

Because the " minibuffer" string follows the non affected " from" string
this is unexpected from a caller/UI viewpoint IMO. I don't understand 
the underlying reasoning for this but if you don't think there is 
something to fix here, I will accept that and continue using my workaround.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46177; Package emacs. (Sat, 30 Jan 2021 12:07:01 GMT) Full text and rfc822 format available.

Message #26 received at 46177 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Clemens <clemens.radermacher <at> posteo.de>
Cc: 46177 <at> debbugs.gnu.org
Subject: Re: bug#46177: 27.1; Display problem with minibuffer overlay when
 using display property
Date: Sat, 30 Jan 2021 14:06:56 +0200
> Cc: 46177 <at> debbugs.gnu.org
> From: Clemens <clemens.radermacher <at> posteo.de>
> Date: Sat, 30 Jan 2021 12:09:57 +0100
> 
> Because the " minibuffer" string follows the non affected " from" string
> this is unexpected from a caller/UI viewpoint IMO.

Once Emacs is about to display a 'display' property string, the rules
for which faces are relevant change.

> I don't understand the underlying reasoning for this but if you
> don't think there is something to fix here, I will accept that and
> continue using my workaround.

It's just how Emacs worked since v21, so I think it's too late to
change now.




Reply sent to Clemens <clemens.radermacher <at> posteo.de>:
You have taken responsibility. (Sat, 30 Jan 2021 12:11:01 GMT) Full text and rfc822 format available.

Notification sent to Clemens <clemens.radermacher <at> posteo.de>:
bug acknowledged by developer. (Sat, 30 Jan 2021 12:11:01 GMT) Full text and rfc822 format available.

Message #31 received at 46177-done <at> debbugs.gnu.org (full text, mbox):

From: Clemens <clemens.radermacher <at> posteo.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 46177-done <at> debbugs.gnu.org
Subject: Re: bug#46177: 27.1; Display problem with minibuffer overlay when
 using display property
Date: Sat, 30 Jan 2021 13:10:39 +0100
> It's just how Emacs worked since v21, so I think it's too late to
> change now.

I see, thanks for your discussion and help, I will close this then.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 27 Feb 2021 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 110 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.