From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any Window System Date: Sat, 31 Jul 2021 13:10:10 -0400 Message-ID: References: <2774d41f.9c06.178365811f7.Coremail.johnson9009@163.com> <874kh9t4pw.fsf@gnus.org> <87o8akxkvd.fsf@tcd.ie> <87eebgqd7w.fsf@gnus.org> <874kcbvlur.fsf@tcd.ie> <87im0rlri1.fsf@gnus.org> <838s1mpqt9.fsf@gnu.org> <87h7gafu48.fsf@gnus.org> <834kcapnml.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36482"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: contovob@tcd.ie, Lars Ingebrigtsen , johnson9009@163.com, 47162@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 31 19:11:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m9sVz-0009IM-3b for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 31 Jul 2021 19:11:11 +0200 Original-Received: from localhost ([::1]:41088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m9sVx-0006BA-Ne for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 31 Jul 2021 13:11:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9sVq-0006B0-Ki for bug-gnu-emacs@gnu.org; Sat, 31 Jul 2021 13:11:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51453) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m9sVq-0006Hm-CR for bug-gnu-emacs@gnu.org; Sat, 31 Jul 2021 13:11:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m9sVq-0008AU-8h for bug-gnu-emacs@gnu.org; Sat, 31 Jul 2021 13:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 31 Jul 2021 17:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47162 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 47162-submit@debbugs.gnu.org id=B47162.162775142031341 (code B ref 47162); Sat, 31 Jul 2021 17:11:02 +0000 Original-Received: (at 47162) by debbugs.gnu.org; 31 Jul 2021 17:10:20 +0000 Original-Received: from localhost ([127.0.0.1]:34766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m9sVA-00089R-3d for submit@debbugs.gnu.org; Sat, 31 Jul 2021 13:10:20 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:46894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m9sV8-00089F-HY for 47162@debbugs.gnu.org; Sat, 31 Jul 2021 13:10:18 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 127D11001F9; Sat, 31 Jul 2021 13:10:13 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 8CAFE100104; Sat, 31 Jul 2021 13:10:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1627751411; bh=rrwdwVFkkBriM1/4W5qpQepQJlSMgg+KO7PhOYjt0PU=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=aOLdI8tBh/c+OduKBw2F633MY03GRKyZRL02pwDenwQlPQEJB9eumQp2UxL7KxFjQ Dv1ws1v8JaFeOVG1QDf8Iz1ST1/GxZd00L7r/kzshvT5YrKOU+zgoIkZkSC8u4A5IM LOqhuCWRQZTB/8s2hwPFb55edMmuqOb+ZFXX5ln/zIHDBuOZob2lbmo9eBq8RuDAWi 46zu3WWkzhyS7Xftbht78rmB4YFLOW3uhnfc9Rx2dGcSqC80m3NqAwJ+xn5gvIyEsn +T7ScQJD1MDHulEtQcK7AXhmsT/LlEiXpXXPNeGkWmh7MCp7ziWyBQivKPwELIhX1A UHYB+2N8Lxjcw== Original-Received: from alfajor (unknown [216.154.29.138]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 49652120377; Sat, 31 Jul 2021 13:10:11 -0400 (EDT) In-Reply-To: <834kcapnml.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 31 Jul 2021 17:24:34 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:211011 Archived-At: > 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.