]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow obsoleting themes
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 3 Oct 2021 09:03:07 +0000 (11:03 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 3 Oct 2021 09:04:04 +0000 (11:04 +0200)
* 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).

etc/NEWS
lisp/cus-theme.el
lisp/custom.el

index 8c22230daf5a612f6e35aad8b035ef80b52e9627..20ed20308e2b9e2a167e932fe24e6fbad71ca622 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -80,6 +80,11 @@ Emacs buffers, like indentation and the like.  The new ert function
 \f
 * 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.
+
 \f
 * Changes in Emacs 29.1 on Non-Free Operating Systems
 
index 07881e9b74e9bbcf4f09a29aec38b91738cff936..f618e3341cb7ab84cf56a92a31ec6958c7c34227 100644 (file)
@@ -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))
 
index 858b158051cdc4d810bc19585c01cc690ec3bcd9..0cd4318e63df8e7dbd8607e45779b908bf53064f 100644 (file)
@@ -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.