Composing in utf8 from latin1 terminal
nunojsilva at ist.utl.pt
nunojsilva at ist.utl.pt
Thu Oct 25 11:24:06 UTC 2018
On 2018-10-24, Ian Zimmerman wrote:
> On 2018-10-23 22:31, Nuno Silva wrote:
>
>> So far I did not find a way to change this on the mutt side, but I made
>> a new major mode for mutt messages in Emacs (the editor I use with
>> mutt), with a hook that changes the file encoding to latin1 if the file
>> was opened in a latin1 terminal and Emacs cannot detect a non-ASCII file
>> encoding.
>>
>> It appears to work here. I'm sure someone who is more versed in Emacs
>> than me would be able to come up with a more elegant solution, but I'm
>> sharing mine here just in case it is useful to somebody else someday:
>>
>> (define-derived-mode my-mutt-message-mode message-mode "MuttMSG")
>> (add-hook
>> 'my-mutt-message-mode-hook
>> (lambda ()
>> (when (equal (terminal-coding-system) 'iso-latin-1-unix)
>> (let ((encoding (detect-coding-region (point-min) (point-max))))
>> (when (or
>> (equal encoding '(undecided-unix))
>> (equal encoding '(undecided)))
>> (setq buffer-file-coding-system 'iso-latin-1-unix))))))
>> (add-to-list 'auto-mode-alist '("/mutt" . my-mutt-message-mode))
>
> You could just hook message-mode-hook with a function that checks
> buffer-file-name, I think that would be a bit more straightforward than
> adding a new mode.
Yes, it would be. In my case, I am also redefining a keybinding (C-c
C-c, and possibly more in the future), so the new mode is a way to keep
these mutt-related changes together.
> Other possibilities: you could handle this still in Emacs, but after you
> finish writing, at the point you save the temporary file (with one of
> the write hooks). Or you can write a script that runs Emacs and then
> recodes the file outside of Emacs, using something like iconv(1).
--
Nuno Silva
More information about the Mutt-users
mailing list