[Top][All Lists]

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

Re: substitute-in-file-name and "$"

From: Luc Teirlinck
Subject: Re: substitute-in-file-name and "$"
Date: Sat, 5 Jul 2003 18:58:21 -0500 (CDT)

Michael Albinus wrote:

   At least the examples in the Elisp manual give the feeling that
   substitute-in-file-name could be called without special attention. The
   trap with the "$" char isn't obvious.

None of the examples in the Elisp manual, (elisp)File Name Expansion,
involves Elisp variables.  Even when working with variables, it would
seem that you can call (substitute-in-file-name filename) 1001 times
without danger (it has no side effects).  Danger arises from stuff

1. (setq filename (substitute-in-file-name filename))


2. (my-favorite-file-function (substitute-in-file-name filename))

The Elisp manual could point out that (1) should only be done if the
user really knows what he is doing.  Usually, using the return value
of (substitute-in-file-name filename) only at the time it is actually
needed (and _not_ changing filename itself at that time) or doing:

(1b) (setq substituted-filename (substitute-in-file-name filename))

will be safer.

In as far as (2) is concerned, the documentation string of
`my-favorite-file-function' should clearly point out what operations
it is going to perform on filename.  If not, that is a bug in the
documentation string.  In that case, the Elisp user could try to
figure it out by experimentation and file a bug report.  If
`my-favorite-file-function' is going to pass filename on to other
functions it calls, it should exercise a similar care itself.

   And, btw, if substitute-in-file-name can be called only once, how do I
   know it where to perform this call? And what shall the others do, if
   they would like to perform substitute-in-file-name?  Requote "$"? Or
   apply an optional parameter (to be introduced), which forces this?

Do you have examples where there is a real need to do (1) instead of
(1b)?  I have a hard time thinking of examples in the abstract, let
alone of examples occurring in actual situations.  Unquoting and then
requoting seems like a senseless circular operation to me.



reply via email to

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