unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* find-function-source-directory
@ 2018-02-18 16:16 Richard Copley
  2018-02-18 18:40 ` find-function-source-directory Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Copley @ 2018-02-18 16:16 UTC (permalink / raw)
  To: help-gnu-emacs

I want 'find-function' to go to the .el files in my build directory
"c:/projects/emacs/", not the installed .el.gz files
in "c:/msys64/mingw64/share/emacs/27.0.50/". The docstring for
'find-function' suggests it's possible (but doesn't give an example):

    The library where FUNCTION is defined is searched for in
    ‘find-function-source-path’, if non-nil, otherwise in ‘load-path’.

I tried each of these in my init file, with no effect:

(setq find-function-source-path "c:/projects/emacs/")
(setq find-function-source-path "c:/projects/emacs/lisp/")
(setq find-function-source-path
      (mapcar
       (lambda (x)
         (if (string-match "\\`c:/msys64/mingw64/share/emacs/27.0.50/" x)
             (replace-match "c:/projects/emacs/" nil nil x)
           x))
       load-path))

Did I miss something?



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

* Re: find-function-source-directory
  2018-02-18 16:16 find-function-source-directory Richard Copley
@ 2018-02-18 18:40 ` Eli Zaretskii
  2018-02-18 19:35   ` find-function-source-directory Eli Zaretskii
                     ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Eli Zaretskii @ 2018-02-18 18:40 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Richard Copley <rcopley@gmail.com>
> Date: Sun, 18 Feb 2018 16:16:03 +0000
> 
> I want 'find-function' to go to the .el files in my build directory
> "c:/projects/emacs/", not the installed .el.gz files
> in "c:/msys64/mingw64/share/emacs/27.0.50/". The docstring for
> 'find-function' suggests it's possible (but doesn't give an example):
> 
>     The library where FUNCTION is defined is searched for in
>     ‘find-function-source-path’, if non-nil, otherwise in ‘load-path’.
> 
> I tried each of these in my init file, with no effect:
> 
> (setq find-function-source-path "c:/projects/emacs/")
> (setq find-function-source-path "c:/projects/emacs/lisp/")
> (setq find-function-source-path
>       (mapcar
>        (lambda (x)
>          (if (string-match "\\`c:/msys64/mingw64/share/emacs/27.0.50/" x)
>              (replace-match "c:/projects/emacs/" nil nil x)
>            x))
>        load-path))
> 
> Did I miss something?

Anything that is called "path" should be a list of directories, nopt a
single file name (this is GNU, remember?).  So try something like
this:

  (setq find-function-source-path
    '("c:/projects/emacs/lisp/"
      "c:/projects/emacs/lisp/emacs-lisp/"
      "c:/projects/emacs/lisp/net/"
      ...))

(add more subdirectories instead of the ellipsis).



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

* Re: find-function-source-directory
  2018-02-18 18:40 ` find-function-source-directory Eli Zaretskii
@ 2018-02-18 19:35   ` Eli Zaretskii
  2018-02-19 11:13     ` find-function-source-directory Richard Copley
  2018-02-18 19:53   ` find-function-source-directory Drew Adams
       [not found]   ` <<a8455f40-e18a-44ac-8523-435e84f2d2e8@default>
  2 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2018-02-18 19:35 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sun, 18 Feb 2018 20:40:50 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> 
>   (setq find-function-source-path
>     '("c:/projects/emacs/lisp/"
>       "c:/projects/emacs/lisp/emacs-lisp/"
>       "c:/projects/emacs/lisp/net/"
>       ...))
> 
> (add more subdirectories instead of the ellipsis).

This notwithstanding, I think that doc string is misleading: what you
want to accomplish isn't possible, because find-function-source-path
cannot override load-path in this use case.  Or maybe I'm missing
something.



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

* RE: find-function-source-directory
  2018-02-18 18:40 ` find-function-source-directory Eli Zaretskii
  2018-02-18 19:35   ` find-function-source-directory Eli Zaretskii
@ 2018-02-18 19:53   ` Drew Adams
  2018-02-18 20:18     ` find-function-source-directory Eli Zaretskii
       [not found]   ` <<a8455f40-e18a-44ac-8523-435e84f2d2e8@default>
  2 siblings, 1 reply; 11+ messages in thread
From: Drew Adams @ 2018-02-18 19:53 UTC (permalink / raw)
  To: Eli Zaretskii, help-gnu-emacs

> Anything that is called "path" should be a list of directories, nopt a
> single file name (this is GNU, remember?).  So try something like
> this:
> 
>   (setq find-function-source-path
>     '("c:/projects/emacs/lisp/"
>       "c:/projects/emacs/lisp/emacs-lisp/"
>       "c:/projects/emacs/lisp/net/"
>       ...))

FWIW, I don't think Emacs calls even such a list a "path".

I'd suggest a name such as `find-function-source-dirs'
or `find-function-source-directories' or
`find-function-source-dir-list'.

The value is a list of directories.  If you want the
name to also reflect the usage, then add a words such
as "lookup" (or whatever is most appropriate for the use).



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

