comparison lisp/code-files.el @ 4308:41e88d0c934e

[xemacs-hg @ 2007-12-05 19:22:03 by aidan] Use Stephen's suggested docstring for #'write-region.
author aidan
date Wed, 05 Dec 2007 19:22:05 +0000
parents fdf43260ae29
children 7a8c613ee283
comparison
equal deleted inserted replaced
4307:1bdc3bc255a4 4308:41e88d0c934e
511 511
512 The functions on this hook are called with arguments START, END, 512 The functions on this hook are called with arguments START, END,
513 FILENAME, APPEND, VISIT, LOCKNAME, and CODING-SYSTEM, the same as the 513 FILENAME, APPEND, VISIT, LOCKNAME, and CODING-SYSTEM, the same as the
514 corresponding arguments in the call to `write-region'.") 514 corresponding arguments in the call to `write-region'.")
515 515
516 (defun write-region (start end filename 516 (defun write-region (start end filename &optional append visit lockname
517 &optional append visit lockname
518 coding-system-or-mustbenew) 517 coding-system-or-mustbenew)
519 "Write current region into specified file. 518 "Write current region into specified file.
520 By default the file's existing contents are replaced by the specified region. 519 Called interactively, prompts for a file name.
521 Called interactively, prompts for a file name. With a prefix arg, prompts 520 With a prefix arg, prompts for a coding system as well.
522 for a coding system as well.
523 521
524 When called from a program, takes three required arguments: 522 When called from a program, takes three required arguments:
525 START, END and FILENAME. START and END are buffer positions. 523 START, END and FILENAME. START and END are buffer positions.
526 Optional fourth argument APPEND if non-nil means 524 APPEND, if non-nil, means append to existing file contents (if any), else
527 append to existing file contents (if any). 525 the file's existing contents are replaced by the specified region.
528 Optional fifth argument VISIT if t means 526 VISIT, if non-nil, should be a string naming a file. The buffer is marked
529 set last-save-file-modtime of buffer to this file's modtime 527 as visiting VISIT. VISIT is also the file name to lock
530 and mark buffer not modified. 528 and unlock for clash detection.
531 If VISIT is a string, it is a second file name; 529 LOCKNAME, if non-nil, specifies the name to use for locking and unlocking,
532 the output goes to FILENAME, but the buffer is marked as visiting VISIT. 530 overriding FILENAME and VISIT.
533 VISIT is also the file name to lock and unlock for clash detection. 531 CODING-SYSTEM-OR-MUSTBENEW specifies the coding system used to encode the
534 If VISIT is neither t nor nil nor a string, 532 text written. It defaults to the value of `buffer-file-coding-system'
535 that means do not print the \"Wrote file\" message. 533 in the current buffer.
536 The optional sixth arg LOCKNAME, if non-nil, specifies the name to 534
537 use for locking and unlocking, overriding FILENAME and VISIT. 535 For compatibility with GNU Emacs, several arguments are overloaded:
538 Kludgy feature: if START is a string, then that string is written 536 START may be a string, which is written to the file. END is ignored.
539 to the file, instead of any buffer contents, and END is ignored. 537 VISIT may take the value t, meaning to set last-save-file-modtime of buffer
540 538 to this file's modtime and mark buffer not modified. With any other
541 Optional seventh argument CODING-SYSTEM-OR-MUSTBENEW has a rather kludgy 539 non-nil value of VISIT, suppress printing of the \"Wrote file\" message.
542 interpretation. If it is a coding system it describes the coding system 540 CODING-SYSTEM-OR-MUSTBENEW may be a non-nil, non-coding-system value.
543 used to encode the text when it is written out, defaulting to to the value 541 If it is `excl' and FILENAME already exists, signal `file-already-exists'.
544 of `buffer-file-coding-system' in the current buffer. 542 Otherwise, if FILENAME already exists, ask for confirmation before
545 543 writing, and signal `file-already-exists' if not confirmed.
546 If CODING-SYSTEM-OR-MUSTBENEW is non-nil and not a coding system, it means
547 that a check for an existing file with the same name should be made; with
548 a value of 'excl XEmacs will error if the file already exists and never
549 overwrite it. If it is some other non-nil non-coding-system value, the
550 user will be asked for confirmation if the file already exists, and the
551 file will be overwritten if confirmation is given.
552 544
553 See also `write-region-pre-hook' and `write-region-post-hook'." 545 See also `write-region-pre-hook' and `write-region-post-hook'."
554 (interactive "r\nFWrite region to file: \ni\ni\ni\nZCoding-system: ") 546 (interactive "r\nFWrite region to file: \ni\ni\ni\nZCoding-system: ")
555 (let (mustbenew coding-system func hook-result) 547 (let (mustbenew coding-system func hook-result)
556 (setq hook-result 548 (setq hook-result