diff options
| author | João Távora | 2023-11-07 09:09:30 -0600 |
|---|---|---|
| committer | João Távora | 2023-11-07 09:09:44 -0600 |
| commit | 3ab99e977db01939cc42f285d5ce58807cf2e7d0 (patch) | |
| tree | 3f3e12f65d5dbc4be018d26a125a33563a4bd90a | |
| parent | 361f9fe4152f8dbb2a8c36c97bae13f689b606f0 (diff) | |
| download | emacs-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.texi | 27 | ||||
| -rw-r--r-- | lisp/progmodes/eglot.el | 17 |
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 | |||
| 139 | a buffer visiting any file that belongs to the project. This starts | 139 | a buffer visiting any file that belongs to the project. This starts |
| 140 | the language server configured for the programming language of that | 140 | the language server configured for the programming language of that |
| 141 | buffer, and causes Eglot to start managing all the files of the | 141 | buffer, and causes Eglot to start managing all the files of the |
| 142 | project which use the same programming language. The notion of a | 142 | project which use the same programming language. This includes files |
| 143 | ``project'' used by Eglot is the same Emacs uses (@pxref{Projects,,, | 143 | of a given project that are already visited at the time the |
| 144 | emacs, GNU Emacs Manual}): in the simplest case, the ``project'' is | 144 | @code{eglot} command is invoked as well as files visited after this |
| 145 | the single file you are editing, but it can also be all the files in a | 145 | invocation. |
| 146 | single directory or a directory tree under some version control | ||
| 147 | system, such as Git. | ||
| 148 | 146 | ||
| 149 | Alternatively, you can start Eglot automatically from the major-mode | 147 | The notion of a ``project'' used by Eglot is the same Emacs uses |
| 150 | hook of the mode used for the programming language; see @ref{Starting | 148 | (@pxref{Projects,,, emacs, GNU Emacs Manual}): in the simplest case, |
| 151 | Eglot}. | 149 | the ``project'' is the single file you are editing, but it can also be |
| 150 | all the files in a single directory or a directory tree under some | ||
| 151 | version control system, such as Git. | ||
| 152 | |||
| 153 | There are alternate ways of starting Eglot; see @ref{Starting Eglot} | ||
| 154 | for details. | ||
| 152 | 155 | ||
| 153 | @item | 156 | @item |
| 154 | Use Eglot. | 157 | Use Eglot. |
| @@ -344,6 +347,12 @@ starting an Eglot session is non-interactive, so it should be used | |||
| 344 | only when you are confident that Eglot can be started reliably for any | 347 | only when you are confident that Eglot can be started reliably for any |
| 345 | file which may be visited with the major-mode in question. | 348 | file which may be visited with the major-mode in question. |
| 346 | 349 | ||
| 350 | Note that it's often difficult to establish this confidence fully, so | ||
| 351 | it may be wise to use the interactive command @code{eglot} instead. | ||
| 352 | You only need to invoke it once per project, as all other files | ||
| 353 | visited within the same project will automatically be managed with no | ||
| 354 | further user intervention needed. | ||
| 355 | |||
| 347 | When Eglot connects to a language server for the first time in an | 356 | When Eglot connects to a language server for the first time in an |
| 348 | Emacs session, it runs the hook @code{eglot-connect-hook} | 357 | Emacs 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 | |||
| 1371 | Only use this function (in major mode hooks, etc) if you are | ||
| 1372 | confident that Eglot can be started safely and efficiently for | ||
| 1373 | *every* buffer visited where these hooks may execute. | ||
| 1374 | |||
| 1375 | Since it is difficult to establish this confidence fully, it's | ||
| 1376 | often wise to use the interactive command `eglot' instead. This | ||
| 1377 | command only needs to be invoked once per project, as all other | ||
| 1378 | files of a given major mode visited within the same project will | ||
| 1379 | automatically become managed with no further user intervention | ||
| 1380 | needed." | ||
| 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 | ||