]> git.eshelyaron.com Git - emacs.git/commitdiff
Support reverting in Customize buffers
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 5 Jul 2021 14:56:07 +0000 (16:56 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 5 Jul 2021 14:56:07 +0000 (16:56 +0200)
* lisp/cus-edit.el (custom--revert-buffer): New function (bug#26871).
(Custom-mode): Set up reversion.
(custom--invocation-options): New variable.
(custom-buffer-create-internal): Set it.

etc/NEWS
lisp/cus-edit.el

index a62e9c86c9311bcd28c69ac2d8a307be12d7bb10..c3eaf5fcbb630d12f7723d4cc7749198220d20e3 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1266,6 +1266,9 @@ To revert to the previous behavior,
 
 ** Customize
 
+---
+*** Customize buffers can now be reverted with 'C-x x g'.
+
 *** Most customize commands now hide obsolete user options.
 Obsolete user options are no longer shown in the listings produced by
 the commands 'customize', 'customize-group', 'customize-apropos' and
index 7627930c4c8ac779e59b00935eae61e7b4c11911..a8b2640b7d3682a9a49bbfe4d7c07cf98e758db7 100644 (file)
@@ -1665,8 +1665,11 @@ Otherwise use brackets."
                   'custom-button-pressed
                 'custom-button-pressed-unraised))))
 
+(defvar custom--invocation-options nil)
+
 (defun custom-buffer-create-internal (options &optional _description)
   (Custom-mode)
+  (setq custom--invocation-options options)
   (let ((init-file (or custom-file user-init-file)))
     ;; Insert verbose help at the top of the custom buffer.
     (when custom-buffer-verbose-help
@@ -5148,11 +5151,19 @@ if that value is non-nil."
                        :label (nth 5 arg)))
                     custom-commands)
                    (setq custom-tool-bar-map map))))
+  (setq-local custom--invocation-options nil)
+  (setq-local revert-buffer-function #'custom--revert-buffer)
   (make-local-variable 'custom-options)
   (make-local-variable 'custom-local-buffer)
   (custom--initialize-widget-variables)
   (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t))
 
+(defun custom--revert-buffer (_ignore-auto _noconfirm)
+  (unless custom--invocation-options
+    (error "Insufficient data to revert"))
+  (custom-buffer-create custom--invocation-options
+                        (buffer-name)))
+
 (put 'Custom-mode 'mode-class 'special)
 
 (provide 'cus-edit)