all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#60570: 29.0.60; Eglot+pyright freeze Emacs when edit a single file in Home director
@ 2023-01-05  8:57 Eason Huang
  0 siblings, 0 replies; 6+ messages in thread
From: Eason Huang @ 2023-01-05  8:57 UTC (permalink / raw)
  To: 60570


Hi Emacs dev team,

I use Emacs 29 with eglot + pyright, Eglot will freeze Emacs when editing
a single test.py file.

Steps to reproduce:
On macOS, only pyright is installed on the system
1. install pyright
```
$ sudo npm install -g pyright
$ pyright --version
pyright 1.1.286

```
2. C-x C-f ~/test.py Open a python file and I just want to test some simple code.
3. M-x eglot At this point, Emacs freezes and the find program takes up 99% of the
system's resources. Finally, you has to force quit Emacs.

I guess this is because Eglot will delegate project.el to search the entire
`~/` directory by the program `find`.

If I use git to manage my test.py file, the issue is gone.

I am using Emacs 29 with commit:
https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-29&id=2569ede9c496bb060e0b88428cb541088aaba1f9

--
Eason Huang


In GNU Emacs 29.0.60 (build 1, x86_64-apple-darwin22.2.0, NS
 appkit-2299.30 Version 13.1 (Build 22C65)) of 2023-01-02 built on
 macbook
Windowing system distributor 'Apple', version 10.3.2299
System Description:  macOS 13.1

Configured using:
 'configure --with-native-compilation=aot 'CPPFLAGS=-I/opt/local/include
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
 'LDFLAGS=-L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-rpath
 /opt/local/lib/gcc12
 -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
 -arch x86_64''

Configured features:
ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM ZLIB

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

Major mode: Python

Minor modes in effect:
  eglot--managed-mode: t
  flymake-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-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:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny rfc822
mml mml-sec epa derived epg rfc6068 epg-config gnus-util mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
files-x find-dired dired dired-loaddefs grep time-date eglot
external-completion array filenotify jsonrpc ert pp ewoc debug backtrace
find-func xref flymake-proc flymake thingatpt compile
text-property-search url-util url-parse auth-source eieio eieio-core
password-cache json map url-vars imenu vc-svn python project byte-opt
pcase treesit comint ansi-osc ring cl-loaddefs comp comp-cstr warnings
icons subr-x rx cl-seq cl-macs gv cl-extra help-mode bytecomp
byte-compile cl-lib ansi-color rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/ns-win ns-win ucs-normalize mule-util 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 kqueue cocoa ns lcms2
multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 139166 11475)
 (symbols 48 11664 0)
 (strings 32 35088 1771)
 (string-bytes 1 1137571)
 (vectors 16 26979)
 (vector-slots 8 519329 21535)
 (floats 8 53 23)
 (intervals 56 269 0)
 (buffers 984 16))





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

* bug#60570: 29.0.60; Eglot+pyright freeze Emacs when edit a single file in Home director
       [not found] <m2bknd2wb7.fsf@foxmail.com>
@ 2023-01-05 21:38 ` João Távora
  2023-01-06 13:36   ` Eason Huang
  2023-01-06  6:17 ` Yuan Fu
  1 sibling, 1 reply; 6+ messages in thread
From: João Távora @ 2023-01-05 21:38 UTC (permalink / raw)
  To: 60570, Dmitry Gutov, aqua0210

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

Eason,

Eglot is asking project.el to tell it which files belong to a
project. I believe project.el uses find as a last-ditch effort, if
finds no other method to answer.

I'm afraid there can be no good solution to your problem, because by
invoking any project-aware operation on ~/test.py (and Eglot counts as
project-aware functionality) and in the absence of, say, a ~/.git you
are effectively telling `project.el` that your whole home directory is a
gigantic project, and there is no good way to determine the files in
that project but to use find.

You could:

1. configure your language server to not request project-wide file
   watching from the LSP client in certain directories (including the
   $HOME directory).  See your language server's documentation for this
   effect

2. Tell project.el via its interfaces (project-find-functions) that the
   "project" you store in your $HOME is composed of a relatively small and
   manageable set of files.

3. A very simple means -- but not the only means -- to do the above is to
   type `git init` in your $HOME directory.

4. Read project.el's documentation (and ask its maintainers) for other
   means to use project-find-functions to declare that a project exists
   in $HOME but does not include the full contents of your home
   directory as its files.

5. Stop opening Python scripts in your $HOME *and* auto-activating Eglot
   in them.  You may be auto-activating Eglot with eglot-ensure, but this
   is not recommended precisely because it carries with risks like this.

6. Request to project.el's maintainer that project.el interrupt up its
   very slow `find`-based search and returns only subset of results.

7. Request that Eglot honour the keyword didChangeWatchFiles when it is
   included in eglot-ignored-server-capabilities.  If you then also
   change your configuration to do this _only_ in certain directories
   (for example by utilizing directory-local variables or writing a
   slightly complicated whook), this would mitigate your problem. We
   can probably do this in eglot.el, but I don't see this as priority
   because of the burden on the user and it only solves the problem for
   Eglot, not all other project.el-using functionality.

I recommend restricting your use of eglot-ensure. It's very overrated
functionality. M-x eglot will probably only need to be typed once
or twice in a typical Emacs session.

You can also, possibly, "unfreeze" your emacs by using C-g or a killall
find issued from the console.

João

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

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

* bug#60570: 29.0.60; Eglot+pyright freeze Emacs when edit a  single file in Home director
       [not found] <m2bknd2wb7.fsf@foxmail.com>
  2023-01-05 21:38 ` bug#60570: 29.0.60; Eglot+pyright freeze Emacs when edit a single file in Home director João Távora
