all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#60379: [PATCH] Eglot: don't use "nil" as minibuffer initial input
@ 2022-12-28 12:22 Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-01-12  9:31 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-28 12:22 UTC (permalink / raw)
  To: 60379

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

Tags: patch

Hello,

Currently, doing emacs -Q and followed by M-x eglot in the scratch
buffer results in a prompt for major mode to manage with LSP, but the
initial minibuffer input as well as the default value for the
completing-read call are both set to the string "nil", which is not very
helpful as that's not a valid input.

This patch tweaks the prompt a little and avoids this issue by leaving
the minibuffer's initial input empty and making sure we don't set the
default value to "nil" either.

Thanks,
Eshel

In GNU Emacs 30.0.50 (build 19, x86_64-apple-darwin22.1.0, NS
 appkit-2299.00 Version 13.0 (Build 22A380)) of 2022-12-26 built on
 esmac
Repository revision: cc29fab3a66c59e77d0ff67c0f3e2e34ec80a03c
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2299
System Description:  macOS 13.0

Configured using:
 'configure --with-native-compilation --enable-link-time-optimization
 --with-json --with-xwidgets --with-mailutils --with-imagemagick
 --without-dbus'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Eglot-don-t-use-nil-as-minibuffer-initial-input.patch --]
[-- Type: text/patch, Size: 1915 bytes --]

From 66d17efabaca0f3d08b78529c8d64fc65dc799e2 Mon Sep 17 00:00:00 2001
From: Eshel Yaron <me@eshelyaron.com>
Date: Wed, 28 Dec 2022 13:59:53 +0200
Subject: [PATCH] Eglot: don't use "nil" as minibuffer initial input

Doing M-x eglot in a buffer for which buffer-file-name is nil, prompts
the user for a major mode to manage by invoking completing-read.  The
way completing-read was called would end up with the string "nil" as
the initial minibuffer input, which is not very useful nor is it a
valid input.

* lisp/progmodes/eglot.el (eglot--guess-contact): tweak prompt for
major mode.
---
 lisp/progmodes/eglot.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 15cb1b6fad..57f9be718f 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -991,6 +991,7 @@ eglot--guess-contact
 non-nil, maybe prompt user, else error as soon as something can't
 be guessed."
   (let* ((guessed-mode (if buffer-file-name major-mode))
+         (guessed-mode-name (and guessed-mode (symbol-name guessed-mode)))
          (main-mode
           (cond
            ((and interactive
@@ -998,9 +999,10 @@ eglot--guess-contact
                      (not guessed-mode)))
             (intern
              (completing-read
-              "[eglot] Start a server to manage buffers of what major mode? "
-              (mapcar #'symbol-name (eglot--all-major-modes)) nil t
-              (symbol-name guessed-mode) nil (symbol-name guessed-mode) nil)))
+              (format-prompt "Start LSP server for major mode"
+                             guessed-mode-name)
+              (mapcar #'symbol-name (eglot--all-major-modes))
+              nil t nil nil guessed-mode-name nil)))
            ((not guessed-mode)
             (eglot--error "Can't guess mode to manage for `%s'" (current-buffer)))
            (t guessed-mode)))
-- 
2.38.1


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

* bug#60379: [PATCH] Eglot: don't use "nil" as minibuffer initial input
  2022-12-28 12:22 bug#60379: [PATCH] Eglot: don't use "nil" as minibuffer initial input Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-01-12  9:31 ` Eli Zaretskii
  2023-01-12 10:20   ` João Távora
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2023-01-12  9:31 UTC (permalink / raw)
  To: Eshel Yaron, João Távora; +Cc: 60379

> Date: Wed, 28 Dec 2022 14:22:17 +0200
> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> Currently, doing emacs -Q and followed by M-x eglot in the scratch
> buffer results in a prompt for major mode to manage with LSP, but the
> initial minibuffer input as well as the default value for the
> completing-read call are both set to the string "nil", which is not very
> helpful as that's not a valid input.
> 
> This patch tweaks the prompt a little and avoids this issue by leaving
> the minibuffer's initial input empty and making sure we don't set the
> default value to "nil" either.

João, are you looking into this?  WDYT?





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

* bug#60379: [PATCH] Eglot: don't use "nil" as minibuffer initial input
  2023-01-12  9:31 ` Eli Zaretskii
