This repository has been archived by the owner on Jun 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpython-help-mode.el
46 lines (40 loc) · 1.69 KB
/
python-help-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
;;; python-help-mode.el --- python documentation special mode -*- lexical-binding: t -*-
(defconst python-help-keywords
'((;; Various forms of intro
("\\`Help on "
("\\<function \\([[:word:]_.]+\\|<lambda>\\)" nil nil (1 'font-lock-function-name-face))
("\\<\\(?:package\\|module\\|class\\) \\([[:word:]_.]+\\)" nil nil (1 'font-lock-type-face))
("\\<\\([[:word:]_.]+\\) object:$" nil nil (1 'font-lock-type-face))
("\\<in \\([[:word:]_.]+\\):$" nil nil (1 'font-lock-type-face)))
;; Sections
("^[A-Z][A-Z ]+[A-Z]$" 0 'info-title-4)
;; Functions (with args)
("^ *\\(?:| \\)*\\(?:[[:word:]_.]+ = \\)?\\([[:word:]_.]+\\)("
(1 'font-lock-function-name-face)
("\\<self\\|True\\|False\\|None\\>" nil nil (0 'font-lock-keyword-face)))
;; Variables
("^ *\\(?:| \\)*\\([[:word:]_.]+\\) = "
(1 'font-lock-variable-name-face)
("\\<True\\|False\\|None\\>" nil nil (0 'font-lock-keyword-face)))
;; Classes
("^ *\\(?:| \\)*\\(class\\) \\([[:word:]_.]+\\)("
(1 'font-lock-keyword-face)
(2 'font-lock-type-face)
("\\([[:word:]_.]+\\)" nil nil (0 'font-lock-type-face)))
;; Specials
("^ *\\(?:| \\)*\\(__\\w+__\\)" 1 'font-lock-function-name-face))))
(defvar python-help-mode-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?' "\"" table)
table))
(defvar-local python-help--parent-proc nil)
;;;###autoload
(define-derived-mode
python-help-mode special-mode "Python Help"
(buffer-disable-undo)
(set-buffer-modified-p nil)
(setq truncate-lines nil
word-wrap t
font-lock-defaults python-help-keywords))
(provide 'python-help-mode)
;;; python-help-mode.el ends here