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

Major mode leader key doesn't work in Clojure files #3000

Closed
malchmih opened this issue Sep 12, 2015 · 19 comments
Closed

Major mode leader key doesn't work in Clojure files #3000

malchmih opened this issue Sep 12, 2015 · 19 comments

Comments

@malchmih
Copy link
Contributor

On , I get No previous search. SPC m works.

@TheBB
Copy link
Collaborator

TheBB commented Sep 12, 2015

I'm looking at this now. I suspect moving all the mode-specific evil-leader bindings to :init blocks instead of :config blocks will help.

The major mode leader key is not robust in my experience, but this is the first time I've seen the problem reliably reproducible.

@malchmih
Copy link
Contributor Author

Hmm, it doesn't work in project.clj, but works in any other clj/cljs file.
In project.clj I get File mode specification error: (error "No active nREPL connections")

@darker0n
Copy link

yes, it doesn't work for all files in project's root directory

@TheBB
Copy link
Collaborator

TheBB commented Sep 12, 2015

Congratulations on the 3000th issue or PR, by the way. :-)

@malchmih
Copy link
Contributor Author

Thank you 😂 My pleasure!

@justbur
Copy link
Contributor

justbur commented Sep 12, 2015

@malchmih when you have this problem I assume you're in normal mode and using vim keybindings? What's the value of major-mode? (SPC h d v major-mode RET)

@mbertheau
Copy link
Contributor

In my experience , doesn't work in the first clojure buffer, in the 2nd and following it works. Intuitively I'd guess that the error message about nREPL prevents a complete mode startup, which is why the leader doesn't work. Further, the nREPL checking code throws that error only once per session, which is why the leader works in subsequently opened buffers.

@justbur
Copy link
Contributor

justbur commented Sep 12, 2015

That actually makes perfect sense because , is bound in an "after" major mode hook. The failure is probably preventing that hook from firing.

@malchmih
Copy link
Contributor Author

Right now it doesn't work only in project.clj. With messages I mentioned above. Doesn't depend on the order of buffers.

@mbertheau
Copy link
Contributor

Ok, still makes sense though: project.clj is special, and the nREPL thing is apparently checked only for project.clj.

@cpaulik
Copy link
Contributor

cpaulik commented Sep 13, 2015

In the past we had this problem of , not working on the first buffer because of faulty integration of sematic-mode. Do you have the semantic layer enabled?

@malchmih
Copy link
Contributor Author

No, I don't

@justbur
Copy link
Contributor

justbur commented Sep 13, 2015

We could make setting the major mode leader keys independent of the mode hooks running successfully but the proper thing to do would be to track down this error and fix it.

Has anyone produced a backtrace for the error?

Edit typo

@justbur
Copy link
Contributor

justbur commented Sep 13, 2015

#3002 should fix the inconsistency between SPC m working and , not.

syl20bnr pushed a commit that referenced this issue Sep 14, 2015
Use same hook as evil-leader for major-mode-leader. This fixes an
inconsistency that could arise between the leader key being bound but
the major-mode leader key not being bound (See for example #3000). By
using the same hook as evil-leader-mode, we ensure that either both keys
or bound or neither.

A minor problem that was fixed was `mode-map` and `major-mode-map` were
not let bound and had global scope.
@malchmih
Copy link
Contributor Author

Thank you, , works now! Although I still get File mode specification error: (error "No active nREPL connections"). Is it Spacemacs or CIDER?

@mbertheau
Copy link
Contributor

@malchmih I don't know why that error message comes at this point in time, but you can use , s i to start up a REPL. I don't know exactly what the supposed workflow is with CIDER. It works for me if I just start up a REPL after opening a clojure file.

The original bug has been resolved, so this issue can be closed.

@malchmih
Copy link
Contributor Author

Sure, will try to investigate myself

@justbur
Copy link
Contributor

justbur commented Sep 14, 2015

I can't comment on the proper way to set up this layer, but I was able to narrow down the problem to this line. When cider-mode loads it ends up checking for an active repl, which throws an error if it can't find one. Here's the backtrace (note the call to cider-ensure-connected when "project.clj" is opened for the first time).

You could probably remove that hook and find another way to start cider-mode to stop the error

Debugger entered--Lisp error: (error "No active nREPL connections")
  signal(error ("No active nREPL connections"))
  error("No active nREPL connections")
  cider-ensure-connected()
  cider-current-connection()
  cider-current-ns()
  cider-refresh-font-lock()
  cider-mode()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook clojure-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook clojure-mode-hook))
  run-mode-hooks(clojure-mode-hook)
  clojure-mode()
  set-auto-mode-0(clojure-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer project.clj> "~/project.clj" nil nil "~/project.clj" (1125899907078791 2221746863))

@malchmih
Copy link
Contributor Author

Thank you, will take a look at this 👍

dcluna pushed a commit to dcluna/spacemacs that referenced this issue Sep 14, 2015
Use same hook as evil-leader for major-mode-leader. This fixes an
inconsistency that could arise between the leader key being bound but
the major-mode leader key not being bound (See for example syl20bnr#3000). By
using the same hook as evil-leader-mode, we ensure that either both keys
or bound or neither.

A minor problem that was fixed was `mode-map` and `major-mode-map` were
not let bound and had global scope.
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

7 participants