emacs-everywhere icon indicating copy to clipboard operation
emacs-everywhere copied to clipboard

Potential infinite recursion when calling `emacs-everywhere-finish`

Open hanwenguo opened this issue 1 year ago • 1 comments

I have noticed that the emacs-everywhere-finish function contains a call to server-buffer-done, which is added to server-done-hook. However, server-buffer-done executes (run-hooks 'server-done-hook) before performing the actual killing. While I'm not very familiar with Emacs Lisp, I'm not sure if there's a mechanism to prevent infinite recursion, and if there isn't this could potentially cause issues.

hanwenguo avatar Mar 25 '23 13:03 hanwenguo

Here are some potential solutions:

  1. Since C-c C-c is usually used to finish editing emacs-everywhere buffers explicitly (as it is bound to emacs-everywhere-finish-or-ctrl-c-ctrl-c), it may not be necessary to add emacs-everywhere-finish to server-done-hook.

  2. Considering that some users might prefer to use C-x # instead of C-c C-c, and the content of emacs-everywhere buffers usually doesn't need to be saved (as it would already be copied to the clipboard), it might be a good idea to replace server-buffer-done with server-kill-buffer, which checks for potential infinite recursion.

hanwenguo avatar Mar 25 '23 13:03 hanwenguo