From 6a75b6fcb10725fb1e352dec506b84e795baa7c8 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 18 Mar 2021 05:55:16 +0100 Subject: [PATCH] Don't pre-load facemenu * lisp/facemenu.el (facemenu-add-face-function): Move to avoid a compilation warning. (facemenu-color-alist): Made obsolete. * lisp/faces.el (read-color): Don't use it. * lisp/loadup.el ("emacs-lisp/syntax"): Don't load facemenu. * lisp/wid-edit.el (color): Don't use facemenu-color-alist. (widget-color--choose-action): Require facemenu. (widget-color-action): Ditto. * lisp/progmodes/cperl-mode.el (facemenu): Require. * lisp/textmodes/sgml-mode.el (facemenu): Require. --- etc/NEWS | 6 ++++++ lisp/facemenu.el | 17 +++++++++-------- lisp/faces.el | 11 +++++------ lisp/loadup.el | 1 - lisp/progmodes/cperl-mode.el | 1 + lisp/textmodes/sgml-mode.el | 1 + lisp/wid-edit.el | 8 +++++++- 7 files changed, 29 insertions(+), 16 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index ba82174833e..20407db0acd 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2278,6 +2278,12 @@ directory instead of the default directory. * Incompatible Lisp Changes in Emacs 28.1 +** 'facemenu-color-alist' is now obsolete, and is not used. + +** 'facemenu.el' is no longer preloaded. +To use functions/variables from the package, you now have to say +'(require 'facemenu)' or similar. + ** 'pcomplete-ignore-case' is now an obsolete alias of 'completion-ignore-case'. ** 'completions-annotations' face is not used when the caller puts own face. diff --git a/lisp/facemenu.el b/lisp/facemenu.el index 6290b02add2..2d06658b55c 100644 --- a/lisp/facemenu.el +++ b/lisp/facemenu.el @@ -169,6 +169,14 @@ it will remove any faces not explicitly in the list." (defalias 'facemenu-background-menu facemenu-background-menu) (put 'facemenu-background-menu 'menu-enable '(facemenu-enable-faces-p)) +(defcustom facemenu-add-face-function nil + "Function called at beginning of text to change or nil. +This function is passed the FACE to set and END of text to change, and must +return a string which is inserted. It may set `facemenu-end-add-face'." + :type '(choice (const :tag "None" nil) + function) + :group 'facemenu) + ;;; Condition for enabling menu items that set faces. (defun facemenu-enable-faces-p () ;; Enable the facemenu if facemenu-add-face-function is defined @@ -260,14 +268,6 @@ requested in `facemenu-keybindings'.") (defalias 'facemenu-keymap facemenu-keymap) -(defcustom facemenu-add-face-function nil - "Function called at beginning of text to change or nil. -This function is passed the FACE to set and END of text to change, and must -return a string which is inserted. It may set `facemenu-end-add-face'." - :type '(choice (const :tag "None" nil) - function) - :group 'facemenu) - (defcustom facemenu-end-add-face nil "String to insert or function called at end of text to change or nil. This function is passed the FACE to set, and must return a string which is @@ -291,6 +291,7 @@ May also be t meaning to use `facemenu-add-face-function'." (defvar facemenu-color-alist nil "Alist of colors, used for completion. If this is nil, then the value of (defined-colors) is used.") +(make-obsolete-variable 'facemenu-color-alist nil "28.1") (defun facemenu-update () "Add or update the \"Face\" menu in the menu bar. diff --git a/lisp/faces.el b/lisp/faces.el index 573428f1d34..7c6d749120e 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -1917,12 +1917,11 @@ Interactively, or with optional arg MSG non-nil, print the resulting color name in the echo area." (interactive "i\np\ni\np") ; Always convert to RGB interactively. (let* ((completion-ignore-case t) - (colors (or facemenu-color-alist - (append '("foreground at point" "background at point") - (if allow-empty-name '("")) - (if (display-color-p) - (defined-colors-with-face-attributes) - (defined-colors))))) + (colors (append '("foreground at point" "background at point") + (if allow-empty-name '("")) + (if (display-color-p) + (defined-colors-with-face-attributes) + (defined-colors)))) (color (completing-read (or prompt "Color (name or #RGB triplet): ") ;; Completing function for reading colors, accepting diff --git a/lisp/loadup.el b/lisp/loadup.el index 863afe427bd..4a0b8f508c7 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -253,7 +253,6 @@ (load "startup") (load "term/tty-colors") (load "font-core") -(load "facemenu") (load "emacs-lisp/syntax") (load "font-lock") (load "jit-lock") diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 734797b3ad2..cc7614dd107 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -92,6 +92,7 @@ (concat msg ": "))))) (eval-when-compile (require 'cl-lib)) +(require 'facemenu) (defvar msb-menu-cond) (defvar gud-perldb-history) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 876347bc81e..7de5317b025 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -34,6 +34,7 @@ (require 'dom) (require 'seq) +(require 'facemenu) (eval-when-compile (require 'subr-x)) (eval-when-compile (require 'skeleton) diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 35e7b9ce7e1..e71290c7ef9 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -4034,7 +4034,7 @@ is inline." (mapcar #'length (defined-colors)))) :tag "Color" :value "black" - :completions (or facemenu-color-alist (defined-colors)) + :completions (defined-colors) :sample-face-get 'widget-color-sample-face-get :notify 'widget-color-notify :match #'widget-color-match @@ -4049,7 +4049,10 @@ is inline." :tag " Choose " :action 'widget-color--choose-action) (widget-insert " ")) +(declare-function list-colors-display "facemenu") + (defun widget-color--choose-action (widget &optional _event) + (require 'facemenu) (list-colors-display nil nil (let ((cbuf (current-buffer)) @@ -4072,8 +4075,11 @@ is inline." (list (cons 'foreground-color value)) 'default))) +(declare-function facemenu-read-color "facemenu") + (defun widget-color-action (widget &optional event) "Prompt for a color." + (require 'facemenu) (let* ((tag (widget-apply widget :menu-tag-get)) (prompt (concat tag ": ")) (answer (facemenu-read-color prompt))) -- 2.39.5