Subject: bug#31062: 26.0.91; warning on UTF-8 encoding of unibyte text

From: [email-masked] (Charles A. Roelli)
Date: Sun, 08 Apr 2018 11:49:12 +0200

> Date: Thu, 05 Apr 2018 21:47:11 +0300
> From: Eli Zaretskii <[email-masked]>
>
> > > These default coding systems were tried to encode text in the buffer
> > > 'test', but failed for the listed (POSITION . CODEPOINT) elements:
> > 
> > to make that clear to the user?
> 
> Feel free to suggest a patch, but the list includes the coding-systems
> tried, not just positions and codepoints.

That's true, but after looking at the code of
select-safe-coding-system-interactively, it seems that the "rejected"
list is also printed in the same run as "unsafe", and "rejected" is
indeed a list of coding systems.

	    (insert
	     "These default coding systems were tried to encode"
	     (if (stringp from)
		 (concat " \"" (if (> (length from) 10)
				   (concat (substring from 0 10) "...\"")
				 (concat from "\"")))
	       (format-message " text\nin the buffer `%s'" bufname))
	     ":\n")
	    (let ((pos (point))
		  (fill-prefix "  "))
	      (dolist (x (append rejected unsafe)) ← "rejected" printed here
		(princ "  ") (princ x))
	      (insert "\n")
	      (fill-region-as-paragraph pos (point)))

Strangely, the "rejected" list is then printed again, if it's non-nil:

	    (when rejected
	      (insert "These safely encode the text in the buffer,
but are not recommended for encoding text in this context,
e.g., for sending an email message.\n ")
	      (dolist (x rejected)
		(princ " ") (princ x))
	      (insert "\n"))

One solution might be to only print the "rejected" list in this second
form, and in the first form explain more clearly what is the meaning
of the elements in the "unsafe" list.