all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#24804: 25.1; posn-at-point erroneously signals an error
@ 2016-10-26 19:43 Andreas Politz
       [not found] ` <handler.24804.B.147751104225420.ack@debbugs.gnu.org>
  2016-10-27 17:35 ` bug#24804: 25.1; posn-at-point erroneously signals an error martin rudalics
  0 siblings, 2 replies; 11+ messages in thread
From: Andreas Politz @ 2016-10-26 19:43 UTC (permalink / raw)
  To: 24804

[-- Attachment #1: Type: text/plain, Size: 587 bytes --]


The documentation of the function posn-at-point states

"Return nil if position is not visible in window.",

but it may also signal an error in this case.  This happens, if
Fpos_visible_in_window_p returns a list of (X Y RTOP RBOT ROWH VPOS)
and at least Y is negative (which indicates, that pos is not visible
IIUC).  The error is then signaled by Fposn_at_x_y, which only accpets
non-negative numbers (neglecting the exceptional case of -1 for X).

I think this function should include a similar test for y, as is already
in place for x, returning nil if it is negative (see below).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: posn_at_point.diff --]
[-- Type: text/x-diff, Size: 686 bytes --]

diff --git a/src/keyboard.c b/src/keyboard.c
index bb411e7..215fcb9 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -10791,9 +10791,10 @@ The `posn-' functions access elements of such lists.  */)
       Lisp_Object x = XCAR (tem);
       Lisp_Object y = XCAR (XCDR (tem));
 
-      /* Point invisible due to hscrolling?  X can be -1 when a
-	 newline in a R2L line overflows into the left fringe.  */
-      if (XINT (x) < -1)
+      /* Point invisible due to hscrolling or vscrolling?  X can be -1
+	 when a newline in a R2L line overflows into the left
+	 fringe.  */
+      if (XINT (x) < -1 || XINT (y) < 0)
 	return Qnil;
       tem = Fposn_at_x_y (x, y, window, Qnil);
     }

[-- Attachment #3: Type: text/plain, Size: 616 bytes --]


--

Reproducing this state may be a little bit tricky, anyway evaluate the
following lines, starting with `emacs -Q'.

(defvar img "foo.png");; The image should be taller then the window
                      ;; it's displayed in.
(setq debug-on-error t)
(find-file img)
(redisplay t)         ;; If in batch mode.
(image-scroll-up 999)
;; The image should be scrolled to the bottom now, while point equals 1.
(posn-at-point (point-max) (selected-window))

--

Note, that this bug may make switching buffers difficult in certain
situations, as was reported here:
https://github.com/politza/pdf-tools/issues/200

-ap

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-10-29 22:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-26 19:43 bug#24804: 25.1; posn-at-point erroneously signals an error Andreas Politz
     [not found] ` <handler.24804.B.147751104225420.ack@debbugs.gnu.org>
2016-10-26 19:49   ` bug#24804: Acknowledgement (25.1; posn-at-point erroneously signals an error) Andreas Politz
2016-10-27 17:35 ` bug#24804: 25.1; posn-at-point erroneously signals an error martin rudalics
2016-10-27 18:26   ` Andreas Politz
2016-10-28  8:12   ` Eli Zaretskii
2016-10-29 10:23     ` Eli Zaretskii
2016-10-29 14:26       ` Andreas Politz
2016-10-29 14:36         ` Eli Zaretskii
2016-10-29 14:42           ` Eli Zaretskii
2016-10-29 20:33             ` Andreas Politz
2016-10-29 22:03               ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.