Some language servers use the "untitled:" URI scheme for unsaved
documents. Handle these in window/showDocument and workspace/applyEdit
by creating suitably named buffers, applying edits to them
unconditionally (no diff, no confirmation), and returning early if
nothing else remains in the batch.
* lisp/progmodes/eglot.el (eglot--untitled-buffer): New helper.
(eglot-handle-request): Refactor, handle :untitled URI's.
(eglot--apply-workspace-edit): Make so-called 'untitled-text-edit's
Most of these tests are for the scontrol/"anxious continuation"
mechanism
The new ERT tests use Python subprocesses via stdin/stdout pipe as
JSONRPC endpoints. A shared framing library lives in
jsonrpc-resources/common.py.
* test/lisp/jsonrpc-tests.el (jsonrpc--test-dir): New constant.
(jsonrpc--with-python-fixture): New macro.
(scontrol-remote-during-sync): New test.
(scontrol-anxious-nested): New test.
(scontrol-remote-error): New test.
(shutdown-clean-after-notification): New test.
* test/lisp/jsonrpc-resources/common.py: New file.
* test/lisp/jsonrpc-resources/server-remote-during-sync.py: New file.
* test/lisp/jsonrpc-resources/server-anxious-nested.py: New file.
* test/lisp/jsonrpc-resources/server-remote-error.py: New file.
* test/lisp/jsonrpc-resources/server-harakiri.py: New file.
When the remote endpoint is handling a local request 'A' it can
sometimes make a remote sync request 'B' as part of its handling. Some
servers (like the gopls LSP server) wait for reply to 'B' before
responding to 'A', others respond to 'A' immediately, and then wait for
the local response 'B'. Both approaches are valid, but in the latter
case the handling of 'B' (which could be waiting for user input to
complete) is unexpectedly aborted when the reply to 'A' comes in,
interrupting the handling of 'B' and causing a spurious -32603 reply to
be sent.
This commit first refactors the sync request/anxious queue handling and
replace plain integer keys of the rebaptized "scontrol" alist with
structured (:local ID) / (:remote ID) pairs, using `equal' for
comparisons.
Then, remote-request dispatch is fixed: we push a (:remote ID) entry
onto -control before calling rdispatcher to so any client-to-server
response arriving during dispatch is deferred as an "anxious"
continuation rather than firing its `throw' immediately. Pop it with
jsonrpc--continue after sending the reply, which reschedules deferred
continuations via run-at-time.
* lisp/jsonrpc.el (jsonrpc-connection): Rename -sync-request-alist to
-scontrol; accessor from jsonrpc--sync-request-alist to
jsonrpc--scontrol; update docstring for new key structure.
(jsonrpc-connection-receive): Update with-slots binding to scontrol.
Tighten anxious check to match (:local ID) keys with `equal'. In
remote-request branch, push (:remote ID) entry before rdispatcher and
call jsonrpc--continue after jsonrpc--reply.
(jsonrpc-request): Pass (:local ID) to jsonrpc--continue.
(jsonrpc--continue): Use jsonrpc--scontrol; change `=' to `equal' in
sanity check.
(jsonrpc--async-request-1): Push (:local ID) entry.
(jsonrpc--log-event): Use jsonrpc--scontrol.
* lisp/progmodes/eglot.el (eglot--server-buffer-name): New function.
(eglot--connect): Rename events and stderr buffers after serverInfo
arrives to include the server's self-reported name.
(eglot-show-workspace-configuration, eglot-describe-connection)
(eglot--define-hierarchy-command): Use eglot--server-buffer-name.
(eglot--propose-changes-as-diff): Add SERVER argument; use
eglot--server-buffer-name.
(eglot--apply-workspace-edit): Add SERVER argument; pass server to
eglot--propose-changes-as-diff.
(eglot-handle-request workspace/applyEdit, eglot-execute)
(eglot-rename): Pass server to eglot--apply-workspace-edit.
* lisp/leim/quail/latin-ltx.el: Add a regex to match Greek
subscripts. Currently there are only five in unicode: beta, gamma,
rho, phi, and chi. They can now be input with the TeX input method
as, e.g., _\beta . (Bug#80791)
When the user renames a buffer's file via set-visited-file-name,
notify the server with didClose (old URI) and didOpen (new URI).
The TextDocumentIdentifier cache still holds the old URI when
after-set-visited-file-name-hook fires, so didClose uses it
correctly; didOpen then clears and rebuilds it from the new name.
* lisp/progmodes/eglot.el (eglot--managed-mode): Hook and unhook
eglot--after-set-visited-file-name-hook.
(eglot--after-set-visited-file-name-hook): New function.
Use box-drawing characters for the tree guides in hierarchy
buffers when the display supports them.
* lisp/progmodes/eglot.el (eglot--hierarchy-2): Rework.
The general idea here is to make it easier to handle situations
where you might have a symbol designating a package name or a
'package-desc' object, but you really want the latter.
* lisp/emacs-lisp/package.el (package--get-deps): Remove
function superseded by 'package--dependencies'.
(package--builtin-alist, package--archive-contents): Add new
functions.
(package--removable-packages): Use 'package--dependencies'.
(package--dependencies): Check for circular dependencies.
(package-upgrade, package--upgradeable-packages)
(package--user-installed-p, package-reinstall, package-recompile)
(describe-package-1, package-desc-status, package--mapc)
(package-menu--find-upgrades): Use 'package-get-descriptor'.
(package-get-descriptor): Add optional arguments to allow for
different kinds of queries.
* lisp/emacs-lisp/package-vc.el
(package-vc-install-selected-packages)
(package-vc--generate-description-file)
(package-vc-install-dependencies, package-vc--read-package-desc)
(package-vc-install, package-vc-checkout): Use
'package-get-descriptor'.
Now that 'eglot-uri-to-path' tries to return
"project-root-familiar" paths, unresolving the absolute path
name, it's important to update 'eglot--find-buffer-visiting' to
consider the two alternative ways to refer to a file. IOW, this
was already a bug, but the latest changes to 'eglot-uri-to-path'
made it more evident.
* lisp/progmodes/eglot.el (eglot--find-buffer-visiting): Also
consider buffer-file-name.
* lisp/net/tramp-sh.el (tramp-get-remote-arg-max): New defun.
(tramp-open-connection-setup-interactive-shell): Use it.
* lisp/net/tramp.el (tramp-multi-hop-p-hook): New defvar.
(tramp-multi-hop-p): Use it.
(tramp-handle-make-process): Set TERM environment.
Now that emacsclient can receive long lines without problems,
don’t bother splitting long lines when sending to it.
* lisp/server.el (server-msg-size): Now obsolete.
(server-reply-print): Send qtext without trying to break it
into pieces (Bug#80807#49).
Commit 6942d508f0 made js-mode-regexp-syntax-bug-25529 fail,
because it changes the moment and place in which
`syntax-propertize` gets called, uncovering a bug where
`js-jsx--detect-after-change` narrows the buffer, then calls
`re-search-forward` which calls `syntax-propertize`, so we end
up doing `syntax-propertize` while narrowed which can fail in
all kinds of ways.
* lisp/progmodes/js.el (js-jsx--detect-and-enable): Change optional arg
to BEG and END.
(js-jsx--detect-after-change): Use them to avoid narrowing.
* lisp/emacs-lisp/syntax.el (syntax-propertize): Emit a message
when called narrowed and the narrowing starts later than the
nearest already propertized position.
* lisp/emacs-lisp/package.el (package-install-file): Assume it
is OK to set the visited file name, since we are not actually
touching anything on disk, and prevent the modified flag from
preventing us to kill the temporary buffer. The flag is set by
tar-mode.
* lisp/emacs-lisp/package.el (package--review-git-diff-command):
Add new constant to avoid duplicating the exact command as the
default value and in the type of the user option.
(package-review-diff-command): Use git-diff(1) if Git is
installed, and fall back to regular diff(1) otherwise. The
previous default value has been moved to the user option, as a
suggested alternative.
(package-review): Support the ability to use symbols, that get
replaced and expanded into the list of switches.
(Bug#80684)
Co-Authored-By: Daniel Mendler <mail@daniel-mendler.de>
* lisp/vc/vc-hg.el (vc-hg--active-bookmark-internal): Make it
work when default-directory is not the repository root.
(vc-hg--checkin): Use vc-hg--active-bookmark-internal instead of
vc-hg--working-branch.
* lisp/dired.el (dired--ls-accept-b-switch-p): New function.
(dired-internal-noselect): Use it in the condition on displaying
warning about filenames with newlines.
(dired--set-auto-toggle-b-switch): Use it to conditionalize
calling 'dired--toggle-b-switch'.
(dired-auto-toggle-b-switch, dired--toggle-b-switch): Improve doc
string.
* test/lisp/dired-tests.el (dired-test-filename-with-newline-1)
(dired-test-filename-with-newline-2): Skip unless Dired uses an
'ls' that supports the '-b' switch.
* etc/NEWS: Adjust accordingly the announcements of the Dired
warning and the new user option for file names with newlines.
* doc/misc/tramp.texi (Extension packages): Use another format
char in example.
(New operations): Document different argument types. Extend example.
* lisp/net/tramp.el: Use consequently `eq', `assq', `memq'.
(tramp-file-name-for-operation-external): Extend docstring.
(tramp-file-name-for-operation): Make more use of
`tramp-file-name-for-operation-external'.
(tramp-add-external-operation): New optional argument `arg-type'.
* test/lisp/net/tramp-tests.el (tramp--handle-test-operation):
Rename from `tramp--handler-for-test-operation'.
(tramp--handle-process-id)
(tramp--test-operation-file-name-for-operation): New defuns.
(tramp-test49-external-backend-function): Extend test.
Problem reported by Zhengyi Fu (bug#80844).
* lisp/server.el (server--process-filter-1, server-return-error)
(server-edit-abort): Append newline to -error commands, too.
Otherwise emacsclient has no reliable way to find the end of the
error command’s argument, except to wait for EOF which is
undesirable since the Emacs server keeps the socket open
for a while, waiting for emacsclient to exit.
Also add more bindings to M-x eglot-list-connections
* lisp/progmodes/eglot.el (eglot-list-connections-mode-map): Add
bindings for e, w, RET.
(eglot-events-buffer-of-listed-connection)
(eglot-show-workspace-configuration-of-listed-connection)
(eglot-describe-listed-connection): New commands.
(eglot-describe-connection): New command.
* doc/misc/eglot.texi: Document new keys and eglot-describe-connection.
* etc/EGLOT-NEWS: Announce.