2

After reviewing some functions in my own dot-emacs files, I've noticed that the function signature that describe-function shows for byte-compile-file differs to that for the function definition in the Emacs Lisp source code visible after find-function for byte-compile-file.

The function signature that I'm seeing with describe-function:

(byte-compile-file FILENAME)

The function signature visible in bytecomp.el.gz after find-function:

(byte-compile-file filename &optional load)

I've noticed this with Emacs 28 from openSUSE OBS (openSUSE Tumbleweed) and in Emacs 29 from the emacs-devel ports in FreeBSD ports.

When I noticed this peculiarity, I was trying to revise a hack in my own dot-emacs files, such that would ostensibly byte-compile any source file that does not have a byte compiled file or for which the source file is newer than the first matching byte-compiled file, then writing to a byte compiled dest filename at some translated pathname under user-init-dir. It would load the byte-compiled file by default. It's not been working out, per se - hence the debugging. Considering the previous, I'm not even sure if I can be certain of what byte-compile-file function it's calling.

Could it be simply a quirk in describe-function?

1 Answer 1

5

There is only one function of a given name at a time. describe-function tells you what file the function was defined in, and clicking the link takes you directly to it. When a function is redefined, the new function replaces the old and new metadata about the source of the function replaces the old metadata. Thus find-function and describe-function will always send you to the correct definition. ¹

If you look closely at the definition in bytecomp.el, you will notice that it has a declaration:

(declare (advertised-calling-convention (filename) "28.1"))

This is a way of deprecating arguments. byte-compile-file used to take an optional argument, but in Emacs 28.1 they deprecated it. The argument is still there in the real argument list so that old code will continue to run without error, but the documentation doesn’t mention it and this declaration completely hides it. You can call emacs-lisp-byte-compile-and-load if you wish to immediately load the file that you have compiled.

You can get more information by looking at the help for set-advertised-calling-convention.

¹: There is, of course, a caveat. It is possible to define a function that has no stable source location, in which case that part of the metadata will be empty. find-function will tell you that it doesn’t know where the function is defined, and describe-function will omit the link. The easiest way to do this is to type a definition into a buffer that is not associated with a file, such as the *scratch* buffer, and evaluate it there with C-x C-e.

1
  • Due to the difference in the function signature, I wasn't sure if the byte-compile-file definition I was looking at - from find-function - if it had represented the definition of the byte-compile-file that Emacs was using, in this instance. It's informative to learn about this matter of calling conventions in Emacs.
    – Sean Champ
    Commented Apr 28, 2022 at 1:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.