GNU bug report logs - #47162
Mouse Wheel Won't Work When Emacs Built without Any Window System

Previous Next

Package: emacs;

Reported by: 张强 <johnson9009 <at> 163.com>

Date: Mon, 15 Mar 2021 15:32:02 UTC

Severity: normal

Tags: fixed

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 47162 in the body.
You can then email your comments to 47162 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Mon, 15 Mar 2021 15:32:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 张强 <johnson9009 <at> 163.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 15 Mar 2021 15:32:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 张强 <johnson9009 <at> 163.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Mouse Wheel Won't Work When Emacs Built without Any Window System
Date: Mon, 15 Mar 2021 22:44:04 +0800 (CST)
[Message part 1 (text/plain, inline)]
Dear All,


I found the mouse wheel can't work when I build emacs without any window system, after some investigation I found below code snippet in file "lisp/loadup.el".


(if (fboundp 'x-create-frame)
    ;; Do it after loading term/foo-win.el since the value of the
    ;; mouse-wheel-*-event vars depends on those files being loaded or not.
    (load "mwheel"))


It is strange to me, because the mouse click work well no matter left/right mouse click or double click, but the mouse wheel will not, from comments in above code snippet, it seems the package "mwheel" need to be loaded after "xxx-win.el" for the initialization of variables "mouse-wheel-*-event".
After add below code snippet to my emacs configuration file, I found the package "mwheel" can work well when the emacs built without any window system.


  (load "mwheel")
  (mouse-wheel-mode t)


so I want to know whether the package "mwheel" should be loaded without precondition?
The window system is useless for me, and most of the time the lib needed by window system is not available, so I want to build emacs with configuration options like "--without-x / --without-ns" to reduce the dependent libraries as more as possible. But mouse wheel is important to me, it is very useful especially I discuss problem with my colleagues and they want scroll my emacs screen temporarily.




Thanks.




--

Best Regards,

Qiang Zhang


[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Thu, 18 Mar 2021 05:24:02 GMT) Full text and rfc822 format available.

Message #8 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: 张强 <johnson9009 <at> 163.com>
Cc: 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Thu, 18 Mar 2021 06:23:39 +0100
张强 <johnson9009 <at> 163.com> writes:

> It is strange to me, because the mouse click work well no matter
> left/right mouse click or double click, but the mouse wheel will not,
> from comments in above code snippet, it seems the package "mwheel"
> need to be loaded after "xxx-win.el" for the initialization of
> variables "mouse-wheel-*-event".  After add below code snippet to my
> emacs configuration file, I found the package "mwheel" can work well
> when the emacs built without any window system.
>
>    (load "mwheel")
>    (mouse-wheel-mode t)
>
> so I want to know whether the package "mwheel" should be loaded without
> precondition?

I'm not sure that preloading the mwheel package in non-window builds is
optimal (I think a minority of users use mwheel in non-window builds).
But the mode should be autoloaded, at least, so that you don't have to
say (load "mwheel") to use it.

I've now made this change in Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 18 Mar 2021 05:24:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 47162 <at> debbugs.gnu.org and 张强 <johnson9009 <at> 163.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 18 Mar 2021 05:24:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 15 Apr 2021 11:24:10 GMT) Full text and rfc822 format available.

bug unarchived. Request was from "Basil L. Contovounesios" <contovob <at> tcd.ie> to control <at> debbugs.gnu.org. (Fri, 30 Jul 2021 08:25:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Fri, 30 Jul 2021 08:33:01 GMT) Full text and rfc822 format available.

Message #19 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 张强 <johnson9009 <at> 163.com>, 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Fri, 30 Jul 2021 09:32:22 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> 张强 <johnson9009 <at> 163.com> writes:
>
>> It is strange to me, because the mouse click work well no matter
>> left/right mouse click or double click, but the mouse wheel will not,
>> from comments in above code snippet, it seems the package "mwheel"
>> need to be loaded after "xxx-win.el" for the initialization of
>> variables "mouse-wheel-*-event".  After add below code snippet to my
>> emacs configuration file, I found the package "mwheel" can work well
>> when the emacs built without any window system.
>>
>>    (load "mwheel")
>>    (mouse-wheel-mode t)
>>
>> so I want to know whether the package "mwheel" should be loaded without
>> precondition?
>
> I'm not sure that preloading the mwheel package in non-window builds is
> optimal (I think a minority of users use mwheel in non-window builds).
> But the mode should be autoloaded, at least, so that you don't have to
> say (load "mwheel") to use it.
>
> I've now made this change in Emacs 28.

FYI, as a result of this change mwheel is now effectively preloaded even
--without-x, in the sense that (featurep 'mwheel) returns non-nil even
when starting nox builds with -Q (see my signature for details).

Bother or feature?

Thanks,

-- 
Basil

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu)
 of 2021-07-30 built on tia
Repository revision: 5fb8b20fa35a931660d9d59afc9ca863dd33a123
Repository branch: master
System Description: Debian GNU/Linux 11 (bullseye)

Configured using:
 'configure 'CC=ccache gcc' 'CFLAGS=-O2 -march=native' --config-cache
 --prefix=/home/blc/.local --program-suffix=-nox
 --enable-checking=structs --with-file-notification=yes
 --with-x-toolkit=no --without-x'

Configured features:
ACL DBUS GMP GNUTLS GPM JSON LCMS2 LIBSELINUX LIBSYSTEMD LIBXML2 MODULES
NOTIFY INOTIFY PDUMPER SECCOMP SOUND THREADS XIM ZLIB

Important settings:
  value of $LANG: en_IE.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  mouse-wheel-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail tool-bar
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils term/xterm xterm byte-opt gv
bytecomp byte-compile cconv regexp-opt mwheel iso-transl tooltip eldoc
                                       ^^^^^^
electric uniquify ediff-hook vc-hooks lisp-float-type tabulated-list
replace newcomment text-mode elisp-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select mouse
jit-lock font-lock syntax font-core term/tty-colors frame minibuffer
cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese composite
charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev
obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote threads
dbusbind inotify lcms2 multi-tty make-network-process emacs)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Fri, 30 Jul 2021 10:59:02 GMT) Full text and rfc822 format available.

