diff options
| -rw-r--r-- | doc/emacs/maintaining.texi | 7 | ||||
| -rw-r--r-- | etc/NEWS | 10 | ||||
| -rw-r--r-- | lisp/progmodes/xref.el | 24 |
3 files changed, 34 insertions, 7 deletions
diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index dc0a71511ff..112f1f4d9ed 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi | |||
| @@ -1887,8 +1887,7 @@ the special XREF mode: | |||
| 1887 | @table @kbd | 1887 | @table @kbd |
| 1888 | @item @key{RET} | 1888 | @item @key{RET} |
| 1889 | @itemx mouse-2 | 1889 | @itemx mouse-2 |
| 1890 | Display the reference on the current line and bury the @file{*xref*} | 1890 | Display the reference on the current line. |
| 1891 | buffer. | ||
| 1892 | @item n | 1891 | @item n |
| 1893 | @itemx . | 1892 | @itemx . |
| 1894 | @findex xref-next-line | 1893 | @findex xref-next-line |
| @@ -1903,6 +1902,10 @@ Move to the previous reference and display it in the other window | |||
| 1903 | @findex xref-show-location-at-point | 1902 | @findex xref-show-location-at-point |
| 1904 | Display the reference on the current line in the other window | 1903 | Display the reference on the current line in the other window |
| 1905 | (@code{xref-show-location-at-point}). | 1904 | (@code{xref-show-location-at-point}). |
| 1905 | @item TAB | ||
| 1906 | @findex xref-quit-and-goto-xref | ||
| 1907 | Display the reference on the current line and bury the @file{*xref*} | ||
| 1908 | buffer (@code{xref-quit-and-goto-xref}). | ||
| 1906 | @findex xref-query-replace-in-results | 1909 | @findex xref-query-replace-in-results |
| 1907 | @item r @var{pattern} @key{RET} @var{replacement} @key{RET} | 1910 | @item r @var{pattern} @key{RET} @var{replacement} @key{RET} |
| 1908 | Perform interactive query-replace on references that match | 1911 | Perform interactive query-replace on references that match |
| @@ -1213,6 +1213,16 @@ New user options `term-char-mode-buffer-read-only' and | |||
| 1213 | are non-nil by default. Customize these options to nil if you want | 1213 | are non-nil by default. Customize these options to nil if you want |
| 1214 | the previous behavior. | 1214 | the previous behavior. |
| 1215 | 1215 | ||
| 1216 | ** Xref | ||
| 1217 | |||
| 1218 | +++ | ||
| 1219 | *** When an *xref* buffer is needed, 'TAB' quits and jumps to an xref. | ||
| 1220 | |||
| 1221 | A new command 'xref-quit-and-goto-xref', bound to 'TAB' in *xref* | ||
| 1222 | buffers, quits the window before jumping to the destination. In many | ||
| 1223 | situations, the intended window configuration is restored, just as if | ||
| 1224 | the *xref* buffer hadn't been necessary in the first place. | ||
| 1225 | |||
| 1216 | 1226 | ||
| 1217 | * New Modes and Packages in Emacs 26.1 | 1227 | * New Modes and Packages in Emacs 26.1 |
| 1218 | 1228 | ||
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index ee23bc7a64e..db025d40aa3 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el | |||
| @@ -492,11 +492,17 @@ and finally return the window." | |||
| 492 | (selected-window)))) | 492 | (selected-window)))) |
| 493 | 493 | ||
| 494 | (defun xref--show-location (location &optional select) | 494 | (defun xref--show-location (location &optional select) |
| 495 | "Help `xref-show-xref' and `xref-goto-xref' do their job. | ||
| 496 | Go to LOCATION and if SELECT is non-nil select its window. If | ||
| 497 | SELECT is `quit', also quit the *xref* window." | ||
| 495 | (condition-case err | 498 | (condition-case err |
| 496 | (let* ((marker (xref-location-marker location)) | 499 | (let* ((marker (xref-location-marker location)) |
| 497 | (buf (marker-buffer marker))) | 500 | (buf (marker-buffer marker)) |
| 501 | (xref-buffer (current-buffer))) | ||
| 498 | (cond (select | 502 | (cond (select |
| 499 | (select-window (xref--show-pos-in-buf marker buf))) | 503 | (if (eq select 'quit) (quit-window nil nil)) |
| 504 | (with-current-buffer xref-buffer | ||
| 505 | (select-window (xref--show-pos-in-buf marker buf)))) | ||
| 500 | (t | 506 | (t |
| 501 | (save-selected-window | 507 | (save-selected-window |
| 502 | (xref--with-dedicated-window | 508 | (xref--with-dedicated-window |
| @@ -528,12 +534,19 @@ and finally return the window." | |||
| 528 | (back-to-indentation) | 534 | (back-to-indentation) |
| 529 | (get-text-property (point) 'xref-item))) | 535 | (get-text-property (point) 'xref-item))) |
| 530 | 536 | ||
| 531 | (defun xref-goto-xref () | 537 | (defun xref-goto-xref (&optional quit) |
| 532 | "Jump to the xref on the current line and select its window." | 538 | "Jump to the xref on the current line and select its window. |
| 539 | Non-interactively, non-nil QUIT means to first quit the *xref* | ||
| 540 | buffer." | ||
| 533 | (interactive) | 541 | (interactive) |
| 534 | (let ((xref (or (xref--item-at-point) | 542 | (let ((xref (or (xref--item-at-point) |
| 535 | (user-error "No reference at point")))) | 543 | (user-error "No reference at point")))) |
| 536 | (xref--show-location (xref-item-location xref) t))) | 544 | (xref--show-location (xref-item-location xref) (if quit 'quit t)))) |
| 545 | |||
| 546 | (defun xref-quit-and-goto-xref () | ||
| 547 | "Quit *xref* buffer, then jump to xref on current line." | ||
| 548 | (interactive) | ||
| 549 | (xref-goto-xref t)) | ||
| 537 | 550 | ||
| 538 | (defun xref-query-replace-in-results (from to) | 551 | (defun xref-query-replace-in-results (from to) |
| 539 | "Perform interactive replacement of FROM with TO in all displayed xrefs. | 552 | "Perform interactive replacement of FROM with TO in all displayed xrefs. |
| @@ -657,6 +670,7 @@ references displayed in the current *xref* buffer." | |||
| 657 | (define-key map (kbd "p") #'xref-prev-line) | 670 | (define-key map (kbd "p") #'xref-prev-line) |
| 658 | (define-key map (kbd "r") #'xref-query-replace-in-results) | 671 | (define-key map (kbd "r") #'xref-query-replace-in-results) |
| 659 | (define-key map (kbd "RET") #'xref-goto-xref) | 672 | (define-key map (kbd "RET") #'xref-goto-xref) |
| 673 | (define-key map (kbd "TAB") #'xref-quit-and-goto-xref) | ||
| 660 | (define-key map (kbd "C-o") #'xref-show-location-at-point) | 674 | (define-key map (kbd "C-o") #'xref-show-location-at-point) |
| 661 | ;; suggested by Johan Claesson "to further reduce finger movement": | 675 | ;; suggested by Johan Claesson "to further reduce finger movement": |
| 662 | (define-key map (kbd ".") #'xref-next-line) | 676 | (define-key map (kbd ".") #'xref-next-line) |