[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/mwheel-no-alts ee2a8fd4cff 1/7: (mouse-wheel-*-event): Minor cle
From: |
Stefan Monnier |
Subject: |
scratch/mwheel-no-alts ee2a8fd4cff 1/7: (mouse-wheel-*-event): Minor cleanups |
Date: |
Fri, 12 Jan 2024 19:07:17 -0500 (EST) |
branch: scratch/mwheel-no-alts
commit ee2a8fd4cff84cd5bd672fdde8ec3e0800f132be
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
(mouse-wheel-*-event): Minor cleanups
* lisp/mwheel.el (mwheel-event-button): Mark as obsolete alias.
Change all callers.
* lisp/edmacro.el (mouse-wheel-*-event): Move declarations to ...
(edmacro-fix-menu-commands): ... where we do know that they should
be defined. Obey `mouse-wheel-*-alternate-event`s as well.
---
lisp/edmacro.el | 20 +++++++++++++-------
lisp/mwheel.el | 18 ++++++------------
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/lisp/edmacro.el b/lisp/edmacro.el
index 362ec0ecbb4..5bd0c1892e5 100644
--- a/lisp/edmacro.el
+++ b/lisp/edmacro.el
@@ -720,17 +720,19 @@ This function assumes that the events can be stored in a
string."
(setf (aref seq i) (logand (aref seq i) 127)))
seq)
-;; These are needed in a --without-x build.
-(defvar mouse-wheel-down-event)
-(defvar mouse-wheel-up-event)
-(defvar mouse-wheel-right-event)
-(defvar mouse-wheel-left-event)
-
(defun edmacro-fix-menu-commands (macro &optional noerror)
(if (vectorp macro)
(let (result)
;; Not preloaded in a --without-x build.
(require 'mwheel)
+ (defvar mouse-wheel-down-event)
+ (defvar mouse-wheel-up-event)
+ (defvar mouse-wheel-right-event)
+ (defvar mouse-wheel-left-event)
+ (defvar mouse-wheel-down-alternate-event)
+ (defvar mouse-wheel-up-alternate-event)
+ (defvar mouse-wheel-right-alternate-event)
+ (defvar mouse-wheel-left-alternate-event)
;; Make a list of the elements.
(setq macro (append macro nil))
(dolist (ev macro)
@@ -748,7 +750,11 @@ This function assumes that the events can be stored in a
string."
(memq (event-basic-type ev)
(list mouse-wheel-down-event mouse-wheel-up-event
mouse-wheel-right-event
- mouse-wheel-left-event)))
+ mouse-wheel-left-event
+ mouse-wheel-down-alternate-event
+ mouse-wheel-up-alternate-event
+ mouse-wheel-right-alternate-event
+ mouse-wheel-left-alternate-event)))
nil)
(noerror nil)
(t
diff --git a/lisp/mwheel.el b/lisp/mwheel.el
index b75b6f27d53..735adf42f68 100644
--- a/lisp/mwheel.el
+++ b/lisp/mwheel.el
@@ -216,15 +216,9 @@ Also see `mouse-wheel-tilt-scroll'."
:type 'boolean
:version "26.1")
-(defun mwheel-event-button (event)
- (let ((x (event-basic-type event)))
- ;; Map mouse-wheel events to appropriate buttons
- (if (eq 'mouse-wheel x)
- (let ((amount (car (cdr (cdr (cdr event))))))
- (if (< amount 0)
- mouse-wheel-up-event
- mouse-wheel-down-event))
- x)))
+;; This function used to handle the `mouse-wheel` event which was
+;; removed in 2003 by commit 9eb28007fb27, thus making it obsolete.
+(define-obsolete-function-alias 'mwheel-event-button #'event-basic-type "30.1")
(defun mwheel-event-window (event)
(posn-window (event-start event)))
@@ -347,7 +341,7 @@ value of ARG, and the command uses it in subsequent
scrolls."
(when (numberp amt) (setq amt (* amt (event-line-count event))))
(condition-case nil
(unwind-protect
- (let ((button (mwheel-event-button event)))
+ (let ((button (event-basic-type event)))
(cond ((and (eq amt 'hscroll) (memq button (list
mouse-wheel-down-event
mouse-wheel-down-alternate-event)))
(when (and (natnump arg) (> arg 0))
@@ -434,7 +428,7 @@ See also `text-scale-adjust'."
(interactive (list last-input-event))
(let ((selected-window (selected-window))
(scroll-window (mouse-wheel--get-scroll-window event))
- (button (mwheel-event-button event)))
+ (button (event-basic-type event)))
(select-window scroll-window 'mark-for-redisplay)
(unwind-protect
(cond ((memq button (list mouse-wheel-down-event
@@ -450,7 +444,7 @@ See also `text-scale-adjust'."
"Increase or decrease the global font size according to the EVENT.
This invokes `global-text-scale-adjust', which see."
(interactive (list last-input-event))
- (let ((button (mwheel-event-button event)))
+ (let ((button (event-basic-type event)))
(cond ((memq button (list mouse-wheel-down-event
mouse-wheel-down-alternate-event))
(global-text-scale-adjust 1))
- branch scratch/mwheel-no-alts created (now f355557bb9e), Stefan Monnier, 2024/01/12
- scratch/mwheel-no-alts ee2a8fd4cff 1/7: (mouse-wheel-*-event): Minor cleanups,
Stefan Monnier <=
- scratch/mwheel-no-alts b9959e94d26 4/7: * lisp/completion-preview.el: Fix use in non-GUI session, Stefan Monnier, 2024/01/12
- scratch/mwheel-no-alts 8cb8b973653 6/7: mwheel.el: Remove `mouse-wheel-*-alternate-event` vars, Stefan Monnier, 2024/01/12
- scratch/mwheel-no-alts b0f04ce4d34 5/7: mwheel.el: Unconditionally use the `wheel-up/down/...` events, Stefan Monnier, 2024/01/12
- scratch/mwheel-no-alts a764b503e12 2/7: (mwheel--is-dir-p): New macro to reduce code duplication, Stefan Monnier, 2024/01/12
- scratch/mwheel-no-alts f355557bb9e 7/7: mwheel.el: Code clean to reduce duplication, Stefan Monnier, 2024/01/12
- scratch/mwheel-no-alts 3bd8e963f7c 3/7: * lisp/keymap.el (define-keymap): Demote "duplicate def" to a warning, Stefan Monnier, 2024/01/12