Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use case-fold-search to simplify logic? #61

Open
Trevoke opened this issue Sep 12, 2016 · 4 comments
Open

Use case-fold-search to simplify logic? #61

Trevoke opened this issue Sep 12, 2016 · 4 comments

Comments

@Trevoke
Copy link
Owner

Trevoke commented Sep 12, 2016

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?

@davidshepherd7
Copy link
Contributor

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.

@Trevoke
Copy link
Owner Author

Trevoke commented Sep 13, 2016

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.

@davidshepherd7
Copy link
Contributor

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).

@Trevoke
Copy link
Owner Author

Trevoke commented Sep 15, 2016

The thing is, we do three things:

  1. Check if it's blacklisted (customizable)
  2. Check if it's a keyword (depends on SQL dialect)
  3. 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants