compliment icon indicating copy to clipboard operation
compliment copied to clipboard

Recognise alternative let-like formats

Open vemv opened this issue 3 years ago • 4 comments

Brief

The following vars:

https://github.com/alexander-yakushev/compliment/blob/a112bb85b748d4a34da89ee783e7c64d8183dab7/src/compliment/sources/local_bindings.clj#L6-L13

represent closed sets and typically only will work over clojure.core symbols. So if one uses e.g. my/let, completion accuracy will degrade.

Proposal

In:

https://github.com/alexander-yakushev/compliment/blob/a112bb85b748d4a34da89ee783e7c64d8183dab7/src/compliment/sources/local_bindings.clj#L55

Instead of doing (first form) (which will return let, my/let, etc), perform (-> form first name symbol). This way let-like-forms will work as usual, but also admitting alternative mechanisms that share the name but use a different namespace.

Same for defn, doseq, letfn.

Alternatives

Consumers could use alter-var-root! over the mentioned vars, although that doesn't seem a clean thing to do (and would also have to account for different ns aliases: my/let, com.domain.my/let, etc - which is not a closed set)

Thanks - V

vemv avatar Feb 02 '21 07:02 vemv

Hi, could you please check #77 first? Would it perhaps be enough if I merged something like that?

alexander-yakushev avatar Feb 03 '21 14:02 alexander-yakushev

https://github.com/alexander-yakushev/compliment/pull/77

vemv avatar Oct 21 '21 16:10 vemv

Actually, I agree with your point that it makes sense having it "for free" for symbols that have names exactly like let and defn. I mean, what's the worst that can happen? We guard ourselves against errors already, so at worst we might suggest some redundant locals within such macros, whatever.

I'll keep this open for now.

alexander-yakushev avatar Oct 21 '21 16:10 alexander-yakushev

Ok nice!

I have a patch around, should be at hand

vemv avatar Oct 21 '21 17:10 vemv