From: Allen Li Date: Thu, 25 Oct 2018 02:48:15 +0000 (-0600) Subject: Add setter for 'xref-marker-ring-length' X-Git-Tag: emacs-27.0.90~4192 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=70c75167ede4c54bb796187146437120856f890b;p=emacs.git Add setter for 'xref-marker-ring-length' * lisp/progmodes/xref.el (xref-marker-ring-length): Add setter. * etc/NEWS: Document last change. (Bug#32849) --- diff --git a/etc/NEWS b/etc/NEWS index 668b59a20a4..e5892d718e8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -460,6 +460,11 @@ for example. This command finds definitions of the identifier at the place of a mouse click event, and is intended to be bound to a mouse event. ++++ +*** Changing 'xref-marker-ring-length' works after 'xref.el' is loaded. +Previously, setting 'xref-marker-ring-length' would only take effect +if set before 'xref.el' was loaded. + ** Ecomplete *** The ecomplete sorting has changed to a decay-based algorithm. diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 6b1421a6f78..3b449bf9b15 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -317,8 +317,12 @@ backward." ;;; Marker stack (M-. pushes, M-, pops) (defcustom xref-marker-ring-length 16 - "Length of the xref marker ring." - :type 'integer) + "Length of the xref marker ring. +If this variable is not set through Customize, you must call +`xref-set-marker-ring-length' for changes to take effect." + :type 'integer + :initialize #'custom-initialize-default + :set #'xref-set-marker-ring-length) (defcustom xref-prompt-for-identifier '(not xref-find-definitions xref-find-definitions-other-window @@ -354,6 +358,14 @@ elements is negated: these commands will NOT prompt." (defvar xref--marker-ring (make-ring xref-marker-ring-length) "Ring of markers to implement the marker stack.") +(defun xref-set-marker-ring-length (var val) + "Set `xref-marker-ring-length'. +VAR is the symbol `xref-marker-ring-length' and VAL is the new +value." + (set-default var val) + (if (ring-p xref--marker-ring) + (ring-resize xref--marker-ring val))) + (defun xref-push-marker-stack (&optional m) "Add point M (defaults to `point-marker') to the marker stack." (ring-insert xref--marker-ring (or m (point-marker))))