From: Dmitry Gutov Date: Wed, 22 May 2019 22:30:50 +0000 (+0300) Subject: Make xref-find-definitions more customizable X-Git-Tag: emacs-27.0.90~2807 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1cadab78e242834adab0fae3cb1feb691d52f8c5;p=emacs.git Make xref-find-definitions more customizable * lisp/progmodes/xref.el (xref--show-defs-buffer): New function. Move a bit of logic from xref--show-defs to make it more customizable. (xref--push-markers): New function, extracted from xref--show-xrefs. (xref-show-definitions-function): Set to the new function. --- diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 3951b9f1dd2..b226a41929f 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -792,11 +792,19 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)." xref--original-window-intent (assoc-default 'display-action alist)) (current-buffer))))) +(defun xref--show-defs-buffer (xrefs alist) + (cond + ((not (cdr xrefs)) + (xref--pop-to-location (car xrefs) + (assoc-default 'display-action alist))) + (t + (xref--show-xref-buffer xrefs alist)))) + (defvar xref-show-xrefs-function 'xref--show-xref-buffer "Function to display a list of search results.") -(defvar xref-show-definitions-function 'xref--show-xref-buffer +(defvar xref-show-definitions-function 'xref--show-defs-buffer "Function to display a list of definitions.") (defvar xref--read-identifier-history nil) @@ -804,22 +812,20 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)." (defvar xref--read-pattern-history nil) (defun xref--show-xrefs (xrefs display-action) - (unless (region-active-p) (push-mark nil t)) - (xref-push-marker-stack) + (xref--push-markers) (funcall xref-show-xrefs-function xrefs `((window . ,(selected-window)) (display-action . ,display-action)))) (defun xref--show-defs (xrefs display-action) + (xref--push-markers) + (funcall xref-show-definitions-function xrefs + `((window . ,(selected-window)) + (display-action . ,display-action)))) + +(defun xref--push-markers () (unless (region-active-p) (push-mark nil t)) - (xref-push-marker-stack) - (cond - ((not (cdr xrefs)) - (xref--pop-to-location (car xrefs) display-action)) - (t - (funcall xref-show-definitions-function xrefs - `((window . ,(selected-window)) - (display-action . ,display-action)))))) + (xref-push-marker-stack)) (defun xref--prompt-p (command) (or (eq xref-prompt-for-identifier t)