Subject: bug#23809: 24.5; Positive argument to 'posn-at-point' throws erros as being negative

From: martin rudalics <[email-masked]>
Date: Tue, 21 Jun 2016 15:07:57 +0200

> Sounds like a duplicate of bug #21732.
 >
 >> With these steps, I get this backtrace:
 >>
 >>    Debugger entered--Lisp error: (wrong-type-argument wholenump -14)
 >>      posn-at-point(619194 #)

Without further forensics we could "fix" both bugs using the attached
patch.  WDYT?

martin
diff --git a/lisp/window.el b/lisp/window.el
index f7a547b..a06f334 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2068,7 +2068,9 @@ window-in-direction
 	    (if hor
 		(window-pixel-top window)
 	      (window-pixel-left window)))
-	   ((let ((posn-cons (nth 2 (posn-at-point (window-point window) window))))
+	   ((let ((posn-cons (condition-case nil
+                                 (nth 2 (posn-at-point (window-point window) window))
+                               (error nil))))
 	      (if hor
 		  (+ (or (cdr posn-cons) 1) (window-pixel-top window))
 		(+ (or (car posn-cons) 1) (window-pixel-left window)))))))