Message #22 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: larsi <at> gnus.org, johnson9009 <at> 163.com, 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Fri, 30 Jul 2021 13:57:46 +0300
> Cc: 张强 <johnson9009 <at> 163.com>, 47162 <at> debbugs.gnu.org
> Date: Fri, 30 Jul 2021 09:32:22 +0100
> From:  "Basil L. Contovounesios" via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> > I've now made this change in Emacs 28.
> 
> FYI, as a result of this change mwheel is now effectively preloaded even
> --without-x, in the sense that (featurep 'mwheel) returns non-nil even
> when starting nox builds with -Q (see my signature for details).
> 
> Bother or feature?

It's probably a bother, but could you please show the details, like
what causes mwheel to be loaded at startup or at loadup time in the
"--without-x" builds?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Fri, 30 Jul 2021 11:00:02 GMT) Full text and rfc822 format available.

Message #25 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 张强 <johnson9009 <at> 163.com>, 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Fri, 30 Jul 2021 12:59:31 +0200
"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:

> FYI, as a result of this change mwheel is now effectively preloaded even
> --without-x, in the sense that (featurep 'mwheel) returns non-nil even
> when starting nox builds with -Q (see my signature for details).
>
> Bother or feature?

Sounds like a bug -- I don't understand how adding an ;;;###autoload to
a function would lead to Emacs being pre-built with the .el file the
function exists in.  Unless there's something checking for that function
during the build and then loading mwheel?  Didn't see anything like that
in loadup.el...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Fri, 30 Jul 2021 15:55:01 GMT) Full text and rfc822 format available.

