emacs_chrome icon indicating copy to clipboard operation
emacs_chrome copied to clipboard

edit-server.el: `existing-buffer` is unnecessary

Open elibarzilay opened this issue 11 years ago • 1 comments

Looks like existing-buffer is useless: existing is used to find an existing buffer, but if one is not found, it's not used to create a new buffer. IIUC, not using it for a new buffer name is makes it useless, but using it seems bad since it means that the edit server can choose any victim buffer and obliterate its contents.

This latter effect can be seen now: perhaps as a result of some JS-side missing test, I always get "undefined" as the x-file header. So to see how this is broken, edit a file called "undefined" in Emacs, then use edit-server (from some textarea that leads to an undefined x-file). You're now in the buffer that edits the file, with the edit text squashing whatever was there (but no modification is shown, and the actual file didn't change), and when you make edit-server send the text back, you're left with a messy state (killing the kind-of-modified buffer makes emacs sad, the save hook makes it impossible to save changes). In short, a mess.

(FWIW, if this is all true, then it looks to me like the whole existing-buffer should go away, which also means that parsing and using x-file is redundant.)

elibarzilay avatar Oct 19 '14 01:10 elibarzilay

x-file and x-url are only used for the save-and-continue case. The idea that the contents of the buffer are sent and the browser sends a continue message and you keep editing the current buffer. It's clunky but it does work.

stsquad avatar Oct 19 '14 08:10 stsquad