Question: Question:
I am writing sentences using Sphinx . When editing a file in reStructuredText format like the following in Emacs, I want to syntax highlight only the contents of the code block (code-block) in a major mode different from rst-mode. How can I do this? Is not it.
こんにちは世界
==============
- ほげほげ
.. code-block:: python
# このブロックは rst-mode ではなく python-mode で
# シンタックスハイライト + インデントしたいという話です
def hello():
print("Hello, world!")
hello()
Answer: Answer:
I haven't tried it myself so I'm not sure if it will work, but if you use mumamo or mmm-mode, you can switch between multiple modes depending on the code type in one buffer (Other EmacsWiki) . Please refer to Multiple Modes in).
In mmm-mode, what you're doing is the opposite (editing rst in your Python code), but this answer and this code may be helpful for your configuration.