unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 72762@debbugs.gnu.org, the_wurfkreuz <the_wurfkreuz@proton.me>
Subject: bug#72762: 30.0.60; Incorrect rendering of the completion-preview mode
Date: Fri, 23 Aug 2024 07:30:32 +0200	[thread overview]
Message-ID: <m1ed6fiz5z.fsf@dazzs-mbp.home> (raw)
In-Reply-To: <867cc8saau.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 22 Aug 2024 21:05:13 +0300")

Hi,

>> Date: Thu, 22 Aug 2024 17:29:30 +0000
>> From:  the_wurfkreuz via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> 
>> Apparently, the completion-preview-mode rendering doesn't work correctly with minibuffer messages (i don't know what they're called exactly).
>> 
>> To see the problem, completion-preview-mode should show its completion suggestion simultaneously with any minibuffer messages like "[No Match]" or "[Incomplete Command]" and so on.

Thanks for the report!

Enabling Completion Preview mode in the minibuffer is not currently
supported, precisely because minibuffers make use of different
completion UIs which may conflict with the completion preview.  You
might notice that by default, minibuffer-mode is explicitly excluded in
global-completion-preview-modes.

That said, I do consider minibuffers to be a viable additional use case
for Completion Preview mode, and I'd like to help you make it work:

>> Reproduction:
>> - Load emacs with the evil-mode package.
>> - Activate evil-mode and completion-preview-mode.
>> - Evaluate the hook '(add-hook 'minibuffer-mode-hook #'completion-preview-mode)'.
>> - Execute 'evil-ex'.
>> - Try to write any long command to trigger the preview completion.

I don't use evil-mode, but I understand the situation after following
these steps.  evil-ex uses an overlay with after-string property to
display its automatic messages, which is the same mechanism Completion
Preview mode uses to display the preview.  A quick solution you can try
is to use completion-preview-active-mode-hook to turn off evil-ex's
automatic messages when the preview is visible by temporarily setting
evil-no-display to non-nil.

An arguably nicer solution is to give the completion preview overlay
higher priority, so it is displayed before the "[Incomplete Command]"
message.  However, we don't always want to give the completion preview
overlay a positive priority, since that may lead to incorrect results in
other scenarios.  What we can do is to add a variable that specifies the
overlay priority, so you can set it just where appropriate.

Eli, is the following alright for Emacs 30, or should this go on the
master branch?


diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el
index d3e9acb1ed9..60abdbc0736 100644
--- a/lisp/completion-preview.el
+++ b/lisp/completion-preview.el
@@ -262,11 +262,16 @@ completion-preview-hide
     (setq completion-preview--overlay nil
           completion-preview--inhibit-update-p nil)))
 
+(defvar completion-preview-overlay-priority nil
+  "Value of the `priority' property for the completion preview overlay.")
+
 (defun completion-preview--make-overlay (pos string)
   "Make preview overlay showing STRING at POS, or move existing preview there."
   (if completion-preview--overlay
       (move-overlay completion-preview--overlay pos pos)
     (setq completion-preview--overlay (make-overlay pos pos))
+    (overlay-put completion-preview--overlay 'priority
+                 completion-preview-overlay-priority)
     (overlay-put completion-preview--overlay 'window (selected-window)))
   (add-text-properties 0 1 '(cursor 1) string)
   (overlay-put completion-preview--overlay 'after-string string)






  reply	other threads:[~2024-08-23  5:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22 17:29 bug#72762: 30.0.60; Incorrect rendering of the completion-preview mode the_wurfkreuz via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-22 18:05 ` Eli Zaretskii
2024-08-23  5:30   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-09-04 17:02     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1ed6fiz5z.fsf@dazzs-mbp.home \
    --to=bug-gnu-emacs@gnu.org \
    --cc=72762@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=me@eshelyaron.com \
    --cc=the_wurfkreuz@proton.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).