I just started setting up polymode

I got ESS and r going nicely with markdown.

(use-package markdown-mode)
(use-package polymode)
(require 'poly-R)
(require 'poly-markdown)

I was able to put r code blocks inside a markdown file, and send lines one at a time to the r interactive window

Next, I want to do the same for f#. Here is my markdown document

# Title

let x = 5

That's all.

Now, when I start poly-markdown-mode, it automatically picks up on the fsharp mode, and I get the keybindingd I usually use for fsharp mode. I tried sending the first line to the interactive process, and it worked.

Then I tried sending the second line (just x), and it gave me an error

path/to/file.md(6,1): error FS0010: Unexpected reserved keyword in interaction

If I understand correctly, polymode splits the file into virtual buffers or something and splices them back together. It seems that somehow there is something at the end of the fsharp virtual buffer that I can't see, but is messing the interpreter up.

I tried adding a blank line to the end of the code block, but the result was the same.

fsharp mode has a function for sending the current region; when I use that, it actually works. This seems to confirm my diagnosis. Now, I could just select the last line any time I need to evaluate it, but that is inconvenient. Is there a way to solve this problem

Your Answer

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

Browse other questions tagged or ask your own question.