tpapp / julia-repl

Run an inferior Julia REPL in a terminal inside Emacs
Other
170 stars 35 forks source link

Works great in Linux but 'ctrl-c' commands don't work for me on the Mac #87

Closed compleathorseplayer closed 4 years ago

compleathorseplayer commented 4 years ago

When reporting an issue, please provide

  1. the Emacs version (M-x emacs-version [RET], will also appear in the buffer *Messages*), 26.3
  2. the Julia version (VERSION) 1.4.1
  3. the version of julia-repl (something like “latest master” is fine). latest master
  4. self-contained steps to replicate the issue. M-x julia-repl

All looks fine until I try to do something like ctrl-enter to execute code or any 'ctrl c' Is this a Mac thing, or just me getting lucky? Is there a fix? [like a line for .emacs (if so where in the .emacs file to put it?)]

Thanks for any hints.

prosoitos commented 4 years ago

I don't think that C-c works in term-mode.

Not sure this is a good approach, but what I did is to bind a key of my choice to term-interrupt-subjob to kill the running job.

(add-hook 'term-mode-hook (lambda ()
                (define-key term-raw-map (kbd "<key>") 'term-interrupt-subjob)))

It's working great for me (note in case it matters: I am on Linux).

compleathorseplayer commented 4 years ago

Thanks Prosoitos - I think there is a misunderstanding here... I don't need an interrupt, I just would like to use the given commands like ('ctrl-c ctrl-c' to send the current line to the REPL as listed here) but can't get that to work.

Nathan-Furnal commented 4 years ago

If you add the hook from the docs it should load julia-repl-mode in any julia mode, and work.

compleathorseplayer commented 4 years ago

Thanks so much. I got it to work by explicitly choosing julia-repl-mode for each buffer. For some reason the same configuration file that worked for Linux did not work on the Mac. Could anyone please clarify the line I should add to the .emacs file and (crucially, not always clear in the docs) where it should go? Thanks again!

compleathorseplayer commented 4 years ago

[my main problem is solved, just the configuration in the .emacs file doesn't seem to enable julia-repl-mode automatically]

Nathan-Furnal commented 4 years ago

You can link a mode with a file extension :

(add-to-list 'auto-mode-alist '("\\.jl\\'" . julia-repl-mode))

This should open julia-repl-mode in any julia file. Alternatively, this in your .emacs

(require 'julia-repl)
(add-hook 'julia-mode-hook 'julia-repl-mode) ;; always use minor mode

should open the repl anytime julia-mode starts.

compleathorseplayer commented 4 years ago

Hi Thanks. I already had the second 'hook' section in my .emacs file. I tried adding the first suggestion (then restarting) and it didn't work either - I still have to start julia-repl-mode manually. It could have to do with the way emacs automatically changes the ' and " marks which change their meaning in the .emacs file.

At least I got it working now (just a little less conveniently).

Nathan-Furnal commented 4 years ago

That's strange, I'm not using the first line of code I wrote above and yet it still works for me.

When you open a julia file and type M-: then major-mode what does it say?

compleathorseplayer commented 4 years ago

julia-mode

Nathan-Furnal commented 4 years ago

Alright, what about when you try C-h m? What modes are detected? Do this before you use the repl and do not try in a buffer where the repl is already active.

compleathorseplayer commented 4 years ago

Hi Nathan, I got it fixed - when I had copied lines from a forum to add to the .emacs file, the quotes had changed font (and meaning). I fixed this and now it works.
Thanks to you, I knew where to look. Thanks!

Nathan-Furnal commented 4 years ago

Glad it's sorted, have fun!

prosoitos commented 4 years ago

Sorry I missed the point @compleathorseplayer :slightly_smiling_face:

compleathorseplayer commented 4 years ago

Hi P, You had (helpfully, I might add) answered a question I wasn't asking - which I think was how to send a control-c to interrupt something running in the REPL. I just wanted to be able to send commands by typing control-c twice, etc. What I didn't understand (but was later helped with) was that julia-repl-mode had not started properly in my editing window (the REPL was there, but I couldn't send commands). You ended up giving me a useful bit of info which I have since used, though!
Thanks!