Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
223c69e2
Commit
223c69e2
authored
Feb 17, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new Emacs cython-mode by Georg Brandl
parent
82a11528
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
1 deletion
+63
-1
Tools/cython-mode.el
Tools/cython-mode.el
+63
-1
No files found.
Tools/cython-mode.el
View file @
223c69e2
;;;; `Cython' mode. (add-to-list 'auto-mode-alist '("\\.pyx\\'" . cython-mode)) (define-derived-mode cython-mode python-mode "Cython" (font-lock-add-keywords nil `((,(concat "\\<\\(NULL" "\\|c\\(def\\|har\\|typedef\\)" "\\|e\\(num\\|xtern\\)" "\\|float" "\\|in\\(clude\\|t\\)" "\\|object\\|public\\|struct\\|type\\|union\\|void" "\\)\\>") 1 font-lock-keyword-face t))))
;; Cython mode
\ No newline at end of file
(
require
'python-mode
)
(
add-to-list
'auto-mode-alist
'
(
"\\.pyx\\'"
.
cython-mode
))
(
add-to-list
'auto-mode-alist
'
(
"\\.pxd\\'"
.
cython-mode
))
(
add-to-list
'auto-mode-alist
'
(
"\\.pxi\\'"
.
cython-mode
))
(
defun
cython-compile
()
"Compile the file via Cython."
(
interactive
)
(
let
((
cy-buffer
(
current-buffer
)))
(
with-current-buffer
(
compile
compile-command
)
(
set
(
make-local-variable
'cython-buffer
)
cy-buffer
)
(
add-to-list
(
make-local-variable
'compilation-finish-functions
)
'cython-compilation-finish
)))
)
(
defun
cython-compilation-finish
(
buffer
how
)
"Called when Cython compilation finishes."
;; XXX could annotate source here
)
(
defvar
cython-mode-map
(
let
((
map
(
make-sparse-keymap
)))
;; Will inherit from `python-mode-map' thanks to define-derived-mode.
(
define-key
map
"\C-c\C-c"
'cython-compile
)
map
)
"Keymap used in `cython-mode'."
)
(
defvar
cython-font-lock-keywords
`
(
;; new keywords in Cython language
(
,
(
regexp-opt
'
(
"by"
"cdef"
"cimport"
"cpdef"
"ctypedef"
"enum"
"except?"
"extern"
"gil"
"include"
"nogil"
"property"
"public"
"readonly"
"struct"
"union"
"DEF"
"IF"
"ELIF"
"ELSE"
)
'words
)
1
font-lock-keyword-face
)
;; C and Python types (highlight as builtins)
(
,
(
regexp-opt
'
(
"NULL"
"bint"
"char"
"dict"
"double"
"float"
"int"
"list"
"long"
"object"
"Py_ssize_t"
"short"
"size_t"
"void"
)
'words
)
1
font-lock-builtin-face
)
;; cdef is used for more than functions, so simply highlighting the next
;; word is problematic. struct, enum and property work though.
(
"\\<\\(?:struct\\|enum\\)[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)"
1
py-class-name-face
)
(
"\\<property[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)"
1
font-lock-function-name-face
))
"Additional font lock keywords for Cython mode."
)
(
define-derived-mode
cython-mode
python-mode
"Cython"
"Major mode for Cython development, derived from Python mode.
\\{cython-mode-map}"
(
setcar
font-lock-defaults
(
append
python-font-lock-keywords
cython-font-lock-keywords
))
(
set
(
make-local-variable
'compile-command
)
(
concat
"cython -a "
buffer-file-name
))
(
add-to-list
(
make-local-variable
'compilation-finish-functions
)
'cython-compilation-finish
)
)
(
provide
'cython-mode
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment