[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 14:55:29 -0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
"J.P." <jp@neverwas.me> writes:
> Alcor <alcor@tilde.club> writes:
>
>> I tried out (put 'erc-mode 'mode-class 'special) and was surprised to
>> see that it (mostly) seems to work. With that active, the Erc buffer
>> remains functional on C-x C-w. However, the buffer is renamed to the
>> filename, which is even reflected in the bufbar. I'm not sure whether
>> the latter behavior can be suppressed, but if possible, then this would
>> seem like a fair solution (although some other way of indicating that
>> the Erc buffer is bound to a file will still be needed).
>
> We could just add a note to the manual recommending the usage pattern
> mentioned above re preserving the existing name by specifying a
> directory at the prompt. Or, we could maybe mess around with
> `after-set-visited-file-name-hook', but (AFAIK) its members must be
> global to be effective, which may complicate things somewhat.
Actually, that's likely bogus since there's no mode change, so local
variables won't be killed. If true, it may be possible to undo the
rename via that hook after all (in which case, we'd just do an
`add-hook' locally in the body of the `erc-mode' definition).
> Basically,
> we'd want to rename the buffer to its former name via something like:
>
> (rename-buffer (buffer-last-name))
>
> This shouldn't affect `buffer-file-name', so C-x C-s should still write
> to the previously chosen file.
>
> One approach to implementing this might be to remap `write-file' to our
> own command that either shadows `after-set-visited-file-name-hook'
> around a call to `write-file' or simply reverts the buffer name
> afterwards without involving the hook at all. (I guess it'd come down to
> whether the code in `write-file' following the execution of that hook
> needs to know the final buffer name.)