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

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

Projects

None yet

7 participants

@malchmih
Contributor

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

@TheBB
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
Contributor

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

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

@TheBB
Collaborator
TheBB commented Sep 12, 2015

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

@malchmih
Contributor

Thank you 😂 My pleasure!

@justbur
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
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
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
Contributor

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

@mbertheau
Contributor

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

@cpaulik
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
Contributor

No, I don't

@justbur
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
Contributor
justbur commented Sep 13, 2015

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

@syl20bnr syl20bnr added a commit that referenced this issue Sep 14, 2015
@justbur @syl20bnr justbur + spacemacs-core: Fix issues with major-mode-leader
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.
846fa30
@malchmih
Contributor

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

@mbertheau
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
Contributor

Sure, will try to investigate myself

@malchmih malchmih closed this Sep 14, 2015
@justbur
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
Contributor

Thank you, will take a look at this 👍

@dcluna dcluna added a commit to dcluna/spacemacs that referenced this issue Sep 14, 2015
@justbur @dcluna justbur + dcluna spacemacs-core: Fix issues with major-mode-leader
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.
b36fdee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment