Mercurial > hg > xemacs-beta
changeset 748:ca2d04c5710a
[xemacs-hg @ 2002-02-12 14:24:39 by stephent]
fix write-region-pre-hook <87wuxi944z.fsf@tleeps18.sk.tsukuba.ac.jp>
author | stephent |
---|---|
date | Tue, 12 Feb 2002 14:24:40 +0000 |
parents | 9f953fdc1394 |
children | 9cea8fcd2e61 |
files | lisp/ChangeLog lisp/code-files.el |
diffstat | 2 files changed, 23 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Mon Feb 11 12:43:23 2002 +0000 +++ b/lisp/ChangeLog Tue Feb 12 14:24:40 2002 +0000 @@ -1,3 +1,10 @@ +2002-01-27 Stephen J. Turnbull <stephen@xemacs.org> + + * code-files.el (convert-mbox-coding-system): Improve comment. + (write-region): Improve docstring. Reformat to 80 columns. Add + coding-system argument to `write-region-pre-hook' call. + (write-region-pre-hook): Fix docstring to mention lockname argument. + 2002-02-11 Mike Sperber <mike@xemacs.org> * info.el (Info-maybe-update-dir): Regenerate dir if we're
--- a/lisp/code-files.el Mon Feb 11 12:43:23 2002 +0000 +++ b/lisp/code-files.el Tue Feb 12 14:24:40 2002 +0000 @@ -198,12 +198,11 @@ ((find-coding-system codesys)) )))) -;; This is completely broken, not only in implementation (does not +;; This was completely broken, not only in implementation (does not ;; understand MIME), but in concept -- such high-level decoding should -;; be done by mail readers, not by IO code! +;; be done by mail readers, not by IO code! Removed 2000-04-18. -;(defun convert-mbox-coding-system (filename visit start end) -;... +;(defun convert-mbox-coding-system (filename visit start end) ...) (defun load (file &optional noerror nomessage nosuffix) "Execute a file of Lisp code named FILE. @@ -413,12 +412,11 @@ (defvar write-region-pre-hook nil "A special hook to decide the coding system used for writing out a file. -Before writing a file, `write-region' calls the functions on this hook -with arguments START, END, FILENAME, APPEND, VISIT, and CODING-SYSTEM, -the same as the corresponding arguments in the call to -`write-region'. +Before writing a file, `write-region' calls the functions on this hook with +arguments START, END, FILENAME, APPEND, VISIT, LOCKNAME, and CODING-SYSTEM, +the same as the corresponding arguments in the call to `write-region'. -The return value of the functions should be either +The return value of each function should be one of -- nil -- A coding system or a symbol denoting it, indicating the coding system @@ -426,7 +424,7 @@ -- A list of two elements (absolute pathname and length of data written), which is used as the return value to `write-region'. In this case, `write-region' assumes that the function has written - the file for itself and suppresses further writing. + the file, and returns. If any function returns non-nil, the remaining functions are not called.") @@ -434,13 +432,16 @@ "A hook called by `write-region' after a file has been written out. The functions on this hook are called with arguments START, END, -FILENAME, APPEND, VISIT, and CODING-SYSTEM, the same as the +FILENAME, APPEND, VISIT, LOCKNAME, and CODING-SYSTEM, the same as the corresponding arguments in the call to `write-region'.") (defun write-region (start end filename &optional append visit lockname coding-system) "Write current region into specified file. By default the file's existing contents are replaced by the specified region. -When called from a program, takes three arguments: +Call interactively, prompts for the filename. With a prefix arg, also prompts +for a coding system. + +When called from a program, takes three required arguments: START, END and FILENAME. START and END are buffer positions. Optional fourth argument APPEND if non-nil means append to existing file contents (if any). @@ -459,19 +460,19 @@ Optional seventh argument CODING-SYSTEM specifies the coding system used to encode the text when it is written out, and defaults to the value of `buffer-file-coding-system' in the current buffer. - Interactively, with a prefix arg, you will be prompted for the - coding system. See also `write-region-pre-hook' and `write-region-post-hook'." (interactive "r\nFWrite region to file: \ni\ni\ni\nZCoding-system: ") (setq coding-system (or coding-system-for-write (run-hook-with-args-until-success - 'write-region-pre-hook start end filename append visit lockname) + 'write-region-pre-hook + start end filename append visit lockname coding-system) coding-system buffer-file-coding-system (find-file-coding-system-for-write-from-filename filename) )) (if (consp coding-system) + ;; One of the `write-region-pre-hook' functions wrote the file coding-system (let ((func (coding-system-property coding-system 'pre-write-conversion)))