This repository has been archived by the owner on Nov 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmmm-rst-python.el
67 lines (61 loc) · 1.64 KB
/
mmm-rst-python.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
(require 'python)
(defun rst-python-docstrings-find-front (bound)
(when (not bound)
(setq bound (point-max))
)
(message "Start %s" (point))
(loop
while (< (point) bound)
do (progn
(message "Search at %s" (point))
(when (re-search-forward "\\(\"\"\"\\|\'\'\'\\)" bound 'limit)
(let* ((start (match-beginning 0)))
(save-excursion
(goto-char start)
(save-match-data
(python-nav-beginning-of-statement)
)
(when (and (= (point) start))
(return (match-end 0))
)
)
)
)
)
)
)
(defun rst-python-docstrings-find-back (bound)
(when (not bound)
(setq bound (point-max))
)
(loop
while (< (point) bound)
do (when (re-search-forward "\\(\"\"\"\\|\'\'\'\\)" bound t)
(let* ((delim (match-string 0)))
(save-excursion
(save-match-data (python-nav-beginning-of-statement))
(when (looking-at-p delim)
(return (match-end 0))
)
)
)
)
)
)
(require 'mmm-mode)
(add-to-list 'mmm-save-local-variables 'adaptive-fill-regexp)
(add-to-list 'mmm-save-local-variables 'fill-paragraph-function)
(mmm-add-classes
'((rst-python-docstrings
:submode rst-mode
:face mmm-comment-submode-face
:front rst-python-docstrings-find-front
:back rst-python-docstrings-find-back
:save-matches 1
:insert ((?d embdocstring nil @ "\"\"\"" @ _ @ "\"\"\"" @))
:delimiter-mode nil
)
)
)
;;;(assq-delete-all 'rst-python-docstrings mmm-classes-alist)
(mmm-add-mode-ext-class 'python-mode nil 'rst-python-docstrings)