-
Notifications
You must be signed in to change notification settings - Fork 245
Emacs Xref improvements #1385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emacs Xref improvements #1385
Conversation
|
With the last part of this PR, xref can now more easily be used for looking up definitions and occurrences of operators. |
|
@rgrinberg I requested your review since you appear to be the author of the initial xref support. |
|
I don't use any Emacs anymore and don't remember much of elisp. I think we need to find someone else to review unfortunately. |
|
Tell me if there is anything more I should do with the patch set. I did consult the author of the Xref facility in Emacs for how best to use the interface in a way that's compatible with different versions. |
|
The changes look good to me. |
Allow xref operations initiated from a mouse click to work correctly by encoding the location of a selected identifier in a string property on that identifier.
Use `xref-file-location` instead of `xref-buffer-location` since the former gives line numbers and nicer display when there are multiple matches on the same line. Since Emacs 28, we have to partition the line when populating the `summary` field. Use the `match` face for highlighting if `xref-match` isn't available (for Emacs 26 or older).
This will be used for `xref-find-references` (`M-?`), although that command currently ignores the string and only uses the location. If an identifier both succeeds and precedes point, prefer the former. For instance, in `a+b` with the cursor on `+`, use `+` as the idenfier; with the cursor on `b`, use `b`.
For some reason, the occurrences command output sometimes contains bogus locations (line 0, col -1). It really shouldn't, but filter them out until that has been fixed (ocaml#1410).
|
Not sure what this patch is waiting for – all rather straightforward things I thought. Anyway, it's up to date with master. |
|
@rgrinberg Can you help us to get this merged? |
Done. |
from mattiase/xref
CHANGES:
Fri Feb 24 16:55:42 CEST 2023
+ merlin binary
- Recognize OCaml 5.0 cmi magic number in compiler version mismatch message
(ocaml/merlin#1554, fixes ocaml/merlin#1553)
- Upgrade Merlin from the RC2 to the stable 5.0.0 compiler release (ocaml/merlin#1559,
fixes ocaml/merlin#1558)
- Improve type-enclosing behaviour when used on records' labels (ocaml/merlin#1565,
fixes ocaml/merlin#1564)
- Restore compatibility with the compiler's command line by accepting the
`-safe-string` flag as a no-op instead of rejecting it (ocaml/merlin#1544, fixes
ocaml/merlin#1518)
- Traverse aliases when jumping to declaration. This matches
jump-to-definition's behavior (ocaml/merlin#1563)
- Improve locate's behavior in various ill-typed expressions (ocaml/merlin#1546, fixes
ocaml/merlin#1567 and partially ocaml/merlin#1543)
- Correctly traverse patterns when looking for docs in the typedtree (ocaml/merlin#1572)
- Get documentation when the declaration or definition is selected (ocaml/merlin#1542,
fixes ocaml/merlin#1540)
- On Windows, change to a harmless directory when launching server to avoid
locking down current directory (ocaml/merlin#1569, fixes ocaml/merlin#1474)
+ editor modes
- emacs: Fix misuse of `eq` comparison (ocaml/merlin#1549, @mattiase)
- emacs: xref works from context menus; better highlighting of xref matches;
xref recognises operators and binding operators at the cursor position;
bad locations are filtered out (ocaml/merlin#1385, fixes ocaml/merlin#1410, @mattiase)
+ test suite
- Add a test for incorrect alert defaults (ocaml/merlin#1559)
- Add multiple tests for locate over ill-typed expressions (ocaml/merlin#1546)
- Add non-regression tests for other fixes in this release
CHANGES:
Fri Feb 24 16:55:42 CEST 2023
+ merlin binary
- Recognize OCaml 5.0 cmi magic number in compiler version mismatch message
(ocaml/merlin#1554, fixes ocaml/merlin#1553)
- Upgrade Merlin from the RC2 to the stable 5.0.0 compiler release (ocaml/merlin#1559,
fixes ocaml/merlin#1558)
- Improve type-enclosing behaviour when used on records' labels (ocaml/merlin#1565,
fixes ocaml/merlin#1564)
- Restore compatibility with the compiler's command line by accepting the
`-safe-string` flag as a no-op instead of rejecting it (ocaml/merlin#1544, fixes
ocaml/merlin#1518)
- Traverse aliases when jumping to declaration. This matches
jump-to-definition's behavior (ocaml/merlin#1563)
- Improve locate's behavior in various ill-typed expressions (ocaml/merlin#1546, fixes
ocaml/merlin#1567 and partially ocaml/merlin#1543)
- Correctly traverse patterns when looking for docs in the typedtree (ocaml/merlin#1572)
- Get documentation when the declaration or definition is selected (ocaml/merlin#1542,
fixes ocaml/merlin#1540)
- On Windows, change to a harmless directory when launching server to avoid
locking down current directory (ocaml/merlin#1569, fixes ocaml/merlin#1474)
+ editor modes
- emacs: Fix misuse of `eq` comparison (ocaml/merlin#1549, @mattiase)
- emacs: xref works from context menus; better highlighting of xref matches;
xref recognises operators and binding operators at the cursor position;
bad locations are filtered out (ocaml/merlin#1385, fixes ocaml/merlin#1410, @mattiase)
+ test suite
- Add a test for incorrect alert defaults (ocaml/merlin#1559)
- Add multiple tests for locate over ill-typed expressions (ocaml/merlin#1546)
- Add non-regression tests for other fixes in this release
from mattiase/xref
from mattiase/xref
Fix uses of Xref from mouse events, such as the context menu new in Emacs 28, by implementing the necessary methods and smuggle the buffer position in a text property of the string.
We also get better highlighting of Xref hits in the target buffer by taking advantage of a bug fixed in Emacs 28.