sage-shell-mode icon indicating copy to clipboard operation
sage-shell-mode copied to clipboard

mmm-mode sage-shell:sage-mode integration in specific latex environments

Open Poetastrophe opened this issue 8 years ago • 1 comments

I was looking into how I could get sage-shell:sage-mode to work in sageblock and sagesilent environments. I found this post about getting python-mode to work in specific environments. https://emacs.stackexchange.com/questions/20136/pythontex-and-auctex#20150 But I honestly do not know how to implement this correctly for sage-shell:sage-mode. But I thought it would be neat for working with math-documents.

Poetastrophe avatar Nov 27 '17 18:11 Poetastrophe

I am not familiar with mmm-mode but the following code seems to work to some extent:

(require 'mmm-auto)
(setq mmm-global-mode 'maybe)

(let ((envs '("sageblock" "sagesilent")))
  (mmm-add-classes
   `((latex-sage
      :submode sage-shell:sage-mode
      :face mmm-default-submode-face
      :front ,(rx-to-string
               `(and "\\begin{" (or ,@envs) "}" eol))
      :back ,(rx-to-string
              `(and "\\end{" (or ,@envs) "}" eol))))))

(mmm-add-mode-ext-class 'latex-mode nil 'latex-sage)

Unfortunately syntax highlighting in example.tex is broken with this configuration. I guess the method used by org-mode better than mmm-mode. Perhaps I should examine how org-mode highlights source blocks.

stakemori avatar Nov 28 '17 16:11 stakemori