aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2002-06-03 22:55:26 +0000
committerRichard M. Stallman2002-06-03 22:55:26 +0000
commitefa2c6d77f75dd4722fe97bd7a9be7f17c0f3fa3 (patch)
tree69f74b1b9c6310d088df74b3086634258084c747
parent5b6d51b6e89cf9f35cef15e2c30f66a4a19b6fd4 (diff)
downloademacs-efa2c6d77f75dd4722fe97bd7a9be7f17c0f3fa3.tar.gz
emacs-efa2c6d77f75dd4722fe97bd7a9be7f17c0f3fa3.zip
(select-safe-coding-system): New arg FILE; use that for set-auto-coding.
When computing auto-cs, narrow to FROM...TO. Put save-excursion outside save-restriction.
-rw-r--r--lisp/international/mule-cmds.el15
1 files changed, 10 insertions, 5 deletions
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 747ea0a9a8a..f9f030cfb82 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -543,7 +543,7 @@ function `select-safe-coding-system' (which see). This variable
543overrides that argument.") 543overrides that argument.")
544 544
545(defun select-safe-coding-system (from to &optional default-coding-system 545(defun select-safe-coding-system (from to &optional default-coding-system
546 accept-default-p) 546 accept-default-p file)
547 "Ask a user to select a safe coding system from candidates. 547 "Ask a user to select a safe coding system from candidates.
548The candidates of coding systems which can safely encode a text 548The candidates of coding systems which can safely encode a text
549between FROM and TO are shown in a popup window. Among them, the most 549between FROM and TO are shown in a popup window. Among them, the most
@@ -564,6 +564,10 @@ determine the acceptability of the silently selected coding system.
564It is called with that coding system, and should return nil if it 564It is called with that coding system, and should return nil if it
565should not be silently selected and thus user interaction is required. 565should not be silently selected and thus user interaction is required.
566 566
567Optional 5th arg FILE is the file name to use for this purpose.
568That is different from `buffer-file-name' when handling `write-region'
569\(for example).
570
567The variable `select-safe-coding-system-accept-default-p', if 571The variable `select-safe-coding-system-accept-default-p', if
568non-nil, overrides ACCEPT-DEFAULT-P. 572non-nil, overrides ACCEPT-DEFAULT-P.
569 573
@@ -718,11 +722,12 @@ and TO is ignored."
718 ;; Check we're not inconsistent with what `coding:' spec &c would 722 ;; Check we're not inconsistent with what `coding:' spec &c would
719 ;; give when file is re-read. 723 ;; give when file is re-read.
720 (unless (stringp from) 724 (unless (stringp from)
721 (let ((auto-cs (save-restriction 725 (let ((auto-cs (save-excursion
722 (widen) 726 (save-restriction
723 (save-excursion 727 (widen)
728 (narrow-to-region from to)
724 (goto-char (point-min)) 729 (goto-char (point-min))
725 (set-auto-coding (or buffer-file-name "") 730 (set-auto-coding (or file buffer-file-name "")
726 (buffer-size)))))) 731 (buffer-size))))))
727 (if (and auto-cs 732 (if (and auto-cs
728 (not (coding-system-equal (coding-system-base coding-system) 733 (not (coding-system-equal (coding-system-base coding-system)