bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#47162: Mouse Wheel Won't Work When Emacs Built without Any Window Sy


From: Stefan Monnier
Subject: bug#47162: Mouse Wheel Won't Work When Emacs Built without Any Window System
Date: Sat, 31 Jul 2021 13:10:10 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> 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.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]