@ 2023-01-12 10:20   ` João Távora
  2023-01-14  8:16     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: João Távora @ 2023-01-12 10:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Eshel Yaron, 60379

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Wed, 28 Dec 2022 14:22:17 +0200
>> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> 
>> Currently, doing emacs -Q and followed by M-x eglot in the scratch
>> buffer results in a prompt for major mode to manage with LSP, but the
>> initial minibuffer input as well as the default value for the
>> completing-read call are both set to the string "nil", which is not very
>> helpful as that's not a valid input.
>> 
>> This patch tweaks the prompt a little and avoids this issue by leaving
>> the minibuffer's initial input empty and making sure we don't set the
>> default value to "nil" either.
>
> João, are you looking into this?  WDYT?

No, I wasn't until now.

The idea looks sane, but I think 'format-prompt' can't be used if Eglot
is to continue supporting Emacs 26 and 27.  Also I'd prefer if the patch
is slightly less disruptive to whitespace, like this:

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 15cb1b6fad..eb3b51ed8b 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -991,6 +991,7 @@ eglot--guess-contact
 non-nil, maybe prompt user, else error as soon as something can't
 be guessed."
   (let* ((guessed-mode (if buffer-file-name major-mode))
+         (guessed-mode-name (and guessed-mode (symbol-name guessed-mode)))
          (main-mode
           (cond
            ((and interactive
@@ -1000,7 +1001,7 @@ eglot--guess-contact
              (completing-read
               "[eglot] Start a server to manage buffers of what major mode? "
               (mapcar #'symbol-name (eglot--all-major-modes)) nil t
-              (symbol-name guessed-mode) nil (symbol-name guessed-mode) nil)))
+              guessed-mode-name nil guessed-mode-name nil)))
            ((not guessed-mode)
             (eglot--error "Can't guess mode to manage for `%s'" (current-buffer)))
            (t guessed-mode)))

Other than that, it's fine to commit.

João





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

* bug#60379: [PATCH] Eglot: don't use "nil" as minibuffer initial input
  2023-01-12 10:20   ` João Távora
@ 2023-01-14  8:16     ` Eli Zaretskii
  2023-01-14  9:33       ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2023-01-14  8:16 UTC (permalink / raw)
  To: João Távora; +Cc: me, 60379-done

> From: João Távora <joaotavora@gmail.com>
> Cc: Eshel Yaron <me@eshelyaron.com>,  60379@debbugs.gnu.org
> Date: Thu, 12 Jan 2023 10:20:27 +0000
> 
> The idea looks sane, but I think 'format-prompt' can't be used if Eglot
> is to continue supporting Emacs 26 and 27.  Also I'd prefer if the patch
> is slightly less disruptive to whitespace, like this:
> 
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index 15cb1b6fad..eb3b51ed8b 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -991,6 +991,7 @@ eglot--guess-contact
>  non-nil, maybe prompt user, else error as soon as something can't
>  be guessed."
>    (let* ((guessed-mode (if buffer-file-name major-mode))
> +         (guessed-mode-name (and guessed-mode (symbol-name guessed-mode)))
>           (main-mode
>            (cond
>             ((and interactive
> @@ -1000,7 +1001,7 @@ eglot--guess-contact
>               (completing-read
>                "[eglot] Start a server to manage buffers of what major mode? "
>                (mapcar #'symbol-name (eglot--all-major-modes)) nil t
> -              (symbol-name guessed-mode) nil (symbol-name guessed-mode) nil)))
> +              guessed-mode-name nil guessed-mode-name nil)))
>             ((not guessed-mode)
>              (eglot--error "Can't guess mode to manage for `%s'" (current-buffer)))
>             (t guessed-mode)))
> 
> Other than that, it's fine to commit.