* Re: find-function-source-directory
  2018-02-18 19:53   ` find-function-source-directory Drew Adams
@ 2018-02-18 20:18     ` Eli Zaretskii
  0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2018-02-18 20:18 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sun, 18 Feb 2018 11:53:19 -0800 (PST)
> From: Drew Adams <drew.adams@oracle.com>
> 
> > Anything that is called "path" should be a list of directories, nopt a
> > single file name (this is GNU, remember?).  So try something like
> > this:
> > 
> >   (setq find-function-source-path
> >     '("c:/projects/emacs/lisp/"
> >       "c:/projects/emacs/lisp/emacs-lisp/"
> >       "c:/projects/emacs/lisp/net/"
> >       ...))
> 
> FWIW, I don't think Emacs calls even such a list a "path".
> 
> I'd suggest a name such as `find-function-source-dirs'
> or `find-function-source-directories' or
> `find-function-source-dir-list'.
> 
> The value is a list of directories.

In GNU, a "path" is a list of directories.  The separator is
colon/semi-colon in a shell, but in Lisp it's a simple list.  Cf.
load-path, exec-path, image-load-path, etc.




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

* RE: find-function-source-directory
       [not found]     ` <<83h8qe9hld.fsf@gnu.org>
@ 2018-02-18 21:56       ` Drew Adams
  2018-02-19  3:24         ` find-function-source-directory Richard Copley
  0 siblings, 1 reply; 11+ messages in thread
From: Drew Adams @ 2018-02-18 21:56 UTC (permalink / raw)
  To: Eli Zaretskii, help-gnu-emacs

> In GNU, a "path" is a list of directories.  The separator is
> colon/semi-colon in a shell, but in Lisp it's a simple list.  Cf.
> load-path, exec-path, image-load-path, etc.

Oops; yes, that's true.  It's generally a list of
directories that are searched, or otherwise processed,
in order.



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

* Re: find-function-source-directory
  2018-02-18 21:56       ` find-function-source-directory Drew Adams
@ 2018-02-19  3:24         ` Richard Copley
  0 siblings, 0 replies; 11+ messages in thread
From: Richard Copley @ 2018-02-19  3:24 UTC (permalink / raw)
  To: Drew Adams; +Cc: help-gnu-emacs

On 18 February 2018 at 21:56, Drew Adams <drew.adams@oracle.com> wrote:
>> In GNU, a "path" is a list of directories.  The separator is
>> colon/semi-colon in a shell, but in Lisp it's a simple list.  Cf.
>> load-path, exec-path, image-load-path, etc.
>
> Oops; yes, that's true.  It's generally a list of
> directories that are searched, or otherwise processed,
> in order.

I know, thanks. I have already tried that and it didn't
work -- see the last lisp expression in my OP.



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

* Re: find-function-source-directory
  2018-02-18 19:35   ` find-function-source-directory Eli Zaretskii
@ 2018-02-19 11:13     ` Richard Copley
  2018-02-19 11:44       ` find-function-source-directory tomas
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Copley @ 2018-02-19 11:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On 18 February 2018 at 19:35, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Sun, 18 Feb 2018 20:40:50 +0200
>> From: Eli Zaretskii <eliz@gnu.org>
>>
>>   (setq find-function-source-path
>>     '("c:/projects/emacs/lisp/"
>>       "c:/projects/emacs/lisp/emacs-lisp/"
>>       "c:/projects/emacs/lisp/net/"
>>       ...))
>>
>> (add more subdirectories instead of the ellipsis).
>
> This notwithstanding, I think that doc string is misleading: what you
> want to accomplish isn't possible, because find-function-source-path
> cannot override load-path in this use case.  Or maybe I'm missing
> something.

Ah, thanks. (Sorry, I missed this message earlier.)
I'm wondering if there is there any use for
find-function-source-path, if not that. Perhaps it
is an ex-feature?



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

