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).
This commit is contained in:
parent
13651833c7
commit
6e0080e755
3 changed files with 36 additions and 0 deletions
|
@ -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
|
||||
|
|
5
etc/NEWS
5
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
|
||||
|
||||
---
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue