all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* convert-standard-filename on w32 does not preserve match-data?
@ 2006-12-20 22:17 Lennart Borgman
  2006-12-20 23:06 ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Lennart Borgman @ 2006-12-20 22:17 UTC (permalink / raw)


Should not the whole body of convert-standard-filename in w32-fns.el be 
protected by save-match-data? Does not match-string set match-data?

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-20 22:17 convert-standard-filename on w32 does not preserve match-data? Lennart Borgman
@ 2006-12-20 23:06 ` Stefan Monnier
  2006-12-20 23:13   ` Lennart Borgman
  2006-12-21 18:07   ` Richard Stallman
  0 siblings, 2 replies; 15+ messages in thread
From: Stefan Monnier @ 2006-12-20 23:06 UTC (permalink / raw)
  Cc: Emacs Devel

> Should not the whole body of convert-standard-filename in w32-fns.el be
> protected by save-match-data? Does not match-string set match-data?

No, I think instead that code that calls convert-standard-filename shouldn't
expect it to preserve the match-data.
Could you point us to the code that incorrectly expects it to preserve the
match data, or at least to a case where your suggested change fixes a bug?


        Stefan

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-20 23:06 ` Stefan Monnier
@ 2006-12-20 23:13   ` Lennart Borgman
  2006-12-21 18:07   ` Richard Stallman
  1 sibling, 0 replies; 15+ messages in thread
From: Lennart Borgman @ 2006-12-20 23:13 UTC (permalink / raw)
  Cc: Emacs Devel

Stefan Monnier wrote:
>> Should not the whole body of convert-standard-filename in w32-fns.el be
>> protected by save-match-data? Does not match-string set match-data?
>>     
>
> No, I think instead that code that calls convert-standard-filename shouldn't
> expect it to preserve the match-data.
> Could you point us to the code that incorrectly expects it to preserve the
> match data, or at least to a case where your suggested change fixes a bug?
>   

There is already a call to save-match-data in convert-standard-filename 
in w32-fns.el. I am just saying that it is in the wrong place.
 Useless. And I can't understand why it should not protect match-data?

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-20 23:06 ` Stefan Monnier
  2006-12-20 23:13   ` Lennart Borgman
