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

Introduce completable-for-cljr-slash? #493

Closed
wants to merge 9 commits into from

Conversation

vemv
Copy link
Member

@vemv vemv commented Jul 8, 2021

Fixes #492

clj-refactor.el Outdated Show resolved Hide resolved
Copy link
Member

@expez expez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea for an improvement 👍

clj-refactor.el Show resolved Hide resolved
clj-refactor.el Show resolved Hide resolved
clj-refactor.el Outdated Show resolved Hide resolved
clj-refactor.el Outdated Show resolved Hide resolved
clj-refactor.el Outdated Show resolved Hide resolved
@vemv vemv force-pushed the 492--completable-for-cljr-slash branch from d7679e8 to 642dd4a Compare July 9, 2021 21:44
Copy link
Member Author

@vemv vemv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks guys for the guidance!

CI is looking decent. However it might be a good idea to prioritize #491 before proceeding with this PR.

clj-refactor.el Show resolved Hide resolved
clj-refactor.el Show resolved Hide resolved
@vemv
Copy link
Member Author

vemv commented Aug 29, 2021

Ready for re-review

@vemv vemv force-pushed the 492--completable-for-cljr-slash branch from 7d15089 to 5134e25 Compare August 29, 2021 13:42
@@ -1983,37 +1988,47 @@ the alias in the project."
(backward-sexp 1)
(looking-at-p "[-+0-9]")))

(defun completable-for-cljr-slash? (sym)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All definitions should have a docstring, especially the "public" ones.

(when sym
(or
;; vanilla symbols, maybe prefixed by ^, :: or ^::
(not (null (string-match-p "^\\^?\\(::\\)?\\([a-zA-Z]+[a-zA-Z0-9\\-]*\\)+\\(\\.?[a-zA-Z]+[a-zA-Z0-9\\-]*\\)*$" sym)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me you can rewrite this code with the not null check and it'd read better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cargo-culted the pattern from https://github.com/magnars/s.el/blob/08661efb075d1c6b4fa812184c1e5e90c08795a9/s.el#L281-L283 (s--truthy? is used a few times there, so transitively the not-null check is used a bunch of times there)

No strong opinion from my side, but maybe if in doubt we can do as s.el does

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(bump)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can live with this, it just seems quite verbose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these regexps are correct - Clojure symbols allow much more than alphanumerics.
Probably can be rewritten with the help of clojure--sym-regexp

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably can be rewritten with the help of clojure--sym-regexp

Good idea! Will keep in mind.

Will also leave this PR on hold for a bit - not good to mix old with possibly newly-introduced bugs

@@ -9,11 +9,13 @@ default: &default-steps
- run: make elpa
- run: emacs --version
- run: cask --version
- run: make unit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a target like unit-tests would be better here. make test should probably run all tests and there should be a separate make target for the integration tests.

(describe "completable-for-cljr-slash?"
(it "Returns `t' for tokens that can represent alias-prefixed named things (symbols, keywords, metadata)"
(expect (completable-for-cljr-slash? nil) :to-be nil)
(dolist (prefix '(""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about #'my-alias/private-var?

Think that's the only other form that I use regularly that isn't covered.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! backtick also

(unrelated, I think some CIDER features don't parse #' or backtick either...)

(string-remove-prefix "^::")
(string-remove-prefix "::")
(string-remove-prefix "^")
(string-remove-prefix "@")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#'?

@bbatsov
Copy link
Member

bbatsov commented Sep 30, 2021

Seems we forgot about this one.

@vemv
Copy link
Member Author

vemv commented Sep 30, 2021

Will give it some Elisp love soon enough :)

@vemv vemv mentioned this pull request Oct 8, 2021
@vemv vemv marked this pull request as draft November 5, 2021 09:13
vemv added a commit that referenced this pull request Nov 17, 2021
Reflects the decisions we made over #493.

Code has been copied as is, except for the unit tests in question, which are for `cljr--ns-name` (as a random example that I picked).
vemv added a commit that referenced this pull request Nov 17, 2021
Reflects the decisions we made over #493.

Code has been copied as is, except for the unit tests in question, which are for `cljr--ns-name` (as a random example that I picked).
vemv added a commit that referenced this pull request Nov 17, 2021
Reflects the decisions we made over #493.

Code has been copied as is, except for the unit tests in question, which are for `cljr--ns-name` (as a random example that I picked).
vemv added a commit that referenced this pull request Nov 17, 2021
Reflects the decisions we made over #493.

Code has been copied as is, except for the unit tests in question, which are for `cljr--ns-name` (as a random example that I picked).
vemv added a commit that referenced this pull request Nov 17, 2021
Reflects the decisions we made over #493.

Code has been copied as is, except for the unit tests in question, which are for `cljr--ns-name` (as a random example that I picked).
vemv added a commit that referenced this pull request Nov 18, 2021
Reflects the decisions we made over #493.

Code has been copied as is, except for the unit tests in question, which are for `cljr--ns-name` (as a random example that I picked).
vemv added a commit that referenced this pull request Nov 18, 2021
Reflects the decisions we made over #493.

Code has been copied as is, except for the unit tests in question, which are for `cljr--ns-name` (as a random example that I picked).
vemv added a commit that referenced this pull request Nov 18, 2021
Reflects the decisions we made over #493.

Code has been copied as is, except for the unit tests in question, which are for `cljr--ns-name` (as a random example that I picked).
@vemv
Copy link
Member Author

vemv commented Jul 11, 2022

Will re-do at a later point.

@vemv vemv closed this Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cljr-slash: rule out some edge cases
4 participants