Subject: bug#18643: 25.0.50; elisp--expect-function-p

From: Dmitry Gutov <[email-masked]>
Date: Sat, 11 Oct 2014 21:07:57 +0400

On 10/10/2014 05:20 PM, Stefan Monnier wrote:

>> Now I just have to wrap my head around `elisp--local-variables'. :)
>
> It's very simple:

:)

> It takes the string between the first opening paren and point, appends
> a special symbol (the witness) followed by the number of missing closing
> parens to make the whole string a valid sexp, than reads&macroexpands
> that.  And then we traverse the expanded code (a tree) straight from the
> root to the leaf corresponding to point (which is done in
> elisp--local-variables-1), collecting various info along the way.

Thanks!

I guess it might fail if some macros along the way require more 
arguments than we actually give them. But that can be worked around on 
case-by-case basis.

> Of course, traversing the tree efficiently is hard/impossible because
> we don't know for sure where is the witness (which represents point) in
> the tree, so we'd have to go through all the nodes of the tree, whereas
> we want to limit ourselves to going down from the root straight to the
> right leaf without backtracking.

I can see how performance could be a problem, but so far it's never been 
the bottleneck for me. In the cases I measured, (lisp--local-variables) 
takes around 1-2 ms (and up to 10ms near the end of the huge 
`cl--parse-loop-clause').

So even the caching mechanism you have in 
`lisp--local-variables-completion-table' could be unnecessary.

On the other hand, I've managed to find a specific case when it fails 
(will file the bug shortly).