Mercurial > emacs
changeset 45631:b01cd9b1ae08
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 03 Jun 2002 22:55:26 +0000 |
parents | c6e4c52881d7 |
children | 9d60ac21968f |
files | lisp/international/mule-cmds.el |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/international/mule-cmds.el Mon Jun 03 22:44:31 2002 +0000 +++ b/lisp/international/mule-cmds.el Mon Jun 03 22:55:26 2002 +0000 @@ -543,7 +543,7 @@ overrides that argument.") (defun select-safe-coding-system (from to &optional default-coding-system - accept-default-p) + accept-default-p file) "Ask a user to select a safe coding system from candidates. The candidates of coding systems which can safely encode a text between FROM and TO are shown in a popup window. Among them, the most @@ -564,6 +564,10 @@ It is called with that coding system, and should return nil if it should not be silently selected and thus user interaction is required. +Optional 5th arg FILE is the file name to use for this purpose. +That is different from `buffer-file-name' when handling `write-region' +\(for example). + The variable `select-safe-coding-system-accept-default-p', if non-nil, overrides ACCEPT-DEFAULT-P. @@ -718,11 +722,12 @@ ;; Check we're not inconsistent with what `coding:' spec &c would ;; give when file is re-read. (unless (stringp from) - (let ((auto-cs (save-restriction - (widen) - (save-excursion + (let ((auto-cs (save-excursion + (save-restriction + (widen) + (narrow-to-region from to) (goto-char (point-min)) - (set-auto-coding (or buffer-file-name "") + (set-auto-coding (or file buffer-file-name "") (buffer-size)))))) (if (and auto-cs (not (coding-system-equal (coding-system-base coding-system)