[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Saving Erc buffers (Or: Broken C-x C-w)
From: |
J.P. |
Subject: |
Re: Saving Erc buffers (Or: Broken C-x C-w) |
Date: |
Wed, 13 Nov 2024 00:46:27 -0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Alcor <alcor@tilde.club> writes:
> Hi all,
>
> I'm not sure if this is a bug, but I'll ask just to make sure: I'd like
> to save an Erc (channel) buffer to a file. Intuitively, the Emacsism for
> this would be C-x C-w or `write-file'.
>
> However, this does not work on Erc. Or rather, it _does_ save the buffer
> to a file, at the rather steep price of breaking the Erc server
> state. It looks like Erc's part hook isn't executed, and there seems to
> be no simple way to repair the Erc session afterwards (except via
> quitting and /reconnect'ing).
One consequence of the PART hook not running is that items in the
`erc-server-users' table retain stale references to the saved buffer,
which is no longer an ERC buffer. Aside from that, it seems the saved
buffer's `local-minor-modes' value retains ERC-specific minor modes and
its `kill-buffer-hook' is still set to `erc-kill-buffer-function'.
> So the question is - what's the Erc-approved way for doing a one-off
> write out of a channel buffer to a file? (as opposed to logging).
>
> And, if possible, is there a way to fix the behavior of C-x C-w in Erc?
Perhaps we ought to ask ourselves what we want to happen when running
this command and how that compares to what happens when doing so in
other non-file-based modes, like `gud-mode' or various REPLs.
If the answer turns out to be that C-x C-w (or C-x C-s) should act like
C-x h M-x write-region RET, then we should maybe consider declaring
`erc-mode' as `special', something that's been brought up casually on
occasion but never proposed in earnest (AFAIK).
As far as implementations go, we likely couldn't have `erc-mode' inherit
from `special-mode' because `readonly' is a module and thus optional.
So, we'd most likely have to do a
(put 'erc-mode 'mode-class 'special)
in ERC's major-mode definition.