sqlup-mode.el
sqlup-mode.el copied to clipboard
Use case-fold-search to simplify logic?
case-fold-search is a variable defined in `C source code'. Its value is t
Automatically becomes buffer-local when set.
Documentation: Non-nil if searches and matches should ignore case.
You can customize this variable.
If we always go to the cloned buffer for logic, then we can make this change without messing with the users' settings.
Any thoughts on this?
I think if we wanted to use case-fold-search
the idiomatic and IMO correct thing to do would be to let-bind it around the function call. But I don't think it's worth it anyway: either let-binding or with-current-buffer is more complex than a call to downcase
.
If you want to get rid of the scattered downcases it might be good to move them inside the various helper functions, i.e. move the downcase inside sqlup-get-redis-keywords
, sqlup-keyword-p
and sqlup-blacklisted-p
.
I reorganized the logic around a little, and I'm not sure the way it exists makes COMPLETE sense. we're doing some keyword checks in the main buffer and some logic in the cloned buffer. I'm tempted to move all the checking to the clone buffer.
I noticed that here: https://github.com/Trevoke/sqlup-mode.el/blob/master/sqlup-mode.el#L152 because I was trying to find a way to make those function calls, in the next function, more homogeneous. Some use (point)
and some use a symbol and/or symbol boundaries.
Ah yeah I see what you mean. I would probably try to use the cloned buffer as little as possible though, because it's likely to be confusing to anyone trying to read/copy/modify the code (since it's sort of like a global variable).
The thing is, we do three things:
- Check if it's blacklisted (customizable)
- Check if it's a keyword (depends on SQL dialect)
- Check if it's capitalizable (depends on buffer environment)
1 depends on users, but 2 and 3 might as well be cloned-buffer-centric, don't you think?