2

I'm using ob-go from melpa and go-ts-mode, which I set to be automatically loaded with .go files. Code execution of org-mode go code blocks with C-c C-c works.

However, while syntax highlighting works in .go files, it does not in go code blocks (it does for all other languages).

Is it supposed to work out of the box or further configuration is needed?

I'm using Emacs 29.4 on Gentoo.

1
  • 1
    You're using "go" as the language identifier in the syntax highlight, right? What does evaluating (org-src-get-lang-mode "go") show? Commented Feb 21 at 7:37

1 Answer 1

2

This is because for org-mode code blocks highlight you may need to add association of "language identifier" (i.e. the one you're writing like #+begin_src python or #+begin_src go, etc) to the mode.

So in your case:

(add-to-list 'org-src-lang-modes '("go" . go-ts)) 

Note that -mode postfix is missing. It's because it is appended by org-src-get-lang-mode.

P.S.: I think you can contribute such change to go-ts-mode, so it populates the variable if it's enabled. Or maybe better, contributing a org-src-get-lang-mode change so it takes into account -ts modes, since these days there are many of them.

P.P.S: FYI, I don't even use go nor org modes (I prefer markdown to org-mode and don't even know org-mode syntax). Everything I wrote was inferred in 2 minutes by git-grepping over Emacs sources; in this case I found this Q/A on org syntax-highlight, and then grepped for org-src-fontify-natively. This is the power of open-source: I recommend you to look at source code more often in search for answers 😊

1
  • 1
    +1 for the answer and another +1 if I could for the P.P.S :-) Commented Feb 21 at 16:05

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.