From: Kenichi Handa <handa@m17n.org>
Cc: emacs-devel@gnu.org
Subject: Re: iso-8859-1 and non-latin-1 chars
Date: Fri, 13 Dec 2002 11:58:34 +0900 (JST) [thread overview]
Message-ID: <200212130258.LAA00403@etlken.m17n.org> (raw)
In-Reply-To: <E18MDdz-0005Mz-00@fencepost.gnu.org> (message from Richard Stallman on Wed, 11 Dec 2002 15:39:47 -0500)
In article <E18MDdz-0005Mz-00@fencepost.gnu.org>, Richard Stallman <rms@gnu.org> 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 <handa@m17n.org>
+
+ * 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 <nick@nick.uklinux.net>
* 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 <handa@m17n.org>
+ * 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 <handa@m17n.org>
+
* coding.c (Funencodable_char_position): Set pend correctly.
2002-12-12 Jason Rumney <jasonr@gnu.org>
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,
next prev parent reply other threads:[~2002-12-13 2:58 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-28 17:01 iso-8859-1 and non-latin-1 chars Dave Love
2002-12-02 15:47 ` Richard Stallman
2002-12-06 16:38 ` Dave Love
2002-12-09 6:08 ` Kenichi Handa
2002-12-15 16:24 ` Dave Love
2002-12-16 0:42 ` Kenichi Handa
2002-12-19 22:35 ` Dave Love
2002-12-23 6:40 ` Kenichi Handa
2002-12-23 12:27 ` Dave Love
2002-12-25 13:05 ` Kenichi Handa
2002-12-31 17:14 ` Ken Stevens
2003-01-06 19:28 ` Dave Love
2003-01-06 19:18 ` Dave Love
2003-01-07 13:01 ` Kenichi Handa
2003-01-10 10:59 ` Dave Love
2003-01-06 19:19 ` Dave Love
2002-12-16 14:06 ` Stefan Monnier
2002-12-19 22:33 ` Dave Love
2002-12-16 16:42 ` Richard Stallman
[not found] ` <E18LZqb-0007si-00@fencepost.gnu.org>
2002-12-15 16:25 ` Dave Love
2002-12-16 16:42 ` Richard Stallman
[not found] ` <E18LCz8-0004It-00@fencepost.gnu.org>
2002-12-10 23:47 ` Dave Love
2002-12-11 20:39 ` Richard Stallman
2002-12-13 2:58 ` Kenichi Handa [this message]
2002-12-14 18:31 ` Richard Stallman
2002-12-17 11:41 ` None Kenichi Handa
-- strict thread matches above, loose matches on Subject: below --
2002-11-07 14:57 iso-8859-1 and non-latin-1 chars Stefan Monnier
2002-11-07 15:25 ` Eli Zaretskii
2002-11-07 17:06 ` Stefan Monnier
2002-11-07 23:42 ` Kenichi Handa
2002-11-07 23:58 ` Stefan Monnier
2002-11-09 11:54 ` Richard Stallman
2002-11-09 20:32 ` Stefan Monnier
2002-11-11 10:19 ` Richard Stallman
2002-11-11 4:00 ` Kenichi Handa
2002-11-12 5:47 ` Richard Stallman
2002-11-18 0:08 ` Kenichi Handa
2002-11-18 19:09 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200212130258.LAA00403@etlken.m17n.org \
--to=handa@m17n.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).