OK, done, and closing the bug.

Yaron, this change was small enough to accept without copyright
assignment, but if you intend to continue contributing to Emacs (and
we hope you do), I recommend to start your copyright assignment
paperwork rolling at this time.  If you agree, I will send you the
form to fill and the instructions to email it.

Thanks.





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

* bug#60379: [PATCH] Eglot: don't use "nil" as minibuffer initial input
  2023-01-14  8:16     ` Eli Zaretskii
@ 2023-01-14  9:33       ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-01-14 10:52         ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-01-14  9:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: João Távora, 60379-done

Eli Zaretskii <eliz@gnu.org> writes:

>> From: João Távora <joaotavora@gmail.com>
>> Cc: Eshel Yaron <me@eshelyaron.com>,  60379@debbugs.gnu.org
>> Date: Thu, 12 Jan 2023 10:20:27 +0000
>> 
>> The idea looks sane, but I think 'format-prompt' can't be used if Eglot
>> is to continue supporting Emacs 26 and 27.  Also I'd prefer if the patch
>> is slightly less disruptive to whitespace, like this:
>> 
>> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
>> index 15cb1b6fad..eb3b51ed8b 100644
>> --- a/lisp/progmodes/eglot.el
>> +++ b/lisp/progmodes/eglot.el
>> @@ -991,6 +991,7 @@ eglot--guess-contact
>>  non-nil, maybe prompt user, else error as soon as something can't
>>  be guessed."
>>    (let* ((guessed-mode (if buffer-file-name major-mode))
>> +         (guessed-mode-name (and guessed-mode (symbol-name guessed-mode)))
>>           (main-mode
>>            (cond
>>             ((and interactive
>> @@ -1000,7 +1001,7 @@ eglot--guess-contact
>>               (completing-read
>>                "[eglot] Start a server to manage buffers of what major mode? "
>>                (mapcar #'symbol-name (eglot--all-major-modes)) nil t
>> -              (symbol-name guessed-mode) nil (symbol-name guessed-mode) nil)))
>> +              guessed-mode-name nil guessed-mode-name nil)))
>>             ((not guessed-mode)
>>              (eglot--error "Can't guess mode to manage for `%s'" (current-buffer)))
>>             (t guessed-mode)))
>> 
>> Other than that, it's fine to commit.
>
> OK, done, and closing the bug.

Hello João and Eli,

Thanks for looking into it and applying the patch.

> Yaron, this change was small enough to accept without copyright
> assignment, but if you intend to continue contributing to Emacs (and
> we hope you do), I recommend to start your copyright assignment
> paperwork rolling at this time.  If you agree, I will send you the
> form to fill and the instructions to email it.

Alright, please send it over.


Eshel





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

* bug#60379: [PATCH] Eglot: don't use "nil" as minibuffer initial input
  2023-01-14  9:33       ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-01-14 10:52         ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2023-01-14 10:52 UTC (permalink / raw)
  To: Eshel Yaron; +Cc: joaotavora, 60379-done

> From: Eshel Yaron <me@eshelyaron.com>
> Cc: João Távora <joaotavora@gmail.com>,
>   60379-done@debbugs.gnu.org
> Date: Sat, 14 Jan 2023 11:33:27 +0200
> 
> > Yaron, this change was small enough to accept without copyright
> > assignment, but if you intend to continue contributing to Emacs (and
> > we hope you do), I recommend to start your copyright assignment
> > paperwork rolling at this time.  If you agree, I will send you the
> > form to fill and the instructions to email it.
> 
> Alright, please send it over.

Form sent off-list.





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

end of thread, other threads:[~2023-01-14 10:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-28 12:22 bug#60379: [PATCH] Eglot: don't use "nil" as minibuffer initial input Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-12  9:31 ` Eli Zaretskii
2023-01-12 10:20   ` João Távora
2023-01-14  8:16     ` Eli Zaretskii
2023-01-14  9:33       ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-14 10:52         ` Eli Zaretskii

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.