Subject: bug#57349: 29.0.50; pixel-scroll-precision-mode. error integer-or-marker-p nil

From: Gerd Möllmann <[email-masked]>
Date: Tue, 23 Aug 2022 08:12:54 +0200

In GNU Emacs 29.0.50 (build 1, aarch64-apple-darwin21.6.0, NS
 appkit-2113.60 Version 12.5.1 (Build 21G83)) of 2022-08-22 built on
 Mini.fritz.box
Repository revision: 0c410206aa91b9bc9a0922d63ec34de765eb86a6
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2113
System Description:  macOS 12.5.1

emacs -Q
M-x pixel-scroll-precision-mode RET

Move the mouse to the lower right corner of the Emacs frame.  On macOS,
the mouse cursor changes shape to a double-arrow pointing 45 degrees in
the direction of the upper-left and lower-right corner of the screen.

Scroll the mouse wheel.

This either prints messages like this

<nil> <wheel-up> is undefined
<nil> <double-wheel-up> is undefined
<nil> <triple-wheel-up> is undefined [45 times]
<nil> <wheel-down> is undefined

or sometimes errors 'Wrong type argument: integer-or-marker-p, nil'.
Not sure what to make of this.  Looks like posn-at-x-y returns a posn
with a nil point?  Or maybe posn-point returns nil?

