Ar an seachtú lá de mí Meitheamh, scríobh Stephen J. Turnbull:
Aidan Kehoe writes:
> + ;; If the file was zero-length, used-codesys is undecided. Set it to
> + ;; a more sane value.
> + (if (eq 'undecided (coding-system-type coding-system))
> + (setq coding-system (default-value 'buffer-file-coding-system)))
Ben's original concept for the new detection mechanism was to assign
likelihoods and pick the best of the matching coding systems.
However, it's possible that there would be no match or a tie
(depending on how the algorithm is tuned), in which case it might be
natural for the result to be undecided.
While this is quite unsafe currently (since our coding systems
currently allow you to save in an incompatible coding system),
combined with appropriate checks at save time (which we need anyway),
a detection algorithm which produces 'undecided wouldn't be too bad.
What do you think, Aidan?
The coding system value in question is set in
#'insert-file-contents-internal like so:
if (!NILP (used_codesys))
{
Fset (used_codesys,
XCODING_SYSTEM_NAME
(coding_stream_detected_coding_system (XLSTREAM (stream))));
}
It may be that coding_stream_detected_coding_system *should* never give
undecided, even if no data have been seen, in which case the correct thing
to do to fix this bug is to change coding_stream_detected_coding_system to
do that.
It may also be that undecided is a reasonable value there. It’s just not
clear, and my patch as written is minimally invasive and fixes the issue.
Your warning below risks having people think that autodetection succeeding
means that the characters in the buffer reflect what whoever wrote the
octets to disk meant them to mean, which is not true, our autodetection gets
things wrong all the time.
If that logic is reasonable, then changing the comment above to
"Some
buffers may remain 'undecided (eg, zero-length files). Set it to a
more sane value." would be a good idea.
If it isn't, the code should look like
(when (eq 'undecided (coding-system-type coding-system))
(unless (= 0 (buffer-size))
(warn "Autodetection failed: setting to default."))
(setq coding-system (default-value 'buffer-file-coding-system)))
--
¿Dónde estará ahora mi sobrino Yoghurtu Nghe, que tuvo que huir
precipitadamente de la aldea por culpa de la escasez de rinocerontes?
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta