2

I am unable to change keybinding in a minor mode.

Initiaton of minor mode:

(add-hook 'julia-mode-hook 'julia-repl-mode)

I tried a view variatons for the keybinding:

(add-hook 'julia-repl-mode
    (lambda ()
    (define-key map [C-shift-return] 'julia-repl-send-line)
    (define-key map [C-return] 'julia-repl-send-region-or-line)))

or:

(eval-after-load 'julia-repl '(define-key julia-repl-map [C-return]
                 'julia-repl-send-region-or-line))

But finally without result. I want to bind the command julia-repl-send-region-or-line to C-<eturn>. I was at least able to change it interactively with M-x local-set-key. But I would like to define it in the init file. What am I missing?

  • Consider saying whether julia-repl-mode gets turned on when julia-mode is turned on. If so, you can remove the first add-hook from your question. – Drew Nov 17 '17 at 0:43
1

The variable map is undefined (aka free) here:

(add-hook 'julia-repl-mode
    (lambda ()
      (define-key map [C-shift-return] 'julia-repl-send-line)
      (define-key map [C-return] 'julia-repl-send-region-or-line)))

What keymap do you want to bind the keys in? Is it julia-mode-map? julia-repl-mode-map? You need to provide an actual keymap as the first argument of define-key.

Do you see an error or warning message in buffer *Messages* that mentions your unbound variable when your hook function is invoked? (The error might be ignored.)

(You can put (debug) as the first thing inside your lambda, and use d in the debugger to see what happens and understand the unbound variable problem, if it's not already clear from what I've said.)

  • I also tried both versions: julia-mode-map and julia-repl-mode-map which resulted in the following error: variable void. – Krisselack Nov 17 '17 at 8:45
  • What variable did it say was void - the map variable? Check the julia code, to see what the map variable is called. And be sure that the julia code that defines it actually gets loaded before Emacs tries to evaluate your code that makes use of it. – Drew Nov 17 '17 at 16:27
  • Thank you, it worked now. I forgot to add -hook. I will post the solution below. – Krisselack Nov 17 '17 at 18:11
0

I forgot to add a hook (solution):

(add-hook 'julia-repl-mode-hook
  (lambda ()
    (define-key julia-repl-mode-map [C-shift-return] 'julia-repl-send-line)
        (define-key julia-repl-mode-map [C-return] 'julia-repl-send-region-or-line)))

(add-hook 'julia-mode-hook 'julia-repl-mode)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.