Subject: Re: bug#46151: 28.0.50; Set revert-buffer-function in shell command output buffers

From: Sean Whitton <[email-masked]>
Date: Mon, 01 Feb 2021 11:00:22 -0700

Hello,

On Mon 01 Feb 2021 at 09:49AM +01, Lars Ingebrigtsen wrote:

> I think a global `revert-buffer' binding is the way to go.  How to
> reload a file is something that comes up all the time, so I think it is
> high time it got bound.

Okay, here is a patch.

-- 
Sean Whitton
>From 4e5db21270cebc6027ad991bffb6e48756f00191 Mon Sep 17 00:00:00 2001
From: Sean Whitton <[email-masked]>
Date: Mon, 1 Feb 2021 10:56:49 -0700
Subject: [PATCH] Bind 'revert-buffer' to 'C-x g' globally

* lisp/bindings.el: Bind 'revert-buffer' to 'C-x g' globally.
* doc/emacs/files.texi: Replace 'M-x revert-buffer' with 'C-x g'.
* etc/NEWS: Document the change.
---
 doc/emacs/files.texi | 6 +++---
 etc/NEWS             | 3 +++
 lisp/bindings.el     | 2 ++
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index ede382c146..12ceac800e 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -927,9 +927,9 @@ Manual}).  For customizations, see the Custom group @code{time-stamp}.
 
   If you have made extensive changes to a file-visiting buffer and
 then change your mind, you can @dfn{revert} the changes and go back to
-the saved version of the file.  To do this, type @kbd{M-x
-revert-buffer}.  Since reverting unintentionally could lose a lot of
-work, Emacs asks for confirmation first.
+the saved version of the file.  To do this, type @kbd{C-x g}.  Since
+reverting unintentionally could lose a lot of work, Emacs asks for
+confirmation first.
 
   The @code{revert-buffer} command tries to position point in such a
 way that, if the file was edited only slightly, you will be at
diff --git a/etc/NEWS b/etc/NEWS
index 29499639e7..c8c9535cfb 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -233,6 +233,9 @@ search string is at least this long.  'lazy-highlight-initial-delay'
 still applies for shorter search strings, which avoids flicker in the
 search buffer due to too many matches being highlighted.
 
++++
+** 'revert-buffer' is now bound to 'C-x g' globally.
+
 
 * Editing Changes in Emacs 28.1
 
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 43b62f9bbf..9ea188d1a0 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -1413,6 +1413,8 @@ if `inhibit-field-text-motion' is non-nil."
 
 (define-key ctl-x-map "z" 'repeat)
 
+(define-key ctl-x-map "g" #'revert-buffer)
+
 (define-key esc-map "\C-l" 'reposition-window)
 
 (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
-- 
2.29.2