From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#43519: 28.0.50; Overlay at end of minibuf hides minibuf's real content Date: Sat, 19 Sep 2020 18:06:20 -0400 Message-ID: References: <83wo0p1twr.fsf@gnu.org> <83r1qx1q9v.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23482"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 43519@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 20 00:07:09 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJl0e-00060J-TC for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Sep 2020 00:07:09 +0200 Original-Received: from localhost ([::1]:58296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJl0d-00076m-RF for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Sep 2020 18:07:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJl0Y-00076S-4x for bug-gnu-emacs@gnu.org; Sat, 19 Sep 2020 18:07:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kJl0X-0006xT-Ri for bug-gnu-emacs@gnu.org; Sat, 19 Sep 2020 18:07:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kJl0X-0002VH-LP for bug-gnu-emacs@gnu.org; Sat, 19 Sep 2020 18:07:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Sep 2020 22:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43519 X-GNU-PR-Package: emacs Original-Received: via spool by 43519-submit@debbugs.gnu.org id=B43519.16005531929583 (code B ref 43519); Sat, 19 Sep 2020 22:07:01 +0000 Original-Received: (at 43519) by debbugs.gnu.org; 19 Sep 2020 22:06:32 +0000 Original-Received: from localhost ([127.0.0.1]:48332 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJl03-0002UV-U1 for submit@debbugs.gnu.org; Sat, 19 Sep 2020 18:06:32 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:50182) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJl00-0002UF-Fq for 43519@debbugs.gnu.org; Sat, 19 Sep 2020 18:06:30 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 4833A10022D; Sat, 19 Sep 2020 18:06:23 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 8A09A10022A; Sat, 19 Sep 2020 18:06:21 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1600553181; bh=q8ecgnt4qG77aa+EPf8gnzVcSCSb27gOYiVGu2T3Xlc=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=FbwmSe5xLub3OjQzGpFN8fUjrW4ENxdVpmqKINPpBrx0kKEjSy72HDDH3Z/bCfyaB ojEk8sx2ue8xkvn7EWbYG8DNxEo+DBLFt5fHP/Of+0Wu14vVH7CirZAndGsdYWOBSa ZtQOcUATngJpcdtB1YvmtQEyePnciwy1zsnQVxrRPdsXbTpbMy/3YvIE1D6AZTcE8C liZq8A0Nl1Vf2QtivtJayWTAlHTl6BF/Z7nXDUxjpj5VL8whZaSZIP58RMVQg7nzon BGh0YbKO8pTr/ficMq5C5J3zLWGqapUPQwkZHm5LaoCC4sC5OEMg4C3VJ4Xpb/8STn paBNurK6zIcDQ== Original-Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4CB241202E9; Sat, 19 Sep 2020 18:06:21 -0400 (EDT) In-Reply-To: <83r1qx1q9v.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 19 Sep 2020 23:10:36 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:188445 Archived-At: >> I disagree: icomplete merely added text after point via an overlay and >> didn't do anything which explicitly justifies horizontal scrolling. > > Maybe I'm missing something, but what does the code in > icomplete-completions that calls string-width and window-width try to > do, then? I mean this part: > > ;;"-prospects" - more than one candidate > (prospects-len (+ (string-width > (or determ (concat open-bracket close-bracket))) > (string-width icomplete-separator) > (+ 2 (string-width ellipsis)) ;; take {=E2=80=A6} into account > (string-width (buffer-string)))) > (prospects-max > ;; Max total length to use, including the minibuffer conten= t. > (* (+ icomplete-prospects-height > ;; If the minibuffer content already uses up more than > ;; one line, increase the allowable space accordingly. > (/ prospects-len (window-width))) > (window-width))) That's not relevant to the issue at hand. I used `icomplete-mode` only as a vehicle to show the underlying behavior with a short recipe which exhibits a real-life problem. >> > It should produce an overlay string that fits in the window, then the >> > prompt will be visible. >> That would merely work around the underlying problem > What do you think is the underlying problem? That the redisplay performed horizontal scrolling when it was not needed since the cursor was already visible without such scrolling. >> (and as you know it's wickedly difficult to construct a string which >> will have "just the right size" to fit into the minibuffer window). > It doesn't have to be "just the right size", it could err on the safe > side. It already attempts to do so, by avoiding truncation in the > middle of a candidate. It should just do a better job, that's all. And how do we generalize that to the case where the overlay contains newlines, TABs, chars in different scripts using different fonts, different faces, images, etc.... ? >> Maybe there's a good reason for the redisplay to behave this way > Behave in what way? what's special about what you see on display in > this case, given the contents of the mini-window's buffer? Try the recipe below instead: (minibuffer-with-setup-hook (lambda () (insert "hello") (let ((ol (make-overlay (point) (point))) (max-mini-window-height 1) (text "askdjfhaklsjdfhlkasjdfhklasdhflkasdhflkajsdhflkashdf= kljahsdlfkjahsdlfkjhasldkfhalskdjfhalskdfhlaksdhfklasdhflkasdhflkasdhflkajs= dhklajsdgh")) (save-excursion (insert text)) (sit-for 2) (delete-region (point) (point-max)) (put-text-property 0 1 'cursor t text) (overlay-put ol 'after-string text) (sit-for 2) (delete-overlay ol))) (read-string "toto: ")) This performs "display of text after point" in 2 different ways: - first by `insert`. - then with an overlay. The visual rendering of the text is the same, with the cursor at the same place. When we do it with `insert` there is no horizontal scrolling, but when we do it with an overlay the text gets scrolled so the cursor is at `window-start`. `icomplete` needs the behavior to be the same as with `insert`, but it prefers to use an overlay to avoid some undesirable side-effects of modifying the actual text. So the question is: how to get the same behavior as what we'd get with `insert` but without actually modifying the buffer's contents? Is it more clear now? Stefan