7

I want to be able to view C source code of Emacs functions. For example, I want to be able to do M-: (find-function 'message).

Emacs prompts me for directory the C sources, so it can set find-function-C-source-directory. However, my distro (Arch Linux) has just done the usual make; make install steps (see the package recipe here) so there are no C sources available without manually downloading them.

So, I want to fix the packaging. My questions are:

  1. Are there configuration options Emacs' makefile that mean make install copies the C sources too? I can't see anything obvious.
  2. What's the correct way to set find-function-C-source-directory in the package? Create a site-lisp?
  3. Are there any distros or platforms that already do this?
phils
  • 48,657
  • 3
  • 76
  • 115
Wilfred Hughes
  • 6,890
  • 2
  • 29
  • 59
  • 1
    `find-function-C-source-directory` uses `source-directory` internally, therefore things should just work for an Emacs run in its build directory... – wasamasa Feb 27 '16 at 18:07
  • 1
    A brief search for "src" kind of RPM with Emacs shows: https://rpmfind.net/linux/rpm2html/search.php?query=emacs&submit=Search+...&system=&arch=src there are indeed such creatures. I would try to look into these, however, I'm not sure they set up source lookup (though it might be nice). – wvxvw Feb 27 '16 at 19:41
  • My guess would be that Arch Linux deletes all of the files used during the build, after completing the installation? If so, I suppose you'll need to add a build step to move the relevant files elsewhere. Using a site-lisp .el file to set the directory is correct. – phils Feb 27 '16 at 20:32
  • thought that emacs was written in lisp, not C – user3629249 Feb 29 '16 at 00:46
  • @user3629249: it is written in both. The lisp interpreter itself is written in C as well as some of the functions where efficiency is required (like the core of the screen update). Most of the code that makes up a running emacs is written in lisp to run on top of the interpreter written in C. So, when you follow the links in the help screens for the source of a given function, it could be either. – MAP Jul 05 '16 at 08:51
  • 1
    See "**How to include / copy over the `src` directory when building Emacs**": http://stackoverflow.com/questions/21241967/how-to-include-copy-over-the-src-directory-when-building-emacs – lawlist Nov 30 '16 at 01:47

1 Answers1

2

If what you are asking is "how to include source code in my Arch package", it doesn't seem to belong here but maybe https://unix.stackexchange.com/.

Are there configuration options Emacs' makefile that mean make install copies the C sources too?

No.

What's the correct way to set find-function-C-source-directory in the package? Create a site-lisp?

If you know, at build time, where your source code package will be installed, you could patch the source code. But I'd override in site-lisp.

Are there any distros or platforms that already do this?

Not that I know of.

Because you, as a user, can always download Emacs source code, unpack in your home dir, set find-function-C-source-directory accordingly to make it work just fine.

A great thing about find-function is that it doesn't have to know the exact line number. It will, instead, search the function in the source file. So, minor changes or version differences do not affect the ability at all.

Yasushi Shoji
  • 2,151
  • 15
  • 35