Commit 1071dfe1 authored by Damien Cassou's avatar Damien Cassou Committed by Lars Ingebrigtsen

Add imenu support to xref

* lisp/progmodes/xref.el (xref--imenu-prev-index-position)
(xref--imenu-extract-index-name): Add functions to get imenu support.
(xref--xref-buffer-mode): Set imenu variables to the new functions.
* etc/NEWS: Add corresponding entry (bug#36974).
parent fbbc2571
Pipeline #2946 failed with stage
in 90 minutes and 1 second
......@@ -1849,6 +1849,11 @@ and 'gravatar-force-default'.
*** The built-in ada-mode is now deleted. The Gnu ELPA package is a
good replacement, even in very large source files.
** xref
*** Imenu support has been added to 'xref--xref-buffer-mode'.
* New Modes and Packages in Emacs 27.1
......@@ -728,7 +728,11 @@ references displayed in the current *xref* buffer."
"Mode for displaying cross-references."
(setq buffer-read-only t)
(setq next-error-function #'xref--next-error-function)
(setq next-error-last-buffer (current-buffer)))
(setq next-error-last-buffer (current-buffer))
(setq imenu-prev-index-position-function
(setq imenu-extract-index-name-function
(defvar xref--transient-buffer-mode-map
(let ((map (make-sparse-keymap)))
......@@ -740,6 +744,22 @@ references displayed in the current *xref* buffer."
"XREF Transient")
(defun xref--imenu-prev-index-position ()
"Move point to previous line in `xref' buffer.
This function is used as a value for
(if (bobp)
(xref--search-property 'xref-group t)))
(defun xref--imenu-extract-index-name ()
"Return imenu name for line at point.
This function is used as a value for
`imenu-extract-index-name-function'. Point should be at the
beginning of the line."
(buffer-substring-no-properties (line-beginning-position)
(defun xref--next-error-function (n reset?)
(when reset?
(goto-char (point-min)))
......@@ -789,7 +809,8 @@ GROUP is a string for decoration purposes and XREF is an
for line-format = (and max-line-width
(format "%%%dd: " max-line-width))
(xref--insert-propertized '(face xref-file-header) group "\n")
(xref--insert-propertized '(face xref-file-header 'xref-group t)
group "\n")
(cl-loop for (xref . more2) on xrefs do
(with-slots (summary location) xref
(let* ((line (xref-location-line location))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment