alphapapa / ement.el

A Matrix client for GNU Emacs
GNU General Public License v3.0
476 stars 44 forks source link

Changing major mode in composition buffer erases header line and binding #130

Open alphapapa opened 1 year ago

alphapapa commented 1 year ago

From @wolfjb:matrix.org:

using M-RET to compose in a buffer, then using M-x org-mode to switch the major mode, the C-x C-s keybinding disappears and the message doesn't post. But copying it, killing the window, and then M-RET again does show the keybindings and pasting the message works.

phil-s commented 9 months ago

"Don't use M-x org-mode" is the answer to that, I would have thought? Changing major mode in any buffer will kill the buffer's header- and footer-lines (along with most other buffer-local values), and change the mode-specific key bindings that are available; so that's just expected behaviour, no? Hence the M-x ement-room-compose-org command for switching to org formatting without incurring these problems...

That said, a buffer-local change-major-mode-hook function could be used to stash away any particular things deemed desirable to restore after a major mode change, if reacting to arbitrary mode changes was going to be a thing.

alphapapa commented 9 months ago

Yes, knowing what we do about Emacs's internals, this is obviously wrong to us. But to a non-developer user, simply activating org-mode normally would be natural. So it'd be nice to handle this in some way to prevent the composition buffer from getting "broken," or at least direct the user to the proper command.