From: Lars Ingebrigtsen Date: Sun, 3 Oct 2021 09:03:07 +0000 (+0200) Subject: Allow obsoleting themes X-Git-Tag: emacs-29.0.90~3671^2~685 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=344634d7cc5206027fda8e791beef8c43de8aedb;p=emacs.git Allow obsoleting themes * lisp/cus-theme.el (customize-themes): Don't list obsolete themes. * lisp/custom.el (load-theme): Issue a warning if the theme is obsolete (bug#47047). --- diff --git a/etc/NEWS b/etc/NEWS index 8c22230daf5..20ed20308e2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -80,6 +80,11 @@ Emacs buffers, like indentation and the like. The new ert function * Lisp Changes in Emacs 29.1 +--- +** Themes can now be made obsolete. +Using 'make-obsolete' on a theme is now supported. This will make +'load-theme' issue a warning when loading the theme. + * Changes in Emacs 29.1 on Non-Free Operating Systems diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el index 07881e9b74e..f618e3341cb 100644 --- a/lisp/cus-theme.el +++ b/lisp/cus-theme.el @@ -627,22 +627,24 @@ Theme files are named *-theme.el in `")) (let ((help-echo "mouse-2: Enable this theme for this session") widget) (dolist (theme (custom-available-themes)) - (setq widget (widget-create 'checkbox - :value (custom-theme-enabled-p theme) - :theme-name theme - :help-echo help-echo - :action #'custom-theme-checkbox-toggle)) - (push (cons theme widget) custom--listed-themes) - (widget-create-child-and-convert widget 'push-button - :button-face-get 'ignore - :mouse-face-get 'ignore - :value (format " %s" theme) - :action #'widget-parent-action - :help-echo help-echo) - (widget-insert " -- " - (propertize (custom-theme-summary theme) - 'face 'shadow) - ?\n))) + ;; Don't list obsolete themes. + (unless (get theme 'byte-obsolete-info) + (setq widget (widget-create 'checkbox + :value (custom-theme-enabled-p theme) + :theme-name theme + :help-echo help-echo + :action #'custom-theme-checkbox-toggle)) + (push (cons theme widget) custom--listed-themes) + (widget-create-child-and-convert widget 'push-button + :button-face-get 'ignore + :mouse-face-get 'ignore + :value (format " %s" theme) + :action #'widget-parent-action + :help-echo help-echo) + (widget-insert " -- " + (propertize (custom-theme-summary theme) + 'face 'shadow) + ?\n)))) (goto-char (point-min)) (widget-setup)) diff --git a/lisp/custom.el b/lisp/custom.el index 858b158051c..0cd4318e63d 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -1331,6 +1331,13 @@ Return t if THEME was successfully loaded, nil otherwise." t)))) (t (error "Unable to load theme `%s'" theme)))) + (when-let ((obs (get theme 'byte-obsolete-info))) + (display-warning 'initialization + (format "The `%s' theme is obsolete%s" + theme + (if (nth 2 obs) + (format " since Emacs %s" (nth 2 obs)) + "")))) ;; Optimization: if the theme changes the `default' face, put that ;; entry first. This avoids some `frame-set-background-mode' rigmarole ;; by assigning the new background immediately.