diff options
| author | Richard M. Stallman | 2002-06-03 22:55:26 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-06-03 22:55:26 +0000 |
| commit | efa2c6d77f75dd4722fe97bd7a9be7f17c0f3fa3 (patch) | |
| tree | 69f74b1b9c6310d088df74b3086634258084c747 | |
| parent | 5b6d51b6e89cf9f35cef15e2c30f66a4a19b6fd4 (diff) | |
| download | emacs-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.el | 15 |
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 | |||
| 543 | overrides that argument.") | 543 | overrides 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. |
| 548 | The candidates of coding systems which can safely encode a text | 548 | The candidates of coding systems which can safely encode a text |
| 549 | between FROM and TO are shown in a popup window. Among them, the most | 549 | between 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. | |||
| 564 | It is called with that coding system, and should return nil if it | 564 | It is called with that coding system, and should return nil if it |
| 565 | should not be silently selected and thus user interaction is required. | 565 | should not be silently selected and thus user interaction is required. |
| 566 | 566 | ||
| 567 | Optional 5th arg FILE is the file name to use for this purpose. | ||
| 568 | That is different from `buffer-file-name' when handling `write-region' | ||
| 569 | \(for example). | ||
| 570 | |||
| 567 | The variable `select-safe-coding-system-accept-default-p', if | 571 | The variable `select-safe-coding-system-accept-default-p', if |
| 568 | non-nil, overrides ACCEPT-DEFAULT-P. | 572 | non-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) |