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

* bug#36974: 26.2.90; [PATCH] Add imenu support to xref
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Lars Ingebrigtsen @ 2019-08-23  4:32 UTC (permalink / raw)
  To: Damien Cassou; +Cc: 36974

Damien Cassou <damien@cassou.me> writes:

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

I'm not a big imenu user, so I'm probably not the best to judge the
applicability of this patch, but it looked logical to me, and I've
applied the patch (after folding a couple of too-long lines).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#36974: 26.2.90; [PATCH] Add imenu support to xref
  2019-08-23  4:32 ` Lars Ingebrigtsen
@ 2019-12-24 20:41   ` Dmitry Gutov
  2019-12-25 16:17     ` Lars Ingebrigtsen
  2019-12-27 10:11     ` Damien Cassou
  0 siblings, 2 replies; 11+ messages in thread
From: Dmitry Gutov @ 2019-12-24 20:41 UTC (permalink / raw)
  To: Lars Ingebrigtsen, Damien Cassou; +Cc: 36974

On 23.08.2019 7:32, Lars Ingebrigtsen wrote:
> Damien Cassou<damien@cassou.me>  writes:
> 
>> * 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.
> I'm not a big imenu user, so I'm probably not the best to judge the
> applicability of this patch, but it looked logical to me, and I've
> applied the patch (after folding a couple of too-long lines).

This patch had a typo which made it not work at all (which is easy to 
see by calling 'M-x imenu' in any of the Xref buffers).

Considering it's been applied 4 months ago and nobody noticed the 
problem, maybe it's not that useful after all?





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

* bug#36974: 26.2.90; [PATCH] Add imenu support to xref
  2019-12-24 20:41   ` Dmitry Gutov
@ 2019-12-25 16:17     ` Lars Ingebrigtsen
  2019-12-25 16:29       ` Dmitry Gutov
  2019-12-27 10:11     ` Damien Cassou
  1 sibling, 1 reply; 11+ messages in thread
From: Lars Ingebrigtsen @ 2019-12-25 16:17 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Damien Cassou, 36974

Dmitry Gutov <dgutov@yandex.ru> writes:

> This patch had a typo which made it not work at all (which is easy to
> see by calling 'M-x imenu' in any of the Xref buffers).

I get

imenu-unavailable-error: imenu unavailable: "No items suitable for an
index found in this buffer"

when I say `M-x imenu' in an xref buffer, but I assumed that was
expected. 

> Considering it's been applied 4 months ago and nobody noticed the
> problem, maybe it's not that useful after all?

Possibly?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#36974: 26.2.90; [PATCH] Add imenu support to xref
  2019-12-25 16:17     ` Lars Ingebrigtsen
@ 2019-12-25 16:29       ` Dmitry Gutov
  2019-12-25 16:43         ` Dmitry Gutov
  0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Gutov @ 2019-12-25 16:29 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Damien Cassou, 36974

On 25.12.2019 18:17, Lars Ingebrigtsen wrote:
> I get
> 
> imenu-unavailable-error: imenu unavailable: "No items suitable for an
> index found in this buffer"
> 
> when I say `M-x imenu' in an xref buffer, but I assumed that was
> expected.

Do you get it still?

It should error out because the implementation in this patch offers all 
file names as imenu entries. And there must be at least one.





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

* bug#36974: 26.2.90; [PATCH] Add imenu support to xref
  2019-12-25 16:29       ` Dmitry Gutov
@ 2019-12-25 16:43         ` Dmitry Gutov
  2019-12-25 17:10           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Gutov @ 2019-12-25 16:43 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Damien Cassou, 36974

Sorry,

On 25.12.2019 18:29, Dmitry Gutov wrote:
> On 25.12.2019 18:17, Lars Ingebrigtsen wrote:
>> I get
>>
>> imenu-unavailable-error: imenu unavailable: "No items suitable for an
>> index found in this buffer"
>>
>> when I say `M-x imenu' in an xref buffer, but I assumed that was
>> expected.
> 
> Do you get it still?
> 
> It should error out ... 

      ^ shouldn't





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

* bug#36974: 26.2.90; [PATCH] Add imenu support to xref
  2019-12-25 16:43         ` Dmitry Gutov
@ 2019-12-25 17:10           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 11+ messages in thread
From: Lars Ingebrigtsen @ 2019-12-25 17:10 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Damien Cassou, 36974

Dmitry Gutov <dgutov@yandex.ru> writes:

>>> when I say `M-x imenu' in an xref buffer, but I assumed that was
>>> expected.
>> Do you get it still?
>> It should error out ... 
>
>      ^ shouldn't

