unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#36974: 26.2.90; [PATCH] Add imenu support to xref
@ 2019-08-08 11:53 Damien Cassou
  2019-08-23  4:32 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 11+ messages in thread
From: Damien Cassou @ 2019-08-08 11:53 UTC (permalink / raw)
  To: 36974

[-- Attachment #1: Type: text/plain, Size: 421 bytes --]

* 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.

-- 
Damien Cassou
Företagsplatsen AB
Phone/Fax: +46 (0)8 774 63 00
Mobile: +33 (0)6 80 50 18 91
Address: Skeppsbron 26, 4tr, SE-111 30 Stockholm
Web: www.foretagsplatsen.se

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-imenu-support-to-xref.patch --]
[-- Type: text/x-patch, Size: 2921 bytes --]

From e7def47af8c5d8dfedadc5079d1f791c709b2be8 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Thu, 8 Aug 2019 13:42:20 +0200
Subject: [PATCH] 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.
---
 etc/NEWS               |  5 +++++
 lisp/progmodes/xref.el | 23 +++++++++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 818875f7a0..50b2a0f76d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1810,6 +1810,11 @@ This results in the use of Gravatar's default size of 80 pixels.
 This is possible using the new user options 'gravatar-default-image'
 and 'gravatar-force-default'.
 
+** xref
+
+---
+*** Imenu support has been added to 'xref--xref-buffer-mode'.
+
 \f
 * New Modes and Packages in Emacs 27.1
 
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 57d803894c..c00622f747 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -728,7 +728,11 @@ xref--xref-buffer-mode
   "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
+        #'xref--imenu-prev-index-position)
+  (setq imenu-extract-index-name-function
+        #'xref--imenu-extract-index-name))
 
 (defvar xref--transient-buffer-mode-map
   (let ((map (make-sparse-keymap)))
@@ -740,6 +744,21 @@ xref--transient-buffer-mode
   xref--xref-buffer-mode
   "XREF Transient")
 
+(defun xref--imenu-prev-index-position ()
+  "Move point to previous line in `xref' buffer.
+This function is used as a value for
+`imenu-prev-index-position-function'."
+  (if (bobp)
+      nil
+    (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) (line-end-position)))
+
 (defun xref--next-error-function (n reset?)
   (when reset?
     (goto-char (point-min)))
@@ -789,7 +808,7 @@ xref--insert-xrefs
            for line-format = (and max-line-width
                                   (format "%%%dd: " max-line-width))
            do
-           (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))
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-12-27 14:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-08 11:53 bug#36974: 26.2.90; [PATCH] Add imenu support to xref Damien Cassou
2019-08-23  4:32 ` Lars Ingebrigtsen
2019-12-24 20:41   ` Dmitry Gutov
2019-12-25 16:17     ` Lars Ingebrigtsen
2019-12-25 16:29       ` Dmitry Gutov
2019-12-25 16:43         ` Dmitry Gutov
2019-12-25 17:10           ` Lars Ingebrigtsen
2019-12-27 10:11     ` Damien Cassou
2019-12-27 13:50       ` Dmitry Gutov
2019-12-27 14:24         ` Damien Cassou
2019-12-27 14:32           ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).