Subject: Re: bug#50256: thing-at-mouse

From: martin rudalics <[email-masked]>
Date: Thu, 2 Sep 2021 08:48:15 +0200

> Then what is the semantics of the code snippet above, and why did you
 > call with-current-buffer the second time?  What did you want to
 > accomplish, except make a point?

I tried to write a simple example with emacs -Q showing how code breaks
a contract stated in a manual.

 > IOW, what kind of real-life situation needs such a code?

Any call of `pos-visible-in-window-p' might happen within the context of
`with-current-buffer'.  Just check how often these forms are used in the
Emacs code base.

 >> (pos-visible-in-window-p nil nil t) should never return nil as it
 >> does in the above recipe.
 >
 > Why not?

Because in the manual we say that

   "The argument POSITION defaults to the current position
    of point in WINDOW; WINDOW defaults to the selected window."

If the current buffer is not shown in WINDOW, the first part of this
sentence is wrong.

martin