annotate lisp/prim/files-nomule.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents
children b9518feda344
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1 ;;; files-nomule.el --- file I/O stubs when not under Mule.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
2
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985-1987, 1992-1994 Free Software Foundation, Inc.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Sun Microsystems.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
5
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
6 ;; This file is part of XEmacs.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
7
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
8 ;; XEmacs is free software; you can redistribute it and/or modify it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
9 ;; under the terms of the GNU General Public License as published by
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
11 ;; any later version.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
12
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
13 ;; XEmacs is distributed in the hope that it will be useful, but
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
16 ;; General Public License for more details.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
17
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
19 ;; along with XEmacs; see the file COPYING. If not, write to the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
20 ;; Free Software Foundation, 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
21 ;; Boston, MA 02111-1307, USA.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
22
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
23 ;;; Synched up with: Not in FSF.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
24
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
25 (defun insert-file-contents (filename &optional visit beg end replace)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
26 "Insert contents of file FILENAME after point.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
27 Returns list of absolute file name and length of data inserted.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
28 If second argument VISIT is non-nil, the buffer's visited filename
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
29 and last save file modtime are set, and it is marked unmodified.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
30 If visiting and the file does not exist, visiting is completed
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
31 before the error is signaled.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
32
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
33 The optional third and fourth arguments BEG and END
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
34 specify what portion of the file to insert.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
35 If VISIT is non-nil, BEG and END must be nil.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
36 If optional fifth argument REPLACE is non-nil,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
37 it means replace the current buffer contents (in the accessible portion)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
38 with the file contents. This is better than simply deleting and inserting
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
39 the whole thing because (1) it preserves some marker positions
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
40 and (2) it puts less data in the undo list."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
41 (insert-file-contents-internal filename visit beg end replace nil nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
42
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
43 (defun write-region (start end filename &optional append visit lockname)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
44 "Write current region into specified file.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
45 When called from a program, takes three arguments:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
46 START, END and FILENAME. START and END are buffer positions.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
47 Optional fourth argument APPEND if non-nil means
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
48 append to existing file contents (if any).
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
49 Optional fifth argument VISIT if t means
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
50 set the last-save-file-modtime of buffer to this file's modtime
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
51 and mark buffer not modified.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
52 If VISIT is a string, it is a second file name;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
53 the output goes to FILENAME, but the buffer is marked as visiting VISIT.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
54 VISIT is also the file name to lock and unlock for clash detection.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
55 If VISIT is neither t nor nil nor a string,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
56 that means do not print the \"Wrote file\" message.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
57 The optional sixth arg LOCKNAME, if non-nil, specifies the name to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
58 use for locking and unlocking, overriding FILENAME and VISIT.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
59 Kludgy feature: if START is a string, then that string is written
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
60 to the file, instead of any buffer contents, and END is ignored."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
61 (interactive "r\nFWrite region to file: ")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
62 (write-region-internal start end filename append visit lockname nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
63
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
64 (defun load (file &optional noerror nomessage nosuffix)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
65 "Execute a file of Lisp code named FILE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
66 First try FILE with `.elc' appended, then try with `.el',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
67 then try FILE unmodified.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
68 This function searches the directories in `load-path'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
69 If optional second arg NOERROR is non-nil,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
70 report no error if FILE doesn't exist.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
71 Print messages at start and end of loading unless
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
72 optional third arg NOMESSAGE is non-nil (ignored in -batch mode).
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
73 If optional fourth arg NOSUFFIX is non-nil, don't try adding
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
74 suffixes `.elc' or `.el' to the specified name FILE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
75 Return t if file exists."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
76 (load-internal file noerror nomessage nosuffix nil nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
77