From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: iso-8859-1 and non-latin-1 chars Date: Fri, 13 Dec 2002 11:58:34 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200212130258.LAA00403@etlken.m17n.org> References: NNTP-Posting-Host: main.gmane.org X-Trace: main.gmane.org 1039748373 19066 80.91.224.249 (13 Dec 2002 02:59:33 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 13 Dec 2002 02:59:33 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18Mg31-0004xM-00 for ; Fri, 13 Dec 2002 03:59:31 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18MgEq-00081u-00 for ; Fri, 13 Dec 2002 04:11:44 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18Mg2h-00035x-00 for emacs-devel@quimby.gnus.org; Thu, 12 Dec 2002 21:59:11 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18Mg2M-00035Y-00 for emacs-devel@gnu.org; Thu, 12 Dec 2002 21:58:50 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18Mg2K-00035H-00 for emacs-devel@gnu.org; Thu, 12 Dec 2002 21:58:49 -0500 Original-Received: from tsukuba.m17n.org ([192.47.44.130]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18Mg29-0002m4-00; Thu, 12 Dec 2002 21:58:37 -0500 Original-Received: from fs.m17n.org (fs.m17n.org [192.47.44.2])gBD2wZk19675; Fri, 13 Dec 2002 11:58:35 +0900 (JST) (envelope-from handa@m17n.org) Original-Received: from etlken.m17n.org (etlken.m17n.org [192.47.44.125]) gBD2wYR19501; Fri, 13 Dec 2002 11:58:34 +0900 (JST) Original-Received: (from handa@localhost) by etlken.m17n.org (8.8.8+Sun/3.7W-2001040620) id LAA00403; Fri, 13 Dec 2002 11:58:34 +0900 (JST) Original-To: rms@gnu.org In-reply-to: (message from Richard Stallman on Wed, 11 Dec 2002 15:39:47 -0500) Original-cc: d.love@dl.ac.uk X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:10105 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10105 In article , Richard Stallman writes: >> If you specify a coding system with C-x RET c, and it doesn't >> handle all the text, should Emacs warn about that? > I don't think so. That would amount to a significant overhead on all > i/o, since C-x RET c just amounts to binding > coding-system-for-{read,write} around the invocation of the command. > It could also bind a flag saying "do warn". How about the attached change? Shall I install it? Notes on the change: (1) I made a new variable coding-system-require-warning, and universal-coding-system-argument binds it to t. (2) If car of the arg DEFAULT-CODING-SYSTEM is t, it indicates that select-safe-coding-system should not include buffer-file-coding-system and most preferred coding system in a list of coding systems tried by default. Fwrite_region calls select-safe-coding-system in this way if coding-system-require-warning is non-nil. (3) Now a user can specify any coding system in select-safe-coding-system on his risk. At least, this is necessary when an unsafe coding sysetm is specified by C-x RET c. --- Ken'ichi HANDA handa@m17n.org Index: lisp/ChangeLog =================================================================== RCS file: /cvs/emacs/lisp/ChangeLog,v retrieving revision 1.4625 diff -u -c -b -r1.4625 ChangeLog *** lisp/ChangeLog 13 Dec 2002 00:40:52 -0000 1.4625 --- lisp/ChangeLog 13 Dec 2002 02:51:25 -0000 *************** *** 1,3 **** --- 1,12 ---- + 2002-12-13 Kenichi Handa + + * international/mule-cmds.el (universal-coding-system-argument): + Bind coding-system-require-warning to t. + (select-safe-coding-system): Handle t in the arg + DEFAULT-CODING-SYSTEM specially. Use read-coding-system to read a + coding-system to allow users to specify unsafe coding system on + their risk. + 2002-12-13 Nick Roberts * gdb-ui.el: Improve documentation strings. Index: lisp/international/mule-cmds.el =================================================================== RCS file: /cvs/emacs/lisp/international/mule-cmds.el,v retrieving revision 1.211 diff -u -c -b -r1.211 mule-cmds.el *** lisp/international/mule-cmds.el 12 Dec 2002 00:51:31 -0000 1.211 --- lisp/international/mule-cmds.el 13 Dec 2002 02:51:30 -0000 *************** *** 305,310 **** --- 305,311 ---- (let ((coding-system-for-read coding-system) (coding-system-for-write coding-system) + (coding-system-require-warning t) (current-prefix-arg prefix)) (message "") (call-interactively cmd)))) *************** *** 604,610 **** Optional 3rd arg DEFAULT-CODING-SYSTEM specifies a coding system or a list of coding systems to be prepended to the default coding system ! list. Optional 4th arg ACCEPT-DEFAULT-P, if non-nil, is a function to determine the acceptability of the silently selected coding system. --- 605,614 ---- Optional 3rd arg DEFAULT-CODING-SYSTEM specifies a coding system or a list of coding systems to be prepended to the default coding system ! list. However, if DEFAULT-CODING-SYSTEM is a list and the first ! element is t, the cdr part is used as the defualt coding system list, ! i.e. `buffer-file-coding-system' and the most prepended coding system ! is not used. Optional 4th arg ACCEPT-DEFAULT-P, if non-nil, is a function to determine the acceptability of the silently selected coding system. *************** *** 624,634 **** --- 628,644 ---- (not (listp default-coding-system))) (setq default-coding-system (list default-coding-system))) + (let ((no-other-defaults nil)) + (if (eq (car default-coding-system) t) + (setq no-other-defaults t + default-coding-system (cdr default-coding-system))) + ;; Change elements of the list to (coding . base-coding). (setq default-coding-system (mapcar (function (lambda (x) (cons x (coding-system-base x)))) default-coding-system)) + (unless no-other-defaults ;; If buffer-file-coding-system is not nil nor undecided, append it ;; to the defaults. (if buffer-file-coding-system *************** *** 653,659 **** (not (assq preferred default-coding-system)) (not (rassq base default-coding-system)) (setq default-coding-system ! (append default-coding-system (list (cons preferred base)))))) (if select-safe-coding-system-accept-default-p (setq accept-default-p select-safe-coding-system-accept-default-p)) --- 663,670 ---- (not (assq preferred default-coding-system)) (not (rassq base default-coding-system)) (setq default-coding-system ! (append default-coding-system ! (list (cons preferred base)))))))) (if select-safe-coding-system-accept-default-p (setq accept-default-p select-safe-coding-system-accept-default-p)) *************** *** 821,840 **** (mapcar (function (lambda (x) (princ " ") (princ x))) codings) (insert "\n") ! (fill-region-as-paragraph pos (point))))) ;; Read a coding system. ! (if safe ! (setq codings (append safe codings))) ! (let* ((safe-names (mapcar (lambda (x) (list (symbol-name x))) ! codings)) ! (name (completing-read (format "Select coding system (default %s): " ! (car codings)) ! safe-names nil t nil nil ! (car (car safe-names))))) ! (setq last-coding-system-specified (intern name) ! coding-system last-coding-system-specified))) (kill-buffer "*Warning*") (set-window-configuration window-configuration))) --- 832,850 ---- (mapcar (function (lambda (x) (princ " ") (princ x))) codings) (insert "\n") ! (fill-region-as-paragraph pos (point))) ! (insert "Or specify any other coding system ! on your risk of loosing the problematic characters.\n"))) ;; Read a coding system. ! (setq default-coding-system (or (car safe) (car codings))) ! (setq coding-system ! (read-coding-system (format "Select coding system (default %s): " ! default-coding-system) ! default-coding-system)) ! (setq last-coding-system-specified coding-system)) ! (kill-buffer "*Warning*") (set-window-configuration window-configuration))) Index: src/ChangeLog =================================================================== RCS file: /cvs/emacs/src/ChangeLog,v retrieving revision 1.2994 diff -u -c -b -r1.2994 ChangeLog *** src/ChangeLog 13 Dec 2002 02:35:34 -0000 1.2994 --- src/ChangeLog 13 Dec 2002 02:51:31 -0000 *************** *** 1,5 **** --- 1,17 ---- 2002-12-13 Kenichi Handa + * coding.c (coding_system_require_warning): New variable. + (syms_of_coding): DEFVAR it. + + * coding.h (coding_system_require_warning): Extern it. + + * fileio.c (choose_write_coding_system): Even if + Vcoding_system_for_write is non-nil, if + coding_system_require_warning is nonzero, call + Vselect_safe_coding_system_function. + + 2002-12-13 Kenichi Handa + * coding.c (Funencodable_char_position): Set pend correctly. 2002-12-12 Jason Rumney Index: src/coding.c =================================================================== RCS file: /cvs/emacs/src/coding.c,v retrieving revision 1.265 diff -u -c -b -r1.265 coding.c *** src/coding.c 13 Dec 2002 02:35:51 -0000 1.265 --- src/coding.c 13 Dec 2002 02:51:33 -0000 *************** *** 367,372 **** --- 367,374 ---- Lisp_Object Vselect_safe_coding_system_function; + int coding_system_require_warning; + /* Mnemonic string for each format of end-of-line. */ Lisp_Object eol_mnemonic_unix, eol_mnemonic_dos, eol_mnemonic_mac; /* Mnemonic string to indicate format of end-of-line is not yet *************** *** 7530,7535 **** --- 7532,7546 ---- The default value is `select-safe-coding-system' (which see). */); Vselect_safe_coding_system_function = Qnil; + + DEFVAR_BOOL ("coding-system-require-warning", + &coding_system_require_warning, + doc: /* Internal use only. + If non-nil, on writing a file, select-safe-coding-system-function is + called even if coding-system-for-write is non-nil. The command + universal-coding-system-argument binds this variable to t temporarily. */); + coding_system_require_warning = 0; + DEFVAR_LISP ("char-coding-system-table", &Vchar_coding_system_table, doc: /* Char-table containing safe coding systems of each characters. Index: src/coding.h =================================================================== RCS file: /cvs/emacs/src/coding.h,v retrieving revision 1.64 diff -u -c -b -r1.64 coding.h *** src/coding.h 19 Jul 2002 14:27:01 -0000 1.64 --- src/coding.h 13 Dec 2002 02:51:33 -0000 *************** *** 705,710 **** --- 705,714 ---- system. */ extern Lisp_Object Vselect_safe_coding_system_function; + /* If nonzero, on writing a file, Vselect_safe_coding_system_function + is called even if Vcoding_system_for_write is non-nil. */ + extern int coding_system_require_warning; + /* Coding system for file names, or nil if none. */ extern Lisp_Object Vfile_name_coding_system; Index: src/fileio.c =================================================================== RCS file: /cvs/emacs/src/fileio.c,v retrieving revision 1.467 diff -u -c -b -r1.467 fileio.c *** src/fileio.c 7 Dec 2002 21:39:50 -0000 1.467 --- src/fileio.c 13 Dec 2002 02:51:34 -0000 *************** *** 4624,4630 **** --- 4624,4638 ---- if (auto_saving) val = Qnil; else if (!NILP (Vcoding_system_for_write)) + { val = Vcoding_system_for_write; + if (coding_system_require_warning + && !NILP (Ffboundp (Vselect_safe_coding_system_function))) + /* Confirm that VAL can surely encode the current region. */ + val = call5 (Vselect_safe_coding_system_function, + start, end, Fcons (Qt, Fcons (val, Qnil)), + Qnil, filename); + } else { /* If the variable `buffer-file-coding-system' is set locally,