Коллега генерировал pdf c помощью latex, а для подстановки переменных в шаблон использовал erb. Ну и огорчался конечно, что ни подсветка синтаксиса не работает, ни автодополнение. И тут мне стало интересно. Поэтому с помощью библиотеки Polymode был изготовлен режим для emacs, который внутри erb-блоков включал ruby-mode со всеми плюшками, а на всем остальном тексте работал как latex-mode.
Last active
July 19, 2016 08:35
-
-
Save olmstadfm/96f2b4e54a2aa52ba554 to your computer and use it in GitHub Desktop.
Emacs polymode for LaTex with erb-chunks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'polymode) | |
(if window-system (require 'font-latex)) | |
(defcustom pm-host/latex | |
(pm-bchunkmode "latex" :mode 'latex-mode) | |
"Latex host chunkmode" | |
:group 'hostmodes | |
:type 'object) | |
(defcustom pm-inner/nolatex | |
(pm-hbtchunkmode "nolatex" | |
:head-reg "\<\%[-=]?" | |
:tail-reg "\%\>") | |
"No latex chunk." | |
:group 'innermodes | |
:type 'object) | |
(defcustom pm-inner/erb | |
(clone pm-inner/nolatex :mode 'ruby-mode) | |
"Notex innermode for ruby" | |
:group 'innermodes | |
:type 'object) | |
(defcustom pm-poly/latex+erb | |
(pm-polymode-one "awesome" | |
:hostmode 'pm-host/latex | |
:innermode 'pm-inner/erb) | |
"Awesome polymode." | |
:group 'polymodes | |
:type 'object) | |
(define-polymode poly-latex+erb-mode pm-poly/latex+erb) | |
(add-to-list 'auto-mode-alist '("\\.pdf.erb" . poly-latex+erb-mode)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; * supress colors in dired | |
;; defaults are too bright | |
;; * turn on max decoration in latex | |
;; for some reason syntax highlight is turned off in latex-mode | |
(setq font-lock-maximum-decoration (quote ( | |
(latex-mode . t) | |
(dired-mode . nil) | |
))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment