Subject: bug#24245: 25.0.93; AUCTeX TeX-function-p

From: Robert Cochran <[email-masked]>
Date: Fri, 19 Aug 2016 09:42:24 -0700

<[email-masked]> writes:

> What is the actual purpose of the Lisp function `TeX-function-p' found
> in AUCTeX ‘tex.el’?
>
> (defun TeX-function-p (arg)
>   "Return non-nil if ARG is callable as a function."
>   (or (and (fboundp 'byte-code-function-p)
>        (byte-code-function-p arg))
>       (and (listp arg)
>        (eq (car arg) 'lambda))
>       (and (symbolp arg)
> 	   (fboundp arg))))
>
> How this code is better of `functionp'?
> If there is no actual design improvement of `TeX-function-p' over
> `functionp', the latter is supposed to be faster as it is built-in.

It's not 'better'. A blame of the AUCTeX repository shows that
`TeX-function-p` was written (and last touched) in 1994. The only
history that's in the Emacs repository commit-wise about `functionp`
dates back to 2010, and the files within it show relevant history from
2005 (which aren't in the repo as their own commits). Doubtless it's
hard to pin down without the complete history, but it's likely
`TeX-function-p` was written before `functionp`.

> A similar function, `message-functionp', in `message.el' has been
> removed. See Debian Bug report log #223493.

I'd imagine this case is slightly different, as Gnus is an Emacs builtin
(since 1997 if the logs are accurate), so there's a tighter intergration
with the progression of Emacs than AUCTeX. I'm sure that it's a similar
situation here: the invention of `message-functionp` predates that of
`functionp`.

I'd also like to point out that the original reporter reported it
because he was apparently having autoload issues, so `message-functionp`
wasn't defined, which is probably how it got noticed in the first place.

It's probably a good idea to fix it in the AUCTeX repository by removing
`TeX-function-p` and do a M-% for `functionp` and ensuring nothing gets
borked when you do so. I believe the phrase is "patches welcome". :)

(Disclaimer: This is independent and likely incomplete research, along
with what are my best guesses so far as the history bits. Anyone that
sees I've gotten something wrong or missed an important point, please
report in.)

HTH

-- 
~Robert Cochran

GPG Fingerprint - E778 2DD4 FEA6 6A68 6F26  AD2D E5C3 EB36 4886 8871