aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2023-11-07 09:09:30 -0600
committerJoão Távora2023-11-07 09:09:44 -0600
commit3ab99e977db01939cc42f285d5ce58807cf2e7d0 (patch)
tree3f3e12f65d5dbc4be018d26a125a33563a4bd90a
parent361f9fe4152f8dbb2a8c36c97bae13f689b606f0 (diff)
downloademacs-3ab99e977db01939cc42f285d5ce58807cf2e7d0.tar.gz
emacs-3ab99e977db01939cc42f285d5ce58807cf2e7d0.zip
Eglot: Demote errors to warnings in eglot-ensure
Github-reference: https://github.com/joaotavora/eglot/discussions/1318 * doc/misc/eglot.texi (Quick Start): Reword. (Starting Eglot): Reword. * lisp/progmodes/eglot.el (eglot-ensure): Demote errors to warnings.
-rw-r--r--doc/misc/eglot.texi27
-rw-r--r--lisp/progmodes/eglot.el17
2 files changed, 33 insertions, 11 deletions
diff --git a/doc/misc/eglot.texi b/doc/misc/eglot.texi
index 9ffea80b641..2d9b2a2b60e 100644
--- a/doc/misc/eglot.texi
+++ b/doc/misc/eglot.texi
@@ -139,16 +139,19 @@ To start using Eglot for a project, type @kbd{M-x eglot @key{RET}} in
139a buffer visiting any file that belongs to the project. This starts 139a buffer visiting any file that belongs to the project. This starts
140the language server configured for the programming language of that 140the language server configured for the programming language of that
141buffer, and causes Eglot to start managing all the files of the 141buffer, and causes Eglot to start managing all the files of the
142project which use the same programming language. The notion of a 142project which use the same programming language. This includes files
143``project'' used by Eglot is the same Emacs uses (@pxref{Projects,,, 143of a given project that are already visited at the time the
144emacs, GNU Emacs Manual}): in the simplest case, the ``project'' is 144@code{eglot} command is invoked as well as files visited after this
145the single file you are editing, but it can also be all the files in a 145invocation.
146single directory or a directory tree under some version control
147system, such as Git.
148 146
149Alternatively, you can start Eglot automatically from the major-mode 147The notion of a ``project'' used by Eglot is the same Emacs uses
150hook of the mode used for the programming language; see @ref{Starting 148(@pxref{Projects,,, emacs, GNU Emacs Manual}): in the simplest case,
151Eglot}. 149the ``project'' is the single file you are editing, but it can also be
150all the files in a single directory or a directory tree under some
151version control system, such as Git.
152
153There are alternate ways of starting Eglot; see @ref{Starting Eglot}
154for details.
152 155
153@item 156@item
154Use Eglot. 157Use Eglot.
@@ -344,6 +347,12 @@ starting an Eglot session is non-interactive, so it should be used
344only when you are confident that Eglot can be started reliably for any 347only when you are confident that Eglot can be started reliably for any
345file which may be visited with the major-mode in question. 348file which may be visited with the major-mode in question.
346 349
350Note that it's often difficult to establish this confidence fully, so
351it may be wise to use the interactive command @code{eglot} instead.
352You only need to invoke it once per project, as all other files
353visited within the same project will automatically be managed with no
354further user intervention needed.
355
347When Eglot connects to a language server for the first time in an 356When Eglot connects to a language server for the first time in an
348Emacs session, it runs the hook @code{eglot-connect-hook} 357Emacs session, it runs the hook @code{eglot-connect-hook}
349(@pxref{Eglot Variables}). 358(@pxref{Eglot Variables}).
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index eba66503bf7..816f6952d2e 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1366,7 +1366,18 @@ INTERACTIVE is t if called interactively."
1366 1366
1367;;;###autoload 1367;;;###autoload
1368(defun eglot-ensure () 1368(defun eglot-ensure ()
1369 "Start Eglot session for current buffer if there isn't one." 1369 "Start Eglot session for current buffer if there isn't one.
1370
1371Only use this function (in major mode hooks, etc) if you are
1372confident that Eglot can be started safely and efficiently for
1373*every* buffer visited where these hooks may execute.
1374
1375Since it is difficult to establish this confidence fully, it's
1376often wise to use the interactive command `eglot' instead. This
1377command only needs to be invoked once per project, as all other
1378files of a given major mode visited within the same project will
1379automatically become managed with no further user intervention
1380needed."
1370 (let ((buffer (current-buffer))) 1381 (let ((buffer (current-buffer)))
1371 (cl-labels 1382 (cl-labels
1372 ((maybe-connect 1383 ((maybe-connect
@@ -1374,7 +1385,9 @@ INTERACTIVE is t if called interactively."
1374 (eglot--when-live-buffer buffer 1385 (eglot--when-live-buffer buffer
1375 (remove-hook 'post-command-hook #'maybe-connect t) 1386 (remove-hook 'post-command-hook #'maybe-connect t)
1376 (unless eglot--managed-mode 1387 (unless eglot--managed-mode
1377 (apply #'eglot--connect (eglot--guess-contact)))))) 1388 (condition-case-unless-debug oops
1389 (apply #'eglot--connect (eglot--guess-contact))
1390 (error (eglot--warn (error-message-string oops))))))))
1378 (when buffer-file-name 1391 (when buffer-file-name
1379 (add-hook 'post-command-hook #'maybe-connect 'append t))))) 1392 (add-hook 'post-command-hook #'maybe-connect 'append t)))))
1380 1393