unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Enhancement for file-attributes
@ 2012-09-30 14:26 Eli Zaretskii
  2012-09-30 21:14 ` Paul Eggert
  2012-10-01  1:16 ` Stefan Monnier
  0 siblings, 2 replies; 11+ messages in thread
From: Eli Zaretskii @ 2012-09-30 14:26 UTC (permalink / raw)
  To: emacs-devel

Would it be a good idea to enhance file-attributes by adding one more
optional argument to it, which, when non-nil, will cause Emacs call
'stat', not 'lstat', on the argument file name?  This should avoid the
need to call file-chase-links when all we want is to get the
attributes of the file pointed to by the symlink.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Enhancement for file-attributes
  2012-09-30 14:26 Enhancement for file-attributes Eli Zaretskii
@ 2012-09-30 21:14 ` Paul Eggert
  2012-09-30 22:08   ` Eli Zaretskii
  2012-10-01  0:45   ` Stefan Monnier
  2012-10-01  1:16 ` Stefan Monnier
  1 sibling, 2 replies; 11+ messages in thread
From: Paul Eggert @ 2012-09-30 21:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 09/30/2012 07:26 AM, Eli Zaretskii wrote:
> Would it be a good idea to enhance file-attributes by adding one more
> optional argument to it, which, when non-nil, will cause Emacs call
> 'stat', not 'lstat', on the argument file name?

Yes, thanks, I've wanted that myself in the past.  This seems like a
no-brainer so I installed it as trunk bzr 110295.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Enhancement for file-attributes
  2012-09-30 21:14 ` Paul Eggert
@ 2012-09-30 22:08   ` Eli Zaretskii
  2012-10-01  0:45   ` Stefan Monnier
  1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2012-09-30 22:08 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

> Date: Sun, 30 Sep 2012 14:14:14 -0700
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: emacs-devel@gnu.org
> 
> On 09/30/2012 07:26 AM, Eli Zaretskii wrote:
> > Would it be a good idea to enhance file-attributes by adding one more
> > optional argument to it, which, when non-nil, will cause Emacs call
> > 'stat', not 'lstat', on the argument file name?
> 
> Yes, thanks, I've wanted that myself in the past.  This seems like a
> no-brainer so I installed it as trunk bzr 110295.

Thanks.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Enhancement for file-attributes
  2012-09-30 21:14 ` Paul Eggert
  2012-09-30 22:08   ` Eli Zaretskii
@ 2012-10-01  0:45   ` Stefan Monnier
  2012-10-01  2:08     ` Paul Eggert
  1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2012-10-01  0:45 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Eli Zaretskii, emacs-devel

> This seems like a no-brainer so I installed it as trunk bzr 110295.

Seems like it, but changing the signature of such core function is not
always as harmless as it seems.
E.g. have you committed corresponding changes to Tramp?


        Stefan



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Enhancement for file-attributes
  2012-09-30 14:26 Enhancement for file-attributes Eli Zaretskii
  2012-09-30 21:14 ` Paul Eggert
@ 2012-10-01  1:16 ` Stefan Monnier
  2012-10-01  2:04   ` Juanma Barranquero
  2012-10-01 12:59   ` Eli Zaretskii
  1 sibling, 2 replies; 11+ messages in thread
From: Stefan Monnier @ 2012-10-01  1:16 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> Would it be a good idea to enhance file-attributes by adding one more
> optional argument to it, which, when non-nil, will cause Emacs call
> 'stat', not 'lstat', on the argument file name?  This should avoid the
> need to call file-chase-links when all we want is to get the
> attributes of the file pointed to by the symlink.

It would have made a lot of sense originally, but I'm wondering whether
it's worth the trouble now.  In how many places would we save the
file-chase-links all?  Are these places important?


        Stefan



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Enhancement for file-attributes
  2012-10-01  1:16 ` Stefan Monnier
@ 2012-10-01  2:04   ` Juanma Barranquero
  2012-10-01 12:59   ` Eli Zaretskii
  1 sibling, 0 replies; 11+ messages in thread
From: Juanma Barranquero @ 2012-10-01  2:04 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, emacs-devel

On Mon, Oct 1, 2012 at 3:16 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> It would have made a lot of sense originally, but I'm wondering whether
> it's worth the trouble now.  In how many places would we save the
> file-chase-links all?  Are these places important?

I don't know about that, but a way to ask file-attributes for a
specific value, instead of computing them all and consing them into a
list would perhaps make sense.

I recently counted uses of (nth X (file-attributes ...)), and
variants, like (car (file-attributes ...)) and (let ((atr
(file-attributes ...))) ...), etc. Asking for the file size happens >
110 times in the sources; last modification time, > 50; all the rest,
<10 each (approx, as I counted by hand).

