Subject: Re: bug#38797: 27.0.50; Feature request: provide the opposite of xref-pop-marker-stack

From: Juri Linkov <[email-masked]>
Date: Mon, 08 Nov 2021 20:23:06 +0200

> I favour (lightly) "Go Back" / "Go Forward" because they make sense in
> context with the other Xref operations in that separator-delimited group of
> entries in the menu, and because it's a wording often used for these
> operations elsewhere such as in web browsers and IDEs (though often it's
> just "Back" and "Forward").

There are more votes for "Go Back" / "Go Forward", so I'll push
two patches - one for emacs-28 (not to be merged to master), and
another for master:

diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index 3e1a915e32..4997c2746f 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -51,7 +51,7 @@ prog-context-menu
 
   (unless (xref-marker-stack-empty-p)
     (define-key-after menu [xref-pop]
-      '(menu-item "Back Definition" xref-pop-marker-stack
+      '(menu-item "Go Back" xref-pop-marker-stack
                   :help "Back to the position of the last search")
       'prog-separator))
 
diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index db350a5f70..30b6edf0d9 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -49,9 +49,15 @@ prog-context-menu
   (define-key-after menu [prog-separator] menu-bar-separator
     'middle-separator)
 
+  (unless (xref-forward-history-empty-p)
+    (define-key-after menu [xref-forward]
+      '(menu-item "Go Forward" xref-go-forward
+                  :help "Forward to the position gone Back from")
+      'prog-separator))
+
   (unless (xref-marker-stack-empty-p)
     (define-key-after menu [xref-pop]
-      '(menu-item "Back Definition" xref-go-back
+      '(menu-item "Go Back" xref-go-back
                   :help "Back to the position of the last search")
       'prog-separator))