[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: iso-8859-1 and non-latin-1 chars
From: |
Kenichi Handa |
Subject: |
Re: iso-8859-1 and non-latin-1 chars |
Date: |
Fri, 13 Dec 2002 11:58:34 +0900 (JST) |
In article <address@hidden>, Richard Stallman <address@hidden> 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
address@hidden
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 <address@hidden>
+
+ * 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 <address@hidden>
* 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 <address@hidden>
+ * 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 <address@hidden>
+
* coding.c (Funencodable_char_position): Set pend correctly.
2002-12-12 Jason Rumney <address@hidden>
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,
Re: iso-8859-1 and non-latin-1 chars, Kenichi Handa, 2002/12/09
Re: iso-8859-1 and non-latin-1 chars, Dave Love, 2002/12/15
Re: iso-8859-1 and non-latin-1 chars, Kenichi Handa, 2002/12/15
Re: iso-8859-1 and non-latin-1 chars, Dave Love, 2002/12/19
Re: iso-8859-1 and non-latin-1 chars, Kenichi Handa, 2002/12/23