aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2002-12-17 11:40:47 +0000
committerKenichi Handa2002-12-17 11:40:47 +0000
commit0e9ec6091e747af74434ce8109630544ef80effb (patch)
treedab9ef778d54b0aca4f85b3c920085b839a0f09d
parent42b01e1e9b09b8e8fbbfe921a894e01bd0de4d44 (diff)
downloademacs-0e9ec6091e747af74434ce8109630544ef80effb.tar.gz
emacs-0e9ec6091e747af74434ce8109630544ef80effb.zip
(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.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/international/mule-cmds.el96
2 files changed, 62 insertions, 43 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5d8ac7f0a56..6f295d0601a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12002-12-17 Kenichi Handa <handa@m17n.org>
2
3 * international/mule-cmds.el (universal-coding-system-argument):
4 Bind coding-system-require-warning to t.
5 (select-safe-coding-system): Handle t in the arg
6 DEFAULT-CODING-SYSTEM specially. Use read-coding-system to read a
7 coding-system to allow users to specify unsafe coding system on
8 their risk.
9
12002-12-16 Francesco Potorti` <pot@gnu.org> 102002-12-16 Francesco Potorti` <pot@gnu.org>
2 11
3 * mail/undigest.el (rmail-digest-methods) 12 * mail/undigest.el (rmail-digest-methods)
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 2ee7c484bea..fa0520a2f27 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -305,6 +305,7 @@ wrong, use this command again to toggle back to the right mode."
305 305
306 (let ((coding-system-for-read coding-system) 306 (let ((coding-system-for-read coding-system)
307 (coding-system-for-write coding-system) 307 (coding-system-for-write coding-system)
308 (coding-system-require-warning t)
308 (current-prefix-arg prefix)) 309 (current-prefix-arg prefix))
309 (message "") 310 (message "")
310 (call-interactively cmd)))) 311 (call-interactively cmd))))
@@ -604,7 +605,10 @@ re-visited and edited.)
604 605
605Optional 3rd arg DEFAULT-CODING-SYSTEM specifies a coding system or a 606Optional 3rd arg DEFAULT-CODING-SYSTEM specifies a coding system or a
606list of coding systems to be prepended to the default coding system 607list of coding systems to be prepended to the default coding system
607list. 608list. However, if DEFAULT-CODING-SYSTEM is a list and the first
609element is t, the cdr part is used as the defualt coding system list,
610i.e. `buffer-file-coding-system' and the most prepended coding system
611is not used.
608 612
609Optional 4th arg ACCEPT-DEFAULT-P, if non-nil, is a function to 613Optional 4th arg ACCEPT-DEFAULT-P, if non-nil, is a function to
610determine the acceptability of the silently selected coding system. 614determine the acceptability of the silently selected coding system.
@@ -624,36 +628,43 @@ and TO is ignored."
624 (not (listp default-coding-system))) 628 (not (listp default-coding-system)))
625 (setq default-coding-system (list default-coding-system))) 629 (setq default-coding-system (list default-coding-system)))
626 630
627 ;; Change elements of the list to (coding . base-coding). 631 (let ((no-other-defaults nil))
628 (setq default-coding-system 632 (if (eq (car default-coding-system) t)
629 (mapcar (function (lambda (x) (cons x (coding-system-base x)))) 633 (setq no-other-defaults t
630 default-coding-system)) 634 default-coding-system (cdr default-coding-system)))
631 635
632 ;; If buffer-file-coding-system is not nil nor undecided, append it 636 ;; Change elements of the list to (coding . base-coding).
633 ;; to the defaults. 637 (setq default-coding-system
634 (if buffer-file-coding-system 638 (mapcar (function (lambda (x) (cons x (coding-system-base x))))
635 (let ((base (coding-system-base buffer-file-coding-system))) 639 default-coding-system))
636 (or (eq base 'undecided) 640
637 (assq buffer-file-coding-system default-coding-system) 641 (unless no-other-defaults
638 (rassq base default-coding-system) 642 ;; If buffer-file-coding-system is not nil nor undecided, append it
639 (setq default-coding-system 643 ;; to the defaults.
640 (append default-coding-system 644 (if buffer-file-coding-system
641 (list (cons buffer-file-coding-system base))))))) 645 (let ((base (coding-system-base buffer-file-coding-system)))
642 646 (or (eq base 'undecided)
643 ;; If the most preferred coding system has the property mime-charset, 647 (assq buffer-file-coding-system default-coding-system)
644 ;; append it to the defaults. 648 (rassq base default-coding-system)
645 (let ((tail coding-category-list) 649 (setq default-coding-system
646 preferred base) 650 (append default-coding-system
647 (while (and tail 651 (list (cons buffer-file-coding-system base)))))))
648 (not (setq preferred (symbol-value (car tail))))) 652
649 (setq tail (cdr tail))) 653 ;; If the most preferred coding system has the property mime-charset,
650 (and (coding-system-p preferred) 654 ;; append it to the defaults.
651 (setq base (coding-system-base preferred)) 655 (let ((tail coding-category-list)
652 (coding-system-get preferred 'mime-charset) 656 preferred base)
653 (not (assq preferred default-coding-system)) 657 (while (and tail
654 (not (rassq base default-coding-system)) 658 (not (setq preferred (symbol-value (car tail)))))
655 (setq default-coding-system 659 (setq tail (cdr tail)))
656 (append default-coding-system (list (cons preferred base)))))) 660 (and (coding-system-p preferred)
661 (setq base (coding-system-base preferred))
662 (coding-system-get preferred 'mime-charset)
663 (not (assq preferred default-coding-system))
664 (not (rassq base default-coding-system))
665 (setq default-coding-system
666 (append default-coding-system
667 (list (cons preferred base))))))))
657 668
658 (if select-safe-coding-system-accept-default-p 669 (if select-safe-coding-system-accept-default-p
659 (setq accept-default-p select-safe-coding-system-accept-default-p)) 670 (setq accept-default-p select-safe-coding-system-accept-default-p))
@@ -821,20 +832,19 @@ one of the following safe coding systems, or edit the buffer:\n")
821 (mapcar (function (lambda (x) (princ " ") (princ x))) 832 (mapcar (function (lambda (x) (princ " ") (princ x)))
822 codings) 833 codings)
823 (insert "\n") 834 (insert "\n")
824 (fill-region-as-paragraph pos (point))))) 835 (fill-region-as-paragraph pos (point)))
836 (insert "Or specify any other coding system
837on your risk of loosing the problematic characters.\n")))
825 838
826 ;; Read a coding system. 839 ;; Read a coding system.
827 (if safe 840 (setq default-coding-system (or (car safe) (car codings)))
828 (setq codings (append safe codings))) 841 (setq coding-system
829 (let* ((safe-names (mapcar (lambda (x) (list (symbol-name x))) 842 (read-coding-system
830 codings)) 843 (format "Select coding system (default %s): "
831 (name (completing-read 844 default-coding-system)
832 (format "Select coding system (default %s): " 845 default-coding-system))
833 (car codings)) 846 (setq last-coding-system-specified coding-system))
834 safe-names nil t nil nil 847
835 (car (car safe-names)))))
836 (setq last-coding-system-specified (intern name)
837 coding-system last-coding-system-specified)))
838 (kill-buffer "*Warning*") 848 (kill-buffer "*Warning*")
839 (set-window-configuration window-configuration))) 849 (set-window-configuration window-configuration)))
840 850