From 8bef7b6ad1775124eeed81acf46551c0fc3aa75e Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sat, 3 Jan 2015 16:02:04 +0200 Subject: [PATCH] Only show "Back" when the marker stack is non-empty * lisp/menu-bar.el (menu-bar-goto-menu): Use it. * lisp/progmodes/xref.el (xref-marker-stack-empty-p): New function. --- lisp/ChangeLog | 6 ++++++ lisp/menu-bar.el | 1 + lisp/progmodes/xref.el | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 34e22af92a9..49640f89055 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2015-01-03 Dmitry Gutov + + * progmodes/xref.el (xref-marker-stack-empty-p): New function. + + * menu-bar.el (menu-bar-goto-menu): Use it. + 2015-01-03 Dmitry Gutov * progmodes/xref.el (xref--window-configuration): New variable. diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 7d7e4660fb5..67cb3273d23 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -381,6 +381,7 @@ (bindings--define-key menu [xref-pop] '(menu-item "Back" xref-pop-marker-stack + :visible (not (xref-marker-stack-empty-p)) :help "Back to the position of the last search")) (bindings--define-key menu [xref-apropos] diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index cb331e1c833..7bc6500a8de 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -301,6 +301,10 @@ backward." (let ((marker (ring-remove ring))) (set-marker marker nil nil))))) +(defun xref-marker-stack-empty-p () + "Return t if the marker stack is empty; nil otherwise." + (ring-empty-p xref--marker-ring)) + (defun xref--goto-location (location) "Set buffer and point according to xref-location LOCATION." -- 2.39.2