Just a quick update (also answering my own question(s) below): Regarding the status of this bug report: The fix for emacs-29 which was initially intended to be emacs-29 only has (inadvertently?) found its way to master. So I think we can close the report. The discussion about the additional changes I made (I'm still working on that s. below) could be moved elsewhere (emacs-devel?). Even though, from my side there is no urgent need for that. I really appreciate the feedback I got from Eli and hope to get some more. > I've now added an additional patch which automatically handles unix/dos > eol-types when downloading/uploading sieve scripts. So far, if a script > downloaded from the server contained CRLF EOLs, the script buffer was > full of '^M's. With the additional patch > (0005-Autodetect-eol-type-of-sieve-manage-scripts), the EOL type is > detected and used for decoding during script download (and subsequently > also for encoding during upload). > > For that, I changed the interface between 'sieve-upload' (in sieve.el), > and 'manage-sieve-putscript' (plus 'sieve-manage-decode' and > 'sieve-manage-send' in sieve-manage.el). Instead of transferring the > script data as a string, the functions are now using the actual script > buffer. > > The eol-type detection is done in the new function > 'sieve-manage--guess-buffer-coding-system'. But I would assume, that > this functionality already exists somewhere else. E.g. 'find-file' must > do a similar, much more detailed analysis. However, that seems to happen > in the C implementation, so it's not directly usable in sieve-manage. Or > am I missing something? In the meantime, I found `detect-coding-region'/`detect-coding-string' which in combination with `coding-system-eol-type' do exactly what I was missing. I've now started to refactor the encoding and sending functions in sieve-manage.el with the intent to improve the readability and testability of the code. I'm also adding some more tests. These additional changes are in yet another patch (0006-WiP-new-encode-tested-OK.patch). I also added NEWS entries to patches 0002-Handle-BYE... and 0005-Autodetect-eol-type... (these were already present in the patches of the previous mail).