Subject: bug#76565: 30.1; emacs xref: cannot jump back to the previous position when `xref-history-storage' is set to `xref-window-local-history'

From: Guoyu Ou <[email-masked]>
Date: Tue, 25 Feb 2025 22:36:27 +0800

Dear maintainers,

I installed emacs 30.1 from debian sid, and found that xref cannot jump
back to the previous position when `xref-history-storage` is set to
`xref-window-local-history`. It works in emacs 29.4 with xref 1.6.3.

### settings and tests

The following is my `~/.emacs`:

```lisp
(when (>= emacs-major-version 29)
  (setq xref-history-storage 'xref-window-local-history))
```

And two c++ files for reproducing this bug:

content of `func-def.cpp`:

```c++
void func() {
}

void func(int) {
}
```

and `main.cpp`:

```c++
int main() {
  func();
}
```

### how to reproduce

Use the following command to generate a `TAGS` file:

```bash
/usr/bin/etags *.cpp
```

Then run

```bash
emacs -Q
```

open `main.cpp` and move the cursor to the word `func` and run

   M-x xref-find-definitions

a `*xref*` buffer is opened and shows two candidates of `func`.

Then I press `n RET` in the `*xref*` buffer to choose the first
candidate in the xref buffer.

Now the cursor is in a new buffer named `func-def.cpp`. Then I press
`M-,` and a message "At start of xref history" is shown in the
minibuffer.

In emacs 29.4 I can jump back to `main.cpp` when pressing `M-,`.

--
Best Regards,
Guoyu