From: Lars Ingebrigtsen Date: Mon, 5 Jul 2021 14:56:07 +0000 (+0200) Subject: Support reverting in Customize buffers X-Git-Tag: emacs-28.0.90~1951 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=68276f6d30bbdc09cc26fb49d7f0c3aa4bce35f2;p=emacs.git Support reverting in Customize buffers * 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. --- diff --git a/etc/NEWS b/etc/NEWS index a62e9c86c93..c3eaf5fcbb6 100644 --- 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 diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 7627930c4c8..a8b2640b7d3 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -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)