Subject: bug#64547: `show-paren-mode` thinks that a paren is offscreen in `M-:` when it isn't

From: [email-masked]
Date: Fri, 14 Jul 2023 03:03:31 +0000

On 2023-07-10 14:17 UTC, Eli Zaretskii wrote:
>> From: Stephen Berman <[email-masked]>
>> Cc: Okamsn <[email-masked]>,  [email-masked]
>> Date: Mon, 10 Jul 2023 15:26:34 +0200
>>
>> 0. emacs -Q
>> 1. M-x customize-option show-paren-style RET.  Choose "mixed" from the
>>     Value Menu and set for current session.
>> 2. M-x customize-option show-paren-context-when-offscreen RET.  Choose
>>     "In overlay" from the Value Menu and set for current session.
>> 3. M-x customize-option line-spacing RET.  Choose "Number" from the
>>     Value Menu, enter 0.06 or greater and set for current session.
>> 4. M-: ()
>> => On typing ")" the "Eval: " prompt vanishes, the string "(" is
>>     displayed with a hollow box over it, followed directly by the string
>>     "()" with a cyan background.  Typing DEL to delete the final ")"
>>     displays the "Eval: " prompt again, the "(" with a hollow box over it
>>     vanishes, and the remaining "(" has no cyan overlay.  Typing any
>>     characters and then ")" at the end again makes the prompt vanishes,
>>     "(" with the hollow box and the cyan overlay return.  Lather, rinse,
>>     repeat...
> 
> Thanks, should be fixed now on the emacs-29 branch.

Hello,

The change fixed it for the minibuffer, but also disabled it when the 
opening parenthesis was offscreen.  I think this is because
`(pos-visible-in-window-p openparen nil t)` seems to return nil in that 
case.

I got it to work by swapping

     (or (< (length part) 4)
         (and
          (< (nth 2 part) dfh4)
          (< (nth 3 part) dfh4)))

with

     (and (>= (length part) 4)
          (< (nth 2 part) dfh4)
          (< (nth 3 part) dfh4))

, which did not re-introduce the problem in the minibuffer.

Thank you.