aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2019-05-23 01:30:50 +0300
committerDmitry Gutov2019-05-23 01:30:50 +0300
commit1cadab78e242834adab0fae3cb1feb691d52f8c5 (patch)
treedfa3d476112727bcec26176cd0cda79c524ed91d
parent49a363c875c66f3d937a7d33e1a1451227a1887d (diff)
downloademacs-1cadab78e242834adab0fae3cb1feb691d52f8c5.tar.gz
emacs-1cadab78e242834adab0fae3cb1feb691d52f8c5.zip
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.
-rw-r--r--lisp/progmodes/xref.el28
1 files changed, 17 insertions, 11 deletions
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 ...)) ...)."
792 xref--original-window-intent (assoc-default 'display-action alist)) 792 xref--original-window-intent (assoc-default 'display-action alist))
793 (current-buffer))))) 793 (current-buffer)))))
794 794
795(defun xref--show-defs-buffer (xrefs alist)
796 (cond
797 ((not (cdr xrefs))
798 (xref--pop-to-location (car xrefs)
799 (assoc-default 'display-action alist)))
800 (t
801 (xref--show-xref-buffer xrefs alist))))
802
795 803
796(defvar xref-show-xrefs-function 'xref--show-xref-buffer 804(defvar xref-show-xrefs-function 'xref--show-xref-buffer
797 "Function to display a list of search results.") 805 "Function to display a list of search results.")
798 806
799(defvar xref-show-definitions-function 'xref--show-xref-buffer 807(defvar xref-show-definitions-function 'xref--show-defs-buffer
800 "Function to display a list of definitions.") 808 "Function to display a list of definitions.")
801 809
802(defvar xref--read-identifier-history nil) 810(defvar xref--read-identifier-history nil)
@@ -804,22 +812,20 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)."
804(defvar xref--read-pattern-history nil) 812(defvar xref--read-pattern-history nil)
805 813
806(defun xref--show-xrefs (xrefs display-action) 814(defun xref--show-xrefs (xrefs display-action)
807 (unless (region-active-p) (push-mark nil t)) 815 (xref--push-markers)
808 (xref-push-marker-stack)
809 (funcall xref-show-xrefs-function xrefs 816 (funcall xref-show-xrefs-function xrefs
810 `((window . ,(selected-window)) 817 `((window . ,(selected-window))
811 (display-action . ,display-action)))) 818 (display-action . ,display-action))))
812 819
813(defun xref--show-defs (xrefs display-action) 820(defun xref--show-defs (xrefs display-action)
821 (xref--push-markers)
822 (funcall xref-show-definitions-function xrefs
823 `((window . ,(selected-window))
824 (display-action . ,display-action))))
825
826(defun xref--push-markers ()
814 (unless (region-active-p) (push-mark nil t)) 827 (unless (region-active-p) (push-mark nil t))
815 (xref-push-marker-stack) 828 (xref-push-marker-stack))
816 (cond
817 ((not (cdr xrefs))
818 (xref--pop-to-location (car xrefs) display-action))
819 (t
820 (funcall xref-show-definitions-function xrefs
821 `((window . ,(selected-window))
822 (display-action . ,display-action))))))
823 829
824(defun xref--prompt-p (command) 830(defun xref--prompt-p (command)
825 (or (eq xref-prompt-for-identifier t) 831 (or (eq xref-prompt-for-identifier t)