emacs/lisp
João Távora 9b3855e164 Jsonrpc: rework sync request handling (bug#80623)
When the remote endpoint is handling a local request 'LR' it can
sometimes make a remote sync request 'RR' as part of its handling.  Some
endpoints (like Go's gopls) wait for Emacs's reply to 'RR' before
responding to 'LR'.  Others (like Julia's JETLS) respond to 'LR'
immediately, and only then wait for Emacs's reply to 'RR'.  Both
approaches are valid.  However, in the latter case, the handling of 'RR'
(which could well be waiting for user input from the minibuffer to
complete) is vulnerable to 'throw' from process filters handling (which
is just what happens when the endpoints replies to 'LR'), so if that
happens it will unexpectedly be aborted when the reply to 'LR' comes in,
suprising the user and causing a spurious -32603 reply to be sent.

To solve this problem, 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.  This is to introduce some
clarity/sanity into this somewhat hairy code.

Then, the 'RR' situation is fixed: we push a (:remote ID) entry onto the
top of the 'jsonrpc-connection--control' stack and only then call
rdispatcher.  Any 'LR' reply arriving during dispatch is deferred as an
"anxious" continuation rather than firing its `throw' immediately.  When
rdispatcher is done, we call jsonrpc--continue at a safe point, this
will run any "anxious" continuations.

* 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.
p
(jsonrpc--async-request-1): Push (:local ID) entry.

(jsonrpc--log-event): Use jsonrpc--scontrol.
2026-05-04 11:47:21 +01:00
..
calc Use single-arg form of signal to re-throw an error 2026-03-10 10:48:22 -04:00
calendar ; Spelling fixes. 2026-04-29 22:45:51 -07:00
cedet
emacs-lisp Ensure package archives are loaded for 'package-isolate' 2026-05-03 20:25:53 +02:00
emulation Rename 'any' to 'member-if' and deprecate 'cl-member-if' 2026-03-04 14:43:05 +00:00
erc Only perform erc-log-insert-log-on-open setup once 2026-04-30 15:46:42 -07:00
eshell Use single-arg form of signal to re-throw an error 2026-03-10 10:48:22 -04:00
gnus Gnus logo in server buffer's mode line (bug#80850) 2026-05-03 12:01:21 +01:00
image
international Use plain autoload cookie with transient-define-prefix 2026-04-27 21:58:39 +02:00
language Add language-environment and input methods for Syriac 2026-04-23 11:31:10 +03:00
leim/quail Add language-environment and input methods for Syriac 2026-04-23 11:31:10 +03:00
mail (mail-citation-prefix-regexp): Fix excessive backtracking (bug#80808) 2026-04-22 08:39:48 -04:00
mh-e Improve previous change. 2026-04-10 11:04:29 -07:00
net eww-handle-link: Split HTML rel on spaces 2026-04-30 11:56:29 +01:00
nxml Fix defining a few faces as empty 2026-04-27 21:35:44 +02:00
obsolete Add predicate for initial_terminal 2026-03-26 15:19:56 +01:00
org ; Spelling fixes. 2026-04-29 22:45:51 -07:00
play Window handling bug fixes. 2026-03-17 18:32:40 -04:00
progmodes Eglot: find well behaved UTF char for code actions (bug#80326) 2026-05-02 09:56:41 +01:00
term ; * lisp/term/w32console.el (set-screen-color): Fix signature. 2026-04-08 16:33:57 +03:00
textmodes Add for <picture> to 'html-tag-alist' and 'html-tag-help' 2026-05-03 20:25:53 +02:00
url Improve documentation of 'url-retrieve' and GnuTLS peer status 2026-04-08 11:02:47 +03:00
use-package ; Fix handling of string by the use-package keyword :vc 2026-03-16 18:23:37 +01:00
vc Fix 'vc-dir-resynch-file' (bug#80803) 2026-05-02 15:11:37 +02:00
abbrev.el
align.el
allout-widgets.el
allout.el
ansi-color.el
ansi-osc.el
apropos.el
arc-mode.el
array.el
auth-source-pass.el Improve last change to auth-source-pass 2026-03-26 15:05:22 +01:00
auth-source.el
autoinsert.el
autorevert.el
avoid.el
battery.el
bind-key.el Avoid infinite recursion in bind-keys-form (bug#80759) 2026-04-08 14:56:02 +00:00
bindings.el ; * lisp/bindings.el (mode-line-percent-position): Doc fix (bug#80617). 2026-03-15 12:16:40 +02:00
bookmark.el Use single-arg form of signal to re-throw an error 2026-03-10 10:48:22 -04:00
bs.el
buff-menu.el
button.el
calculator.el
case-table.el
ChangeLog.1
ChangeLog.2
ChangeLog.3
ChangeLog.4
ChangeLog.5
ChangeLog.6
ChangeLog.7
ChangeLog.8
ChangeLog.9
ChangeLog.10
ChangeLog.11
ChangeLog.12
ChangeLog.13
ChangeLog.14
ChangeLog.15
ChangeLog.16
ChangeLog.17
char-fold.el
chistory.el
cmuscheme.el
color.el
comint.el (comint--fontify-input-fontify-region): Silence messages (bug#80870) 2026-04-23 11:16:05 -04:00
completion-preview.el Remove 'completion-preview--is-calling' 2026-05-02 21:46:31 +02:00
completion.el
composite.el
COPYING
cus-dep.el
cus-edit.el New macro setopt-local and function set-local (bug#80709) 2026-04-02 13:47:36 -04:00
cus-face.el
cus-start.el
cus-theme.el
custom.el
dabbrev.el (dabbrev-completion): Improve last fix for bug#80645 2026-03-22 10:58:40 -04:00
delim-col.el
delsel.el (delete-selection-repeat-replace-region): Partial fix for bug#80216 2026-03-17 12:40:22 -04:00
descr-text.el
desktop.el Add predicate for initial_terminal 2026-03-26 15:19:56 +01:00
dframe.el
dired-aux.el vc-rename-file: New OK-IF-ALREADY-EXISTS parameter 2026-04-15 10:06:20 -04:00
dired-x.el
dired.el Restrict Dired handling of newlines in file names 2026-04-17 19:26:37 +02:00
dirtrack.el
disp-table.el
display-fill-column-indicator.el Add predicate for initial_terminal 2026-03-26 15:19:56 +01:00
display-line-numbers.el
dnd.el
doc-view.el
dom.el
dos-fns.el
dos-vars.el
dos-w32.el
double.el
dynamic-setting.el
ebuff-menu.el Use the new error API functions 2026-03-10 10:48:21 -04:00
ecomplete.el
editorconfig-conf-mode.el
editorconfig-core-handle.el
editorconfig-core.el
editorconfig-fnmatch.el
editorconfig-tools.el
editorconfig.el
edmacro.el
ehelp.el
elec-pair.el
electric.el
elide-head.el
emacs-lock.el
env.el
epa-dired.el
epa-file.el Fix last change 2026-04-01 16:48:09 +02:00
epa-hook.el
epa-ks.el
epa-mail.el
epa.el Use single-arg form of signal to re-throw an error 2026-03-10 10:48:22 -04:00
epg-config.el
epg.el
expand.el
external-completion.el ; (external-completion-table): Fix a couple of typos. 2026-05-01 11:23:09 +02:00
ezimage.el
face-remap.el
facemenu.el
faces.el New faces 'tab-line-active' and 'tab-line-inactive' (bug#80742) 2026-04-14 20:14:15 +03:00
ffap.el (dired-at-point-prompter): Fix bug#80545 2026-04-08 15:19:06 -04:00
filecache.el
fileloop.el
filenotify.el
files-x.el Set indent property for with-connection-local-variables 2026-04-27 21:38:00 +02:00
files.el ; Spelling fixes. 2026-04-29 22:45:51 -07:00
filesets.el
find-cmd.el
find-dired.el
find-file.el
find-lisp.el
finder.el
flow-ctrl.el
foldout.el
follow.el
font-core.el
font-lock.el
format-spec.el Call format-spec substitution functions in current buffer 2026-04-27 21:11:52 +02:00
format.el
forms.el
frame.el Add predicate for initial_terminal 2026-03-26 15:19:56 +01:00
frameset.el Add predicate for initial_terminal 2026-03-26 15:19:56 +01:00
fringe.el
generic-x.el
help-at-pt.el
help-fns.el
help-macro.el
help-mode.el
help.el lisp/help.el (help-function-arglist): Fix last change 2026-04-02 15:53:40 -04:00
hex-util.el
hexl.el
hfy-cmap.el
hi-lock.el
hilit-chg.el
hippie-exp.el
hl-line.el
htmlfontify.el
ibuf-ext.el
ibuf-macs.el
ibuffer.el ; * lisp/ibuffer.el (ibuffer-fontification-alist): Doc fix (bug#80618). 2026-03-19 17:46:57 +02:00
icomplete.el In fido-vertical-mode, let C-s and C-r recover their original use 2026-04-29 10:12:41 +01:00
ido.el
ielm.el
iimage.el
image-file.el
image-mode.el
image.el
imenu.el
indent-aux.el
indent.el
info-look.el
info-xref.el
info.el (Info-documentlanguage): Keep Info-related code in info.el 2026-04-25 09:56:25 -04:00
informat.el
isearch.el ; * lisp/isearch.el (isearch-occur): Doc fix. (Bug#80785) 2026-04-16 08:26:33 +03:00
isearchb.el
jit-lock.el Use single-arg form of signal to re-throw an error 2026-03-10 10:48:22 -04:00
jka-cmpr-hook.el
jka-compr.el Use the new error API functions 2026-03-10 10:48:21 -04:00
json.el
jsonrpc.el Jsonrpc: rework sync request handling (bug#80623) 2026-05-04 11:47:21 +01:00
keymap.el Improve documentation of 'define-keymap' 2026-03-07 10:55:23 +02:00
kmacro.el (kmacro-end-call-mouse): Make obsolete 2026-03-27 08:54:14 -04:00
ldefs-boot.el ; Update ldefs-boot.el. 2026-04-29 14:55:23 +01:00
loadhist.el
loadup.el * lisp/loadup.el: No longer GC after loading each file 2026-03-13 15:35:05 +01:00
locate.el
lpr.el
ls-lisp.el Use the new error API functions 2026-03-10 10:48:21 -04:00
macros.el
Makefile.in
man.el
master.el
mb-depth.el
md4.el
menu-bar.el Add predicate for initial_terminal 2026-03-26 15:19:56 +01:00
midnight.el
minibuf-eldef.el
minibuffer.el (completion--file-name-table): Improve completion of /a/~b/c 2026-04-27 15:03:19 -04:00
misc.el
misearch.el
mouse-copy.el
mouse-drag.el
mouse.el Use single-arg form of signal to re-throw an error 2026-03-10 10:48:22 -04:00
mpc.el
msb.el
mwheel.el
newcomment.el
notifications.el
novice.el
obarray.el
outline.el ; Fix quotation of some symbols 2026-04-04 13:44:08 +01:00
paren.el Fix text visibility issue with show-paren--show-context-in-overlay 2026-04-01 06:28:51 +02:00
password-cache.el
pcmpl-cvs.el
pcmpl-git.el
pcmpl-gnu.el
pcmpl-linux.el
pcmpl-rpm.el
pcmpl-unix.el
pcmpl-x.el
pcomplete.el
pgtk-dnd.el
pixel-scroll.el
plstore.el Use single-arg form of signal to re-throw an error 2026-03-10 10:48:22 -04:00
printing.el ; Fix 2 defcustoms in printing.el 2026-04-03 15:44:38 +03:00
proced.el ; Improve documentation of Proced 2026-04-25 09:01:48 +03:00
profiler.el
ps-bdf.el
ps-mule.el
ps-print.el
ps-samp.el
pulse.el
README
recentf.el ; recentf-exclude-file-by-extension-p: Restore and-let*. 2026-03-08 14:55:23 +00:00
rect.el
register.el (register--get-method-type): Fix one more case (bug#80894) 2026-04-26 12:18:44 -04:00
registry.el
repeat.el
replace.el
reposition.el
reveal.el
rfn-eshadow.el
ring-bell-fns.el
rot13.el
rtree.el
ruler-mode.el
savehist.el Use single-arg form of signal to re-throw an error 2026-03-10 10:48:22 -04:00
saveplace.el
scroll-all.el
scroll-bar.el
scroll-lock.el
select.el
send-to.el
server.el ; Improve documentation of Emacs server-client protocol 2026-05-02 12:35:48 +03:00
ses.el
shadowfile.el
shell.el
simple.el Fix value of 'default-line-height' 2026-04-30 19:39:42 +03:00
skeleton.el
so-long.el
sort.el
soundex.el
speedbar.el
sqlite-mode.el
sqlite.el
startup.el Adjust default value of 'user-lisp-ignored-directories' 2026-04-25 20:29:53 +02:00
strokes.el
subr.el Fix computation of package description file 2026-04-12 12:37:58 +02:00
svg.el
system-sleep.el
system-taskbar.el
t-mouse.el
tab-bar.el Rebind 'tab-bar-mouse-close-tab' from <down-mouse-2> to <mouse-2> 2026-04-21 19:30:03 +03:00
tab-line.el New faces 'tab-line-active' and 'tab-line-inactive' (bug#80742) 2026-04-14 20:14:15 +03:00
tabify.el
talk.el
tar-mode.el Use single-arg form of signal to re-throw an error 2026-03-10 10:48:22 -04:00
tempo.el
term.el
thingatpt.el
thread.el
time-stamp.el ; time-stamp: rename some internal functions to include "--" 2026-04-07 09:28:32 -07:00
time.el
timezone.el
tmm.el
tool-bar.el ; * lisp/tool-bar.el (tool-bar-setup): Adapt to change for bug#80545. 2026-03-26 11:20:53 +02:00
tooltip.el
touch-screen.el
transient.el Update to Transient v0.13.2-10-gf7894ca4 2026-05-01 22:06:03 +02:00
tree-widget.el
treesit-x.el
treesit.el * lisp/treesit.el (treesit-outline-level): Add guard condition. 2026-05-03 18:38:43 +03:00
tty-tip.el
tutorial.el
type-break.el Use the new error API functions 2026-03-10 10:48:21 -04:00
uniquify.el
userlock.el
vcursor.el
version.el
view.el
visual-wrap.el
w32-fns.el
w32-vars.el
wdired.el
which-key.el
whitespace.el ; * lisp/whitespace.el (whitespace-global-modes): Grammar fix. 2026-03-23 21:11:38 +00:00
wid-browse.el
wid-edit.el
widget.el
windmove.el
window-tool-bar.el
window-x.el
window.el ; Fix last fix to 'window--make-major-side-window' 2026-03-27 23:35:24 +01:00
winner.el
woman.el
x-dnd.el
xdg.el
xml.el
xt-mouse.el Add predicate for initial_terminal 2026-03-26 15:19:56 +01:00
xwidget.el
yank-media.el

This directory contains source code for the parts of Emacs that are
written in Emacs Lisp.  *.el files are Emacs Lisp source, and the
corresponding *.elc files are byte-compiled versions.  Byte-compiled
files are architecture-independent.

The term subdirectory contains Lisp files that customize Emacs for
certain terminal types.  When Emacs starts, it checks the TERM
environment variable to get the terminal type and loads
'term/${TERM}.el' if it exists.

The other subdirectories hold Lisp packages grouped by their general
purpose.