* Re: find-function-source-directory
  2018-02-19 11:13     ` find-function-source-directory Richard Copley
@ 2018-02-19 11:44       ` tomas
  2018-02-19 15:36         ` find-function-source-directory Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: tomas @ 2018-02-19 11:44 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Feb 19, 2018 at 11:13:12AM +0000, Richard Copley wrote:
> On 18 February 2018 at 19:35, Eli Zaretskii <eliz@gnu.org> wrote:
> >> Date: Sun, 18 Feb 2018 20:40:50 +0200
> >> From: Eli Zaretskii <eliz@gnu.org>
> >>
> >>   (setq find-function-source-path
> >>     '("c:/projects/emacs/lisp/"
> >>       "c:/projects/emacs/lisp/emacs-lisp/"
> >>       "c:/projects/emacs/lisp/net/"
> >>       ...))
> >>
> >> (add more subdirectories instead of the ellipsis).
> >
> > This notwithstanding, I think that doc string is misleading: what you
> > want to accomplish isn't possible, because find-function-source-path
> > cannot override load-path in this use case.  Or maybe I'm missing
> > something.
> 
> Ah, thanks. (Sorry, I missed this message earlier.)
> I'm wondering if there is there any use for
> find-function-source-path, if not that. Perhaps it
> is an ex-feature?


Hm. Looking at the elisp sources, it seems to me that this variable
is used (cf. find-library-name) in a way that corresponds with its
docstring. An extract:

  (defun find-library-name (library)
    "Return the absolute file name of the Emacs Lisp source of LIBRARY.
  LIBRARY should be a string (the name of the library)."
    ;; If the library is byte-compiled, try to find a source library by
    ;; the same name.
    (when (string-match "\\.el\\(c\\(\\..*\\)?\\)\\'" library)
      (setq library (replace-match "" t t library)))
    (or
     (locate-file library
                  (or find-function-source-path load-path)
                  (find-library-suffixes))
    [...]

So definitely not an ex-feature (at least not on 27.0.50).

I don't know why ti isn't doing what you expect, though...

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlqKuJQACgkQBcgs9XrR2kaWYACggHyx+NU6iCJ0cadfrO2d78TF
GW0An1xe9g9gfrd7L87WV8Lwmg/dm0hH
=UbYA
-----END PGP SIGNATURE-----



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

* Re: find-function-source-directory
  2018-02-19 11:44       ` find-function-source-directory tomas
@ 2018-02-19 15:36         ` Eli Zaretskii
  2018-02-19 15:43           ` find-function-source-directory tomas
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2018-02-19 15:36 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Mon, 19 Feb 2018 12:44:20 +0100
> From: <tomas@tuxteam.de>
> 
> > > This notwithstanding, I think that doc string is misleading: what you
> > > want to accomplish isn't possible, because find-function-source-path
> > > cannot override load-path in this use case.  Or maybe I'm missing
> > > something.
> > 
> > Ah, thanks. (Sorry, I missed this message earlier.)
> > I'm wondering if there is there any use for
> > find-function-source-path, if not that. Perhaps it
> > is an ex-feature?
> 
> 
> Hm. Looking at the elisp sources, it seems to me that this variable
> is used (cf. find-library-name) in a way that corresponds with its
> docstring. An extract:

Yes, I've seen that as well.  But it turns out the code pulls a few
rabbits out of its hat before it even gets there: it uses load-history
and other related stuff, which gives absolute file names, so no need
to search any directories.

I propose to step in Edebug through the function and its subroutines,
and see what happens.  It looks like it uses different approaches for
preloaded symbols, autoloaded symbols, and the rest.  I didn't have
enough time to figure out all the details, but one thing that tripped
me was that, even if I start with a symbol that is neither preloaded
nor autoloaded, fairly soon it becomes boundp or fboundp, which means
Emacs loads its package, and at that time, there's no reason for Emacs
to do any path search.

If someone actually figures out what the code does, please tell the
details, as I'm quite sure we will have to update the doc string.

Thanks.



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

* Re: find-function-source-directory
  2018-02-19 15:36         ` find-function-source-directory Eli Zaretskii
@ 2018-02-19 15:43           ` tomas
  0 siblings, 0 replies; 11+ messages in thread
From: tomas @ 2018-02-19 15:43 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Feb 19, 2018 at 05:36:31PM +0200, Eli Zaretskii wrote:
> > Date: Mon, 19 Feb 2018 12:44:20 +0100
> > From: <tomas@tuxteam.de>

> > Hm. Looking at the elisp sources, it seems to me that this variable
> > is used [...]

> Yes, I've seen that as well.  But it turns out the code pulls a few
> rabbits out of its hat before it even gets there [...]

Uh, oh. Rabbits in Emacs ;-/

I'll try to have a look this afternoon. No guarantees, though :-)

Cheers&thanks
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlqK8K0ACgkQBcgs9XrR2kZgGwCePpg7M8WZsap1SRVrmnkhQVzo
Y4EAmQH/GzJXTnTVdrhWVa9JlUkftiaC
=Wd2C
-----END PGP SIGNATURE-----



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

end of thread, other threads:[~2018-02-19 15:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-18 16:16 find-function-source-directory Richard Copley
2018-02-18 18:40 ` find-function-source-directory Eli Zaretskii
2018-02-18 19:35   ` find-function-source-directory Eli Zaretskii
2018-02-19 11:13     ` find-function-source-directory Richard Copley
2018-02-19 11:44       ` find-function-source-directory tomas
2018-02-19 15:36         ` find-function-source-directory Eli Zaretskii
2018-02-19 15:43           ` find-function-source-directory tomas
2018-02-18 19:53   ` find-function-source-directory Drew Adams
2018-02-18 20:18     ` find-function-source-directory Eli Zaretskii
     [not found]   ` <<a8455f40-e18a-44ac-8523-435e84f2d2e8@default>
     [not found]     ` <<83h8qe9hld.fsf@gnu.org>
2018-02-18 21:56       ` find-function-source-directory Drew Adams
2018-02-19  3:24         ` find-function-source-directory Richard Copley

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).