Ah; no, it seems to work now.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#36974: 26.2.90; [PATCH] Add imenu support to xref
  2019-12-24 20:41   ` Dmitry Gutov
  2019-12-25 16:17     ` Lars Ingebrigtsen
@ 2019-12-27 10:11     ` Damien Cassou
  2019-12-27 13:50       ` Dmitry Gutov
  1 sibling, 1 reply; 11+ messages in thread
From: Damien Cassou @ 2019-12-27 10:11 UTC (permalink / raw)
  To: Dmitry Gutov, Lars Ingebrigtsen; +Cc: 36974

Dmitry Gutov <dgutov@yandex.ru> writes:
> This patch had a typo which made it not work at all (which is easy to 
> see by calling 'M-x imenu' in any of the Xref buffers).


can you please tell what typo you are referring to? Also, when you say
"had" a typo, do you mean someone fixed it somewhere? Can you please
give a little more details? I can't find any fix.


> Considering it's been applied 4 months ago and nobody noticed the 
> problem, maybe it's not that useful after all?


I haven't switched to Emacs 27 yet.

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill





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

* bug#36974: 26.2.90; [PATCH] Add imenu support to xref
  2019-12-27 10:11     ` Damien Cassou
@ 2019-12-27 13:50       ` Dmitry Gutov
  2019-12-27 14:24         ` Damien Cassou
  0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Gutov @ 2019-12-27 13:50 UTC (permalink / raw)
  To: Damien Cassou, Lars Ingebrigtsen; +Cc: 36974

On 27.12.2019 12:11, Damien Cassou wrote:
> can you please tell what typo you are referring to? Also, when you say
> "had" a typo, do you mean someone fixed it somewhere? Can you please
> give a little more details? I can't find any fix.

It's this one:

commit 9ea9ac9a61067995a3f7a38f62766f32a8c38bb2
Author: Dmitry Gutov <dgutov@yandex.ru>
Date:   Tue Dec 24 22:30:02 2019 +0200

     Apply the 'xref-group' property properly

     * lisp/progmodes/xref.el (xref--insert-xrefs):
     Apply the 'xref-group' property properly (bug#36974).

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 8d8e7ab208..13a1600594 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -814,7 +814,7 @@ xref--insert-xrefs
             for line-format = (and max-line-width
                                    (format "%%%dd: " max-line-width))
             do
-           (xref--insert-propertized '(face xref-file-header 'xref-group t)
+           (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

>> Considering it's been applied 4 months ago and nobody noticed the
>> problem, maybe it's not that useful after all?
> 
> 
> I haven't switched to Emacs 27 yet.

I hope you were going to do that before the release.





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

* bug#36974: 26.2.90; [PATCH] Add imenu support to xref
  2019-12-27 13:50       ` Dmitry Gutov
@ 2019-12-27 14:24         ` Damien Cassou
  2019-12-27 14:32           ` Dmitry Gutov
  0 siblings, 1 reply; 11+ messages in thread
From: Damien Cassou @ 2019-12-27 14:24 UTC (permalink / raw)
  To: Dmitry Gutov, Lars Ingebrigtsen; +Cc: 36974

Dmitry Gutov <dgutov@yandex.ru> writes:
> On 27.12.2019 12:11, Damien Cassou wrote:
>> can you please tell what typo you are referring to? Also, when you say
>> "had" a typo, do you mean someone fixed it somewhere? Can you please
>> give a little more details? I can't find any fix.
>
> It's this one: […]



ok. I guess I only checked my patch in Emacs 26 and not in Emacs
27. Sorry about that.


>> I haven't switched to Emacs 27 yet.
>
> I hope you were going to do that before the release.

I have done that some hours ago.

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill





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

* bug#36974: 26.2.90; [PATCH] Add imenu support to xref
  2019-12-27 14:24         ` Damien Cassou
@ 2019-12-27 14:32           ` Dmitry Gutov
  0 siblings, 0 replies; 11+ messages in thread
From: Dmitry Gutov @ 2019-12-27 14:32 UTC (permalink / raw)
  To: Damien Cassou, Lars Ingebrigtsen; +Cc: 36974

On 27.12.2019 16:24, Damien Cassou wrote:
> ok. I guess I only checked my patch in Emacs 26 and not in Emacs
> 27. Sorry about that.

Um. I don't think it should have worked in either version. Could be 
mistaken, though.

> I have done that some hours ago.

Cool.





^ permalink raw reply	[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).