So a function (file-size X) doing an optimized equivalent of  (nth 7
(file-attributes (file-truename NAME))) would be useful, and cleaner
IMO.

    Juanma



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Enhancement for file-attributes
  2012-10-01  0:45   ` Stefan Monnier
@ 2012-10-01  2:08     ` Paul Eggert
  2012-10-08 10:36       ` Michael Albinus
  0 siblings, 1 reply; 11+ messages in thread
From: Paul Eggert @ 2012-10-01  2:08 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, emacs-devel

On 09/30/2012 05:45 PM, Stefan Monnier wrote:
> have you committed corresponding changes to Tramp?

Good point, and I won't have time to wade through the Tramp mess before the
feature-freeze tomorrow, so I reverted that change to file-attributes
in trunk bzr 110303.  Some other time perhaps.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Enhancement for file-attributes
  2012-10-01  1:16 ` Stefan Monnier
  2012-10-01  2:04   ` Juanma Barranquero
@ 2012-10-01 12:59   ` Eli Zaretskii
  2012-10-01 14:31     ` Stefan Monnier
  1 sibling, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2012-10-01 12:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: emacs-devel@gnu.org
> Date: Sun, 30 Sep 2012 21:16:31 -0400
> 
> > Would it be a good idea to enhance file-attributes by adding one more
> > optional argument to it, which, when non-nil, will cause Emacs call
> > 'stat', not 'lstat', on the argument file name?  This should avoid the
> > need to call file-chase-links when all we want is to get the
> > attributes of the file pointed to by the symlink.
> 
> It would have made a lot of sense originally, but I'm wondering whether
> it's worth the trouble now.

What trouble can this make?  An additional argument whose default is
nil should never cause any trouble.  Am I missing something?

> In how many places would we save the file-chase-links all?  Are
> these places important?

One place is in files.el: after-find-file, when we visit a file that
is a symlink, and backup-buffer.  These are quite frequently used
APIs.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Enhancement for file-attributes
  2012-10-01 12:59   ` Eli Zaretskii
@ 2012-10-01 14:31     ` Stefan Monnier
  2012-10-01 14:56       ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2012-10-01 14:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>> In how many places would we save the file-chase-links all?  Are
>> these places important?
> One place is in files.el: after-find-file, when we visit a file that
> is a symlink, and backup-buffer.  These are quite frequently used APIs.

So you're saying it's important because it can impose
a noticeable overhead in those cases?  Do we have actual numbers?
It seems that both operations do so many other things that it might be
lost in the noise.


        Stefan



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Enhancement for file-attributes
  2012-10-01 14:31     ` Stefan Monnier
@ 2012-10-01 14:56       ` Eli Zaretskii
  0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2012-10-01 14:56 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: emacs-devel@gnu.org
> Date: Mon, 01 Oct 2012 10:31:58 -0400
> 
> >> In how many places would we save the file-chase-links all?  Are
> >> these places important?
> > One place is in files.el: after-find-file, when we visit a file that
> > is a symlink, and backup-buffer.  These are quite frequently used APIs.
> 
> So you're saying it's important because it can impose
> a noticeable overhead in those cases?  Do we have actual numbers?

No, I don't, at least not on Posix systems.  On MS-Windows, chasing
links is expensive, but that might be because the equivalent of
'readlink' is slower than on Posix.

> It seems that both operations do so many other things that it might be
> lost in the noise.

Maybe so, but it's a boon to the programmer to pass one more argument
instead of invoking another API, I think.  And I see no danger in the
change of the interface.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Enhancement for file-attributes
  2012-10-01  2:08     ` Paul Eggert
@ 2012-10-08 10:36       ` Michael Albinus
  0 siblings, 0 replies; 11+ messages in thread
From: Michael Albinus @ 2012-10-08 10:36 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Eli Zaretskii, Stefan Monnier, emacs-devel

Paul Eggert <eggert@cs.ucla.edu> writes:

Hi Paul,

> Good point, and I won't have time to wade through the Tramp mess before the
> feature-freeze tomorrow, so I reverted that change to file-attributes
> in trunk bzr 110303.  Some other time perhaps.

If you plan to add this feature again, you could contact me. I will help
you fighting the Tramp mess.

Best regards, Michael.



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-10-08 10:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-30 14:26 Enhancement for file-attributes Eli Zaretskii
2012-09-30 21:14 ` Paul Eggert
2012-09-30 22:08   ` Eli Zaretskii
2012-10-01  0:45   ` Stefan Monnier
2012-10-01  2:08     ` Paul Eggert
2012-10-08 10:36       ` Michael Albinus
2012-10-01  1:16 ` Stefan Monnier
2012-10-01  2:04   ` Juanma Barranquero
2012-10-01 12:59   ` Eli Zaretskii
2012-10-01 14:31     ` Stefan Monnier
2012-10-01 14:56       ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).