Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs replicating M-RET functionality of the org-mode in the rst-mode

In org-mode, typing M-RET at the end of a headline will create a new headline of the same level on a new line. Can I replicate this functionality in rst-mode (especially for lists)? Currently M-RET is not defined, and it would be great if I can just press M-RET and rst-mode would intelligently add another list header. For example,

- Item1 <M-RET>

renders

- Item1
- 

automatically.

like image 394
joon Avatar asked Oct 21 '22 11:10

joon


1 Answers

It turns out that the rst.el included in the particular version of Emacs I'm using is old. You can get the newer rst.el from the Subversion repository, and put it into your load-path. Then, you can make rst-mode specific key binding to rst-insert-list:

(eval-after-load "rst"
  '(progn 
     (define-key rst-mode-map (kbd "<M-RET>")
       (lambda ()
         (interactive)
         (rst-insert-list)))))

Then you can use M-RET to make new list.

Thanks for Stefan Merten for his kind instructions in the mailing list.

You can also take a look at the Installation section of the Emacs Support for reStructuredText documentation.

like image 152
joon Avatar answered Oct 30 '22 23:10

joon