emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 6e0080e: Add commands xref-next-group and xref-prev-group


From: Lars Ingebrigtsen
Subject: master 6e0080e: Add commands xref-next-group and xref-prev-group
Date: Mon, 7 Dec 2020 11:01:52 -0500 (EST)

branch: master
commit 6e0080e755b460adc7a1fda74e26f83cb342b6dc
Author: Daniel Martín <mardani29@yahoo.es>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add commands xref-next-group and xref-prev-group
    
    * lisp/progmodes/xref.el (xref-next-group): New command that navigates
    to the first item of the next xref group (typically a file).
    (xref-prev-group): New command that navigates
    to the first item of the next xref group (typically a file).
    (xref--xref-buffer-mode-map): Bound the new commands to 'N' and 'P',
    respectively.
    * doc/emacs/maintaining.texi (Xref Commands): Document the new
    commands in the Emacs manual.
    * etc/NEWS: Announce them (bug#45089).
---
 doc/emacs/maintaining.texi | 10 ++++++++++
 etc/NEWS                   |  5 +++++
 lisp/progmodes/xref.el     | 21 +++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 1f10b68..aa4513e 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -2199,12 +2199,22 @@ Display the reference on the current line.
 Move to the next reference and display it in the other window
 (@code{xref-next-line}).
 
+@item N
+@findex xref-next-group
+Move to the first reference of the next reference group and display it
+in the other window (@code{xref-next-group}).
+
 @item p
 @itemx ,
 @findex xref-prev-line
 Move to the previous reference and display it in the other window
 (@code{xref-prev-line}).
 
+@item P
+@findex xref-prev-group
+Move to the first reference of the previous reference group and
+display it in the other window (@code{xref-prev-group}).
+
 @item C-o
 @findex xref-show-location-at-point
 Display the reference on the current line in the other window
diff --git a/etc/NEWS b/etc/NEWS
index 49d66cc..c80325c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1205,6 +1205,11 @@ So far Grep and ripgrep are supported.  ripgrep seems to 
offer better
 performance in certain cases, in particular for case-insensitive
 searches.
 
++++
+*** New commands 'xref-prev-group' and 'xref-next-group'.
+These commands are bound respectively to 'P' and 'N', and navigate to
+the first item of the previous or next group in the "*xref*" buffer.
+
 ** json.el
 
 ---
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 9f5fc57..389b7cf 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -593,6 +593,25 @@ SELECT is `quit', also quit the *xref* window."
   (xref--search-property 'xref-item t)
   (xref-show-location-at-point))
 
+(defun xref-next-group ()
+  "Move to the first item of the next xref group and display its source."
+  (interactive)
+  (xref--search-property 'xref-group)
+  (xref--search-property 'xref-item)
+  (xref-show-location-at-point))
+
+(defun xref-prev-group ()
+  "Move to the first item of the previous xref group and display its source."
+  (interactive)
+  ;; Search for the xref group of the current item, provided that the
+  ;; point is not already in an xref group.
+  (unless (plist-member (text-properties-at (point)) 'xref-group)
+    (xref--search-property 'xref-group t))
+  ;; Search for the previous xref group.
+  (xref--search-property 'xref-group t)
+  (xref--search-property 'xref-item)
+  (xref-show-location-at-point))
+
 (defun xref--item-at-point ()
   (save-excursion
     (back-to-indentation)
@@ -738,6 +757,8 @@ references displayed in the current *xref* buffer."
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "n") #'xref-next-line)
     (define-key map (kbd "p") #'xref-prev-line)
+    (define-key map (kbd "N") #'xref-next-group)
+    (define-key map (kbd "P") #'xref-prev-group)
     (define-key map (kbd "r") #'xref-query-replace-in-results)
     (define-key map (kbd "RET") #'xref-goto-xref)
     (define-key map (kbd "TAB")  #'xref-quit-and-goto-xref)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]