@end defvar
@defvar buffer-file-number
-This buffer-local variable holds the file number and directory device
+This buffer-local variable holds the inode number and directory device
number of the file visited in the current buffer, or @code{nil} if no
file or a nonexistent file is visited. It is a permanent local,
unaffected by @code{kill-all-local-variables}.
-The value is normally a list of the form @code{(@var{filenum}
+The value is normally a list of the form @code{(@var{inodenum}
@var{devnum})}. This pair of numbers uniquely identifies the file among
all files accessible on the system. See the function
@code{file-attributes}, in @ref{File Attributes}, for more information
@item
The filesystem number of the device that the file is on
-@code{file-attribute-device-number}), an integer.
-This element and the file's inode number
-together give enough information to distinguish any two files on the
-system---no two files can have the same values for both of these
-numbers.
+(@code{file-attribute-device-number}), an integer or a cons cell of
+integers. The latter is sometimes used by remote files, in order to
+distinguish the remote filesystems from the local ones.
@end enumerate
+The file's inode and device numbers together give enough information
+to distinguish any two files on the system---no two files can have the
+same values for both of these numbers. This tupel is returned by
+@code{file-attribute-file-number}.
+
For example, here are the file attributes for @file{files.texi}:
@example
'completing-read-multiple'.
---
-*** New function 'vc-read-multiple-revisions'
+*** New function 'vc-read-multiple-revisions'.
This function invokes 'vc-read-revision' with a non-nil value for
MULTIPLE.
*** New command 'vc-prepare-patch'.
Patches for any version control system can be prepared using VC. The
command will query what commits to send and will compose messages for
-your mail user agent. The behaviour of 'vc-prepare-patch' can be
+your mail user agent. The behavior of 'vc-prepare-patch' can be
modified by the user options 'vc-prepare-patches-separately' and
'vc-default-patch-addressee'.
\f
* Lisp Changes in Emacs 29.1
++++
+** New accessor function 'file-attribute-file-number'.
+It returns the list of the inode and device numbers retrieved by
+'file-attributes'. This value can be used to identify a file uniquely.
+
+++
** New macro 'while-let'.
This is like 'when-let', but repeats until a binding form is nil.
(setq attr (eshell-file-attributes (car files)))
(file-attribute-inode-number attr-target)
(file-attribute-inode-number attr)
- (equal (file-attribute-inode-number attr-target)
- (file-attribute-inode-number attr))
(file-attribute-device-number attr-target)
(file-attribute-device-number attr)
- (equal (file-attribute-device-number attr-target)
- (file-attribute-device-number attr)))
+ (equal (file-attribute-file-number attr-target)
+ (file-attribute-file-number attr)))
(eshell-error (format-message "%s: `%s' and `%s' are the same file\n"
command (car files) target)))
(t
:group 'find-file)
(defvar-local buffer-file-number nil
- "The device number and file number of the file visited in the current buffer.
-The value is a list of the form (FILENUM DEVNUM).
+ "The inode and device numbers of the file visited in the current buffer.
+The value is a list of the form (INODENUM DEVNUM).
This pair of numbers uniquely identifies the file.
If the buffer is visiting a new file, the value is nil.")
(put 'buffer-file-number 'permanent-local t)
(setq list (cdr list)))
found)
(let* ((attributes (file-attributes truename))
- (number (nthcdr 10 attributes))
+ (number (file-attribute-file-number attributes))
(list (buffer-list)) found)
(and buffer-file-numbers-unique
(car-safe number) ;Make sure the inode is not just nil.
(let* ((buf (get-file-buffer filename))
(truename (abbreviate-file-name (file-truename filename)))
(attributes (file-attributes truename))
- (number (nthcdr 10 attributes))
+ (number (file-attribute-file-number attributes))
;; Find any buffer for a file that has same truename.
(other (and (not buf)
(find-buffer-visiting
(setq buffer-file-name truename))))
(setq buffer-file-number
(if filename
- (nthcdr 10 (file-attributes buffer-file-name))
+ (file-attribute-file-number (file-attributes buffer-file-name))
nil))
;; write-file-functions is normally used for things like ftp-find-file
;; that visit things that are not local files as if they were files.
(setq save-buffer-coding-system last-coding-system-used)
(setq buffer-file-coding-system last-coding-system-used))
(setq buffer-file-number
- (nthcdr 10 (file-attributes buffer-file-name)))
+ (file-attribute-file-number (file-attributes buffer-file-name)))
(if setmodes
(condition-case ()
(progn
(defsubst file-attribute-device-number (attributes)
"The file system device number in ATTRIBUTES returned by `file-attributes'.
-It is an integer."
+It is an integer or a cons cell of integers."
(nth 11 attributes))
+(defsubst file-attribute-file-number (attributes)
+ "The inode and device numbers in ATTRIBUTES returned by `file-attributes'.
+The value is a list of the form (INODENUM DEVNUM).
+This pair of numbers uniquely identifies the file."
+ (nthcdr 10 attributes))
+
(defun file-attribute-collect (attributes &rest attr-names)
"Return a sublist of ATTRIBUTES returned by `file-attributes'.
ATTR-NAMES are symbols with the selected attribute names.
Valid attribute names are: type, link-number, user-id, group-id,
access-time, modification-time, status-change-time, size, modes,
-inode-number and device-number."
+inode-number, device-number and file-number."
(let ((all '(type link-number user-id group-id access-time
modification-time status-change-time
- size modes inode-number device-number))
+ size modes inode-number device-number file-number))
result)
(while attr-names
(let ((attr (pop attr-names)))
;; The Windows version doesn't report meaningful inode numbers, so
;; use the canonicalized absolute file name of the directory instead.
(setq attrs (or canonicalized
- (nthcdr 10 (file-attributes this-dir))))
+ (file-attribute-file-number (file-attributes this-dir))))
(unless (member attrs normal-top-level-add-subdirs-inode-list)
(push attrs normal-top-level-add-subdirs-inode-list)
(dolist (file contents)
8. File modes, as a string of ten letters or dashes as in ls -l.
9. An unspecified value, present only for backward compatibility.
10. inode number, as a nonnegative integer.
-11. Filesystem device number, as an integer.
+11. Filesystem device number, as an integer or a cons cell of integers.
Large integers are bignums, so `eq' might not work on them.
On most filesystems, the combination of the inode and the device
-number uniquely identifies the file.
+number uniquely identifies the file. This is provided by the access
+function `file-attribute-file-number'.
On MS-Windows, performance depends on `w32-get-true-file-attributes',
which see.