@ 2006-12-21 18:07   ` Richard Stallman
  2006-12-22 23:33     ` Eli Zaretskii
  2006-12-25 23:19     ` Stefan Monnier
  1 sibling, 2 replies; 15+ messages in thread
From: Richard Stallman @ 2006-12-21 18:07 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

    No, I think instead that code that calls convert-standard-filename shouldn't
    expect it to preserve the match-data.

It seems cleaner to me for a general subroutine, that does a job not
specifically related to searching or matching, to preserve the match
data, rather than making all its callers take care.

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-21 18:07   ` Richard Stallman
@ 2006-12-22 23:33     ` Eli Zaretskii
  2006-12-24  1:35       ` Richard Stallman
  2006-12-25 23:19     ` Stefan Monnier
  1 sibling, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2006-12-22 23:33 UTC (permalink / raw)
  Cc: lennart.borgman.073, monnier, emacs-devel

> From: Richard Stallman <rms@gnu.org>
> Date: Thu, 21 Dec 2006 13:07:04 -0500
> Cc: lennart.borgman.073@student.lu.se, emacs-devel@gnu.org
> 
>     No, I think instead that code that calls convert-standard-filename shouldn't
>     expect it to preserve the match-data.
> 
> It seems cleaner to me for a general subroutine, that does a job not
> specifically related to searching or matching, to preserve the match
> data, rather than making all its callers take care.

Done.

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-22 23:33     ` Eli Zaretskii
@ 2006-12-24  1:35       ` Richard Stallman
  0 siblings, 0 replies; 15+ messages in thread
From: Richard Stallman @ 2006-12-24  1:35 UTC (permalink / raw)
  Cc: lennart.borgman.073, monnier, emacs-devel

    > It seems cleaner to me for a general subroutine, that does a job not
    > specifically related to searching or matching, to preserve the match
    > data, rather than making all its callers take care.

    Done.

Thanks.

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-21 18:07   ` Richard Stallman
  2006-12-22 23:33     ` Eli Zaretskii
@ 2006-12-25 23:19     ` Stefan Monnier
  2006-12-26 17:22       ` Richard Stallman
  1 sibling, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2006-12-25 23:19 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

>     No, I think instead that code that calls convert-standard-filename
>     shouldn't expect it to preserve the match-data.

> It seems cleaner to me for a general subroutine, that does a job not
> specifically related to searching or matching, to preserve the match
> data, rather than making all its callers take care.

Until now the way things have worked apparently is:

  any function that is not a "simple builtin" does not need to save the
  match data.

Now what is a "simple builtin" is not clearly specified anywhere, but
I wouldn't expect convert-standard-filename to be one.

The main reason for limiting the number of functions that preserve the match
data is that, on the one hand save-match-data is a relatively costly
operation, and on the other, 99% of the uses of the match-data is
immediately after a regex-match, with very few operations in-between (if
any), so it's much more efficient performancewise and programmerwise to
place the save-match-data at the few places where the use of the match data
does not come immediately after the regexp-match, than to place around each
and every function that's not obviously related to searching or matching
(i.e. a majority of the functions).


        Stefan

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-25 23:19     ` Stefan Monnier
@ 2006-12-26 17:22       ` Richard Stallman
  2006-12-27 14:55         ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Richard Stallman @ 2006-12-26 17:22 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

The time it takes to call save-match-data is irrelevant for
convert-standard-filename.

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-26 17:22       ` Richard Stallman
@ 2006-12-27 14:55         ` Stefan Monnier
  2006-12-27 15:02           ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2006-12-27 14:55 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> The time it takes to call save-match-data is irrelevant for
> convert-standard-filename.

Inded, I'm only arguing against the principle of adding save-match-data
around any non-regexp-related function.

In thre particular case of convert-standard-filename, I think it would be
wrong to add save-match-data (unless there's a particular reason to do it,
of course), but I agree that it's not worth removing it either.


        Stefan

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-27 14:55         ` Stefan Monnier
@ 2006-12-27 15:02           ` Lennart Borgman (gmail)
  2006-12-27 16:08             ` Stefan Monnier
  2006-12-28 17:19             ` Richard Stallman
  0 siblings, 2 replies; 15+ messages in thread
From: Lennart Borgman (gmail) @ 2006-12-27 15:02 UTC (permalink / raw)
  Cc: rms, emacs-devel

Stefan Monnier wrote:
> In thre particular case of convert-standard-filename, I think it would be
> wrong to add save-match-data (unless there's a particular reason to do it,
> of course), but I agree that it's not worth removing it either.
>   

The code using convert-standard-filename probably already feels a bit 
overloaded. convert-standard-filename is an "add on" to what one 
actually tries to do and it is easily left out. Requiring the coder to 
also add save-match-data seems like an unnecessary burden in this case 
and I therefore think that convert-standard-filename should call 
save-match-data internally.

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-27 15:02           ` Lennart Borgman (gmail)
@ 2006-12-27 16:08             ` Stefan Monnier
  2006-12-27 17:46               ` Lennart Borgman (gmail)
  2006-12-28 17:19             ` Richard Stallman
  1 sibling, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2006-12-27 16:08 UTC (permalink / raw)
  Cc: rms, emacs-devel

>> In thre particular case of convert-standard-filename, I think it would be
>> wrong to add save-match-data (unless there's a particular reason to do it,
>> of course), but I agree that it's not worth removing it either.

> The code using convert-standard-filename probably already feels a bit
> overloaded.

Which code are you talking about?


        Stefan

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-27 16:08             ` Stefan Monnier
@ 2006-12-27 17:46               ` Lennart Borgman (gmail)
  2006-12-29 21:02                 ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Lennart Borgman (gmail) @ 2006-12-27 17:46 UTC (permalink / raw)
  Cc: rms, emacs-devel

Stefan Monnier wrote:
>>> In thre particular case of convert-standard-filename, I think it would be
>>> wrong to add save-match-data (unless there's a particular reason to do it,
>>> of course), but I agree that it's not worth removing it either.
>>>       
>
>   
>> The code using convert-standard-filename probably already feels a bit
>> overloaded.
>>     
>
> Which code are you talking about?
>   

I did not mean a specific case, but I did look around to find missing 
quoting before. Let me see if I remember...

When you use call-process you just need to do something like (at least 
in some cases):

    (call-process
        ...
       (convert-standard-filename (expand-file-name file))

but when using shell-command you should do

    (shell-command
        ...
        (shell-quote-argument (convert-standard-filename 
(expand-file-name file))

However this may depend on the exact circumstances. Of course, the only 
place were this is noticed is on w32. And as I said before the test for 
quoting is not correct at the moment since it should be buffer specific 
(or rather specific to the circumstances).

The difference above comes from the face that call-process (actually, on 
w32, in the behind the scenes) quotes the argument whereas shell-command 
does not if I remember correctly. (But please correct me if I am wrong now!)

In many cases the code just had expand-file-name.

I am not at all satisfied with this little mess. I think we should have 
some functions that does the above things and that SHOULD be used in our 
code. I e somthing like

        (defun file-arg-for-call-process(file, expand) ....)
        (defun file-arg-for-shell-command(file, expand) ....)

And I believe there currently are still bugs in this area.

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-27 15:02           ` Lennart Borgman (gmail)
  2006-12-27 16:08             ` Stefan Monnier
@ 2006-12-28 17:19             ` Richard Stallman
  1 sibling, 0 replies; 15+ messages in thread
