aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2002-05-03 04:23:31 +0000
committerRichard M. Stallman2002-05-03 04:23:31 +0000
commit43afed8cf03b13bce0684c3236c3e3a027d7a09e (patch)
tree57b26c027d2b9b350f68a55b62b52cb8c2ea0283
parentc5020b5bcc943c258280e7ad52bd045300aa2e6f (diff)
downloademacs-43afed8cf03b13bce0684c3236c3e3a027d7a09e.tar.gz
emacs-43afed8cf03b13bce0684c3236c3e3a027d7a09e.zip
(select-safe-coding-system): Don't offer coding systems that use locking shift.
Ask for confirmation if chosen coding system disagrees with a `coding:' spec in the file.
-rw-r--r--lisp/international/mule-cmds.el28
1 files changed, 27 insertions, 1 deletions
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index ed11d69fb9b..453f53fb126 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -636,6 +636,16 @@ and TO is ignored."
636 (setcar l mime-charset)) 636 (setcar l mime-charset))
637 (setq l (cdr l)))) 637 (setq l (cdr l))))
638 638
639 ;; Don't offer variations with locking shift, which you
640 ;; basically never want.
641 (let (l)
642 (dolist (elt codings (setq codings (nreverse l)))
643 (unless (or (eq 'coding-category-iso-7-else
644 (coding-system-category elt))
645 (eq 'coding-category-iso-8-else
646 (coding-system-category elt)))
647 (push elt l))))
648
639 ;; Make sure the offending buffer is displayed. 649 ;; Make sure the offending buffer is displayed.
640 (or (stringp from) 650 (or (stringp from)
641 (pop-to-buffer bufname)) 651 (pop-to-buffer bufname))
@@ -705,7 +715,23 @@ and TO is ignored."
705 715
706 (if (eq coding-system t) 716 (if (eq coding-system t)
707 (setq coding-system buffer-file-coding-system)) 717 (setq coding-system buffer-file-coding-system))
708 coding-system)) 718 ;; Check we're not inconsistent with what `coding:' spec &c would
719 ;; give when file is re-read.
720 (unless (stringp from)
721 (let ((auto-cs (save-restriction
722 (widen)
723 (save-excursion
724 (goto-char (point-min))
725 (set-auto-coding (or buffer-file-name "")
726 (buffer-size))))))
727 (if (and auto-cs
728 (not (coding-system-equal (coding-system-base coding-system)
729 (coding-system-base auto-cs))))
730 (unless (yes-or-no-p
731 (format "Selected encoding %s disagrees with \
732%s specified by file contents. Really save (else edit coding cookies \
733and try again)? " coding-system auto-cs))
734 (error "Save aborted"))))) coding-system))
709 735
710(setq select-safe-coding-system-function 'select-safe-coding-system) 736(setq select-safe-coding-system-function 'select-safe-coding-system)
711 737