]> git.eshelyaron.com Git - emacs.git/commitdiff
(define-minor-mode): Don't compute a default :group (bug#41145)
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 9 Sep 2020 17:29:59 +0000 (13:29 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 9 Sep 2020 17:30:20 +0000 (13:30 -0400)
* lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Rely on the
`defcustom`s own defaulting for the :group.

* lisp/display-fill-column-indicator.el
(global-display-fill-column-indicator-mode): Remove now redundant :group.

* lisp/cus-dep.el (custom--get-def): New function.
(custom-make-dependencies): Use it.

lisp/cus-dep.el
lisp/display-fill-column-indicator.el
lisp/emacs-lisp/easy-mmode.el

index b1027ce34f9e53559193ea9b316dcf77f6c45f66..9003b7fc1b5144c7ded6d7c0706852ebd9e21132 100644 (file)
@@ -51,6 +51,25 @@ ldefs-boot\\|cus-load\\|finder-inf\\|esh-groups\\|subdirs\\)\\.el$\\)"
                          (defalias sym e))))
        '(defcustom defface defgroup)))
 
+(defun custom--get-def (expr)
+  (if (not (memq (car-safe expr)
+                 '( define-minor-mode define-globalized-minor-mode)))
+      expr
+    ;; For define-minor-mode, we don't want to evaluate the whole
+    ;; expression, because it tends to define functions which aren't
+    ;; usable (because they call other functions that were skipped).
+    ;; Concretely it gave us an error
+    ;; "void-function bug-reference--run-auto-setup"
+    ;; when subsequently loading `cus-load.el'.
+    (let ((es (list (macroexpand-all expr)))
+          defs)
+      (while es
+        (let ((e (pop es)))
+          (pcase e
+            (`(progn . ,exps) (setq es (append exps es)))
+            (`(custom-declare-variable . ,_) (push e defs)))))
+      (macroexp-progn (nreverse defs)))))
+
 (defun custom-make-dependencies ()
   "Batch function to extract custom dependencies from .el files.
 Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS"
@@ -102,12 +121,16 @@ Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS"
                           "^(def\\(custom\\|face\\|group\\|ine\\(?:-globalized\\)?-minor-mode\\)" nil t)
                     (beginning-of-line)
                     (let ((type (match-string 1))
-                         (expr (read (current-buffer))))
+                         (expr (custom--get-def (read (current-buffer)))))
                       (condition-case nil
-                          (let ((custom-dont-initialize t))
+                          (let ((custom-dont-initialize t)
+                                (sym (nth 1 expr)))
+                            (put (if (eq (car-safe sym) 'quote)
+                                     (cadr sym)
+                                   sym)
+                                 'custom-where name)
                             ;; Eval to get the 'custom-group, -tag,
                             ;; -version, group-documentation etc properties.
-                            (put (nth 1 expr) 'custom-where name)
                             (eval expr))
                         ;; Eval failed for some reason.  Eg maybe the
                         ;; defcustom uses something defined earlier
@@ -148,7 +171,8 @@ Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS"
                    (when found
                      (push (cons (symbol-name symbol)
                                  (with-output-to-string
-                                   (prin1 (sort found 'string<)))) alist))))))
+                                   (prin1 (sort found #'string<))))
+                           alist))))))
     (dolist (e (sort alist (lambda (e1 e2) (string< (car e1) (car e2)))))
       (insert "(put '" (car e) " 'custom-loads '" (cdr e) ")\n")))
   (insert "\
index 3391aa371b707f0edaad9d3aaa9fe54af3a56a03..e1395f000bfeba5fbcc4f8cc6597a5901672b956 100644 (file)
@@ -57,12 +57,13 @@ See Info node `Displaying Boundaries' for details."
       (progn
         (setq display-fill-column-indicator t)
         (unless display-fill-column-indicator-character
-          (if (and (char-displayable-p ?\u2502)
-                   (or (not (display-graphic-p))
-                       (eq (aref (query-font (car (internal-char-font nil ?\u2502))) 0)
-                           (face-font 'default))))
-              (setq display-fill-column-indicator-character ?\u2502)
-            (setq display-fill-column-indicator-character ?|))))
+          (setq display-fill-column-indicator-character
+                (if (and (char-displayable-p ?\u2502)
+                         (or (not (display-graphic-p))
+                             (eq (aref (query-font (car (internal-char-font nil ?\u2502))) 0)
+                                 (face-font 'default))))
+                    ?\u2502
+                  ?|))))
     (setq display-fill-column-indicator nil)))
 
 (defun display-fill-column-indicator--turn-on ()
@@ -73,9 +74,7 @@ See Info node `Displaying Boundaries' for details."
 
 ;;;###autoload
 (define-globalized-minor-mode global-display-fill-column-indicator-mode
-  display-fill-column-indicator-mode display-fill-column-indicator--turn-on
-  ;; See bug#41145
-  :group 'display-fill-column-indicator)
+  display-fill-column-indicator-mode display-fill-column-indicator--turn-on)
 
 (provide 'display-fill-column-indicator)
 
index 24c9e79f2c168bfb976c4b534856af2a54f513a7..e3eb9294ed6a3bf9082d88ab7a2c0de616675fd0 100644 (file)
@@ -1,4 +1,4 @@
-;;; easy-mmode.el --- easy definition for major and minor modes
+;;; easy-mmode.el --- easy definition for major and minor modes  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1997, 2000-2020 Free Software Foundation, Inc.
 
@@ -157,9 +157,6 @@ BODY contains code to execute each time the mode is enabled or disabled.
   the minor mode is global):
 
 :group GROUP   Custom group name to use in all generated `defcustom' forms.
-               Defaults to MODE without the possible trailing \"-mode\".
-               Don't use this default group name unless you have written a
-               `defgroup' to define that group properly.
 :global GLOBAL If non-nil specifies that the minor mode is not meant to be
                buffer-local, so don't make the variable MODE buffer-local.
                By default, the mode is buffer-local.
@@ -262,12 +259,6 @@ For example, you could write
     (unless initialize
       (setq initialize '(:initialize 'custom-initialize-default)))
 
-    (unless group
-      ;; We might as well provide a best-guess default group.
-      (setq group
-           `(:group ',(intern (replace-regexp-in-string
-                               "-mode\\'" "" mode-name)))))
-
     ;; TODO? Mark booleans as safe if booleanp?  Eg abbrev-mode.
     (unless type (setq type '(:type 'boolean)))