• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/src/

Lines Matching +defs:temp +defs:file +defs:name

6 This file is part of GNU Emacs.
19 along with GNU Emacs; see the file COPYING. If not, write to
113 `expand-file-name' doesn't always down-case the drive letter. */
118 #include <file.h>
158 /* Set by auto_save_1 to mode of original file so Fwrite_region will create
159 a new file with the same mode as the original */
163 insert-file-contents is called for recovering a file. This is not
164 an actual coding system name, but just an indicator to tell
165 insert-file-contents to use `emacs-mule' with a special flag for
166 auto saving and recovering a file. */
169 /* Coding system for file names, or nil if none. */
172 /* Coding system for file names used only when
176 /* Alist of elements (REGEXP . HANDLER) for file names
180 /* Property name of a file name handler,
184 /* Lisp functions for translating file formats */
187 /* Function to be called to decide a coding system of a reading file. */
190 /* Functions to be called to process text properties in inserted file. */
193 /* Lisp function for setting buffer-file-coding-system and the
194 multibyteness of the current buffer after inserting a file. */
197 /* Functions to be called to create text property annotations for file. */
205 /* File name in which we write a list of all our auto save files. */
208 /* Function to call to read a file name. */
214 /* Nonzero means completion ignores case when reading file name. */
226 expanding file names. This can be bound to / or \. */
249 Vinhibit_file_name_handlers is a list of file name handlers.
350 DEFUN ("find-file-name-handler", Ffind_file_name_handler, Sfind_file_name_handler, 2, 2, 0,
353 A file name is handled if one of the regular expressions in
354 `file-name-handler-alist' matches it.
356 If OPERATION equals `inhibit-file-name-operation', then we ignore
357 any handlers that are members of `inhibit-file-name-handlers',
412 DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory,
414 doc: /* Return the directory component in file name FILENAME.
417 Given a Unix syntax file name, returns a string ending in slash;
432 /* If the file name has special constructs in it,
433 call the corresponding file handler. */
489 DEFUN ("file-name-nondirectory", Ffile_name_nondirectory,
491 doc: /* Return file name FILENAME sans its directory.
492 For example, in a Unix-syntax file name,
494 or the entire name if it contains no slash. */)
503 /* If the file name has special constructs in it,
504 call the corresponding file handler. */
528 DEFUN ("unhandled-file-name-directory", Funhandled_file_name_directory,
530 doc: /* Return a directly usable directory name somehow associated with FILENAME.
531 A `directly usable' directory name is one that may be used without the
532 intervention of any file handler.
533 If FILENAME is a directly usable file itself, return
534 \(file-name-directory FILENAME).
542 /* If the file name has special constructs in it,
543 call the corresponding file handler. */
573 /* Is it a VMS directory file name? If so, hack VMS syntax. */
641 DEFUN ("file-name-as-directory", Ffile_name_as_directory,
643 doc: /* Return a string representing the file name FILE interpreted as a directory.
644 This operation exists because a directory is also a file, but its name as
645 a directory is different from its name as a file.
647 or passed as second argument to `expand-file-name'.
648 For a Unix-syntax file name, just appends a slash.
650 (file)
651 Lisp_Object file;
656 CHECK_STRING (file);
657 if (NILP (file))
660 /* If the file name has special constructs in it,
661 call the corresponding file handler. */
662 handler = Ffind_file_name_handler (file, Qfile_name_as_directory);
664 return call2 (handler, Qfile_name_as_directory, file);
666 buf = (char *) alloca (SBYTES (file) + 10);
667 file_name_as_directory (buf, SDATA (file));
669 STRING_MULTIBYTE (file));
674 * Convert from directory name to filename.
727 { /* Xlate logical name and see what we get */
742 name...
835 DEFUN ("directory-file-name", Fdirectory_file_name, Sdirectory_file_name,
837 doc: /* Returns the file name of the directory named DIRECTORY.
838 This is the name of the file that holds the data for the directory DIRECTORY.
839 This operation exists because a directory is also a file, but its name as
840 a directory is different from its name as a file.
842 On VMS, given a VMS-syntax directory name such as \"[X.Y]\",
843 it returns a file name such as \"[X]Y.DIR.1\". */)
855 /* If the file name has special constructs in it,
856 call the corresponding file handler. */
863 logical name translation. an equivalence string can be up to 255
888 /* Value is a temporary file name starting with PREFIX, a string.
891 no danger of generating a name being used by another process.
892 In addition, this function makes an attempt to choose a name
893 which has no existing file. To make this work, PREFIX should be
894 an absolute file name.
898 form the file name. Otherwise, if Emacs is running on a system
899 with long file names, add the pid as a decimal number.
901 This function signals an error if no unique file name could be
920 three are incremented if the file already exists. This ensures
921 262144 unique file names per PID per PREFIX. */
961 We don't want make-temp-name to be called while dumping,
998 report_file_error ("Cannot create temporary name for prefix",
1004 error ("Cannot create temporary name for prefix `%s'",
1010 DEFUN ("make-temp-name", Fmake_temp_name, Smake_temp_name, 1, 1, 0,
1011 doc: /* Generate temporary file name (string) starting with PREFIX (a string).
1013 so there is no danger of generating a name being used by another process.
1015 In addition, this function makes an attempt to choose a name
1016 which has no existing file. To make this work,
1017 PREFIX should be an absolute file name.
1019 There is a race condition between calling `make-temp-name' and creating the
1020 file which opens all kinds of security holes. For that reason, you should
1021 probably use `make-temp-file' instead, except in three circumstances:
1023 * If you are creating the file in the user's home directory.
1024 * If you are creating a directory rather than an ordinary file.
1025 * If you are taking special precautions as `make-temp-file' does. */)
1035 DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0,
1040 File name components that are `.' are removed, and
1041 so are file name components followed by `..', along with the `..' itself;
1043 file names in the file system.
1046 See also the function `substitute-in-file-name'. */)
1047 (name, default_directory)
1048 Lisp_Object name, default_directory;
1073 CHECK_STRING (name);
1075 /* If the file name has special constructs in it,
1076 call the corresponding file handler. */
1077 handler = Ffind_file_name_handler (name, Qexpand_file_name);
1079 return call3 (handler, Qexpand_file_name, name, default_directory);
1091 (expand-file-name "a"))
1107 return call3 (handler, Qexpand_file_name, name, default_directory);
1122 if (! NILP (default_directory) && !EQ (default_directory, name)
1124 is not relative, it can be canonicalized with name below (if it
1127 /* Detect MSDOS file names with drive specifiers. */
1130 /* Detect Windows file names in UNC format. */
1134 /* Detect Unix absolute file names (/... alone is not absolute on
1142 GCPRO1 (name);
1147 name = FILE_SYSTEM_CASE (name);
1148 nm = SDATA (name);
1149 multibyte = STRING_MULTIBYTE (name);
1164 even if the rest of the name appears to be relative. Only look for
1191 allocating a new string if name is already fully expanded. */
1216 /* Since we know the name is absolute, we can assume that each
1283 /* if /name/dev:, move nm to dev: */
1326 if (strcmp (nm, SDATA (name)) != 0)
1327 name = make_specified_string (nm, -1, strlen (nm), multibyte);
1332 if (strcmp (nm - 2, SDATA (name)) != 0)
1334 char temp[] = " :";
1336 name = make_specified_string (nm, -1, p - nm, multibyte);
1337 temp[0] = DRIVE_LETTER (drive);
1338 name = concat2 (build_string (temp), name);
1340 return name;
1342 if (nm == SDATA (name))
1343 return name;
1349 /* At this point, nm might or might not be an absolute file name. We
1362 return an absolute name, if the final prefix is not absolute we
1412 /* If we don't find a user of that name, leave the name
1418 /* On DOS and Windows, nm is absolute if a drive name was specified;
1472 /* First ensure newdir is an absolute name. */
1474 /* Detect MSDOS file names with drive specifiers. */
1478 /* Detect Windows file names in UNC format. */
1483 /* Effectively, let newdir be (expand-file-name newdir cwd).
1484 Because of the admonition against calling expand-file-name
1511 /* Strip off drive name from prefix, if present. */
1542 just / or // (an incomplete UNC name). */
1550 unsigned char *temp = (unsigned char *) alloca (length);
1551 bcopy (newdir, temp, length - 1);
1552 temp[length - 1] = 0;
1553 newdir = temp;
1560 /* Now concatenate the directory and name to new space in the stack frame */
1667 /* `/../' is the "superroot" on certain file systems.
1670 file names like "d:/../foo" which fail file-related
1681 /* Keep initial / only if this is the whole name. */
1697 /* At last, set drive name. */
1699 /* Except for network file name. */
1720 /* Again look to see if the file name has special constructs in it
1721 and perhaps call the corresponding file handler. This is needed
1734 This is the old version of expand-file-name, before it was thoroughly
1744 DEAFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0,
1751 See also the function `substitute-in-file-name'.")
1752 (name, defalt)
1753 Lisp_Object name, defalt;
1771 CHECK_STRING (name);
1775 name = Fupcase (name);
1778 nm = SDATA (name);
1855 /* If /name/dev:, move nm to dev: */
1887 if (nm == SDATA (name))
1888 return name;
1915 /* Find end of name. */
1923 /* Copy the user name into temp storage. */
1928 /* Look up the user name. */
1937 /* Discard the user name from NM. */
1953 /* Now concatenate the directory and name to new space in the stack frame */
2042 /* `/../' is the "superroot" on certain file systems. */
2105 /* // at start of file name is meaningful in Apollo,
2125 ~user alone, it might be a literal file name. */
2139 DEFUN ("substitute-in-file-name", Fsubstitute_in_file_name,
2142 `$FOO' where FOO is an environment variable name means to substitute
2143 the value of that variable. The variable name should be terminated
2145 the entire variable name in braces.
2149 duplicates what `expand-file-name' does. */)
2164 /* If the file name has special constructs in it,
2165 call the corresponding file handler. */
2181 /* Start over with the new string, so we check the file-name-handler
2225 /* Copy out the variable name */
2252 /* Copy the rest of the name through, replacing $ constructs with values */
2280 /* Copy out the variable name */
2337 (directory-file-name (expand-file-name FOO)). */
2358 /* We cannot take shortcuts; they might be wrong for magic file names. */
2365 /* Signal an error if the file ABSNAME already exists.
2368 QUERYSTRING is a name for the action that is being considered
2369 to alter the file.
2371 *STATPTR is used to store the stat information if the file exists.
2372 If the file does not exist, STATPTR->st_mode is set to 0.
2391 /* stat is a good way to tell whether the file exists,
2420 DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 5,
2421 "fCopy file: \nGCopy %s to file: \np\nP",
2425 This function always sets the file modes of the output file to match
2426 the input file.
2429 if file NEWNAME already exists. If OK-IF-ALREADY-EXISTS is nil, we
2430 signal a `file-already-exists' error without overwriting. If
2434 existing file.
2436 Fourth arg KEEP-TIME non-nil means give the output file the same
2443 (file, newname, ok_if_already_exists, keep_time, preserve_uid_gid)
2444 Lisp_Object file, newname, ok_if_already_exists, keep_time;
2457 GCPRO4 (file, newname, encoded_file, encoded_newname);
2458 CHECK_STRING (file);
2462 newname = Fexpand_file_name (Ffile_name_nondirectory (file), newname);
2466 file = Fexpand_file_name (file, Qnil);
2468 /* If the input file name has special constructs in it,
2469 call the corresponding file handler. */
2470 handler = Ffind_file_name_handler (file, Qcopy_file);
2471 /* Likewise for output file name. */
2475 RETURN_UNGCPRO (call5 (handler, Qcopy_file, file, newname,
2478 encoded_file = ENCODE_FILE (file);
2492 report_file_error ("Copying file", Fcons (file, Fcons (newname, Qnil)));
2503 /* Ensure file is writable while its modified time is set. */
2511 build_string ("Cannot set file date"), newname);
2522 report_file_error ("Opening input file", Fcons (file, Qnil));
2536 Fcons (file, Fcons (newname, Qnil)));
2549 report_file_error ("Non-regular file", Fcons (file, Qnil));
2555 /* Create the copy file with the same record format as the input file */
2559 /* System's default file type was set to binary by _fmode in emacs.c. */
2572 report_file_error ("Opening output file", Fcons (newname, Qnil));
2584 /* Preserve the original file modes, and if requested, also its
2594 /* Closing the output clobbers the file times on some systems. */
2608 build_string ("Cannot set file date"), newname);
2617 /* In DJGPP v2.0 and later, fstat usually returns true file mode bits,
2619 get only the READ bit, which will make the copied file read-only,
2692 DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 1, "fDelete file: ",
2693 doc: /* Delete file named FILENAME. If it is a symlink, remove the symlink.
2694 If file has multiple names, it continues to exist with the other names. */)
2706 build_string ("Removing old name: is a directory"),
2718 report_file_error ("Removing old name", list1 (filename));
2729 /* Delete file FILENAME, returning 1 if successful and 0 if failed. */
2742 DEFUN ("rename-file", Frename_file, Srename_file, 2, 3,
2743 "fRename file: \nGRename %s to file: \np",
2745 If file has names other than FILE, it continues to have those names.
2746 Signals a `file-already-exists' error if a file NEWNAME already exists
2750 (file, newname, ok_if_already_exists)
2751 Lisp_Object file, newname, ok_if_already_exists;
2758 GCPRO5 (file, newname, encoded_file, encoded_newname, symlink_target);
2759 CHECK_STRING (file);
2761 file = Fexpand_file_name (file, Qnil);
2765 /* If the file names are identical but for the case,
2767 && (NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname))))
2770 newname = Fexpand_file_name (Ffile_name_nondirectory (file), newname);
2774 /* If the file name has special constructs in it,
2775 call the corresponding file handler. */
2776 handler = Ffind_file_name_handler (file, Qrename_file);
2781 file, newname, ok_if_already_exists));
2783 encoded_file = ENCODE_FILE (file);
2787 /* If the file names are identical but for the case, don't ask for
2789 file name. */
2790 if (NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname))))
2806 symlink_target = Ffile_symlink_p (file);
2812 Fcopy_file (file, newname,
2814 so don't have copy-file prompt again. */
2818 Fdelete_file (file);
2821 report_file_error ("Renaming", list2 (file, newname));
2827 DEFUN ("add-name-to-file", Fadd_name_to_file, Sadd_name_to_file, 2, 3,
2828 "fAdd name to file: \nGName to add to %s: \np",
2829 doc: /* Give FILE additional name NEWNAME. Both args must be strings.
2830 Signals a `file-already-exists' error if a file NEWNAME already exists
2834 (file, newname, ok_if_already_exists)
2835 Lisp_Object file, newname, ok_if_already_exists;
2841 GCPRO4 (file, newname, encoded_file, encoded_newname);
2843 CHECK_STRING (file);
2845 file = Fexpand_file_name (file, Qnil);
2848 newname = Fexpand_file_name (Ffile_name_nondirectory (file), newname);
2852 /* If the file name has special constructs in it,
2853 call the corresponding file handler. */
2854 handler = Ffind_file_name_handler (file, Qadd_name_to_file);
2856 RETURN_UNGCPRO (call4 (handler, Qadd_name_to_file, file,
2859 /* If the new name has special constructs in it,
2860 call the corresponding file handler. */
2863 RETURN_UNGCPRO (call4 (handler, Qadd_name_to_file, file,
2866 encoded_file = ENCODE_FILE (file);
2871 barf_or_query_if_file_exists (newname, "make it a new name",
2876 report_file_error ("Adding new name", list2 (file, newname));
2884 "FMake symbolic link to file: \nGMake symbolic link to file %s: \np",
2887 Signals a `file-already-exists' error if a file LINKNAME already exists
2903 a truly valid file name. Otherwise, do not expand;
2904 we want to permit links to relative file names. */
2913 /* If the file name has special constructs in it,
2914 call the corresponding file handler. */
2920 /* If the new link name has special constructs in it,
2921 call the corresponding file handler. */
2937 /* If we didn't complain already, silently delete existing file. */
2958 DEFUN ("define-logical-name", Fdefine_logical_name, Sdefine_logical_name,
2959 2, 2, "sDefine logical name: \nsDefine logical name %s as: ",
2960 doc: /* Define the job-wide logical name NAME to have the value STRING.
2961 If STRING is nil or a null string, the logical name NAME is deleted. */)
2962 (name, string)
2963 Lisp_Object name;
2966 CHECK_STRING (name);
2968 delete_logical_name (SDATA (name));
2974 delete_logical_name (SDATA (name));
2976 define_logical_name (SDATA (name), SDATA (string));
3005 DEFUN ("file-name-absolute-p", Ffile_name_absolute_p, Sfile_name_absolute_p,
3007 doc: /* Return t if file FILENAME specifies an absolute file name.
3008 On Unix, this is a name starting with a `/' or a `~'. */)
3017 /* Return nonzero if file FILENAME exists and can be executed. */
3051 /* Return nonzero if file FILENAME exists and can be written. */
3069 Opening with O_WRONLY could work for an ordinary file,
3076 DEFUN ("file-exists-p", Ffile_exists_p, Sfile_exists_p, 1, 1, 0,
3077 doc: /* Return t if file FILENAME exists (whether or not you can read it.)
3078 See also `file-readable-p' and `file-attributes'.
3079 This returns nil for a symlink to a nonexistent file.
3080 Use `file-symlink-p' to test for such links. */)
3091 /* If the file name has special constructs in it,
3092 call the corresponding file handler. */
3102 DEFUN ("file-executable-p", Ffile_executable_p, Sfile_executable_p, 1, 1, 0,
3114 /* If the file name has special constructs in it,
3115 call the corresponding file handler. */
3125 DEFUN ("file-readable-p", Ffile_readable_p, Sfile_readable_p, 1, 1, 0,
3126 doc: /* Return t if file FILENAME exists and you can read it.
3127 See also `file-exists-p' and `file-attributes'. */)
3140 /* If the file name has special constructs in it,
3141 call the corresponding file handler. */
3174 /* Having this before file-symlink-p mysteriously caused it to be forgotten
3176 DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0,
3177 doc: /* Return t if file FILENAME can be written or created by you. */)
3188 /* If the file name has special constructs in it,
3189 call the corresponding file handler. */
3212 whether a file or directory can be created within it. Some day we
3224 DEFUN ("access-file", Faccess_file, Saccess_file, 2, 2, 0,
3225 doc: /* Access file FILENAME, and get an error if that does not work.
3239 /* If the file name has special constructs in it,
3240 call the corresponding file handler. */
3256 DEFUN ("file-symlink-p", Ffile_symlink_p, Sfile_symlink_p, 1, 1, 0,
3257 doc: /* Return non-nil if file FILENAME is the name of a symbolic link.
3261 This function returns t when given the name of a symlink that
3262 points to a nonexistent file. */)
3271 /* If the file name has special constructs in it,
3272 call the corresponding file handler. */
3324 DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0,
3327 See `file-symlink-p' to distinguish symlinks. */)
3337 /* If the file name has special constructs in it,
3338 call the corresponding file handler. */
3350 DEFUN ("file-accessible-directory-p", Ffile_accessible_directory_p, Sfile_accessible_directory_p, 1, 1, 0,
3351 doc: /* Return t if file FILENAME names a directory you can open.
3352 For the value to be t, FILENAME must specify the name of a directory as a file,
3355 A directory name spec may be given instead; then the value is t
3365 /* If the file name has special constructs in it,
3366 call the corresponding file handler. */
3378 DEFUN ("file-regular-p", Ffile_regular_p, Sfile_regular_p, 1, 1, 0,
3379 doc: /* Return t if FILENAME names a regular file.
3380 This is the sort of file that holds an ordinary stream of data bytes.
3382 See `file-symlink-p' to distinguish symlinks. */)
3392 /* If the file name has special constructs in it,
3393 call the corresponding file handler. */
3422 DEFUN ("file-modes", Ffile_modes, Sfile_modes, 1, 1, 0,
3423 doc: /* Return mode bits of file named FILENAME, as an integer.
3424 Return nil, if file does not exist or is not accessible. */)
3434 /* If the file name has special constructs in it,
3435 call the corresponding file handler. */
3452 DEFUN ("set-file-modes", Fset_file_modes, Sset_file_modes, 2, 2, 0,
3453 doc: /* Set mode bits of file named FILENAME to MODE (an integer).
3464 /* If the file name has special constructs in it,
3465 call the corresponding file handler. */
3478 DEFUN ("set-default-file-modes", Fset_default_file_modes, Sset_default_file_modes, 1, 1, 0,
3479 doc: /* Set the file permission bits for newly created files.
3492 DEFUN ("default-file-modes", Fdefault_file_modes, Sdefault_file_modes, 0, 0, 0,
3493 doc: /* Return the default file protection for created files.
3510 DEFUN ("set-file-times", Fset_file_times, Sset_file_times, 1, 2, 0,
3511 doc: /* Set times of file FILENAME to TIME.
3529 /* If the file name has special constructs in it,
3530 call the corresponding file handler. */
3553 report_file_error ("Setting file times", Fcons (absname, Qnil));
3573 DEFUN ("file-newer-than-file-p", Ffile_newer_than_file_p, Sfile_newer_than_file_p, 2, 2, 0,
3574 doc: /* Return t if file FILE1 is newer than file FILE2.
3595 /* If the file name has special constructs in it,
3596 call the corresponding file handler. */
3671 /* Used to pass values from insert-file-contents to read_non_regular. */
3678 /* Read from a non-regular file.
3699 in insert-file-contents. */
3708 DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents,
3710 doc: /* Insert contents of file FILENAME after point.
3711 Returns list of absolute file name and number of characters inserted.
3713 and last save file modtime are set, and it is marked unmodified.
3714 If visiting and the file does not exist, visiting is completed
3717 specify what portion of the file to insert.
3718 These arguments count bytes in the file, not characters in the buffer.
3723 with the file contents. This is better than simply deleting and inserting
3730 `coding-system-for-read' or `file-coding-system-alist',
3758 error ("Cannot do file visiting in an indirect buffer");
3772 /* If the file name has special constructs in it,
3773 call the corresponding file handler. */
3811 report_file_error ("Opening input file", Fcons (orig_filename, Qnil));
3832 build_string ("not a regular file"), orig_filename);
3848 file sizes to exceed 2Gb. VMS is no longer officially supported, so
3859 error ("Attempt to visit less than an entire file");
3861 error ("Cannot do file visiting in a non-empty buffer");
3878 represent the file size, or if the calculations below
3879 overflow. The calculations below double the file size
3885 /* The file size returned from stat may be zero, but data
3887 file in the /proc filesystem. */
3908 /* Decide the coding system to use for reading the file now
3918 /* Don't try looking inside a file for a coding system
3923 lines or in the tailing several lines of the file.
3937 report_file_error ("Setting file position",
3979 /* Rewind the file for the actual read done later. */
3981 report_file_error ("Setting file position",
3989 file-coding-system-alist. */
4017 with the file contents. Avoid replacing text at the
4018 beginning or end of the buffer that matches the file contents;
4035 because file access counts bytes
4048 report_file_error ("Setting file position",
4054 /* Count how many chars at the start of the file
4070 /* We found that the file should be decoded somehow.
4098 /* If the file matches the buffer completely,
4104 /* Truncate the buffer to the size of the file. */
4110 /* Count how many chars at the end of the file
4117 /* At what file position are we now scanning? */
4119 /* If the entire file matches the buffer tail, stop the scan. */
4125 report_file_error ("Setting file position",
4145 as matching both at the file's beginning and at the end. */
4171 int temp;
4195 /* Arrange to read only the nonmatching middle part of the file. */
4200 /* Insert from the file at the proper position. */
4201 temp = BYTE_TO_CHAR (same_at_start);
4202 SET_PT_BOTH (temp, same_at_start);
4214 with the file contents. Avoid replacing text at the
4215 beginning or end of the buffer that matches the file contents;
4231 int temp;
4233 /* First read the whole file, performing code conversion into
4239 report_file_error ("Setting file position",
4243 total = st.st_size; /* Total bytes in the file. */
4244 how_much = 0; /* Bytes read from file so far. */
4309 or should be <= 0 if we couldn't read the file. */
4319 /* Compare the beginning of the converted file
4327 /* If the file matches the buffer completely,
4336 /* Truncate the buffer to the size of the file. */
4354 as matching both at the file's beginning and at the end. */
4378 we are taking from the file. */
4384 temp = GPT;
4389 temp = BYTE_TO_CHAR (same_at_start);
4391 /* Insert from the file at the proper position. */
4392 SET_PT_BOTH (temp, same_at_start);
4400 inserted = PT - temp;
4402 SET_PT_BOTH (temp, same_at_start);
4413 register Lisp_Object temp;
4418 XSETINT (temp, total);
4419 if (total != XINT (temp))
4423 /* For a special file, all we can do is guess. */
4430 /* Make binding buffer-file-name to nil effective. */
4445 report_file_error ("Setting file position",
4450 far for a regular file, and not changed for a special file. But,
4480 /* Read from the file, capturing `quit'. When an
4515 /* For a regular file, where TOTAL is the real size,
4517 For a special file, where TOTAL is just a buffer size,
4526 /* Now we have read all the file data into the gap.
4555 /* Discard the unwind protect for closing the file. */
4603 file-coding-system-alist. */
4644 /* Visiting a file with these coding system makes the buffer
4666 /* Use the conversion type to determine buffer-file-type
4667 (find-buffer-file-type is now used to help determine the
4706 build_string ("not a regular file"), orig_filename);
4723 /* Decode file format */
4730 point is either nil or t when visiting a file. */
4772 /* If visiting nonexistent file, return nil. */
4773 report_file_error ("Opening input file", Fcons (orig_filename, Qnil));
4849 /* If the variable `buffer-file-coding-system' is set locally,
4850 it means that the file was read with some kind of code
4856 format if the default value of `buffer-file-coding-system'
4872 /* Check file-coding-system-alist. */
4887 default value of buffer-file-coding-system. */
4934 "r\nFWrite region to file: \ni\ni\ni\np",
4935 doc: /* Write current region into specified file.
4940 If START is a string, then output that string to the file
4944 append to existing file contents (if any). If it is an integer,
4945 seek to that offset in the file before writing.
4947 set the last-save-file-modtime of buffer to this file's modtime
4949 If VISIT is a string, it is a second file name;
4951 VISIT is also the file name to lock and unlock for clash detection.
4953 that means do not display the \"Wrote file\" message.
4954 The optional sixth arg LOCKNAME, if non-nil, specifies the name to
4957 for an existing file with the same name. If MUSTBENEW is `excl',
4958 that means to get an error if the file already exists; never overwrite.
4960 confirmation before overwriting, but do go ahead and overwrite the file
4964 `coding-system-for-write', `buffer-file-coding-system', or
4965 `file-coding-system-alist', and sets the variable
4995 error ("Cannot do file visiting in an indirect buffer");
5018 /* If the file name has special constructs in it,
5019 call the corresponding file handler. */
5095 /* If we've locked this file for some other buffer,
5118 if (auto_saving) /* Overwrite any previous version of autosave file */
5127 else /* Write to temporary name and rename if no errors */
5141 /* If we can't open the temporary file, try creating a new
5142 version of the original file. VMS "creat" creates a
5143 new version rather than truncating an existing file. */
5147 #if 0 /* This can clobber an existing file and fail to replace it,
5183 report_file_error ("Opening output file", Fcons (filename, Qnil));
5272 /* If file was empty, still need to write the annotations */
5293 /* mib says that closing the file will try to write as fast as NFS can do
5303 /* Spurious "file has changed on disk" warnings have been
5327 /* If we wrote to a temporary name and had no errors, rename to real name. */
5350 to avoid a "file has changed on disk" warning on
5451 /* Now do the same for annotation functions implied by the file-format */
5653 DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime,
5655 doc: /* Return t if last mod time of BUF's visited file matches what BUF records.
5656 This means that the file has not been changed since it was visited or saved.
5672 /* If the file name has special constructs in it,
5673 call the corresponding file handler. */
5683 /* If the file doesn't exist now and didn't exist before,
5699 DEFUN ("clear-visited-file-modtime", Fclear_visited_file_modtime,
5701 doc: /* Clear out records of last mod time of visited file.
5709 DEFUN ("visited-file-modtime", Fvisited_file_modtime,
5711 doc: /* Return the current buffer's recorded visited file modification time.
5713 that `file-attributes' returns. If the current buffer has no recorded
5714 file modification time, this function returns 0.
5725 DEFUN ("set-visited-file-modtime", Fset_visited_file_modtime,
5727 doc: /* Update buffer's recorded modification time from the visited file's time.
5728 Useful if the buffer was not read from the file normally
5729 or if the file itself has been changed for some known benign reason.
5731 \(instead of that of the visited file), in the form of a list
5746 /* If the file name has special constructs in it,
5747 call the corresponding file handler. */
5750 /* The handler can find the file name the same way we did. */
5776 args[1] = current_buffer->name;
5806 /* Get visited file's mode to become the auto save file's mode. */
5869 Auto-saving writes the buffer into a file
5871 This file is not the file you visited; that changes only when you save.
5951 couldn't handle some ange-ftp'd file. */
5960 in the special file that lists them. For each of these buffers,
5961 Record visited name (if any) and auto save name. */
5988 and file changed since last auto save
5989 and file changed since last real save. */
6010 /* A short file is likely to change a large fraction;
6020 b->name, 1);
6074 No auto-save file will be written until the buffer changes again. */)
6096 in the visited file. If the buffer has no visited file,
6104 /* Reading and completing file names */
6149 DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_internal,
6151 doc: /* Internal subroutine for read-file-name. Do not call this. */)
6157 Lisp_Object name, specdir, realdir, val, orig_string;
6164 name = string;
6169 GCPRO5 (string, realdir, name, specdir, orig_string);
6184 name = Ffile_name_nondirectory (string);
6193 val = Ffile_name_completion (name, realdir, Vread_file_name_predicate);
6214 Lisp_Object all = Ffile_name_all_completions (name, realdir);
6262 if (SCHARS (name) == 0)
6271 DEFUN ("next-read-file-uses-dialog-p", Fnext_read_file_uses_dialog_p,
6273 doc: /* Return t if a call to `read-file-name' will use a dialog.
6274 The return value is only relevant for a call to `read-file-name' that happens
6288 DEFUN ("read-file-name", Fread_file_name, Sread_file_name, 1, 6, 0,
6289 doc: /* Read file name, prompting with PROMPT and completing in directory DIR.
6290 Value is not expanded---you must call `expand-file-name' yourself.
6291 Default name to DEFAULT-FILENAME if user exits the minibuffer with
6293 (If DEFAULT-FILENAME is omitted, the visited file name is used,
6298 Fourth arg MUSTMATCH non-nil means require existing file's name.
6302 the resulting file name must satisfy (funcall PREDICATE NAME).
6303 DIR should be an absolute directory name. It defaults to the value of
6306 If this command was invoked with the mouse, use a file dialog box if
6308 provides a file dialog box.
6310 See also `read-file-name-completion-ignore-case'
6311 and `read-file-name-function'. */)
6413 specbind (intern ("minibuffer-completing-file-name"), Qt);
6414 specbind (intern ("read-file-name-predicate"),
6422 /* If DIR contains a file name, split it. */
6423 Lisp_Object file;
6424 file = Ffile_name_nondirectory (dir);
6425 if (SCHARS (file) && NILP (default_filename))
6427 default_filename = file;
6438 val = Fcompleting_read (prompt, intern ("read-file-name-internal"),
6450 so that commands such as set-visited-file-name can distinguish. */
6464 error ("No file name specified");
6513 Qexpand_file_name = intern ("expand-file-name");
6514 Qsubstitute_in_file_name = intern ("substitute-in-file-name");
6515 Qdirectory_file_name = intern ("directory-file-name");
6516 Qfile_name_directory = intern ("file-name-directory");
6517 Qfile_name_nondirectory = intern ("file-name-nondirectory");
6518 Qunhandled_file_name_directory = intern ("unhandled-file-name-directory");
6519 Qfile_name_as_directory = intern ("file-name-as-directory");
6520 Qcopy_file = intern ("copy-file");
6524 Qdelete_file = intern ("delete-file");
6525 Qrename_file = intern ("rename-file");
6526 Qadd_name_to_file = intern ("add-name-to-file");
6528 Qfile_exists_p = intern ("file-exists-p");
6529 Qfile_executable_p = intern ("file-executable-p");
6530 Qfile_readable_p = intern ("file-readable-p");
6531 Qfile_writable_p = intern ("file-writable-p");
6532 Qfile_symlink_p = intern ("file-symlink-p");
6533 Qaccess_file = intern ("access-file");
6534 Qfile_directory_p = intern ("file-directory-p");
6535 Qfile_regular_p = intern ("file-regular-p");
6536 Qfile_accessible_directory_p = intern ("file-accessible-directory-p");
6537 Qfile_modes = intern ("file-modes");
6538 Qset_file_modes = intern ("set-file-modes");
6539 Qset_file_times = intern ("set-file-times");
6540 Qfile_newer_than_file_p = intern ("file-newer-than-file-p");
6541 Qinsert_file_contents = intern ("insert-file-contents");
6543 Qverify_visited_file_modtime = intern ("verify-visited-file-modtime");
6544 Qset_visited_file_modtime = intern ("set-visited-file-modtime");
6582 Qfile_name_history = intern ("file-name-history");
6586 Qfile_error = intern ("file-error");
6588 Qfile_already_exists = intern ("file-already-exists");
6590 Qfile_date_error = intern ("file-date-error");
6596 Qfind_buffer_file_type = intern ("find-buffer-file-type");
6600 DEFVAR_LISP ("file-name-coding-system", &Vfile_name_coding_system,
6601 doc: /* *Coding system for encoding file names.
6602 If it is nil, `default-file-name-coding-system' (which see) is used. */);
6605 DEFVAR_LISP ("default-file-name-coding-system",
6607 doc: /* Default coding system for encoding file names.
6608 This variable is used only when `file-name-coding-system' is nil.
6612 instead use `file-name-coding-system' to get a constant encoding
6613 of file names regardless of the current language environment. */);
6620 Qafter_insert_file_set_coding = intern ("after-insert-file-set-coding");
6639 build_string ("Cannot set file date"));
6641 DEFVAR_LISP ("read-file-name-function", &Vread_file_name_function,
6642 doc: /* If this is non-nil, `read-file-name' does its work by calling this function. */);
6645 DEFVAR_LISP ("read-file-name-predicate", &Vread_file_name_predicate,
6646 doc: /* Current predicate used by `read-file-name-internal'. */);
6649 DEFVAR_BOOL ("read-file-name-completion-ignore-case", &read_file_name_completion_ignore_case,
6650 doc: /* *Non-nil means when reading a file name completion ignores case. */);
6662 such as making the current buffer visit no file in the case of
6663 `set-visited-file-name'.
6666 default name, if one is provided. Note however that this default name
6667 is not necessarily the name originally inserted in the minibuffer, if
6671 request the default name. */);
6680 doc: /* Directory separator character for built-in functions that return file names.
6683 DEFVAR_LISP ("file-name-handler-alist", &Vfile_name_handler_alist,
6684 doc: /* *Alist of elements (REGEXP . HANDLER) for file names handled specially.
6685 If a file name matches REGEXP, then all I/O on that file is done by calling
6688 The first argument given to HANDLER is the name of the I/O primitive
6691 (file-exists-p FILENAME)
6693 (funcall HANDLER 'file-exists-p FILENAME)
6694 The function `find-file-name-handler' checks this list for a handler
6700 doc: /* If non-nil, a function to call to decide a coding system of file.
6701 Two arguments are passed to this function: the file name
6702 and the length of a file contents following the point.
6703 This function should return a coding system to decode the file contents.
6704 It should check the file name against `auto-coding-alist'.
6711 DEFVAR_LISP ("after-insert-file-functions", &Vafter_insert_file_functions,
6712 doc: /* A list of functions to be called at the end of `insert-file-contents'.
6715 If `insert-file-contents' is intercepted by a handler from
6716 `file-name-handler-alist', that handler is responsible for calling the
6717 functions in `after-insert-file-functions' if appropriate. */);
6726 inserted at the specified positions of the file being written (1 means to
6745 DEFVAR_LISP ("inhibit-file-name-handlers", &Vinhibit_file_name_handlers,
6746 doc: /* A list of file name handlers that temporarily should not be used.
6747 This applies only to the operation `inhibit-file-name-operation'. */);
6750 DEFVAR_LISP ("inhibit-file-name-operation", &Vinhibit_file_name_operation,
6751 doc: /* The operation for which `inhibit-file-name-handlers' is applicable. */);
6754 DEFVAR_LISP ("auto-save-list-file-name", &Vauto_save_list_file_name,
6755 doc: /* File name in which we write a list of all auto save file names.
6756 This variable is initialized automatically from `auto-save-list-file-prefix'
6757 shortly after Emacs reads your `.emacs' file, if you have not yet given it