Commit graph

85 commits

Author SHA1 Message Date
Eli Zaretskii
990d615cab ; * lisp/jsonrpc.el (jsonrpc-shutdown): Doc fix. 2024-04-27 12:19:28 +03:00
Daniel Pettersson
3aed440025 Shut down jsonrpc server more gracefully
* lisp/jsonrpc.el (jsonrpc-running-p): Avoid unnecessarily killing
the server process.  Suggested by Aaron Zeng <azeng@janestreet.com>.
(Bug#70522)
2024-04-27 12:15:33 +03:00
Daniel Pettersson
7c552b22e6 Jsonrpc: improve performance of process filter function
`run-at-time' keeps `timer-list' list sorted by inserting each
timer based on the timer value.  This means that
`timer--time-less-p' needs is executed ~N*N/2 times for each N
pending messages.  This means that jsonrpc becomes unusable
for connections that generate a lot messages at the same time.

* lisp/jsonrpc.el (Version): Bump to 1.0.25.
(jsonrpc--process-filter): Improve performance by activating
timers in a different order.  (Bug#69241)
2024-03-12 15:22:24 +02:00
Stefan Kangas
9364c28959 ; Fix typos in symbol names 2024-01-21 15:28:06 +01:00
Eli Zaretskii
8bb5525b62 ; Fix merge snafus
* lisp/jsonrpc.el:
* lisp/progmodes/eglot.el: Fix merge snafus.
2024-01-20 06:37:09 -05:00
Eli Zaretskii
1b31a784bf Merge from origin/emacs-29
5bb5590dec Fix blunder in labeled_narrow_to_region
78ddb32fad Fix documentation of icon-elements
725a3f32f8 ; Fix typos in symbol names
6653ee66ca Improve two docstrings in ox-latex
7d869a0402 Doc fix in auth-source-read-char-choice
f149de223b Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/...
1f97a87879 Fix info-xref-tests
51f391998b Add @kindex in manuals for existing keybindings on 'C-x x...
2024-01-20 06:25:59 -05:00
João Távora
43612103c2 Jsonrpc: fix bug in jsonrpc--remove
* lisp/jsonrpc.el (jsonrpc--remove): Check timer before cancelling it.
(Version): Bump to 1.2.24

See https://github.com/joaotavora/eglot/issues/1342
2024-01-15 06:36:24 -06:00
Stefan Kangas
725a3f32f8 ; Fix typos in symbol names 2024-01-14 15:16:54 +01:00
Stefan Monnier
f866c85ac4 (jsonrpc--log-event): Try and fix bug#68072
* lisp/jsonrpc.el (jsonrpc--log-event): Force the use of
`lisp-indent-function` in `pp-to-string`.
2024-01-07 00:02:08 -05:00
Po Lu
ecf08f0621 Merge from savannah/emacs-29
dc4e6b1329 ; Update copyright years in more files
64b3777631 ; Run set-copyright from admin.el
8e1c56ae46 ; Add 2024 to copyright years

# Conflicts:
#	doc/misc/modus-themes.org
#	doc/misc/texinfo.tex
#	etc/NEWS
#	etc/refcards/ru-refcard.tex
#	etc/themes/modus-operandi-theme.el
#	etc/themes/modus-themes.el
#	etc/themes/modus-vivendi-theme.el
#	lib/alloca.in.h
#	lib/binary-io.h
#	lib/c-ctype.h
#	lib/c-strcasecmp.c
#	lib/c-strncasecmp.c
#	lib/careadlinkat.c
#	lib/cloexec.c
#	lib/close-stream.c
#	lib/diffseq.h
#	lib/dup2.c
#	lib/filemode.h
#	lib/fpending.c
#	lib/fpending.h
#	lib/fsusage.c
#	lib/getgroups.c
#	lib/getloadavg.c
#	lib/gettext.h
#	lib/gettime.c
#	lib/gettimeofday.c
#	lib/group-member.c
#	lib/malloc.c
#	lib/md5-stream.c
#	lib/md5.c
#	lib/md5.h
#	lib/memmem.c
#	lib/memrchr.c
#	lib/nanosleep.c
#	lib/save-cwd.h
#	lib/sha1.c
#	lib/sig2str.c
#	lib/stdlib.in.h
#	lib/strtoimax.c
#	lib/strtol.c
#	lib/strtoll.c
#	lib/time_r.c
#	lib/xalloc-oversized.h
#	lisp/auth-source-pass.el
#	lisp/emacs-lisp/lisp-mnt.el
#	lisp/emacs-lisp/timer.el
#	lisp/info-look.el
#	lisp/jit-lock.el
#	lisp/loadhist.el
#	lisp/mail/rmail.el
#	lisp/net/ntlm.el
#	lisp/net/webjump.el
#	lisp/progmodes/asm-mode.el
#	lisp/progmodes/project.el
#	lisp/progmodes/sh-script.el
#	lisp/textmodes/flyspell.el
#	lisp/textmodes/reftex-toc.el
#	lisp/textmodes/reftex.el
#	lisp/textmodes/tex-mode.el
#	lisp/url/url-gw.el
#	m4/alloca.m4
#	m4/clock_time.m4
#	m4/d-type.m4
#	m4/dirent_h.m4
#	m4/dup2.m4
#	m4/euidaccess.m4
#	m4/fchmodat.m4
#	m4/filemode.m4
#	m4/fsusage.m4
#	m4/getgroups.m4
#	m4/getloadavg.m4
#	m4/getrandom.m4
#	m4/gettime.m4
#	m4/gettimeofday.m4
#	m4/gnulib-common.m4
#	m4/group-member.m4
#	m4/inttypes.m4
#	m4/malloc.m4
#	m4/manywarnings.m4
#	m4/mempcpy.m4
#	m4/memrchr.m4
#	m4/mkostemp.m4
#	m4/mktime.m4
#	m4/nproc.m4
#	m4/nstrftime.m4
#	m4/pathmax.m4
#	m4/pipe2.m4
#	m4/pselect.m4
#	m4/pthread_sigmask.m4
#	m4/readlink.m4
#	m4/realloc.m4
#	m4/sig2str.m4
#	m4/ssize_t.m4
#	m4/stat-time.m4
#	m4/stddef_h.m4
#	m4/stdint.m4
#	m4/stdio_h.m4
#	m4/stdlib_h.m4
#	m4/stpcpy.m4
#	m4/strnlen.m4
#	m4/strtoimax.m4
#	m4/strtoll.m4
#	m4/time_h.m4
#	m4/timegm.m4
#	m4/timer_time.m4
#	m4/timespec.m4
#	m4/unistd_h.m4
#	m4/warnings.m4
#	nt/configure.bat
#	nt/preprep.c
#	test/lisp/register-tests.el
2024-01-02 10:28:14 +08:00
Po Lu
8e1c56ae46 ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
João Távora
e438215f69 ; Jsonrpc: fix spurious unintended change
* lisp/jsonrpc.el (jsonrpc--log-event): Fix spurious unintended
change.
2023-12-30 06:10:31 -06:00
Stefan Kangas
8f571769e1 ; Fix typos 2023-12-28 01:20:32 +01:00
João Távora
c5a4366b3f Eglot: bump to 1.16
* etc/EGLOT-NEWS: Update.

* lisp/progmodes/eglot.el (Version): Bump to 1.15
(Package-Requires): Bump jsonrpc depedency to 1.23
2023-12-27 08:02:20 -06:00
João Távora
731cfee3b4 Jsonrpc: bump to 1.0.23
* lisp/jsonrpc.el (Version): Bump to 1.0.23
2023-12-27 07:53:45 -06:00
João Távora
dceffddbfe Jsonrpc: clean up previous change
* lisp/jsonrpc.el (jsonrpc-connection): Rework slot names.
(jsonrpc-connection-receive): Rework.
(jsonrpc--call-deferred): Fix typo.
(jsonrpc--process-sentinel)
(jsonrpc--remove): Use new slot names.
(jsonrpc--continue): Rework.
(jsonrpc--async-request-1): Rework.
(jsonrpc--event): Remember to remove :jsonrpc-json from
foreign-message
(jsonrpc--connection-receive): Revamp.
(jsonrpc--connection-send)
(jsonrpc--connection-reply): Rework.
(jsonrpc--log-event): Revamp.
(jsonrpc-continuation-count): Use new slot name.
2023-12-22 11:17:36 -06:00
Stefan Kangas
27d2395879 ; Fix typos 2023-12-22 17:19:20 +01:00
João Távora
e0b9944b69 Jsonrpc: overhaul logging mechanics
* lisp/jsonrpc.el (jsonrpc-connection): Rework.
(initialize-instance :after jsonrpc-connection): New method.
(slot-missing jsonrpc-connection :events-buffer-scrollback-size oset):
New hack.
(jsonrpc-connection-receive): Rework.
(initialize-instance :after jsonrpc-process-connection): Rework
from non-after version.
(jsonrpc-connection-send)
(jsonrpc--call-deferred)
(jsonrpc--process-sentinel)
(jsonrpc--async-request-1, jsonrpc--debug, jsonrpc--log-event)
(jsonrpc--forwarding-buffer): Rework.
(jsonrpc--run-event-hook): New helper.
(jsonrpc-event-hook): New hook.

* lisp/progmodes/eglot.el (eglot-lsp-server): Fix project slot
initform.
(eglot--connect): Use new jsonrpc-connection initarg.

* test/lisp/progmodes/eglot-tests.el (eglot--sniffing): Use
jsonrpc-event-hook.
(eglot-test-basic-completions): Fix test.
2023-12-21 18:29:50 -06:00
João Távora
4adc67c59d Jsonrpc: fix destructuring bug
* lisp/jsonrpc.el (jsonrpc--process-sentinel): Fix destructuring bug.
(Version): Bump to 1.0.22
2023-12-21 09:08:41 -06:00
João Távora
02b99db661 Jsonrpc: deal with nested synchronous jsonrpc-request
See bug#67945

* lisp/jsonrpc.el (jsonrpc-connection): Add -sync-request-alist
(jsonrpc-connection-receive): Rework.
(jsonrpc-request): Rework.  Pass SYNC-REQUEST to
jsonrpc-async-request-1.
(jsonrpc--process-sentinel): Simplify.
(jsonrpc--schedule): New helper.
(jsonrpc--continue): New helper.
(jsonrpc--async-request-1): Rework.
(jsonrpc--process-sentinel): Also cancel deferred action timers.
(Version): Bump to 1.0.21
2023-12-20 18:57:18 -06:00
João Távora
222f563f13 Jsonrpc: rework implementation of continuations
Preparatory work for fix of bug#67945

* lisp/jsonrpc.el (jsonrpc-connection): Change slots.
(jsonrpc--remove): New helper
(jsonrpc-forget-pending-continuations)
(jsonrpc-connection-receive)
(jsonrpc-request)
(jsonrpc--process-sentinel)
(jsonrpc--async-request-1)
(jsonrpc--async-request-1): Rework.
(jsonrpc-continuation-count): New convenience helper.

* lisp/progmodes/eglot.el (eglot--mode-line-format): Stop using
jsonrpc--request-continuations.
2023-12-20 18:57:18 -06:00
João Távora
9e24cde227 Jsonrpc: add new jsonrpc-autoport-bootstrap helper
This will help Eglot and some other extensions connect to network
servers that are started with a call to a local program.

* lisp/jsonrpc.el (jsonrpc--process-sentinel): Also delete inferior.
(jsonrpc-process-connection): Add -autoport-inferior slot.
(initialize-instance jsonrpc-process-connection): Check
process-creating function arity.  Use jsonrpc-forwarding-buffer
(jsonrpc-autoport-bootstrap): New helper.
(Version): Bump to 1.0.20.
2023-12-14 23:53:13 +00:00
João Távora
ea29a48da1 Jsonrpc: support some JSONesque non-JSONRPC protocols, like DAP
* lisp/jsonrpc.el (jsonrpc-convert-to-endpoint)
(jsonrpc-convert-from-endpoint): New generics.
(jsonrpc-connection-send): Call jsonrpc-convert-to-endpoint.
Rework logging.
(jsonrpc-connection-receive): Call jsonrpc-convert-from-endpoint.
Rework logging. jsonrpc--reply with METHOD.
(jsonrpc--log-event): Take subtype.
(Version): Bump to 1.0.19

* test/lisp/progmodes/eglot-tests.el (eglot--sniffing): Adapt
to new protocol of jsonrpc--log-event.

* doc/lispref/text.texi (JSONRPC Overview): Rework.
2023-12-14 00:55:52 +00:00
João Távora
60473c4d90 Jsonrpc: rework fix for bug#60088
Try to decouple receiving text and processing messages in the event
loop.  This should allow for requests within requests in both Eglot
and the Dape extension (https://github.com/svaante/dape).

jsonrpc-connection-receive is now called from timers after the process
filter finished.  Because of this, a detail is that any serialization
errors are now thrown from timers instead of the synchronous process
filter, and there's no good way to test this in ert, so a test has
been deleted.

* lisp/jsonrpc.el (jsonrpc--process-filter): Rework.

* test/lisp/jsonrpc-tests.el (json-el-cant-serialize-this): Delete test.
2023-12-14 00:55:52 +00:00
João Távora
d2f95ea44c Jsonrpc: better initforms in jsonrpc-connection
* lisp/jsonrpc.el (jsonrpc-connection): Better initforms
2023-12-14 00:55:52 +00:00
João Távora
8de749faa1 Jsonrpc: allow method identifiers to be simply strings
* lisp/jsonrpc.el (jsonrpc-connection-send): Support string methods.
2023-12-14 00:55:52 +00:00
Stefan Kangas
06a12b0ccc ; Fix typos 2023-12-10 13:22:04 +01:00
João Távora
5a0250f766 Jsonrpc: prevent while-no-input messing with jsonrpc-request
'jsonrpc-request' already has its "interrupt on user input" mechanism
base on 'sit-for'.  If called from a situation that uses
while-no-input to do basically the same, that mechanism may become
confused, so it's important to prevent that interfence.

This was confirmed to be a problem when using the Corfu completion
front-end.

See also
https://github.com/joaotavora/eglot/discussions/1127#discussioncomment-7277567

Many thanks to JD Smith <jdtsmith@gmail.com> for helping me debug this
and pointing in the right direction.

* lisp/jsonrpc.el (Version): Bump to 1.0.18
(jsonrpc-request): Bind throw-on-input to nil
2023-11-28 18:47:09 -06:00
João Távora
02d88e36e9 Unbreak Eglot, Jsonrpc as EIEIO inches closer to CLOS (bug#67480)
EIEIO is an innacurate emulation of CLOS in many aspects and one of
them in accessor definition.  Before this commit

commit 6c47931a1a
Author: Brandon <brandon.irizarry@gmail.com>
Date:   Sat Nov 4 17:11:32 2023 -0400

    Make EIEIO ':accessor' behave like ':reader' when reading (bug#66938)

An :initform-less, non-:initarg'ed slot with be read using an
:accessor which would just return nil.  This is EIEIO specific of
course, but it made for (my) sloppy programming in jsonrpc.el and
eglot.el.

Tightening up the rules a bit meant these things broke and now I'm
fixing them.

* lisp/jsonrpc.el (jsonrpc-connection): Add a bunch of :initform nil
(jsonrpc-process-connection): Add a bunch of :initform nil

* lisp/progmodes/eglot.el (eglot-lsp-server): Add a bunch of :initform nil
2023-11-28 18:33:09 -06:00
Michael Albinus
65c4e3002e ; * lisp/jsonrpc.el (jsonrpc-error): Fix typo. 2023-07-29 13:23:19 +02:00
João Távora
2af83f215c Jsonrpc: fix error code in jsonrpc-error function (bug#64888)
* lisp/jsonrpc.el (jsonrpc-error): Fix error code.
2023-07-29 11:15:14 +01:00
João Távora
3bbe6f4abc Jsonrpc: fix default value of success-fn (bug#64919)
* lisp/jsonrpc.el (jsonrpc--async-request-1): Fix default value of
success-fn.
2023-07-29 11:08:51 +01:00
Eli Zaretskii
5fecdbcd81 Merge from origin/emacs-29
5ef7ff0573 ; Start a new ChangeLog.4 file.
11126c6d30 Fix 'C-h k' for "Paste from Kill Menu" in context menus
74ddfe811f ; * doc/misc/calc.texi (Rewrites Tutorial): Fix a typo (b...
08cda286c3 Improve the documentation of the XDS support
14d1c00e80 Allow reindentation of images inserted by 'mm-inline-image'
b63a9eda01 Fix "C-h k" and "C-h c" with Paste from Kill Menu
b36c21e27d Change cursor color on NS port when it matches the face b...
96714c106b Improve documentation of image-related commands
6a2863ca01 Fix handling of sliced images
5be79fd05a ; * etc/NEWS: Announce 'cyrillic-mongolian' IM.
ca1a0fda98 ; Fix last change.
ce63462dbd Add cyrillic-mongolian input method
5880179270 ; Minor addition to the Emacs FAQ
88847dee12 Jsonrpc: don't bind inhibit-read-only to t so early
cb8c87a423 Allow active region when IM is used

# Conflicts:
#	etc/NEWS
2023-04-15 12:43:37 -04:00
João Távora
88847dee12 Jsonrpc: don't bind inhibit-read-only to t so early
Related to https://github.com/joaotavora/eglot/discussions/1202, where
because of this very wide binding to inhibit-read-only to t, Eglot was
managing to write into read-only buffers from the response handlers
that ran from within the stack of the jsonrpc.el process filter.

This is of course illegal and dangerous, but Eglot wasn't made aware
because of the binding.

* lisp/jsonrpc.el (jsonrpc--process-filter): Don't bind
inhibit-read-only so early.
2023-04-07 19:33:12 +01:00
João Távora
2d835d64ba Better jsonrpc.el workaround for debug-on-error check
Some extensions, notably ert.el, set `debug-on-error' to non-nil,
which makes it hard to test the behaviour catching of the Elisp
error when processing a request and replying to the endpoint with
an JSONRPC-error.

The previous workaround relied on requiring lisp/emacs-lisp/ert.el in
lisp/jsonrpc.el, which really doesn't make sense.

This is better.  For the single test of that behaviour, set a new
variable, jsonrpc-inhibit-debug-on-error.

Not only is this cleaner, it allows us to use ert.el's useful
debug-on-error setting.

* lisp/jsonrpc.el (ert): Don't require it.
(jsonrpc-inhibit-debug-on-error): New variable.
(jsonrpc-connection-receive): Use it.
(Package-Requires): Bump to 1.0.17

* test/lisp/jsonrpc-tests.el (signals-an--32603-JSONRPC-error):
Bind jsonrpc-inhibit-debug-on-error.
2023-03-14 19:36:47 +00:00
Eli Zaretskii
cae528457c ; Add 2023 to copyright years. 2023-01-01 05:31:12 -05:00
João Távora
8bf4cdcf79 Avoid recursive process filters in lisp/jsonrpc.el (bug#60088)
jsonrpc.el may lose JSON-RPC messages because of recursive process
filters.  The problem happens in jsonrpc.el's jsonrpc--process-filter.

The code of the process filter didn't expect to be called recursively
and fails in that case.

But that can happen if the three conditions are verified.

1. the client code invoked by its jsonrpc--connection-receive inside
   the process filter callee immediately sends follow-up input to
   process within the same Lisp stack.  This is a common scenario,
   especially during LSP initialiation sequence used by Eglot, a
   jsonrpc.el client.

2. that follow-up message is large enough for process-send-string to
   send the input in bunches (output from processes can arrive in
   between bunches).

3. the process happens to have already some more output ready

The fix in this commit detects recursive invocations and immediately
re-schedules them as non-recursive calls to the
jsonrpc--process-filter (but started from timers).

* lisp/jsonrpc.el (jsonrpc--process-filter): Rework.
(Version): Bump to 1.0.16.
2022-12-16 08:53:10 +00:00
Stefan Kangas
5e8c62ffca ; Fix typos 2022-11-23 05:49:22 +01:00
Stefan Kangas
40539c7587 ; Fix typos 2022-11-22 02:24:20 +01:00
Stefan Kangas
2a05479c22 ; Fix typos: prefer American spelling 2022-07-14 12:13:31 +02:00
Stefan Kangas
50654cf0b1 * lisp/jsonrpc.el (Version): Bump to 1.0.15. 2022-01-13 13:00:25 +01:00
Stefan Kangas
9599b5923b * lisp/jsonrpc.el (jsonrpc--debug): Use apply on format args list. 2022-01-13 01:02:22 +01:00
Eli Zaretskii
19dcb237b5 ; Add 2022 to copyright years. 2022-01-01 02:45:51 -05:00
Lars Ingebrigtsen
43c1ee90cb Don't use `format' on strings without % format directives
* lisp/vc/ediff-init.el (ediff-BAD-INFO):
* lisp/url/url-ldap.el (url-ldap):
* lisp/url/url-http.el (url-http--user-agent-default-string):
* lisp/textmodes/reftex.el (reftex-access-parse-file):
* lisp/textmodes/reftex-index.el (reftex-index-phrases-info):
* lisp/textmodes/ispell.el (ispell-create-debug-buffer):
* lisp/term.el (serial-read-speed):
* lisp/progmodes/verilog-mode.el (verilog-scan-debug):
* lisp/progmodes/idlwave.el (idlwave-find-module):
* lisp/progmodes/compile.el (compilation-revert-buffer):
* lisp/org/org-agenda.el (org-search-view):
* lisp/net/telnet.el (telnet-revert-buffer):
* lisp/net/soap-inspect.el (soap-sample-value-for-xs-simple-type):
* lisp/net/newst-backend.el (newsticker--cache-read):
* lisp/mh-e/mh-seq.el (mh-msg-is-in-seq):
* lisp/mail/smtpmail.el (smtpmail-via-smtp):
* lisp/mail/emacsbug.el (report-emacs-bug):
* lisp/jsonrpc.el (jsonrpc-error):
* lisp/help-fns.el (describe-variable):
* lisp/gnus/mm-decode.el (mm-possibly-verify-or-decrypt):
* lisp/gnus/gnus.el (gnus-group-startup-message):
(gnus-group-startup-message):
* lisp/gnus/gnus-group.el (gnus-group-restart):
* lisp/frame.el (make-frame-on-display):
* lisp/emulation/viper-ex.el (ex-help):
* lisp/calendar/icalendar.el (icalendar--convert-ical-to-diary):
(icalendar--add-diary-entry):
* lisp/calendar/cal-tex.el (cal-tex-end-document):
* lisp/calc/calcalg3.el (math-ninteg-romberg): Don't use `format'
on strings that have no % format directives in them.
2021-09-21 17:52:53 +02:00
Stefan Kangas
63f419f133 ; Minor stylistic fixes found by checkdoc 2021-09-16 19:37:07 +02:00
Stefan Kangas
ce35760b19 ; Minor license statement fixes 2021-02-08 09:10:57 +01:00
Paul Eggert
ba05d005e5 Update copyright year to 2021
Run "TZ=UTC0 admin/update-copyright".
2021-01-01 01:13:56 -08:00
Basil L. Contovounesios
805d82197f Avoid spamming view-mode-enter help message
By default, entering view-mode echoes a usage message.  This is
particularly helpful with non-nil view-read-only, to notify the user
that view-mode has been enabled.  It is less useful and more spammy,
however, if view-mode is (possibly inadvertently) entered from some
non-interactive code running in the background, such as when a major
mode is enabled in a temporary buffer for text formatting
purposes (bug#44629).

* lisp/jsonrpc.el (jsonrpc-events-buffer, initialize-instance): Use
buffer-read-only in place of read-only-mode for non-interactive use.
* lisp/view.el (view-mode-enter): Inhibit help message if either
view-inhibit-help-message is non-nil, or view-mode-enter was called
from an interactive command.  Suggested by João Távora
<joaotavora@gmail.com>.
2020-12-03 15:22:00 +00:00
João Tãvora
e7791c7e57 Revert unintended part of last change to jsonrpc-request
While playing around with the timing in this function, I left
this change that could freeze the function on some platforms.

* lisp/jsonrpc.el (jsonrpc-request): Use accept-process-output.
(Version): Bump to 1.0.14
2020-11-20 10:04:20 +00:00
João Távora
59b340c1e6 Fix default timeout handling in jsonrpc-request
* lisp/jsonrpc.el (jsonrpc-request): Use default timeout if not passed.
(Version): Bump to 1.0.13
2020-11-20 01:19:39 +00:00