emacs-devel
[Top][All Lists]
Advanced

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

Re: locate-library, the NOSUFFIX arg and a [PATCH]


From: Stefan Monnier
Subject: Re: locate-library, the NOSUFFIX arg and a [PATCH]
Date: Thu, 21 Jan 2010 09:08:10 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux)

> ,----
> | It can omit the suffix (a.k.a. file-name extension) if NOSUFFIX is
> | nil (which is the default, see below).
> `----

This is poorly worded but means that it will not only look for files
of the form DIR/FILE.SUFFIX but also for DIR/FILE (i.e. it will add the
empty string as a valid suffix).

> I don't think the docstring even reflects the intent of locate-library's
> NOSUFFIX arg esp. as it doesn't appear to be _able_ to return a library name
> sans extension when not called-interactively.

Indeed, this arg only controls how the search is performed, not in which
form the result will be returned.

> (locate-file-completion-table load-path '("") "subr" #'(lambda (y)
> (string-match-p ".*z" y)) 'nil)
  ^^^^^^^^^^^^^^^^^^^^^^^^
  aka (string-match "z" y)

> => "subr.el.gz"

Looks right to me.

> (let (nosuffix)
>   (append (unless nosuffix (get-load-suffixes))
>           load-file-rep-suffixes))
> => (".elc" ".elc.gz" ".el" ".el.gz" "" ".gz")

> (let ((nosuffix t))
>   (append (unless nosuffix (get-load-suffixes))
>           load-file-rep-suffixes))
> => ("" ".gz")

All looks as expected.

> "When called from a program and NOSUFFIX is a boolean, string, or list of
> strings, return LIBRARY's file-truename as if by `file-name-sans-extension'."

That completely changes the meaning of this argument.  Why don't you
call file-name-sans-extension outside of locate-library instead, if you
want that?


        Stefan




reply via email to

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