Skip to content

Dead code removal and minor fixes#90

Merged
xvw merged 7 commits into
tarides:mainfrom
bbatsov:cleanup-dead-code-and-minor-fixes
Mar 3, 2026
Merged

Dead code removal and minor fixes#90
xvw merged 7 commits into
tarides:mainfrom
bbatsov:cleanup-dead-code-and-minor-fixes

Conversation

@bbatsov

@bbatsov bbatsov commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

I noticed a few unused functions while going through the codebase -- I'm not sure what their original purpose was, but they seem to have become obsolete at some point (likely after the xref backend rewrite), so I cleaned them up. The removed functions are:

  • ocaml-eglot-req--PlainUri
  • ocaml-eglot-req--definition and --declaration
  • ocaml-eglot-util--ensure-is-interface
  • ocaml-eglot-util--merlin-location-to-lsp
  • unreachable 25 fallback in the search limit or chain

On top of that there are a few small fixes:

  • compare-position had a bug in the nil handling branch (the when return values were silently discarded in an implicit progn, so the function always returned 0 when either position was nil)
  • load-uri used find-file + switch-to-buffer instead of find-file-noselect, causing visible buffer flicker and spurious hook triggers
  • on-interface checked the file extension twice (once on buffer-file-name, then again via URI conversion)
  • unnecessary progn in find-identifier-in-alternate-file
  • the type display buffer re-initialized the major mode on every update (grow/shrink/verbosity), now it only switches when the mode has actually changed

bbatsov added 6 commits March 2, 2026 11:38
- ocaml-eglot-req--PlainUri (unused)
- ocaml-eglot-req--definition and --declaration (the xref backend
  uses eglot--lsp-xrefs-for-method or Merlin tunneling directly)
- ocaml-eglot-util--ensure-is-interface (only --ensure-interface
  without the -is- variant is used)
- ocaml-eglot-util--merlin-location-to-lsp (unused)
- unreachable fallback 25 in ocaml-eglot--search limit or-chain
  (ocaml-eglot-type-search-limit is always truthy)
The else branch of the if used (when a 1) (when b -1) 0 which is
an implicit progn -- only the final 0 was ever returned. When one
position was nil the function always returned 0 (equal) instead of
indicating ordering. Use cond to handle each case properly.
find-file switches the displayed buffer (causing visible flicker)
and triggers find-file-hook. Since the intent is just ensuring the
file is loaded into a buffer, find-file-noselect is sufficient and
avoids both issues.
The function checked the extension on buffer-file-name, then got
the URI, converted it back to a path, and checked the same
extension again via is-interface. The inner call was always
redundant. Also avoids the unnecessary eglot call when the buffer
has no file or isn't an interface.
The type display buffer called (funcall current-major-mode) on
every update (grow, shrink, verbosity change), which re-runs all
mode hooks. Only switch when the mode has actually changed.
@xvw

xvw commented Mar 2, 2026

Copy link
Copy Markdown
Member

Thanks a lot!
(I think it deserve a small change entry ?)

@bbatsov

bbatsov commented Mar 2, 2026

Copy link
Copy Markdown
Contributor Author

Sure! I don't normally add changelog entries in my projects for changes that are internal (not user-visible), but I can certainly add something here (and for #91 as well).

bbatsov added a commit to bbatsov/ocaml-eglot that referenced this pull request Mar 2, 2026
bbatsov added a commit to bbatsov/ocaml-eglot that referenced this pull request Mar 2, 2026
bbatsov added a commit to bbatsov/ocaml-eglot that referenced this pull request Mar 2, 2026
@bbatsov bbatsov force-pushed the cleanup-dead-code-and-minor-fixes branch from ece9d8c to 1f18f70 Compare March 2, 2026 17:35
bbatsov added a commit to bbatsov/ocaml-eglot that referenced this pull request Mar 2, 2026
@bbatsov

bbatsov commented Mar 2, 2026

Copy link
Copy Markdown
Contributor Author

I've added changelog entries under a new "Unreleased" section as requested. These will likely cause a minor merge conflict with #91 once one of them lands, but that's easy to resolve.

@xvw xvw merged commit bbd10ff into tarides:main Mar 3, 2026
5 checks passed
@bbatsov bbatsov deleted the cleanup-dead-code-and-minor-fixes branch March 3, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants