bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#58446: 28.2; file-attribute-device-number returns a cons cell instea


From: Lars Ingebrigtsen
Subject: bug#58446: 28.2; file-attribute-device-number returns a cons cell instead of an integer
Date: Thu, 13 Oct 2022 08:31:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Michael Albinus <michael.albinus@gmx.de> writes:

[explanation snipped]

> As said, this change happend almost 20 years ago. Device numbers are
> usually ignored by Emacs and external packages, I don't remember a
> problem report for this over the years. Emacs core creates the
> buffer-local variable buffer-file-number, which is indeed (INODE
> DEVNUM). See basic-save-buffer:
>
>             (setq buffer-file-number
>                   (nthcdr 10 (file-attributes buffer-file-name)))
>
> And this variable is used for checking whether two files are equal, see
> find-buffer-visiting:
>
>                             (equal buffer-file-number number)
>
> That's why it works also with Tramp's interpretation of device
> numbers. And again, w/o blame over the years.

Yes, I agree -- we should probably just document this.  But I was
wondering whether it would be useful to make the `file-attribute'
structure extendable?  We could have a twelfth (optional) element that
could be an plist of properties, and then we'd have a place to stash
stuff.

(That might break stuff, though.)

But if we haven't needed that until now, we're probably not going to
need it going forward, and we should just document the current status
quo. 

> And perhaps we could even add a helper function to extract the
> information for a file's uniqueness:
>
> (defsubst file-attribute-file-number (attributes)
>   "The inode and device numbers in ATTRIBUTES returned by `file-attributes'.
> It can be used to determine whether two files are identical."
>   (nthcdr 10 attributes))
>
> WDYT?

Makes sense to me.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]