@ 2023-01-06  6:17 ` Yuan Fu
  2023-01-06 10:29   ` João Távora
  1 sibling, 1 reply; 6+ messages in thread
From: Yuan Fu @ 2023-01-06  6:17 UTC (permalink / raw)
  To: João Távora; +Cc: aqua0210, 60570, Dmitry Gutov


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

> 5. Stop opening Python scripts in your $HOME *and* auto-activating Eglot
>    in them.  You may be auto-activating Eglot with eglot-ensure, but this
>    is not recommended precisely because it carries with risks like this.
[...]
>
> I recommend restricting your use of eglot-ensure. It's very overrated
> functionality. M-x eglot will probably only need to be typed once 
> or twice in a typical Emacs session.

I use a custom function eglot-soft-ensure which only enables eglot if
there is already a LSP server running for the current project. This way
eglot doesn’t auto-start in which files that I don’t want it to start.

(defun eglot-soft-ensure ()
  "Turn on eglot when there is an exising server for the current project."
  (require 'eglot)
  (when-let* ((project (project-current))
              (eglot-server (gethash project eglot--servers-by-project)))
    (eglot-ensure)))

Yuan





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

* bug#60570: 29.0.60; Eglot+pyright freeze Emacs when edit a single file in Home director
  2023-01-06  6:17 ` Yuan Fu
@ 2023-01-06 10:29   ` João Távora
  2023-01-07 22:38     ` Yuan Fu
  0 siblings, 1 reply; 6+ messages in thread
From: João Távora @ 2023-01-06 10:29 UTC (permalink / raw)
  To: Yuan Fu; +Cc: Eason Huang, 60570, Dmitry Gutov

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

On Fri, Jan 6, 2023, 06:17 Yuan Fu <casouri@gmail.com> wrote:

> I use a custom function eglot-soft-ensure which only enables eglot if
> there is already a LSP server running for the current project. This way
> eglot doesn’t auto-start in which files that I don’t want it to start.
>
> (defun eglot-soft-ensure ()
>   "Turn on eglot when there is an exising server for the current project."
>   (require 'eglot)
>   (when-let* ((project (project-current))
>               (eglot-server (gethash project eglot--servers-by-project)))
>     (eglot-ensure)))

Hello Yuan,

I must me missing something, because I would say you can just
get rid of eglot-soft-ensure. I can't understand what it is adding
on top of the normal Eglot behaviour. From the manual:

"When you visit a file under the same project, whether an existing or a
new file, its buffer is automatically added to the set of buffers managed by
Eglot, and the server which supports the buffer’s major-mode is notified
about that. Thus, visiting a non-existent file
/home/joe/projects/fooey/lib/y.foo
in the above example will notify the server of the *.foo files’ language
that a new file was added to the project, even before the file appears
on disk. The special Eglot minor mode is also turned on automatically
in the buffer visiting the file."

https://joaotavora.github.io/eglot/#Eglot-and-Buffers

João

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

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

* bug#60570: 29.0.60; Eglot+pyright freeze Emacs when edit a single file in Home director
  2023-01-05 21:38 ` bug#60570: 29.0.60; Eglot+pyright freeze Emacs when edit a single file in Home director João Távora
@ 2023-01-06 13:36   ` Eason Huang
  0 siblings, 0 replies; 6+ messages in thread
From: Eason Huang @ 2023-01-06 13:36 UTC (permalink / raw)
  To: João Távora; +Cc: 60570, Dmitry Gutov

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

> Eason,
>
> Eglot is asking project.el to tell it which files belong to a
> project. I believe project.el uses find as a last-ditch effort, if
> finds no other method to answer.
>
> I'm afraid there can be no good solution to your problem, because by
> invoking any project-aware operation on ~/test.py (and Eglot counts as
> project-aware functionality) and in the absence of, say, a ~/.git you
> are effectively telling `project.el` that your whole home directory is a
> gigantic project, and there is no good way to determine the files in
> that project but to use find.

> You could:
>
> 1. configure your language server to not request project-wide file
>    watching from the LSP client in certain directories (including the
>    $HOME directory).  See your language server's documentation for this
>    effect

> 2. Tell project.el via its interfaces (project-find-functions) that the
>    "project" you store in your $HOME is composed of a relatively small and
>    manageable set of files.

> 3. A very simple means -- but not the only means -- to do the above is to
>    type `git init` in your $HOME directory.
>
> 4. Read project.el's documentation (and ask its maintainers) for other
>    means to use project-find-functions to declare that a project exists
>    in $HOME but does not include the full contents of your home
>    directory as its files.
>
> 5. Stop opening Python scripts in your $HOME *and* auto-activating Eglot
>    in them.  You may be auto-activating Eglot with eglot-ensure, but this
>    is not recommended precisely because it carries with risks like this.
>
> 6. Request to project.el's maintainer that project.el interrupt up its
>    very slow `find`-based search and returns only subset of results.
>
> 7. Request that Eglot honour the keyword didChangeWatchFiles when it is
>    included in eglot-ignored-server-capabilities.  If you then also
>    change your configuration to do this _only_ in certain directories
>    (for example by utilizing directory-local variables or writing a
>    slightly complicated whook), this would mitigate your problem. We
>    can probably do this in eglot.el, but I don't see this as priority
>    because of the burden on the user and it only solves the problem for
>    Eglot, not all other project.el-using functionality.
>
> I recommend restricting your use of eglot-ensure. It's very overrated
> functionality. M-x eglot will probably only need to be typed once
> or twice in a typical Emacs session.

Thanks for your detailed explanation and solutions.

I will aviod opening Python scripts in $HOME directory and use git to
manage my python project. For the single file, just put it in an empty
directory aslo works as expected.

I enjoy using M-x eglot and never use eglot-ensure.


> You can also, possibly, "unfreeze" your emacs by using C-g or a killall
> find issued from the console.
C-g sometimes can "unfreeze" Eamcs and stop the find program.


-- 
Eason Huang






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

* bug#60570: 29.0.60; Eglot+pyright freeze Emacs when edit a single file in Home director
  2023-01-06 10:29   ` João Távora
@ 2023-01-07 22:38     ` Yuan Fu
  0 siblings, 0 replies; 6+ messages in thread
From: Yuan Fu @ 2023-01-07 22:38 UTC (permalink / raw)
  To: João Távora; +Cc: Eason Huang, 60570, Dmitry Gutov



> On Jan 6, 2023, at 2:29 AM, João Távora <joaotavora@gmail.com> wrote:
> 
> On Fri, Jan 6, 2023, 06:17 Yuan Fu <casouri@gmail.com> wrote:
> 
> > I use a custom function eglot-soft-ensure which only enables eglot if
> > there is already a LSP server running for the current project. This way
> > eglot doesn’t auto-start in which files that I don’t want it to start.
> >
> > (defun eglot-soft-ensure ()
> >   "Turn on eglot when there is an exising server for the current project."
> >   (require 'eglot)
> >   (when-let* ((project (project-current))
> >               (eglot-server (gethash project eglot--servers-by-project)))
> >     (eglot-ensure)))
> 
> Hello Yuan,
> 
> I must me missing something, because I would say you can just 
> get rid of eglot-soft-ensure. I can't understand what it is adding 
> on top of the normal Eglot behaviour. From the manual:
> 
> "When you visit a file under the same project, whether an existing or a 
> new file, its buffer is automatically added to the set of buffers managed by
> Eglot, and the server which supports the buffer’s major-mode is notified 
> about that. Thus, visiting a non-existent file /home/joe/projects/fooey/lib/y.foo 
> in the above example will notify the server of the *.foo files’ language 
> that a new file was added to the project, even before the file appears 
> on disk. The special Eglot minor mode is also turned on automatically 
> in the buffer visiting the file."
> 
> https://joaotavora.github.io/eglot/#Eglot-and-Buffers

Oh! I must have done something wrong that prompted me to write eglot-soft-ensure. But I don’t remember :-) Sorry for the misinformation!

Yuan




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

end of thread, other threads:[~2023-01-07 22:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <m2bknd2wb7.fsf@foxmail.com>
2023-01-05 21:38 ` bug#60570: 29.0.60; Eglot+pyright freeze Emacs when edit a single file in Home director João Távora
2023-01-06 13:36   ` Eason Huang
2023-01-06  6:17 ` Yuan Fu
2023-01-06 10:29   ` João Távora
2023-01-07 22:38     ` Yuan Fu
2023-01-05  8:57 Eason Huang

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.