aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2020-09-09 13:29:59 -0400
committerStefan Monnier2020-09-09 13:30:20 -0400
commit6e7736ac5f42e2f1b17aacdfb2a60d8bb951d038 (patch)
tree8d6086bd706f2c0cae44c3668c6167fc0a64bfea
parent9de9976de003b94d7496a55d4d643ac31514d520 (diff)
downloademacs-6e7736ac5f42e2f1b17aacdfb2a60d8bb951d038.tar.gz
emacs-6e7736ac5f42e2f1b17aacdfb2a60d8bb951d038.zip
(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.
-rw-r--r--lisp/cus-dep.el32
-rw-r--r--lisp/display-fill-column-indicator.el17
-rw-r--r--lisp/emacs-lisp/easy-mmode.el11
3 files changed, 37 insertions, 23 deletions
diff --git a/lisp/cus-dep.el b/lisp/cus-dep.el
index b1027ce34f9..9003b7fc1b5 100644
--- a/lisp/cus-dep.el
+++ b/lisp/cus-dep.el
@@ -51,6 +51,25 @@ ldefs-boot\\|cus-load\\|finder-inf\\|esh-groups\\|subdirs\\)\\.el$\\)"
51 (defalias sym e)))) 51 (defalias sym e))))
52 '(defcustom defface defgroup))) 52 '(defcustom defface defgroup)))
53 53
54(defun custom--get-def (expr)
55 (if (not (memq (car-safe expr)
56 '( define-minor-mode define-globalized-minor-mode)))
57 expr
58 ;; For define-minor-mode, we don't want to evaluate the whole
59 ;; expression, because it tends to define functions which aren't
60 ;; usable (because they call other functions that were skipped).
61 ;; Concretely it gave us an error
62 ;; "void-function bug-reference--run-auto-setup"
63 ;; when subsequently loading `cus-load.el'.
64 (let ((es (list (macroexpand-all expr)))
65 defs)
66 (while es
67 (let ((e (pop es)))
68 (pcase e
69 (`(progn . ,exps) (setq es (append exps es)))
70 (`(custom-declare-variable . ,_) (push e defs)))))
71 (macroexp-progn (nreverse defs)))))
72
54(defun custom-make-dependencies () 73(defun custom-make-dependencies ()
55 "Batch function to extract custom dependencies from .el files. 74 "Batch function to extract custom dependencies from .el files.
56Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS" 75Usage: 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"
102 "^(def\\(custom\\|face\\|group\\|ine\\(?:-globalized\\)?-minor-mode\\)" nil t) 121 "^(def\\(custom\\|face\\|group\\|ine\\(?:-globalized\\)?-minor-mode\\)" nil t)
103 (beginning-of-line) 122 (beginning-of-line)
104 (let ((type (match-string 1)) 123 (let ((type (match-string 1))
105 (expr (read (current-buffer)))) 124 (expr (custom--get-def (read (current-buffer)))))
106 (condition-case nil 125 (condition-case nil
107 (let ((custom-dont-initialize t)) 126 (let ((custom-dont-initialize t)
127 (sym (nth 1 expr)))
128 (put (if (eq (car-safe sym) 'quote)
129 (cadr sym)
130 sym)
131 'custom-where name)
108 ;; Eval to get the 'custom-group, -tag, 132 ;; Eval to get the 'custom-group, -tag,
109 ;; -version, group-documentation etc properties. 133 ;; -version, group-documentation etc properties.
110 (put (nth 1 expr) 'custom-where name)
111 (eval expr)) 134 (eval expr))
112 ;; Eval failed for some reason. Eg maybe the 135 ;; Eval failed for some reason. Eg maybe the
113 ;; defcustom uses something defined earlier 136 ;; defcustom uses something defined earlier
@@ -148,7 +171,8 @@ Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS"
148 (when found 171 (when found
149 (push (cons (symbol-name symbol) 172 (push (cons (symbol-name symbol)
150 (with-output-to-string 173 (with-output-to-string
151 (prin1 (sort found 'string<)))) alist)))))) 174 (prin1 (sort found #'string<))))
175 alist))))))
152 (dolist (e (sort alist (lambda (e1 e2) (string< (car e1) (car e2))))) 176 (dolist (e (sort alist (lambda (e1 e2) (string< (car e1) (car e2)))))
153 (insert "(put '" (car e) " 'custom-loads '" (cdr e) ")\n"))) 177 (insert "(put '" (car e) " 'custom-loads '" (cdr e) ")\n")))
154 (insert "\ 178 (insert "\
diff --git a/lisp/display-fill-column-indicator.el b/lisp/display-fill-column-indicator.el
index 3391aa371b7..e1395f000bf 100644
--- a/lisp/display-fill-column-indicator.el
+++ b/lisp/display-fill-column-indicator.el
@@ -57,12 +57,13 @@ See Info node `Displaying Boundaries' for details."
57 (progn 57 (progn
58 (setq display-fill-column-indicator t) 58 (setq display-fill-column-indicator t)
59 (unless display-fill-column-indicator-character 59 (unless display-fill-column-indicator-character
60 (if (and (char-displayable-p ?\u2502) 60 (setq display-fill-column-indicator-character
61 (or (not (display-graphic-p)) 61 (if (and (char-displayable-p ?\u2502)
62 (eq (aref (query-font (car (internal-char-font nil ?\u2502))) 0) 62 (or (not (display-graphic-p))
63 (face-font 'default)))) 63 (eq (aref (query-font (car (internal-char-font nil ?\u2502))) 0)
64 (setq display-fill-column-indicator-character ?\u2502) 64 (face-font 'default))))
65 (setq display-fill-column-indicator-character ?|)))) 65 ?\u2502
66 ?|))))
66 (setq display-fill-column-indicator nil))) 67 (setq display-fill-column-indicator nil)))
67 68
68(defun display-fill-column-indicator--turn-on () 69(defun display-fill-column-indicator--turn-on ()
@@ -73,9 +74,7 @@ See Info node `Displaying Boundaries' for details."
73 74
74;;;###autoload 75;;;###autoload
75(define-globalized-minor-mode global-display-fill-column-indicator-mode 76(define-globalized-minor-mode global-display-fill-column-indicator-mode
76 display-fill-column-indicator-mode display-fill-column-indicator--turn-on 77 display-fill-column-indicator-mode display-fill-column-indicator--turn-on)
77 ;; See bug#41145
78 :group 'display-fill-column-indicator)
79 78
80(provide 'display-fill-column-indicator) 79(provide 'display-fill-column-indicator)
81 80
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index 24c9e79f2c1..e3eb9294ed6 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -1,4 +1,4 @@
1;;; easy-mmode.el --- easy definition for major and minor modes 1;;; easy-mmode.el --- easy definition for major and minor modes -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 1997, 2000-2020 Free Software Foundation, Inc. 3;; Copyright (C) 1997, 2000-2020 Free Software Foundation, Inc.
4 4
@@ -157,9 +157,6 @@ BODY contains code to execute each time the mode is enabled or disabled.
157 the minor mode is global): 157 the minor mode is global):
158 158
159:group GROUP Custom group name to use in all generated `defcustom' forms. 159:group GROUP Custom group name to use in all generated `defcustom' forms.
160 Defaults to MODE without the possible trailing \"-mode\".
161 Don't use this default group name unless you have written a
162 `defgroup' to define that group properly.
163:global GLOBAL If non-nil specifies that the minor mode is not meant to be 160:global GLOBAL If non-nil specifies that the minor mode is not meant to be
164 buffer-local, so don't make the variable MODE buffer-local. 161 buffer-local, so don't make the variable MODE buffer-local.
165 By default, the mode is buffer-local. 162 By default, the mode is buffer-local.
@@ -262,12 +259,6 @@ For example, you could write
262 (unless initialize 259 (unless initialize
263 (setq initialize '(:initialize 'custom-initialize-default))) 260 (setq initialize '(:initialize 'custom-initialize-default)))
264 261
265 (unless group
266 ;; We might as well provide a best-guess default group.
267 (setq group
268 `(:group ',(intern (replace-regexp-in-string
269 "-mode\\'" "" mode-name)))))
270
271 ;; TODO? Mark booleans as safe if booleanp? Eg abbrev-mode. 262 ;; TODO? Mark booleans as safe if booleanp? Eg abbrev-mode.
272 (unless type (setq type '(:type 'boolean))) 263 (unless type (setq type '(:type 'boolean)))
273 264