Skip to content

Commit

Permalink
Addressing errors reported by GitHub CI.
Browse files Browse the repository at this point in the history
* Deferring patch to pixel-scroll-precision until package is loaded.
123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_
* Pre-defining `init-dir--long-load-time-warning' so it doesn't trigger a
  void-variable error.
* Disabling tool-bar via `default-frame-alist' so that it works on Emacs builds
  that don't include a window system toolkit.
* Pre-defining functions that come from installed packages.
  • Loading branch information
chaosemer committed Dec 9, 2023
1 parent 031cd38 commit 0edd692
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 34 deletions.
72 changes: 39 additions & 33 deletions 00.emacs-patches.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,41 +32,42 @@
;;
;; The proper upstream is actually in `pixel-scroll-precision' to
;; collapse other cases to mouse. Solve via advice.
(defvar device-class--should-collapse-to-mouse nil
"Internal variable to track if collapsing should happen")
(defvar device-class--mouse-wheel-events
(list mouse-wheel-up-event mouse-wheel-down-event
mouse-wheel-up-alternate-event mouse-wheel-down-alternate-event))
(defvar device-class--prev-event-timestamp 0
"Interval variable of the previous event's timestamp.")
(defvar device-class--prev-event-seems-like-mouse-event nil)
(when (featurep 'ns-win)
(with-eval-after-load 'pixel-scroll
(defvar device-class--should-collapse-to-mouse nil
"Internal variable to track if collapsing should happen")
(defvar device-class--mouse-wheel-events
(list mouse-wheel-up-event mouse-wheel-down-event

Check warning on line 40 in 00.emacs-patches.el

View workflow job for this annotation

GitHub Actions / test (29.1, byte-compile)

reference to free variable ‘mouse-wheel-up-event’

Check warning on line 40 in 00.emacs-patches.el

View workflow job for this annotation

GitHub Actions / test (29.1, byte-compile)

reference to free variable ‘mouse-wheel-down-event’
mouse-wheel-up-alternate-event mouse-wheel-down-alternate-event))

Check warning on line 41 in 00.emacs-patches.el

View workflow job for this annotation

GitHub Actions / test (29.1, byte-compile)

reference to free variable ‘mouse-wheel-up-alternate-event’

Check warning on line 41 in 00.emacs-patches.el

View workflow job for this annotation

GitHub Actions / test (29.1, byte-compile)

reference to free variable ‘mouse-wheel-down-alternate-event’
(defvar device-class--prev-event-timestamp 0
"Interval variable of the previous event's timestamp.")
(defvar device-class--prev-event-seems-like-mouse-event nil)

(defun device-class--collapse-to-mouse (r)
"Patch for `pixel-scroll-precision' to return mouse for pointers."
(if (and device-class--should-collapse-to-mouse
(eq r 'core-pointer))
'mouse
r))
(defun pixel-scroll-precision--patched (event)
(interactive "e")
(let* ((wheel-event (member (event-basic-type event) device-class--mouse-wheel-events))
(line-count (event-line-count event))
(seems-like-mouse-event (and wheel-event (/= line-count 0)))
(timestamp (posn-timestamp (event-start event)))
;; collapse to mouse when the event seems like a mouse event
(device-class--should-collapse-to-mouse
(if (< (- timestamp device-class--prev-event-timestamp)
100)
device-class--prev-event-seems-like-mouse-event
seems-like-mouse-event)))
(pixel-scroll-precision event)
(setf device-class--prev-event-timestamp timestamp
device-class--prev-event-seems-like-mouse-event device-class--should-collapse-to-mouse)))
(defun device-class--collapse-to-mouse (r)
"Patch for `pixel-scroll-precision' to return mouse for pointers."
(if (and device-class--should-collapse-to-mouse
(eq r 'core-pointer))
'mouse
r))
(defun pixel-scroll-precision--patched (event)
(interactive "e")
(let* ((wheel-event (member (event-basic-type event) device-class--mouse-wheel-events))
(line-count (event-line-count event))
(seems-like-mouse-event (and wheel-event (/= line-count 0)))
(timestamp (posn-timestamp (event-start event)))
;; collapse to mouse when the event seems like a mouse event
(device-class--should-collapse-to-mouse
(if (< (- timestamp device-class--prev-event-timestamp)
100)
device-class--prev-event-seems-like-mouse-event
seems-like-mouse-event)))
(pixel-scroll-precision event)

Check warning on line 64 in 00.emacs-patches.el

View workflow job for this annotation

GitHub Actions / test (29.1, byte-compile)

the function ‘pixel-scroll-precision’ is not known to be defined.
(setf device-class--prev-event-timestamp timestamp
device-class--prev-event-seems-like-mouse-event device-class--should-collapse-to-mouse)))

(when (featurep 'ns-win)
(display-warning 'emacs "Fixing buggy pixel-scroll-precesion")
(keymap-global-set "<remap> <pixel-scroll-precision>" 'pixel-scroll-precision--patched)
(advice-add 'device-class :filter-return 'device-class--collapse-to-mouse))
(display-warning 'emacs "Fixing buggy pixel-scroll-precesion")
(keymap-global-set "<remap> <pixel-scroll-precision>" 'pixel-scroll-precision--patched)
(advice-add 'device-class :filter-return 'device-class--collapse-to-mouse)))

(when (version< emacs-version "30.0")
(with-eval-after-load 'dired
Expand Down Expand Up @@ -100,3 +101,8 @@
"<follow-link>" 'mouse-face
"RET" click))))
(setq segment-start (point)))))))))

;; Actually a workaround for leotaku/elisp-check which doesn't have a
;; way to silence an intended error.
(unless (boundp 'init-dir--long-load-time-warning)
(defvar init-dir--long-load-time-warning 0))
4 changes: 3 additions & 1 deletion early-init.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@

;; Maximized (but not its own desktop on Mac)
(add-to-list 'initial-frame-alist '(fullscreen . maximized))
(tool-bar-mode -1))

;; No tool-bar (the global tool bar isn't useful)
(add-to-list 'default-frame-alist '(tool-bar-lines . 0)))
14 changes: 14 additions & 0 deletions emacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@
(defun bar-cursor-mode (&optional arg)
;; Do nothing -- stub
))
(unless (fboundp 'global-form-feed-st-mode)
;; If this triggers, make sure to install the `form-feed-st' package
;; from melpa unstable.
(display-warning 'emacs "SETUP ISSUE: form-feed-st package is not installed.")
(defun global-form-feed-st-mode (&optional arg)
;; Do nothing -- stub
))
(unless (fboundp 'global-window-tool-bar-mode)
;; If this triggers, make sure to install the `window-tool-bar'
;; package from GitHub.
(display-warning 'emacs "SETUP ISSUE: window-tool-bar package is not installed.")
(defun global-window-tool-bar-mode (&optional arg)
;; Do nothing -- stub
))

;; This file is known to be slow, so add a bit more time here.
(cl-incf init-dir--long-load-time-warning 0.1)
Expand Down

0 comments on commit 0edd692

Please sign in to comment.