unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#58745: 29.0.50; eglot managed-major-mode must be a list
@ 2022-10-23 17:46 Stephen Leake
  2022-10-27 16:19 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Leake @ 2022-10-23 17:46 UTC (permalink / raw)
  To: 58745

I'm calling `eglot' from lisp. The doc string says the first argument
`managed-major-mode' is an atom, not a list. But it is passed to
eglot--connect as the first argument, which is expected to be a list of
major modes. When called interactively, `managed-major-mode' is set by
(eglot--guess-contact t), which returns a list.

So when not interactive, `eglot' must convert `managed-major-mode' into
a list:

-------------------
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 71001ba680..dee88db022 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1078,6 +1078,8 @@ eglot
 
 INTERACTIVE is t if called interactively."
   (interactive (append (eglot--guess-contact t) '(t)))
+  (unless (listp managed-major-mode)
+    (setq managed-major-mode (list managed-major-mode)))
   (let* ((current-server (eglot-current-server))
          (live-p (and current-server (jsonrpc-running-p current-server))))
     (if (and live-p
------------------


-- 
-- Stephe
In GNU Emacs 29.0.50 (build 1, x86_64-w64-mingw32) of 2022-10-22 built
 on DESKTOP-G20DCG1
Repository revision: 9db7b11cf7fa5d6cf624a467f966a14b347e4429
Repository branch: master
Windowing system distributor 'Microsoft Corp.', version 10.0.19044
System Description: Microsoft Windows 10 Pro (v10.0.2009.19044.2130)

Configured using:
 'configure
 PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig'

Configured features:
ACL DBUS GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY
W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS WEBP XPM ZLIB

Important settings:
  value of $LC_CTYPE: en_US.UTF-8
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: ELisp/l

Minor modes in effect:
  bug-reference-prog-mode: t
  other-frame-window-mode: t
  display-time-mode: t
  delete-selection-mode: t
  outline-minor-mode: t
  icomplete-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
c:/Projects/org.emacs.ada-mode/prj hides c:/Projects/org.emacs.gpr-query/prj
c:/Projects/org.emacs.ada-mode/prj-eglot hides c:/Projects/org.emacs.gpr-query/prj-eglot
c:/Projects/org.emacs.ada-mode/autoloads hides c:/Projects/org.emacs.gpr-query/autoloads
c:/Projects/org.emacs.ada-mode/autoloads hides c:/Projects/org.emacs.gnat-compiler/autoloads
c:/Projects/org.emacs.ada-mode/prj-eglot hides c:/Projects/org.emacs.wisi/prj-eglot
c:/Projects/org.emacs.ada-mode/autoloads hides c:/Projects/org.emacs.wisi/autoloads
c:/Projects/org.emacs.ada-mode/prj hides c:/Projects/org.wisitoken.grammar_mode/prj
c:/Projects/org.emacs.ada-mode/autoloads hides c:/Projects/org.wisitoken.grammar_mode/autoloads
c:/Projects/org.emacs.ada-mode/ada-ref-man hides c:/home/stephe/.emacs.d/elpa/ada-ref-man-2020.1.0.20201129.190419/ada-ref-man
c:/Projects/mmm-mode/mmm-vars hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-vars
c:/Projects/mmm-mode/mmm-utils hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-utils
c:/Projects/mmm-mode/mmm-univ hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-univ
c:/Projects/mmm-mode/mmm-sample hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-sample
c:/Projects/mmm-mode/mmm-rpm hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-rpm
c:/Projects/mmm-mode/mmm-region hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-region
c:/Projects/mmm-mode/mmm-noweb hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-noweb
c:/Projects/mmm-mode/mmm-myghty hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-myghty
c:/Projects/mmm-mode/mmm-mode hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-mode
c:/Projects/mmm-mode/mmm-mason hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-mason
c:/Projects/mmm-mode/mmm-erb hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-erb
c:/Projects/mmm-mode/mmm-defaults hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-defaults
c:/Projects/mmm-mode/mmm-cweb hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-cweb
c:/Projects/mmm-mode/mmm-compat hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-compat
c:/Projects/mmm-mode/mmm-cmds hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-cmds
c:/Projects/mmm-mode/mmm-class hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-class
c:/Projects/mmm-mode/mmm-auto hides c:/home/stephe/.emacs.d/elpa/mmm-mode-0.5.8.0.20221018.153958/mmm-auto

Features:
(shadow sort mail-extr emacsbug pulse color vc bug-reference help-fns
radix-tree cl-print misearch multi-isearch copyright cus-start edebug
ada-eglot ada-mode ada-imenu align ada-skel wisi-skel skeleton
ada_annex_p-process wisi-process-parse ada-indent-user-options ada-core
gnat-compiler vc-git diff-mode easy-mmode vc-dispatcher org-element
avl-tree generator ol-eww eww xdg url-queue mm-url ol-rmail ol-mhe
ol-irc ol-info ol-gnus nnselect gnus-art mm-uu mml2015 mm-view mml-smime
smime gnutls dig gnus-sum shr pixel-fill kinsoku url-file svg dom
gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap
nnmail mail-source utf7 nnoo parse-time gnus-spec gnus-int gnus-range
message sendmail yank-media puny rfc822 mml mml-sec epa derived
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mailabbrev gmm-utils mailheader gnus-win gnus nnheader
gnus-util mail-utils range mm-util mail-prsvr wid-edit ol-docview
doc-view jka-compr image-mode exif ol-bibtex ol-bbdb ol-w3m ol-doi
org-link-doi org-mode-keys org ob ob-tangle ob-ref ob-lob ob-table
ob-exp org-macro org-footnote org-src ob-comint org-pcomplete pcomplete
org-list org-faces org-entities org-version ob-emacs-lisp ob-core
ob-eval org-table oc-basic bibtex iso8601 time-date ol rx org-keys oc
org-compat advice org-macs org-loaddefs format-spec cal-menu calendar
cal-loaddefs wisi-prj wisi wisi-fringe wisi-parse-common semantic/lex
semantic/fw mode-local find-file eglot array filenotify jsonrpc ert pp
debug backtrace find-func flymake-proc flymake warnings pcase imenu
mmm-auto mmm-vars mmm-utils mmm-compat dvc-autoloads dvc-unified ffap
thingatpt dvc-revlist dvc-fileinfo dvc-core dvc-buffers dvc-ui
dvc-register dvc-utils ewoc dvc-emacs dvc-defs autoloads
other-frame-window grep time delsel cus-load stephe-theme noutline
outline icons path-iterator cl-extra help-mode whitespace dired-x
dired-aux dired dired-loaddefs compile text-property-search comint
ansi-osc ansi-color uniquify-files icomplete xref project ring
ada-ref-man-autoloads bbdb-autoloads info debbugs-autoloads
gnu-elpa-keyring-update-autoloads epg rfc6068 epg-config
gnu-elpa-keyring-update helm-autoloads helm-core-autoloads
async-autoloads mmm-mode-autoloads other-frame-window-autoloads
popup-autoloads uniquify-files-autoloads package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x
map byte-opt gv bytecomp byte-compile cconv url-vars cl-loaddefs cl-lib
rmc iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel dos-w32 ls-lisp disp-table
term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads w32notify dbusbind w32 lcms2
multi-tty make-network-process emacs)

Memory information:
((conses 16 283572 42382)
 (symbols 48 29015 0)
 (strings 32 97057 4158)
 (string-bytes 1 2980479)
 (vectors 16 51760)
 (vector-slots 8 619438 29596)
 (floats 8 411 501)
 (intervals 56 3878 22)
 (buffers 1000 28))





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#58745: 29.0.50; eglot managed-major-mode must be a list
  2022-10-23 17:46 bug#58745: 29.0.50; eglot managed-major-mode must be a list Stephen Leake
@ 2022-10-27 16:19 ` Eli Zaretskii
  2022-10-27 17:27   ` João Távora
  2022-10-27 17:34   ` Robert Pluim
  0 siblings, 2 replies; 7+ messages in thread
From: Eli Zaretskii @ 2022-10-27 16:19 UTC (permalink / raw)
  To: Stephen Leake, João Távora; +Cc: 58745

> From: Stephen Leake <stephen_leake@stephe-leake.org>
> Date: Sun, 23 Oct 2022 10:46:08 -0700
> 
> I'm calling `eglot' from lisp. The doc string says the first argument
> `managed-major-mode' is an atom, not a list. But it is passed to
> eglot--connect as the first argument, which is expected to be a list of
> major modes. When called interactively, `managed-major-mode' is set by
> (eglot--guess-contact t), which returns a list.
> 
> So when not interactive, `eglot' must convert `managed-major-mode' into
> a list:
> 
> -------------------
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index 71001ba680..dee88db022 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -1078,6 +1078,8 @@ eglot
>  
>  INTERACTIVE is t if called interactively."
>    (interactive (append (eglot--guess-contact t) '(t)))
> +  (unless (listp managed-major-mode)
> +    (setq managed-major-mode (list managed-major-mode)))
>    (let* ((current-server (eglot-current-server))
>           (live-p (and current-server (jsonrpc-running-p current-server))))
>      (if (and live-p
> ------------------

João, any comments?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#58745: 29.0.50; eglot managed-major-mode must be a list
  2022-10-27 16:19 ` Eli Zaretskii
@ 2022-10-27 17:27   ` João Távora
  2022-10-27 17:37     ` Eli Zaretskii
  2022-10-27 17:51     ` Stephen Leake
  2022-10-27 17:34   ` Robert Pluim
  1 sibling, 2 replies; 7+ messages in thread
From: João Távora @ 2022-10-27 17:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 58745, Stephen Leake

[-- Attachment #1: Type: text/plain, Size: 1822 bytes --]

Yes, this has been discussed on emacs-devel and an equivalent patch
pushed.

So the bug can be closed.

The function eglot doesn't have any non-interactive use that I can envision.
Its INTERACTIVE argument is a historical remnant from a time where
the function was called eglot-start-process.  Nevertheless, it makes sense
that it converts the argument into a list.

Stephen, I would advise against using eglot from Lisp, in principle
but I haven't seen your use case

João


On Thu, Oct 27, 2022 at 5:19 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Stephen Leake <stephen_leake@stephe-leake.org>
> > Date: Sun, 23 Oct 2022 10:46:08 -0700
> >
> > I'm calling `eglot' from lisp. The doc string says the first argument
> > `managed-major-mode' is an atom, not a list. But it is passed to
> > eglot--connect as the first argument, which is expected to be a list of
> > major modes. When called interactively, `managed-major-mode' is set by
> > (eglot--guess-contact t), which returns a list.
> >
> > So when not interactive, `eglot' must convert `managed-major-mode' into
> > a list:
> >
> > -------------------
> > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> > index 71001ba680..dee88db022 100644
> > --- a/lisp/progmodes/eglot.el
> > +++ b/lisp/progmodes/eglot.el
> > @@ -1078,6 +1078,8 @@ eglot
> >
> >  INTERACTIVE is t if called interactively."
> >    (interactive (append (eglot--guess-contact t) '(t)))
> > +  (unless (listp managed-major-mode)
> > +    (setq managed-major-mode (list managed-major-mode)))
> >    (let* ((current-server (eglot-current-server))
> >           (live-p (and current-server (jsonrpc-running-p
> current-server))))
> >      (if (and live-p
> > ------------------
>
> João, any comments?
>


-- 
João Távora

[-- Attachment #2: Type: text/html, Size: 2599 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#58745: 29.0.50; eglot managed-major-mode must be a list
  2022-10-27 16:19 ` Eli Zaretskii
  2022-10-27 17:27   ` João Távora
@ 2022-10-27 17:34   ` Robert Pluim
  2022-10-27 17:39     ` João Távora
  1 sibling, 1 reply; 7+ messages in thread
From: Robert Pluim @ 2022-10-27 17:34 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 58745, Stephen Leake, João Távora

>>>>> On Thu, 27 Oct 2022 19:19:09 +0300, Eli Zaretskii <eliz@gnu.org> said:

    Eli> João, any comments?

João already fixed this on master (but didnʼt put (Bug#58745) in the
commit message).

Robert
-- 





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#58745: 29.0.50; eglot managed-major-mode must be a list
  2022-10-27 17:27   ` João Távora
@ 2022-10-27 17:37     ` Eli Zaretskii
  2022-10-27 17:51     ` Stephen Leake
  1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2022-10-27 17:37 UTC (permalink / raw)
  To: João Távora; +Cc: 58745-done, stephen_leake

> From: João Távora <joaotavora@gmail.com>
> Date: Thu, 27 Oct 2022 18:27:14 +0100
> Cc: Stephen Leake <stephen_leake@stephe-leake.org>, 58745@debbugs.gnu.org
> 
> Yes, this has been discussed on emacs-devel and an equivalent patch
> pushed.
> 
> So the bug can be closed.

Done.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#58745: 29.0.50; eglot managed-major-mode must be a list
  2022-10-27 17:34   ` Robert Pluim
@ 2022-10-27 17:39     ` João Távora
  0 siblings, 0 replies; 7+ messages in thread
From: João Távora @ 2022-10-27 17:39 UTC (permalink / raw)
  To: Robert Pluim; +Cc: 58745, Eli Zaretskii, Stephen Leake

[-- Attachment #1: Type: text/plain, Size: 800 bytes --]

> João already fixed this on master (but didnʼt put (Bug#58745) in the
> commit message).

I think it was Stephen's commit:

commit 31945b6c3fcbdb6f242f0063811d2fb91e4520cd
Author: Stephen Leake <stephen_leake@stephe-leake.org>
Date:   Tue Oct 25 02:15:13 2022 -0700

  * lisp/progmodes/eglot.el (eglot): Ensure managed-major-mode is a list

I just fixed a bug this introduced in a subsequent commit (didn't use a bug
id
because neither did the original commit and the fix was somewhat urgent,
as M-x eglot was broken.  So I didn't search the db for one.):

commit 0b1eda215d32839c9f6281d20f8a347f34bb5ab5
Author: João Távora <joaotavora@gmail.com>
Date:   Tue Oct 25 10:34:08 2022 +0100

  Fix M-x eglot breakage due to typo

  * lisp/progmodes/eglot.el (eglot): Fix bug.

[-- Attachment #2: Type: text/html, Size: 1133 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#58745: 29.0.50; eglot managed-major-mode must be a list
  2022-10-27 17:27   ` João Távora
  2022-10-27 17:37     ` Eli Zaretskii
@ 2022-10-27 17:51     ` Stephen Leake
  1 sibling, 0 replies; 7+ messages in thread
From: Stephen Leake @ 2022-10-27 17:51 UTC (permalink / raw)
  To: João Távora; +Cc: Eli Zaretskii, 58745

João Távora <joaotavora@gmail.com> writes:

> Yes, this has been discussed on emacs-devel and an equivalent patch
> pushed.
>
> So the bug can be closed.
>
> The function eglot doesn't have any non-interactive use that I can envision.
> Its INTERACTIVE argument is a historical remnant from a time where
> the function was called eglot-start-process.  Nevertheless, it makes sense
> that it converts the argument into a list.
>
> Stephen, I would advise against using eglot from Lisp, in principle
> but I haven't seen your use case

It will be in ada-mode 8.0, to be released soon; currently at

https://git.savannah.nongnu.org/cgit/ada-mode.git/tree/ada-eglot.el?h=org.emacs.ada-mode

I'm still fussing with it, but the core reason I'm calling eglot
directly is because the lsp server executable filename needs to be
computed at the time eglot is called, and eglot-workspace-configuration
needs to be let-bound to specify the project file used by the Ada lsp
server.

The first issue is mainly so I can change it easily to test alternate
versions/patches to the server; users may want to do the same, or even
use different versions with different projects. I could change exec-path
instead, but the current way seems cleaner.

The second issue should be fixed by using :initializeOptions instead,
but that's broken in the current Ada server. It still needs to be
computed on a per-project basis.

I could set elgot-server-programs with the locally-computed values, and
then use (call-interactively eglot), if you really want the args to
eglot to go away.

But I think calling eglot directly is more in keeping with the flavor of
ada-mode's use of it; it's just an alternative backend for various
features, not the primary user interface. 

-- 
-- Stephe





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-27 17:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-23 17:46 bug#58745: 29.0.50; eglot managed-major-mode must be a list Stephen Leake
2022-10-27 16:19 ` Eli Zaretskii
2022-10-27 17:27   ` João Távora
2022-10-27 17:37     ` Eli Zaretskii
2022-10-27 17:51     ` Stephen Leake
2022-10-27 17:34   ` Robert Pluim
2022-10-27 17:39     ` João Távora

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).