From: Damien Cassou <damien@cassou.me>
To: 36974@debbugs.gnu.org
Subject: bug#36974: 26.2.90; [PATCH] Add imenu support to xref
Date: Thu, 08 Aug 2019 13:53:03 +0200 [thread overview]
Message-ID: <87h86rlvq8.fsf@cassou.me> (raw)
[-- 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
next reply other threads:[~2019-08-08 11:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-08 11:53 Damien Cassou [this message]
2019-08-23 4:32 ` bug#36974: 26.2.90; [PATCH] Add imenu support to xref 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h86rlvq8.fsf@cassou.me \
--to=damien@cassou.me \
--cc=36974@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.