Message #28 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, johnson9009 <at> 163.com, 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Fri, 30 Jul 2021 16:53:55 +0100
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Cc: 张强 <johnson9009 <at> 163.com>, 47162 <at> debbugs.gnu.org
>> Date: Fri, 30 Jul 2021 09:32:22 +0100
>> From:  "Basil L. Contovounesios" via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> 
>> > I've now made this change in Emacs 28.
>> 
>> FYI, as a result of this change mwheel is now effectively preloaded even
>> --without-x, in the sense that (featurep 'mwheel) returns non-nil even
>> when starting nox builds with -Q (see my signature for details).
>> 
>> Bother or feature?
>
> It's probably a bother, but could you please show the details, like
> what causes mwheel to be loaded at startup or at loadup time in the
> "--without-x" builds?

I built Emacs before and after commit 0aad4d134f, and attach the
resulting configurations as well as their diff.  Note that some other
libraries such as pp are also being loaded in the latter configuration.

After the autoload, I get the attached GDB backtrace with the following:

0. gdb ./emacs
1. set logging file gdb-after.txt
2. set logging on
3. b lread.c:1215 if !strncmp (SDATA (file), "mwheel", 6)
4. r -Q
5. bt

So it seems to be the reevaluation of custom-delayed-init-variables in
command-line that is loading mwheel at startup.

-- 
Basil

[configuration-before.txt (text/plain, attachment)]
[configuration-after.txt (text/plain, attachment)]
[configuration.diff (text/x-diff, attachment)]
[gdb-after.txt (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Fri, 30 Jul 2021 15:55:02 GMT) Full text and rfc822 format available.

Message #31 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 张强 <johnson9009 <at> 163.com>, 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Fri, 30 Jul 2021 16:54:04 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> "Basil L. Contovounesios" <contovob <at> tcd.ie> writes:
>
>> FYI, as a result of this change mwheel is now effectively preloaded even
>> --without-x, in the sense that (featurep 'mwheel) returns non-nil even
>> when starting nox builds with -Q (see my signature for details).
>>
>> Bother or feature?
>
> Sounds like a bug -- I don't understand how adding an ;;;###autoload to
> a function would lead to Emacs being pre-built with the .el file the
> function exists in.  Unless there's something checking for that function
> during the build and then loading mwheel?  Didn't see anything like that
> in loadup.el...

My guess is the salient difference lies in lisp/loaddefs.el, where
autoload cookie results in the following additions:

--8<---------------cut here---------------start------------->8---
(defcustom mouse-wheel-mode t "\
Non-nil if Mouse-Wheel mode is enabled.
See the `mouse-wheel-mode' command
for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `mouse-wheel-mode'." :set #'custom-set-minor-mode :initialize 'custom-initialize-delay :group 'mouse :type 'boolean)

(custom-autoload 'mouse-wheel-mode "mwheel" nil)

(autoload 'mouse-wheel-mode "mwheel" "\
Toggle mouse wheel support (Mouse Wheel mode).

If called interactively, toggle `Mouse-Wheel mode'.  If the prefix
argument is positive, enable the mode, and if it is zero or negative,
disable the mode.

If called from Lisp, toggle the mode if ARG is `toggle'.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

The mode's hook is called both when the mode is enabled and when it is
disabled.

\(fn &optional ARG)" t nil)
--8<---------------cut here---------------end--------------->8---

BTW, another way to tell that mwheel is now being loaded is that the
following warnings disappear following the autoload in nox builds:

--8<---------------cut here---------------start------------->8---
In edmacro-fix-menu-commands:
edmacro.el:625:34: Warning: reference to free variable
    ‘mouse-wheel-down-event’
edmacro.el:625:57: Warning: reference to free variable ‘mouse-wheel-up-event’
edmacro.el:626:34: Warning: reference to free variable
    ‘mouse-wheel-right-event’
edmacro.el:627:34: Warning: reference to free variable
    ‘mouse-wheel-left-event’
--8<---------------cut here---------------end--------------->8---

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Fri, 30 Jul 2021 16:03:01 GMT) Full text and rfc822 format available.

Message #34 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 张强 <johnson9009 <at> 163.com>, 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Fri, 30 Jul 2021 18:02:14 +0200
"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:

> My guess is the salient difference lies in lisp/loaddefs.el, where
> autoload cookie results in the following additions:

[...]

> or call the function `mouse-wheel-mode'." :set #'custom-set-minor-mode :initialize 'custom-initialize-delay :group 'mouse :type 'boolean)

Aaah.  So we basically have the same problem with any define-minor-mode
that has a custom-initialize-delay thing?

But we only have that here because we expect that Emacs is dumped with
mwheel...  So we could guard that :initialize with a (fboundp
'x-create-frame)?  Would that work, I wonder?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Fri, 30 Jul 2021 16:31:01 GMT) Full text and rfc822 format available.

Message #37 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 张强 <johnson9009 <at> 163.com>, 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Fri, 30 Jul 2021 18:30:36 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> But we only have that here because we expect that Emacs is dumped with
> mwheel...  So we could guard that :initialize with a (fboundp
> 'x-create-frame)?  Would that work, I wonder?

I tried removing the :intialize, and that made Emacs not load mweel.el.
But the :initialize parameter isn't evaluated, which makes it more
tricky to use conditionally...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Sat, 31 Jul 2021 13:17:02 GMT) Full text and rfc822 format available.

Message #40 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: contovob <at> tcd.ie, johnson9009 <at> 163.com, 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Sat, 31 Jul 2021 16:15:46 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Fri, 30 Jul 2021 18:02:14 +0200
> Cc: 张强 <johnson9009 <at> 163.com>, 47162 <at> debbugs.gnu.org
> 
> "Basil L. Contovounesios" <contovob <at> tcd.ie> writes:
> 
> > My guess is the salient difference lies in lisp/loaddefs.el, where
> > autoload cookie results in the following additions:
> 
> [...]
> 
> > or call the function `mouse-wheel-mode'." :set #'custom-set-minor-mode :initialize 'custom-initialize-delay :group 'mouse :type 'boolean)
> 
> Aaah.  So we basically have the same problem with any define-minor-mode
> that has a custom-initialize-delay thing?

Yes, and I think Stefan always maintained that minor modes should not
be autoloaded.

> But we only have that here because we expect that Emacs is dumped with
> mwheel...

We do?  I'm afraid I lost you here, because we don't dump mwheel in
builds --without-x, AFAIK.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Sat, 31 Jul 2021 14:15:01 GMT) Full text and rfc822 format available.

Message #43 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: contovob <at> tcd.ie, 47162 <at> debbugs.gnu.org,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, johnson9009 <at> 163.com
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Sat, 31 Jul 2021 16:14:31 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Aaah.  So we basically have the same problem with any define-minor-mode
>> that has a custom-initialize-delay thing?
>
> Yes, and I think Stefan always maintained that minor modes should not
> be autoloaded.

114 matches for "This is a minor mode" in buffer: loaddefs.el<trunk>

So if that's not something we shouldn't do, we've got a lot of splaining
to do.

>> But we only have that here because we expect that Emacs is dumped with
>> mwheel...
>
> We do?  I'm afraid I lost you here, because we don't dump mwheel in
> builds --without-x, AFAIK.

This bit:

  ;; We'd like to use custom-initialize-set here so the setup is done
  ;; before dumping, but at the point where the defcustom is evaluated,
  ;; the corresponding function isn't defined yet, so
  ;; custom-initialize-set signals an error.
  :initialize 'custom-initialize-delay

It's there because we (in some configurations) dump Emacs with mwheel.
But it causes problems when we're not dumping it.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Sat, 31 Jul 2021 14:25:02 GMT) Full text and rfc822 format available.

Message #46 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: contovob <at> tcd.ie, 47162 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca,
 johnson9009 <at> 163.com
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Sat, 31 Jul 2021 17:24:34 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>,  contovob <at> tcd.ie,
>   johnson9009 <at> 163.com,  47162 <at> debbugs.gnu.org
> Date: Sat, 31 Jul 2021 16:14:31 +0200
> 
>   ;; We'd like to use custom-initialize-set here so the setup is done
>   ;; before dumping, but at the point where the defcustom is evaluated,
>   ;; the corresponding function isn't defined yet, so
>   ;; custom-initialize-set signals an error.
>   :initialize 'custom-initialize-delay
> 
> It's there because we (in some configurations) dump Emacs with mwheel.
> But it causes problems when we're not dumping it.

Why does this need to be done via custom-initialize-delay?  Why can't
we simply call the necessary code at startup, explicitly, when mwheel
is available?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Sat, 31 Jul 2021 17:11:02 GMT) Full text and rfc822 format available.

Message #49 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: contovob <at> tcd.ie, Lars Ingebrigtsen <larsi <at> gnus.org>, johnson9009 <at> 163.com,
 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Sat, 31 Jul 2021 13:10:10 -0400
> Why does this need to be done via custom-initialize-delay?

Indeed, using `custom-initialize-delay` causes the setup to be performed
at run-time whereas it could/should be done when loading the file, I think.

> Why can't we simply call the necessary code at startup,

Actually even earlier.
Maybe a patch like the one below is a better approach?


        Stefan


diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index 3a00fdb454..762a97ae33 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -294,20 +294,8 @@ define-minor-mode
                         (internal--format-docstring-line
                          "Use the command `%s' to change this variable." mode)))))
          (t
-	  (let ((base-doc-string
-                 (concat "Non-nil if %s is enabled.
-See the `%s' command
-for a description of this minor mode."
-                         (if body "
-Setting this variable directly does not take effect;
-either customize it (see the info node `Easy Customization')
-or call the function `%s'."))))
-	    `(defcustom ,mode ,init-value
-	       ,(format base-doc-string pretty-name mode mode)
-	       ,@set
-	       ,@initialize
-	       ,@type
-               ,@(nreverse extra-keywords)))))
+	  ;; The actual var definition comes after the function.
+	  `(progn :autoload-end (defvar ,mode))))
 
        ;; The actual function.
        ,(funcall
@@ -374,6 +362,27 @@ define-minor-mode
 	    ;; Return the new setting.
 	    ,getter))
 
+       ;; Put the defcustom *after* the function, so its
+       ;; initializer/setter can call the function.
+       ,(cond
+         (variable nil)
+         ((not globalp) nil)
+         (t
+	  (let ((base-doc-string
+                 (concat "Non-nil if %s is enabled.
+See the `%s' command
+for a description of this minor mode."
+                         (if body "
+Setting this variable directly does not take effect;
+either customize it (see the info node `Easy Customization')
+or call the function `%s'."))))
+	    `(defcustom ,mode ,init-value
+	       ,(format base-doc-string pretty-name mode mode)
+	       ,@set
+	       ,@initialize
+	       ,@type
+               ,@(nreverse extra-keywords)))))
+
        ;; Autoloading a define-minor-mode autoloads everything
        ;; up-to-here.
        :autoload-end
diff --git a/lisp/mwheel.el b/lisp/mwheel.el
index b31805a575..aded0aa8c9 100644
--- a/lisp/mwheel.el
+++ b/lisp/mwheel.el
@@ -418,11 +418,7 @@ mouse-wheel--create-scroll-keys
 (define-minor-mode mouse-wheel-mode
   "Toggle mouse wheel support (Mouse Wheel mode)."
   :init-value t
-  ;; We'd like to use custom-initialize-set here so the setup is done
-  ;; before dumping, but at the point where the defcustom is evaluated,
-  ;; the corresponding function isn't defined yet, so
-  ;; custom-initialize-set signals an error.
-  :initialize 'custom-initialize-delay
+  :initialize #'custom-initialize-set
   :global t
   :group 'mouse
   ;; Remove previous bindings, if any.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Sat, 31 Jul 2021 17:19:01 GMT) Full text and rfc822 format available.

Message #52 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: contovob <at> tcd.ie, larsi <at> gnus.org, johnson9009 <at> 163.com, 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Sat, 31 Jul 2021 20:18:01 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Lars Ingebrigtsen <larsi <at> gnus.org>,  contovob <at> tcd.ie,
>   johnson9009 <at> 163.com,  47162 <at> debbugs.gnu.org
> Date: Sat, 31 Jul 2021 13:10:10 -0400
> 
> > Why can't we simply call the necessary code at startup,
> 
> Actually even earlier.
> Maybe a patch like the one below is a better approach?

If it works reliably, sure.  But it will need to be documented.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Sat, 31 Jul 2021 18:09:02 GMT) Full text and rfc822 format available.

Message #55 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: contovob <at> tcd.ie, Eli Zaretskii <eliz <at> gnu.org>, johnson9009 <at> 163.com,
 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Sat, 31 Jul 2021 20:07:49 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> +       ;; Put the defcustom *after* the function, so its
> +       ;; initializer/setter can call the function.

I like it.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Sat, 31 Jul 2021 18:10:01 GMT) Full text and rfc822 format available.

Message #58 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: contovob <at> tcd.ie, Eli Zaretskii <eliz <at> gnu.org>, johnson9009 <at> 163.com,
 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Sat, 31 Jul 2021 20:09:43 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
>> +       ;; Put the defcustom *after* the function, so its
>> +       ;; initializer/setter can call the function.
>
> I like it.

Spoke some seconds too soon.  The leads to the following when doing a
"make bootstrap":

Loading faces...
Loading loaddefs.el (source)...
Attempt to autoload mouse-wheel-mode while preparing to dump
make[1]: *** [Makefile:569: emacs.pdmp] Error 255


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Mon, 02 Aug 2021 04:41:02 GMT) Full text and rfc822 format available.

Message #61 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: contovob <at> tcd.ie, Eli Zaretskii <eliz <at> gnu.org>, johnson9009 <at> 163.com,
 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Mon, 02 Aug 2021 00:39:47 -0400
Lars Ingebrigtsen [2021-07-31 20:09:43] wrote:
> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>>> +       ;; Put the defcustom *after* the function, so its
>>> +       ;; initializer/setter can call the function.
>>
>> I like it.
>
> Spoke some seconds too soon.  The leads to the following when doing a
> "make bootstrap":
>
> Loading faces...
> Loading loaddefs.el (source)...
> Attempt to autoload mouse-wheel-mode while preparing to dump
> make[1]: *** [Makefile:569: emacs.pdmp] Error 255

This brought to a light a more direct bug that could be reproduced in
the non-GUI build (by setting mouse-wheel-mode before loading mwheel.el)
and the fix to that bug fixes the use of `custom-initialize-delay` as
well so I pushed it to `master`.

[ It's hard to test those things in all the various ways they can be
  loaded, so I'm keeping my fingers crossed that it won't introduce
  another bootstrap problem elsewhere, but since it's now "more
  normal", I'm hopeful.  ]


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47162; Package emacs. (Wed, 04 Aug 2021 06:13:02 GMT) Full text and rfc822 format available.

Message #64 received at 47162 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: contovob <at> tcd.ie, Eli Zaretskii <eliz <at> gnu.org>, johnson9009 <at> 163.com,
 47162 <at> debbugs.gnu.org
Subject: Re: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any
 Window System
Date: Wed, 04 Aug 2021 08:11:44 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> [ It's hard to test those things in all the various ways they can be
>   loaded, so I'm keeping my fingers crossed that it won't introduce
>   another bootstrap problem elsewhere, but since it's now "more
>   normal", I'm hopeful.  ]

Yup; works for me.

And I can confirm that the --without-x build now doesn't load mwheel.el,
so I'm re-closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 47162 <at> debbugs.gnu.org and 张强 <johnson9009 <at> 163.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 04 Aug 2021 06:13:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 01 Sep 2021 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 237 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.