(define-minor-mode): Don't compute a default :group (bug#41145)

* 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.
This commit is contained in:
Stefan Monnier 2020-09-09 13:29:59 -04:00
parent 9de9976de0
commit 6e7736ac5f
3 changed files with 37 additions and 23 deletions

View 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 "\

View 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)

View 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)))