File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ To enable then simply add the following to your init file:
21
21
22
22
``` emacs-lisp
23
23
(require 'ivy-xref)
24
+ ;; Emacs 27 only:
25
+ (setq xref-show-definitions-function #'ivy-xref-show-defs)
26
+ ;; Necessary in Emacs <27. In Emacs 27 it will affect all xref-based commands
27
+ ;; other than xref-find-definitions (e.g. project-find-regexp):
24
28
(setq xref-show-xrefs-function #'ivy-xref-show-xrefs)
25
29
```
26
30
Original file line number Diff line number Diff line change 77
77
(nreverse collection)))
78
78
79
79
;;;### autoload
80
- (defun ivy-xref-show-xrefs (xrefs alist )
81
- " Show the list of XREFS and ALIST via ivy."
80
+ (defun ivy-xref-show-xrefs (fetcher alist )
81
+ " Show the list of xrefs returned by FETCHER and ALIST via ivy."
82
82
; ; call the original xref--show-xref-buffer so we can be used with
83
83
; ; dired-do-find-regexp-and-replace etc which expects to use the normal xref
84
84
; ; results buffer but then bury it and delete the window containing it
85
85
; ; immediately since we don't want to see it - see
86
86
; ; https://github.com/alexmurray/ivy-xref/issues/2
87
- (let ((buffer (xref--show-xref-buffer xrefs alist)))
87
+ (let* ((xrefs (if (functionp fetcher)
88
+ ; ; Emacs 27
89
+ (or (assoc-default 'fetched-xrefs alist)
90
+ (funcall fetcher))
91
+ fetcher))
92
+ (buffer (xref--show-xref-buffer fetcher alist)))
88
93
(quit-window )
89
94
(let ((orig-buf (current-buffer ))
90
95
(orig-pos (point ))
113
118
; ; return value
114
119
buffer))
115
120
121
+ ;;;### autoload
122
+ (defun ivy-xref-show-defs (fetcher alist )
123
+ (let ((xrefs (funcall fetcher)))
124
+ (cond
125
+ ((not (cdr xrefs))
126
+ (xref-pop-to-location (car xrefs)
127
+ (assoc-default 'display-action alist)))
128
+ (t
129
+ (ivy-xref-show-xrefs fetcher
130
+ (cons (cons 'fetched-xrefs xrefs)
131
+ alist))))))
132
+
116
133
(provide 'ivy-xref )
117
134
; ;; ivy-xref.el ends here
You can’t perform that action at this time.
0 commit comments