aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2019-02-04 22:52:25 +0000
committerJoão Távora2019-02-06 22:50:02 +0000
commit94b320849e9655db110ed74ca73974c78f95428a (patch)
treeff9d5c15d74e33571b1f34a1e9b3eb24e5b130de
parent6ed9d0057d9a8ef1331049c55d5df3cc4e02c5f2 (diff)
downloademacs-94b320849e9655db110ed74ca73974c78f95428a.tar.gz
emacs-94b320849e9655db110ed74ca73974c78f95428a.zip
Make window choice in xref commands configurable
Previously, it wasn't easy to tell xref.el commands like xref-find-definitions or xref-find-definitions-other-window how to choose a window for the *xref* buffer or how to find windows for displaying the results after choosing a candidate. This patch makes that task easier, but keeps the current behaviour intact. Co-authored-by: João Távora <joaotavora@gmail.com> * lisp/progmodes/xref.el (xref--show-pos-in-buf): Simplify.
-rw-r--r--lisp/progmodes/xref.el22
1 files changed, 6 insertions, 16 deletions
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 87ce2299c56..9522d7e475b 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -474,27 +474,17 @@ and finally return the window."
474 (or (eq xref--original-window-intent 'frame) 474 (or (eq xref--original-window-intent 'frame)
475 pop-up-frames)) 475 pop-up-frames))
476 (action 476 (action
477 (cond ((memq 477 (cond ((eq xref--original-window-intent 'frame)
478 xref--original-window-intent
479 '(window frame))
480 t) 478 t)
479 ((eq xref--original-window-intent 'window)
480 '(display-buffer-same-window))
481 ((and 481 ((and
482 (window-live-p xref--original-window) 482 (window-live-p xref--original-window)
483 (or (not (window-dedicated-p xref--original-window)) 483 (or (not (window-dedicated-p xref--original-window))
484 (eq (window-buffer xref--original-window) buf))) 484 (eq (window-buffer xref--original-window) buf)))
485 `(,(lambda (buf _alist) 485 `((display-buffer-in-previous-window)
486 (set-window-buffer xref--original-window buf) 486 (previous-window . ,xref--original-window))))))
487 xref--original-window)))))) 487 (with-selected-window (display-buffer buf action)
488 (with-selected-window
489 (with-selected-window
490 ;; Just before `display-buffer', place ourselves in the
491 ;; original window to suggest preserving it. Of course, if
492 ;; user has deleted the original window, all bets are off,
493 ;; just use the selected one.
494 (or (and (window-live-p xref--original-window)
495 xref--original-window)
496 (selected-window))
497 (display-buffer buf action))
498 (xref--goto-char pos) 488 (xref--goto-char pos)
499 (run-hooks 'xref-after-jump-hook) 489 (run-hooks 'xref-after-jump-hook)
500 (let ((buf (current-buffer))) 490 (let ((buf (current-buffer)))