diff options
| author | Dmitry Gutov | 2025-03-02 05:22:56 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2025-03-02 05:22:56 +0200 |
| commit | 625ed68aeaadce4df7bdfd8c08ddfc8ed4f9b01a (patch) | |
| tree | 67d8da385325d963b3f12065980bc5c010dbf2f3 | |
| parent | 8091772767666f2c671a8ba481d50859388152db (diff) | |
| download | emacs-625ed68aeaadce4df7bdfd8c08ddfc8ed4f9b01a.tar.gz emacs-625ed68aeaadce4df7bdfd8c08ddfc8ed4f9b01a.zip | |
Fix the use of xref-window-local-history together with Xref buffer
* lisp/progmodes/xref.el (xref--push-markers): Temporarily
restore the selected window as well, using the value from the
new argument (bug#76565). Update both callers.
| -rw-r--r-- | lisp/progmodes/xref.el | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index e5f583f0103..4c27aff06a4 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el | |||
| @@ -1516,31 +1516,40 @@ The meanings of both arguments are the same as documented in | |||
| 1516 | xrefs | 1516 | xrefs |
| 1517 | (setq xrefs 'called-already))))))) | 1517 | (setq xrefs 'called-already))))))) |
| 1518 | (let ((cb (current-buffer)) | 1518 | (let ((cb (current-buffer)) |
| 1519 | (pt (point))) | 1519 | (pt (point)) |
| 1520 | (win (selected-window))) | ||
| 1520 | (prog1 | 1521 | (prog1 |
| 1521 | (funcall xref-show-xrefs-function fetcher | 1522 | (funcall xref-show-xrefs-function fetcher |
| 1522 | `((window . ,(selected-window)) | 1523 | `((window . ,win) |
| 1523 | (display-action . ,display-action) | 1524 | (display-action . ,display-action) |
| 1524 | (auto-jump . ,xref-auto-jump-to-first-xref))) | 1525 | (auto-jump . ,xref-auto-jump-to-first-xref))) |
| 1525 | (xref--push-markers cb pt)))) | 1526 | (xref--push-markers cb pt win)))) |
| 1526 | 1527 | ||
| 1527 | (defun xref--show-defs (xrefs display-action) | 1528 | (defun xref--show-defs (xrefs display-action) |
| 1528 | (let ((cb (current-buffer)) | 1529 | (let ((cb (current-buffer)) |
| 1529 | (pt (point))) | 1530 | (pt (point)) |
| 1531 | (win (selected-window))) | ||
| 1530 | (prog1 | 1532 | (prog1 |
| 1531 | (funcall xref-show-definitions-function xrefs | 1533 | (funcall xref-show-definitions-function xrefs |
| 1532 | `((window . ,(selected-window)) | 1534 | `((window . ,win) |
| 1533 | (display-action . ,display-action) | 1535 | (display-action . ,display-action) |
| 1534 | (auto-jump . ,xref-auto-jump-to-first-definition))) | 1536 | (auto-jump . ,xref-auto-jump-to-first-definition))) |
| 1535 | (xref--push-markers cb pt)))) | 1537 | (xref--push-markers cb pt win)))) |
| 1536 | 1538 | ||
| 1537 | (defun xref--push-markers (buf pt) | 1539 | (defun xref--push-markers (buf pt win) |
| 1538 | (when (buffer-live-p buf) | 1540 | (when (buffer-live-p buf) |
| 1539 | (save-excursion | 1541 | ;; This was we support the `xref-history-storage' getter which |
| 1540 | (with-no-warnings (set-buffer buf)) | 1542 | ;; depends on the selected window. This is getting pretty complex, |
| 1541 | (goto-char pt) | 1543 | ;; though. The alternative approach to try would be to push early |
| 1542 | (unless (region-active-p) (push-mark nil t)) | 1544 | ;; but undo the stack insertion and mark-pushing in error handler. |
| 1543 | (xref-push-marker-stack)))) | 1545 | (save-window-excursion |
| 1546 | (when (window-live-p win) | ||
| 1547 | (select-window win)) | ||
| 1548 | (save-excursion | ||
| 1549 | (with-no-warnings (set-buffer buf)) | ||
| 1550 | (goto-char pt) | ||
| 1551 | (unless (region-active-p) (push-mark nil t)) | ||
| 1552 | (xref-push-marker-stack))))) | ||
| 1544 | 1553 | ||
| 1545 | (defun xref--prompt-p (command) | 1554 | (defun xref--prompt-p (command) |
| 1546 | (or (eq xref-prompt-for-identifier t) | 1555 | (or (eq xref-prompt-for-identifier t) |