Backtrace of the error:

  goto-char(nil)
  (save-excursion (goto-char point) (vertical-motion (- (1+ scroll-margin))) (point))
  (let* ((edges (window-edges nil t nil t)) (max-y (- (nth 3 edges) (nth 1 edges))) (usable-height max-y) (posn (posn-at-x-y 0 (+ (window-tab-line-height) (window-header-line-height) (- max-y delta)))) (point (posn-point posn)) (up-point (save-excursion (goto-char point) (vertical-motion (- (1+ scroll-margin))) (point)))) (if (> (point) up-point) (progn (if (let ((pos-visible (pos-visible-in-window-p up-point nil t))) (or (eq (length pos-visible) 2) (let* (... ... ...) (if usable-height ...)))) (progn (goto-char up-point))))) (let ((current-vscroll (window-vscroll nil t))) (setq delta (- delta current-vscroll)) (set-window-vscroll nil 0 t t) (if (> delta 0) (progn (let* ((start (window-start)) (dims (window-text-pixel-size nil ... start nil nil nil t)) (height (nth 1 dims)) (position (nth 2 dims))) (set-window-start nil position t) (if (> height usable-height) (progn (goto-char position))) (if (or (not position) (eq position start)) (progn (signal ... nil))) (setq delta (- delta height))))) (if (< delta 0) (progn (set-window-vscroll nil (- delta) t t)))))
  pixel-scroll-precision-scroll-up-page(0)
  (while (> delta max-height) (pixel-scroll-precision-scroll-up-page max-height) (setq delta (- delta max-height)))
  (let ((max-height (- (window-text-height nil t) (frame-char-height)))) (while (> delta max-height) (pixel-scroll-precision-scroll-up-page max-height) (setq delta (- delta max-height))) (pixel-scroll-precision-scroll-up-page delta))
  pixel-scroll-precision-scroll-up(1)
  (if (< delta 0) (pixel-scroll-precision-scroll-down (- delta)) (pixel-scroll-precision-scroll-up delta))
  (progn (if (< delta 0) (pixel-scroll-precision-scroll-down (- delta)) (pixel-scroll-precision-scroll-up delta)) (pixel-scroll-accumulate-velocity delta))
  (condition-case nil (progn (if (< delta 0) (pixel-scroll-precision-scroll-down (- delta)) (pixel-scroll-precision-scroll-up delta)) (pixel-scroll-accumulate-velocity delta)) (beginning-of-buffer (message (error-message-string '(beginning-of-buffer)))) (end-of-buffer (message (error-message-string '(end-of-buffer)))))
  (if (or (and pixel-scroll-precision-interpolate-mice (eq (device-class last-event-frame last-event-device) 'mouse)) (and pixel-scroll-precision-large-scroll-height (> (abs delta) pixel-scroll-precision-large-scroll-height) (let* ((kin-state (pixel-scroll-kinetic-state)) (ring (aref kin-state 0)) (time (aref kin-state 1))) (or (null time) (> (- (float-time) time) 1.0) (and (consp ring) (ring-empty-p ring)))))) (progn (let ((kin-state (pixel-scroll-kinetic-state))) (aset kin-state 0 (make-ring 30)) (aset kin-state 1 nil)) (pixel-scroll-precision-interpolate delta current-window)) (condition-case nil (progn (if (< delta 0) (pixel-scroll-precision-scroll-down (- delta)) (pixel-scroll-precision-scroll-up delta)) (pixel-scroll-accumulate-velocity delta)) (beginning-of-buffer (message (error-message-string '(beginning-of-buffer)))) (end-of-buffer (message (error-message-string '(end-of-buffer))))))
  (progn (select-window (car save-selected-window--state) 'norecord) (if (or (and pixel-scroll-precision-interpolate-mice (eq (device-class last-event-frame last-event-device) 'mouse)) (and pixel-scroll-precision-large-scroll-height (> (abs delta) pixel-scroll-precision-large-scroll-height) (let* ((kin-state (pixel-scroll-kinetic-state)) (ring (aref kin-state 0)) (time (aref kin-state 1))) (or (null time) (> (- ... time) 1.0) (and (consp ring) (ring-empty-p ring)))))) (progn (let ((kin-state (pixel-scroll-kinetic-state))) (aset kin-state 0 (make-ring 30)) (aset kin-state 1 nil)) (pixel-scroll-precision-interpolate delta current-window)) (condition-case nil (progn (if (< delta 0) (pixel-scroll-precision-scroll-down (- delta)) (pixel-scroll-precision-scroll-up delta)) (pixel-scroll-accumulate-velocity delta)) (beginning-of-buffer (message (error-message-string '(beginning-of-buffer)))) (end-of-buffer (message (error-message-string '(end-of-buffer)))))))
  (unwind-protect (progn (select-window (car save-selected-window--state) 'norecord) (if (or (and pixel-scroll-precision-interpolate-mice (eq (device-class last-event-frame last-event-device) 'mouse)) (and pixel-scroll-precision-large-scroll-height (> (abs delta) pixel-scroll-precision-large-scroll-height) (let* ((kin-state ...) (ring ...) (time ...)) (or (null time) (> ... 1.0) (and ... ...))))) (progn (let ((kin-state (pixel-scroll-kinetic-state))) (aset kin-state 0 (make-ring 30)) (aset kin-state 1 nil)) (pixel-scroll-precision-interpolate delta current-window)) (condition-case nil (progn (if (< delta 0) (pixel-scroll-precision-scroll-down (- delta)) (pixel-scroll-precision-scroll-up delta)) (pixel-scroll-accumulate-velocity delta)) (beginning-of-buffer (message (error-message-string '...))) (end-of-buffer (message (error-message-string '...)))))) (internal--after-with-selected-window save-selected-window--state))
  (save-current-buffer (unwind-protect (progn (select-window (car save-selected-window--state) 'norecord) (if (or (and pixel-scroll-precision-interpolate-mice (eq (device-class last-event-frame last-event-device) 'mouse)) (and pixel-scroll-precision-large-scroll-height (> (abs delta) pixel-scroll-precision-large-scroll-height) (let* (... ... ...) (or ... ... ...)))) (progn (let ((kin-state ...)) (aset kin-state 0 (make-ring 30)) (aset kin-state 1 nil)) (pixel-scroll-precision-interpolate delta current-window)) (condition-case nil (progn (if (< delta 0) (pixel-scroll-precision-scroll-down ...) (pixel-scroll-precision-scroll-up delta)) (pixel-scroll-accumulate-velocity delta)) (beginning-of-buffer (message (error-message-string ...))) (end-of-buffer (message (error-message-string ...)))))) (internal--after-with-selected-window save-selected-window--state)))
  (let ((save-selected-window--state (internal--before-with-selected-window window))) (save-current-buffer (unwind-protect (progn (select-window (car save-selected-window--state) 'norecord) (if (or (and pixel-scroll-precision-interpolate-mice (eq ... ...)) (and pixel-scroll-precision-large-scroll-height (> ... pixel-scroll-precision-large-scroll-height) (let* ... ...))) (progn (let (...) (aset kin-state 0 ...) (aset kin-state 1 nil)) (pixel-scroll-precision-interpolate delta current-window)) (condition-case nil (progn (if ... ... ...) (pixel-scroll-accumulate-velocity delta)) (beginning-of-buffer (message ...)) (end-of-buffer (message ...))))) (internal--after-with-selected-window save-selected-window--state))))
  (if (> (abs delta) (window-text-height window t)) (mwheel-scroll event nil) (let ((save-selected-window--state (internal--before-with-selected-window window))) (save-current-buffer (unwind-protect (progn (select-window (car save-selected-window--state) 'norecord) (if (or (and pixel-scroll-precision-interpolate-mice ...) (and pixel-scroll-precision-large-scroll-height ... ...)) (progn (let ... ... ...) (pixel-scroll-precision-interpolate delta current-window)) (condition-case nil (progn ... ...) (beginning-of-buffer ...) (end-of-buffer ...)))) (internal--after-with-selected-window save-selected-window--state)))))
  (if (= 0 delta) nil (if (> (abs delta) (window-text-height window t)) (mwheel-scroll event nil) (let ((save-selected-window--state (internal--before-with-selected-window window))) (save-current-buffer (unwind-protect (progn (select-window (car save-selected-window--state) 'norecord) (if (or ... ...) (progn ... ...) (condition-case nil ... ... ...))) (internal--after-with-selected-window save-selected-window--state))))))
  (let ((delta (round (cdr (nth 4 event))))) (if (= 0 delta) nil (if (> (abs delta) (window-text-height window t)) (mwheel-scroll event nil) (let ((save-selected-window--state (internal--before-with-selected-window window))) (save-current-buffer (unwind-protect (progn (select-window ... ...) (if ... ... ...)) (internal--after-with-selected-window save-selected-window--state)))))))
  (if (and (nth 4 event)) (let ((delta (round (cdr (nth 4 event))))) (if (= 0 delta) nil (if (> (abs delta) (window-text-height window t)) (mwheel-scroll event nil) (let ((save-selected-window--state (internal--before-with-selected-window window))) (save-current-buffer (unwind-protect (progn ... ...) (internal--after-with-selected-window save-selected-window--state))))))) (mwheel-scroll event nil))
  (let ((window (mwheel-event-window event)) (current-window (selected-window))) (if (framep window) (progn (setq window (frame-selected-window window)))) (if (and (nth 4 event)) (let ((delta (round (cdr (nth 4 event))))) (if (= 0 delta) nil (if (> (abs delta) (window-text-height window t)) (mwheel-scroll event nil) (let ((save-selected-window--state ...)) (save-current-buffer (unwind-protect ... ...)))))) (mwheel-scroll event nil)))
  pixel-scroll-precision((wheel-up (#<window 4 on  *Minibuf-0*> right-fringe (865 . 6) 129226600 nil 1 (0 . 0) nil (11 . 6) (0 . 14)) 1 0 (0.0 . 1.0)))
  funcall-interactively(pixel-scroll-precision (wheel-up (#<window 4 on  *Minibuf-0*> right-fringe (865 . 6) 129226600 nil 1 (0 . 0) nil (11 . 6) (0 . 14)) 1 0 (0.0 . 1.0)))
  command-execute(pixel-scroll-precision)