From: Richard Stallman @ 2006-12-28 17:19 UTC (permalink / raw)
  Cc: monnier, emacs-devel

    The code using convert-standard-filename probably already feels a bit 
    overloaded. convert-standard-filename is an "add on" to what one 
    actually tries to do and it is easily left out. Requiring the coder to 
    also add save-match-data seems like an unnecessary burden in this case 
    and I therefore think that convert-standard-filename should call 
    save-match-data internally.

That is how I see it.

There will be some cases where for speed it is better not to do
save-match-data.  But in many cases the cleanliness of adding it
is more important than the speed of omitting it.

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-27 17:46               ` Lennart Borgman (gmail)
@ 2006-12-29 21:02                 ` Stefan Monnier
  2006-12-29 21:54                   ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2006-12-29 21:02 UTC (permalink / raw)
  Cc: rms, emacs-devel

>>>> In thre particular case of convert-standard-filename, I think it would be
>>>> wrong to add save-match-data (unless there's a particular reason to do it,
>>>> of course), but I agree that it's not worth removing it either.
>>> The code using convert-standard-filename probably already feels a bit
>>> overloaded.
>> Which code are you talking about?
> I did not mean a specific case, but I did look around to find missing
> quoting before. Let me see if I remember...

Nowhere in your examples was a need for save-match-data, so removing
save-match-data from convert-standard-filename wouldn't affect them.


        Stefan

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

* Re: convert-standard-filename on w32 does not preserve match-data?
  2006-12-29 21:02                 ` Stefan Monnier
@ 2006-12-29 21:54                   ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 15+ messages in thread
From: Lennart Borgman (gmail) @ 2006-12-29 21:54 UTC (permalink / raw)
  Cc: rms, emacs-devel

Stefan Monnier wrote:
> Nowhere in your examples was a need for save-match-data, so removing
> save-match-data from convert-standard-filename wouldn't affect them.
>   

I guess you are right. I do not know. That was not the point however.

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

end of thread, other threads:[~2006-12-29 21:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-20 22:17 convert-standard-filename on w32 does not preserve match-data? Lennart Borgman
2006-12-20 23:06 ` Stefan Monnier
2006-12-20 23:13   ` Lennart Borgman
2006-12-21 18:07   ` Richard Stallman
2006-12-22 23:33     ` Eli Zaretskii
2006-12-24  1:35       ` Richard Stallman
2006-12-25 23:19     ` Stefan Monnier
2006-12-26 17:22       ` Richard Stallman
2006-12-27 14:55         ` Stefan Monnier
2006-12-27 15:02           ` Lennart Borgman (gmail)
2006-12-27 16:08             ` Stefan Monnier
2006-12-27 17:46               ` Lennart Borgman (gmail)
2006-12-29 21:02                 ` Stefan Monnier
2006-12-29 21:54                   ` Lennart Borgman (gmail)
2006-12-28 17:19             ` Richard Stallman

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.