/
deqn-mode.el
82 lines (68 loc) · 2.74 KB
/
deqn-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
;;; deqn-mode --- Create and export ODE models to various formats
;;; Commentary:
;; Equation mode is an equation editor that allows
;; the easy creation and simulation of ODEs or Boolean models in
;; Emacs with easy exports to python or matlab.
;; 1. DONE Fontify an equation file
;; 2. DONE Export validated model to PyDSTool
;; 3. DONE Export to plain text (separate files for equations, ics, parameters)
;; 4. DONE Export model to SBML format
;; 5. PROG Export to Python
;;; Code:
(require 'subr-x)
(require 'cl)
(require 'deqn-utils)
(require 'deqn-python)
(require 'deqn-pydstool)
(require 'deqn-text)
(require 'deqn-sbml)
(require 'deqn-simulator-interface)
;; (defun deqn/init-buffers ()
;; "Create window configuration.
;; Save windows, close windows, split screen vertically so that
;; the user defined equations on the left are formatted correctly
;; on the right."
;; (save-excursion (generate-new-buffer "*deqn-editor*")
;; (generate-new-buffer "deqn-output.org")
;; (delete-other-windows)
;; (split-window-right)
;; (other-window 1)
;; (set-buffer "*deqn-editor*")
;; (other-window 1)
;; (set-buffer "deqn-output.org")))
;; (defgroup deqns nil
;; "Syntax highlighting for a tab separated variables.txt file."
;; :prefix "deqns/"
;; )
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.eqn\\'" . deqn-mode))
(defvar deqn-highlights
'(("pi" . font-lock-constant-face)
( " sin\\| exp\\| cos\\| shs\\| min\\| max\\|=" . font-lock-function-name-face) ;; (deqn-special-names . font-lock-function-name-face)
( "\\([a-zA-Z0-9_]*\\)[ ]*=" 1 font-lock-keyword-face))) ;; ( (concat "\\([a-zA-Z0-9_]*\\)[ ]*" deqn-separator-symbol) 1 font-lock-keyword-face)))
(defhydra deqn-mode-hydra (:color blue)
"
---------------- ------------------
^Export Options^ ^Invoke Transient^
---------------- ------------------
_P_yDSTool s_i_mulator interface
_p_ython parame_t_er set selector
_S_BML
_t_ext
"
("P" deqn-pydstool/translate-model "PyDSTool")
("p" deqn-python/translate-model "Python")
("t" deqn-text/translate-model "Text")
("S" deqn-sbml/translate-model "SBML")
("i" simulator-options-transient "Simulator")
("t" deqn-read-parameter-table "Parameter Sets"))
(progn
(setq deqn-mode-map (make-sparse-keymap))
(define-key deqn-mode-map (kbd "C-c h") 'deqn-mode-hydra/body))
(define-derived-mode deqn-mode prog-mode "deqn"
"major mode for editing equations."
;; HOLD (deqn/init-buffers)
(setq font-lock-defaults '(deqn-highlights))
)
(provide 'deqn-mode)
;;; deqn-mode.el ends here