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

Clojure predicates not recognized correctly #168

Closed
agzam opened this issue Nov 2, 2017 · 11 comments
Closed

Clojure predicates not recognized correctly #168

agzam opened this issue Nov 2, 2017 · 11 comments

Comments

@agzam
Copy link

agzam commented Nov 2, 2017

It seems when you have:

(defn dev? ...) and (defn dev ...) - which are clearly two different functions, and if the cursor at dev, dumb-jump-go would prefer to jump to (defn dev?) - the wrong one.

That I guess happens because dev? is at the top of the file, and dev is declared few lines later. Nevertheless dumb-jump should not see dev and dev? as equal symbols.

@agzam
Copy link
Author

agzam commented Nov 2, 2017

This probably simply requires setting dumb-jump-find-rules correctly, I'm gonna try doing that, although Emacs regexes sometimes intimidate me.

@jacktasia
Copy link
Owner

Thanks for the report! I think there's a few things going on in this case. I think what you said is correct, but I also think that (bounds-of-thing-at-point 'symbol) does not consider the ? to be part of the symbol at point.

I'll try to look into this further later today (or this week).

If you could try setting (setq dumb-jump-debug t) and then triggering this case again and then copy/paste what dumb-jump dumps into the *Messages* buffer here that could be helpful. Thanks!

@agzam
Copy link
Author

agzam commented Nov 2, 2017

So I have a build.boot file with: defn- dev-env? (deftask dev-env) when I try to use dumb-jump-go from dev-env symbol it takes me to dev-env? function. This is the output of debug:

-----
DUMB JUMP DEBUG ‘dumb-jump-run-command‘ START
----- 

cmd: 
    git grep --color=never --line-number --untracked -E \\\(def\\s\+dev-env\(\$\|\[\^\\w-\]\)\|\\\(defn-\?\\s\+dev-env\(\$\|\[\^\\w-\]\)\|\\\(defmacro\\s\+dev-env\(\$\|\[\^\\w-\]\)\|\\\(deftype\\s\+dev-env\(\$\|\[\^\\w-\]\)\|\\\(defmulti\\s\+dev-env\(\$\|\[\^\\w-\]\)\|\\\(defmethod\\s\+dev-env\(\$\|\[\^\\w-\]\)\|\\\(definterface\\s\+dev-env\(\$\|\[\^\\w-\]\)\|\\\(defprotocol\\s\+dev-env\(\$\|\[\^\\w-\]\)\|\\\(defrecord\\s\+dev-env\(\$\|\[\^\\w-\]\) -- /Users/ag.ibragimov/DevProjects/finops-admin/\*.clj /Users/ag.ibragimov/DevProjects/finops-admin/\*.cljc /Users/ag.ibragimov/DevProjects/finops-admin/\*.cljs /Users/ag.ibragimov/DevProjects/finops-admin/\*.cljx

raw results: 

    src/clj/finops_admin/pages.clj:7:(defn- dev-env? []


-----
DUMB JUMP DEBUG ‘dumb-jump-run-command‘ END
-----

I thought maybe it's a problem with dev-env being a task. So I tried turning it into a function; (defn dev-env ..., saved the file, tried using dumb-jump-go - still takes me to dev-env?.

@agzam
Copy link
Author

agzam commented Nov 2, 2017

Maybe it's also worth reviewing how dumb-jump works with Clojure forms like:

(require '[app.server :as srv])
(require '[app.db :as db])

(srv/run)
(db/run)

Do you think it would be possible to make it more intelligent? So it would take to app.server/run and to app.db/run?

Or that's way too much work?

@jacktasia
Copy link
Owner

@agzam Thanks for the debug output! I'll definitely fix things so deftask and functions with ? work as expected in clojure. Probably by this weekend at the latest.

Do you think it would be possible to make it more intelligent? So it would take to app.server/run and to app.db/run?

It's certainly possible.

Or that's way too much work?

For me, yes. In my opinion this would make dumb-jump no longer "dumb" and require a pretty big re-write for how things are currently done. The idea for dumb-jump is to "just work" most of the time, but not to give any one language too much special treatment. If you need this level of accuracy for clojure I'd recommend using https://github.com/clojure-emacs/cider

@agzam
Copy link
Author

agzam commented Nov 2, 2017

If you need this level of accuracy for clojure I'd recommend using CIDER

well, here's the thing: syl20bnr/spacemacs#9792

I wish there was something lightweight, maybe based on Lumo, that would help navigating Clojure/script projects. Until then dumb-jump is a good alternative

@jacktasia
Copy link
Owner

@agzam The version of dumb jump now available in MELPA should fix the issue you described here with the ?s, but I think I also need to add support for deftasks? Please let me know how this works for you. Thanks!

@agzam
Copy link
Author

agzam commented Nov 6, 2017

@jacktasia kudos for fixing it so quickly! I will definitely test it out later today. Should I expect these changes to be on MELPA or should I grab the package from GH?

@jacktasia
Copy link
Owner

@jacktasia kudos for fixing it so quickly!

No problem!

I will definitely test it out later today.

Awesome, thank you!

Should I expect these changes to be on MELPA or should I grab the package from GH?

It looks like MELPA already has the changes so you should just have to update via Emacs (and maybe restart)

@agzam
Copy link
Author

agzam commented Nov 7, 2017

@jacktasia I just have tried, I think it works correctly now! Thank you very much!

@jacktasia
Copy link
Owner

@jacktasia I just have tried, I think it works correctly now! Thank you very much!

Awesome! Thanks for letting me know!

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

No branches or pull requests

2 participants