From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60379: [PATCH] Eglot: don't use "nil" as minibuffer initial input Date: Wed, 28 Dec 2022 14:22:17 +0200 Message-ID: Reply-To: Eshel Yaron Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5373"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 60379@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 28 13:23:19 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pAVSp-0001G3-Ka for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 28 Dec 2022 13:23:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAVSa-0001eu-31; Wed, 28 Dec 2022 07:23:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pAVSZ-0001el-8L for bug-gnu-emacs@gnu.org; Wed, 28 Dec 2022 07:23:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAVSZ-00072i-00 for bug-gnu-emacs@gnu.org; Wed, 28 Dec 2022 07:23:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pAVSY-0006ef-Fh for bug-gnu-emacs@gnu.org; Wed, 28 Dec 2022 07:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Dec 2022 12:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60379 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167223014425506 (code B ref -1); Wed, 28 Dec 2022 12:23:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Dec 2022 12:22:24 +0000 Original-Received: from localhost ([127.0.0.1]:57226 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAVRv-0006dK-Gb for submit@debbugs.gnu.org; Wed, 28 Dec 2022 07:22:23 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:56384) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAVRu-0006dD-HN for submit@debbugs.gnu.org; Wed, 28 Dec 2022 07:22:22 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pAVRu-0001aE-AY for bug-gnu-emacs@gnu.org; Wed, 28 Dec 2022 07:22:22 -0500 Original-Received: from mail.eshelyaron.com ([107.175.124.16] helo=eshelyaron.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pAVRs-0006z6-Ni for bug-gnu-emacs@gnu.org; Wed, 28 Dec 2022 07:22:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1672230139; bh=kFb8D9+YgqQMWVLpOcboMGMMvp6N1ExdfJVktPbjPoc=; h=From:To:Subject:Date:From; b=Td+Cs3w826TtWGoWwIt7Qa/G1tmjBicNAhrmI/q2K0zRhbWu+9Tqrzmz9rhgDDgoI 6Dttxkw4nVV32i4iNV7S0Z7vK4QnerHYbfOV9V+G77V9zR7ERMwxCIdtN/mfw/BbCx mvtOpaDUvRFo1vxDiwYs3h7Tz3RADzpiG3cFU1JomN7GG5/gaGjEdCbAvmB83HdBhJ mLWfkgAqOM8e080A5M6vyi2nyLIb6RWIEhM3yMFh4htD7qPR3wjwrHHyZ+9iXMubCq EF+b8NXfp8Uy1V81EiYIH0Mkm3+bC7XLUFE0K5xaKovhxE9awkfWr+WzlXp6iIqdd7 fWyCr2x8hbIHw== Received-SPF: pass client-ip=107.175.124.16; envelope-from=me@eshelyaron.com; helo=eshelyaron.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:251981 Archived-At: --=-=-= Content-Type: text/plain 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' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Eglot-don-t-use-nil-as-minibuffer-initial-input.patch >From 66d17efabaca0f3d08b78529c8d64fc65dc799e2 Mon Sep 17 00:00:00 2001 From: Eshel Yaron 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 --=-=-=--