Config for emacs
This commit is contained in:
parent
a09d6431ca
commit
cab3f5d079
|
@ -0,0 +1,44 @@
|
||||||
|
(deftheme deeper-blue
|
||||||
|
"Created 2020-03-12.")
|
||||||
|
|
||||||
|
(custom-theme-set-faces
|
||||||
|
'deeper-blue
|
||||||
|
'(cursor ((t (:background "dark gray"))))
|
||||||
|
'(diff-context ((((class color) (min-colors 89)) (:foreground "seashell4"))))
|
||||||
|
'(diff-file-header ((((class color) (min-colors 89)) (:background "grey60"))))
|
||||||
|
'(diff-function ((((class color) (min-colors 89)) (:inherit diff-header))))
|
||||||
|
'(diff-header ((((class color) (min-colors 89)) (:background "grey45"))))
|
||||||
|
'(diff-hunk-header ((((class color) (min-colors 89)) (:inherit diff-header))))
|
||||||
|
'(diff-index ((((class color) (min-colors 89)) (:inherit diff-file-header))))
|
||||||
|
'(diff-indicator-added ((((class color) (min-colors 89)) (:foreground "white" :background "darkolivegreen"))))
|
||||||
|
'(diff-indicator-changed ((((class color) (min-colors 89)) (:foreground "white" :background "dodgerblue4"))))
|
||||||
|
'(diff-indicator-removed ((((class color) (min-colors 89)) (:foreground "white" :background "indianred4"))))
|
||||||
|
'(error ((((class color) (min-colors 89)) (:foreground "red"))))
|
||||||
|
'(font-lock-builtin-face ((((class color) (min-colors 89)) (:foreground "LightCoral"))))
|
||||||
|
'(font-lock-comment-delimiter-face ((((class color) (min-colors 89)) (:foreground "gray50"))))
|
||||||
|
'(font-lock-comment-face ((((class color) (min-colors 89)) (:foreground "gray50"))))
|
||||||
|
'(font-lock-constant-face ((((class color) (min-colors 89)) (:foreground "DarkOliveGreen3"))))
|
||||||
|
'(font-lock-doc-face ((((class color) (min-colors 89)) (:foreground "moccasin"))))
|
||||||
|
'(font-lock-function-name-face ((((class color) (min-colors 89)) (:foreground "goldenrod"))))
|
||||||
|
'(font-lock-keyword-face ((((class color) (min-colors 89)) (:foreground "DeepSkyBlue1"))))
|
||||||
|
'(font-lock-preprocessor-face ((((class color) (min-colors 89)) (:foreground "gold"))))
|
||||||
|
'(font-lock-regexp-grouping-backslash ((((class color) (min-colors 89)) (:weight bold))))
|
||||||
|
'(font-lock-regexp-grouping-construct ((((class color) (min-colors 89)) (:weight bold))))
|
||||||
|
'(font-lock-string-face ((((class color) (min-colors 89)) (:foreground "burlywood"))))
|
||||||
|
'(font-lock-type-face ((t (:foreground "dark violet"))))
|
||||||
|
'(font-lock-variable-name-face ((((class color) (min-colors 89)) (:foreground "SeaGreen2"))))
|
||||||
|
'(fringe ((((class color) (min-colors 89)) (:background "black"))))
|
||||||
|
'(highlight ((((class color) (min-colors 89)) (:background "DodgerBlue4"))))
|
||||||
|
'(isearch ((((class color) (min-colors 89)) (:background "coral2" :foreground "white"))))
|
||||||
|
'(lazy-highlight ((((class color) (min-colors 89)) (:background "cadetblue" :foreground "white"))))
|
||||||
|
'(match ((((class color) (min-colors 89)) (:background "DeepPink4"))))
|
||||||
|
'(minibuffer-prompt ((((class color) (min-colors 89)) (:foreground "CadetBlue1"))))
|
||||||
|
'(mode-line ((((class color) (min-colors 89)) (:background "gray75" :foreground "black" :box (:line-width 1 :style released-button)))))
|
||||||
|
'(mode-line-buffer-id ((((class color) (min-colors 89)) (:weight bold :background nil :foreground "blue4"))))
|
||||||
|
'(mode-line-inactive ((((class color) (min-colors 89)) (:background "gray40" :foreground "black" :box (:line-width 1 :color "gray40" :style nil)))))
|
||||||
|
'(region ((((class color) (min-colors 89)) (:background "#103050"))))
|
||||||
|
'(success ((((class color) (min-colors 89)) (:foreground "SeaGreen2"))))
|
||||||
|
'(warning ((((class color) (min-colors 89)) (:foreground "Yellow"))))
|
||||||
|
'(default ((((class color) (min-colors 89)) (:background "#181a26" :foreground "gray80")))))
|
||||||
|
|
||||||
|
(provide-theme 'deeper-blue)
|
|
@ -0,0 +1,44 @@
|
||||||
|
(deftheme deeper-blue
|
||||||
|
"Created 2020-03-12.")
|
||||||
|
|
||||||
|
(custom-theme-set-faces
|
||||||
|
'deeper-blue
|
||||||
|
'(cursor ((t (:background "dark gray"))))
|
||||||
|
'(diff-context ((((class color) (min-colors 89)) (:foreground "seashell4"))))
|
||||||
|
'(diff-file-header ((((class color) (min-colors 89)) (:background "grey60"))))
|
||||||
|
'(diff-function ((((class color) (min-colors 89)) (:inherit diff-header))))
|
||||||
|
'(diff-header ((((class color) (min-colors 89)) (:background "grey45"))))
|
||||||
|
'(diff-hunk-header ((((class color) (min-colors 89)) (:inherit diff-header))))
|
||||||
|
'(diff-index ((((class color) (min-colors 89)) (:inherit diff-file-header))))
|
||||||
|
'(diff-indicator-added ((((class color) (min-colors 89)) (:foreground "white" :background "darkolivegreen"))))
|
||||||
|
'(diff-indicator-changed ((((class color) (min-colors 89)) (:foreground "white" :background "dodgerblue4"))))
|
||||||
|
'(diff-indicator-removed ((((class color) (min-colors 89)) (:foreground "white" :background "indianred4"))))
|
||||||
|
'(error ((((class color) (min-colors 89)) (:foreground "red"))))
|
||||||
|
'(font-lock-builtin-face ((((class color) (min-colors 89)) (:foreground "LightCoral"))))
|
||||||
|
'(font-lock-comment-delimiter-face ((((class color) (min-colors 89)) (:foreground "gray50"))))
|
||||||
|
'(font-lock-comment-face ((((class color) (min-colors 89)) (:foreground "gray50"))))
|
||||||
|
'(font-lock-constant-face ((((class color) (min-colors 89)) (:foreground "DarkOliveGreen3"))))
|
||||||
|
'(font-lock-doc-face ((((class color) (min-colors 89)) (:foreground "moccasin"))))
|
||||||
|
'(font-lock-function-name-face ((((class color) (min-colors 89)) (:foreground "goldenrod"))))
|
||||||
|
'(font-lock-keyword-face ((((class color) (min-colors 89)) (:foreground "DeepSkyBlue1"))))
|
||||||
|
'(font-lock-preprocessor-face ((((class color) (min-colors 89)) (:foreground "gold"))))
|
||||||
|
'(font-lock-regexp-grouping-backslash ((((class color) (min-colors 89)) (:weight bold))))
|
||||||
|
'(font-lock-regexp-grouping-construct ((((class color) (min-colors 89)) (:weight bold))))
|
||||||
|
'(font-lock-string-face ((((class color) (min-colors 89)) (:foreground "burlywood"))))
|
||||||
|
'(font-lock-type-face ((t (:foreground "dark red"))))
|
||||||
|
'(font-lock-variable-name-face ((((class color) (min-colors 89)) (:foreground "SeaGreen2"))))
|
||||||
|
'(fringe ((((class color) (min-colors 89)) (:background "black"))))
|
||||||
|
'(highlight ((((class color) (min-colors 89)) (:background "DodgerBlue4"))))
|
||||||
|
'(isearch ((((class color) (min-colors 89)) (:background "coral2" :foreground "white"))))
|
||||||
|
'(lazy-highlight ((((class color) (min-colors 89)) (:background "cadetblue" :foreground "white"))))
|
||||||
|
'(match ((((class color) (min-colors 89)) (:background "DeepPink4"))))
|
||||||
|
'(minibuffer-prompt ((((class color) (min-colors 89)) (:foreground "CadetBlue1"))))
|
||||||
|
'(mode-line ((((class color) (min-colors 89)) (:background "gray75" :foreground "black" :box (:line-width 1 :style released-button)))))
|
||||||
|
'(mode-line-buffer-id ((((class color) (min-colors 89)) (:weight bold :background nil :foreground "blue4"))))
|
||||||
|
'(mode-line-inactive ((((class color) (min-colors 89)) (:background "gray40" :foreground "black" :box (:line-width 1 :color "gray40" :style nil)))))
|
||||||
|
'(region ((((class color) (min-colors 89)) (:background "#103050"))))
|
||||||
|
'(success ((((class color) (min-colors 89)) (:foreground "SeaGreen2"))))
|
||||||
|
'(warning ((((class color) (min-colors 89)) (:foreground "Yellow"))))
|
||||||
|
'(default ((((class color) (min-colors 89)) (:background "#181a26" :foreground "gray80")))))
|
||||||
|
|
||||||
|
(provide-theme 'deeper-blue)
|
|
@ -0,0 +1,3 @@
|
||||||
|
(require 'alect-themes)
|
||||||
|
|
||||||
|
(alect-create-theme black invert)
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
(require 'alect-themes)
|
||||||
|
|
||||||
|
(alect-create-theme black)
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
(require 'alect-themes)
|
||||||
|
|
||||||
|
(alect-create-theme dark invert)
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
(require 'alect-themes)
|
||||||
|
|
||||||
|
(alect-create-theme dark)
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
(require 'alect-themes)
|
||||||
|
|
||||||
|
(alect-create-theme light invert)
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
(require 'alect-themes)
|
||||||
|
|
||||||
|
(alect-create-theme light)
|
Binary file not shown.
|
@ -0,0 +1,41 @@
|
||||||
|
;;; alect-themes-autoloads.el --- automatically extracted autoloads
|
||||||
|
;;
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
(add-to-list 'load-path (directory-file-name
|
||||||
|
(or (file-name-directory #$) (car load-path))))
|
||||||
|
|
||||||
|
|
||||||
|
;;;### (autoloads nil "alect-themes" "alect-themes.el" (0 0 0 0))
|
||||||
|
;;; Generated autoloads from alect-themes.el
|
||||||
|
|
||||||
|
(autoload 'alect-generate-colors "alect-themes" "\
|
||||||
|
Return alist of themes suitable for the variable `alect-colors'.
|
||||||
|
|
||||||
|
THEME-NAMES is a list of symbols.
|
||||||
|
|
||||||
|
COLORS is a list of lists (COLOR-NAME COLOR-VAL...) where
|
||||||
|
COLOR-VAL is a color for specified theme (theme names and color
|
||||||
|
values should be in matching order).
|
||||||
|
|
||||||
|
\(fn THEME-NAMES COLORS)" nil nil)
|
||||||
|
|
||||||
|
(and load-file-name (boundp 'custom-theme-load-path) (add-to-list 'custom-theme-load-path (file-name-as-directory (file-name-directory load-file-name))))
|
||||||
|
|
||||||
|
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "alect-themes" '("alect-")))
|
||||||
|
|
||||||
|
;;;***
|
||||||
|
|
||||||
|
;;;### (autoloads nil nil ("alect-black-alt-theme.el" "alect-black-theme.el"
|
||||||
|
;;;;;; "alect-dark-alt-theme.el" "alect-dark-theme.el" "alect-light-alt-theme.el"
|
||||||
|
;;;;;; "alect-light-theme.el" "alect-themes-pkg.el") (0 0 0 0))
|
||||||
|
|
||||||
|
;;;***
|
||||||
|
|
||||||
|
;; Local Variables:
|
||||||
|
;; version-control: never
|
||||||
|
;; no-byte-compile: t
|
||||||
|
;; no-update-autoloads: t
|
||||||
|
;; coding: utf-8
|
||||||
|
;; End:
|
||||||
|
;;; alect-themes-autoloads.el ends here
|
|
@ -0,0 +1,12 @@
|
||||||
|
(define-package "alect-themes" "20190506.1440" "Configurable light, dark and black themes for Emacs 24 or later"
|
||||||
|
'((emacs "24.0"))
|
||||||
|
:keywords
|
||||||
|
'("color" "theme")
|
||||||
|
:authors
|
||||||
|
'(("Alex Kost" . "alezost@gmail.com"))
|
||||||
|
:maintainer
|
||||||
|
'("Alex Kost" . "alezost@gmail.com")
|
||||||
|
:url "https://github.com/alezost/alect-themes")
|
||||||
|
;; Local Variables:
|
||||||
|
;; no-byte-compile: t
|
||||||
|
;; End:
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org> (trust undefined) created at 2020-03-12T04:05:02+0700 using RSA
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,43 @@
|
||||||
|
;;; cython-mode-autoloads.el --- automatically extracted autoloads
|
||||||
|
;;
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
(add-to-list 'load-path (directory-file-name
|
||||||
|
(or (file-name-directory #$) (car load-path))))
|
||||||
|
|
||||||
|
|
||||||
|
;;;### (autoloads nil "cython-mode" "cython-mode.el" (0 0 0 0))
|
||||||
|
;;; Generated autoloads from cython-mode.el
|
||||||
|
|
||||||
|
(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))
|
||||||
|
|
||||||
|
(let ((loads (get 'cython 'custom-loads))) (if (member '"cython-mode" loads) nil (put 'cython 'custom-loads (cons '"cython-mode" loads))))
|
||||||
|
|
||||||
|
(defvar cython-default-compile-format "cython -a %s" "\
|
||||||
|
Format for the default command to compile a Cython file.
|
||||||
|
It will be passed to `format' with `buffer-file-name' as the only other argument.")
|
||||||
|
|
||||||
|
(custom-autoload 'cython-default-compile-format "cython-mode" t)
|
||||||
|
|
||||||
|
(autoload 'cython-mode "cython-mode" "\
|
||||||
|
Major mode for Cython development, derived from Python mode.
|
||||||
|
|
||||||
|
\\{cython-mode-map}
|
||||||
|
|
||||||
|
\(fn)" t nil)
|
||||||
|
|
||||||
|
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cython-mode" '("cython-")))
|
||||||
|
|
||||||
|
;;;***
|
||||||
|
|
||||||
|
;; Local Variables:
|
||||||
|
;; version-control: never
|
||||||
|
;; no-byte-compile: t
|
||||||
|
;; no-update-autoloads: t
|
||||||
|
;; coding: utf-8
|
||||||
|
;; End:
|
||||||
|
;;; cython-mode-autoloads.el ends here
|
|
@ -0,0 +1,2 @@
|
||||||
|
;;; -*- no-byte-compile: t -*-
|
||||||
|
(define-package "cython-mode" "20190111.2150" "Major mode for editing Cython files" 'nil :commit "22213aa38cfb3460bbcd746910cea00eedea8a2c")
|
|
@ -0,0 +1,304 @@
|
||||||
|
;;; cython-mode.el --- Major mode for editing Cython files
|
||||||
|
;; Package-Version: 20190111.2150
|
||||||
|
|
||||||
|
;; License: Apache-2.0
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
|
||||||
|
;; This should work with python-mode.el as well as either the new
|
||||||
|
;; python.el or the old.
|
||||||
|
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
;; Load python-mode if available, otherwise use builtin emacs python package
|
||||||
|
(when (not (require 'python-mode nil t))
|
||||||
|
(require 'python))
|
||||||
|
(eval-when-compile (require 'rx))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.pyx\\'" . cython-mode))
|
||||||
|
;;;###autoload
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.pxd\\'" . cython-mode))
|
||||||
|
;;;###autoload
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.pxi\\'" . cython-mode))
|
||||||
|
|
||||||
|
|
||||||
|
(defvar cython-buffer nil
|
||||||
|
"Variable pointing to the cython buffer which was compiled.")
|
||||||
|
|
||||||
|
(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
|
||||||
|
`(;; ctypedef statement: "ctypedef (...type... alias)?"
|
||||||
|
(,(rx
|
||||||
|
;; keyword itself
|
||||||
|
symbol-start (group "ctypedef")
|
||||||
|
;; type specifier: at least 1 non-identifier symbol + 1 identifier
|
||||||
|
;; symbol and anything but a comment-starter after that.
|
||||||
|
(opt (regexp "[^a-zA-Z0-9_\n]+[a-zA-Z0-9_][^#\n]*")
|
||||||
|
;; type alias: an identifier
|
||||||
|
symbol-start (group (regexp "[a-zA-Z_]+[a-zA-Z0-9_]*"))
|
||||||
|
;; space-or-comments till the end of the line
|
||||||
|
(* space) (opt "#" (* nonl)) line-end))
|
||||||
|
(1 font-lock-keyword-face)
|
||||||
|
(2 font-lock-type-face nil 'noerror))
|
||||||
|
;; new keywords in Cython language
|
||||||
|
(,(rx symbol-start
|
||||||
|
(or "by" "cdef" "cimport" "cpdef"
|
||||||
|
"extern" "gil" "include" "nogil" "property" "public"
|
||||||
|
"readonly" "DEF" "IF" "ELIF" "ELSE"
|
||||||
|
"new" "del" "cppclass" "namespace" "const"
|
||||||
|
"__stdcall" "__cdecl" "__fastcall" "inline" "api")
|
||||||
|
symbol-end)
|
||||||
|
. font-lock-keyword-face)
|
||||||
|
;; Question mark won't match at a symbol-end, so 'except?' must be
|
||||||
|
;; special-cased. It's simpler to handle it separately than weaving it
|
||||||
|
;; into the lengthy list of other keywords.
|
||||||
|
(,(rx symbol-start "except?") . font-lock-keyword-face)
|
||||||
|
;; C and Python types (highlight as builtins)
|
||||||
|
(,(rx symbol-start
|
||||||
|
(or
|
||||||
|
"object" "dict" "list"
|
||||||
|
;; basic c type names
|
||||||
|
"void" "char" "int" "float" "double" "bint"
|
||||||
|
;; longness/signed/constness
|
||||||
|
"signed" "unsigned" "long" "short"
|
||||||
|
;; special basic c types
|
||||||
|
"size_t" "Py_ssize_t" "Py_UNICODE" "Py_UCS4" "ssize_t" "ptrdiff_t")
|
||||||
|
symbol-end)
|
||||||
|
. font-lock-builtin-face)
|
||||||
|
(,(rx symbol-start "NULL" symbol-end)
|
||||||
|
. font-lock-constant-face)
|
||||||
|
;; cdef is used for more than functions, so simply highlighting the next
|
||||||
|
;; word is problematic. struct, enum and property work though.
|
||||||
|
(,(rx symbol-start
|
||||||
|
(group (or "struct" "enum" "union"
|
||||||
|
(seq "ctypedef" (+ space "fused"))))
|
||||||
|
(+ space) (group (regexp "[a-zA-Z_]+[a-zA-Z0-9_]*")))
|
||||||
|
(1 font-lock-keyword-face prepend) (2 font-lock-type-face))
|
||||||
|
("\\_<property[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)"
|
||||||
|
1 font-lock-function-name-face))
|
||||||
|
"Additional font lock keywords for Cython mode.")
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defgroup cython nil "Major mode for editing and compiling Cython files"
|
||||||
|
:group 'languages
|
||||||
|
:prefix "cython-"
|
||||||
|
:link '(url-link :tag "Homepage" "https://cython.org/"))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defcustom cython-default-compile-format "cython -a %s"
|
||||||
|
"Format for the default command to compile a Cython file.
|
||||||
|
It will be passed to `format' with `buffer-file-name' as the only other argument."
|
||||||
|
:group 'cython
|
||||||
|
:type 'string)
|
||||||
|
|
||||||
|
;; Some functions defined differently in the different python modes
|
||||||
|
(defun cython-comment-line-p ()
|
||||||
|
"Return non-nil if current line is a comment."
|
||||||
|
(save-excursion
|
||||||
|
(back-to-indentation)
|
||||||
|
(eq ?# (char-after (point)))))
|
||||||
|
|
||||||
|
(defun cython-in-string/comment ()
|
||||||
|
"Return non-nil if point is in a comment or string."
|
||||||
|
(nth 8 (syntax-ppss)))
|
||||||
|
|
||||||
|
(defalias 'cython-beginning-of-statement
|
||||||
|
(cond
|
||||||
|
;; python-mode.el
|
||||||
|
((fboundp 'py-beginning-of-statement)
|
||||||
|
'py-beginning-of-statement)
|
||||||
|
;; old python.el
|
||||||
|
((fboundp 'python-beginning-of-statement)
|
||||||
|
'python-beginning-of-statement)
|
||||||
|
;; new python.el
|
||||||
|
((fboundp 'python-nav-beginning-of-statement)
|
||||||
|
'python-nav-beginning-of-statement)
|
||||||
|
(t (error "Couldn't find implementation for `cython-beginning-of-statement'"))))
|
||||||
|
|
||||||
|
(defalias 'cython-beginning-of-block
|
||||||
|
(cond
|
||||||
|
;; python-mode.el
|
||||||
|
((fboundp 'py-beginning-of-block)
|
||||||
|
'py-beginning-of-block)
|
||||||
|
;; old python.el
|
||||||
|
((fboundp 'python-beginning-of-block)
|
||||||
|
'python-beginning-of-block)
|
||||||
|
;; new python.el
|
||||||
|
((fboundp 'python-nav-beginning-of-block)
|
||||||
|
'python-nav-beginning-of-block)
|
||||||
|
(t (error "Couldn't find implementation for `cython-beginning-of-block'"))))
|
||||||
|
|
||||||
|
(defalias 'cython-end-of-statement
|
||||||
|
(cond
|
||||||
|
;; python-mode.el
|
||||||
|
((fboundp 'py-end-of-statement)
|
||||||
|
'py-end-of-statement)
|
||||||
|
;; old python.el
|
||||||
|
((fboundp 'python-end-of-statement)
|
||||||
|
'python-end-of-statement)
|
||||||
|
;; new python.el
|
||||||
|
((fboundp 'python-nav-end-of-statement)
|
||||||
|
'python-nav-end-of-statement)
|
||||||
|
(t (error "Couldn't find implementation for `cython-end-of-statement'"))))
|
||||||
|
|
||||||
|
(defun cython-open-block-statement-p (&optional bos)
|
||||||
|
"Return non-nil if statement at point opens a Cython block.
|
||||||
|
BOS non-nil means point is known to be at beginning of statement."
|
||||||
|
(save-excursion
|
||||||
|
(unless bos (cython-beginning-of-statement))
|
||||||
|
(looking-at (rx (and (or "if" "else" "elif" "while" "for" "def" "cdef" "cpdef"
|
||||||
|
"class" "try" "except" "finally" "with"
|
||||||
|
"EXAMPLES:" "TESTS:" "INPUT:" "OUTPUT:")
|
||||||
|
symbol-end)))))
|
||||||
|
|
||||||
|
(defun cython-beginning-of-defun ()
|
||||||
|
"`beginning-of-defun-function' for Cython.
|
||||||
|
Finds beginning of innermost nested class or method definition.
|
||||||
|
Returns the name of the definition found at the end, or nil if
|
||||||
|
reached start of buffer."
|
||||||
|
(let ((ci (current-indentation))
|
||||||
|
(def-re (rx line-start (0+ space) (or "def" "cdef" "cpdef" "class") (1+ space)
|
||||||
|
(group (1+ (or word (syntax symbol))))))
|
||||||
|
found lep) ;; def-line
|
||||||
|
(if (cython-comment-line-p)
|
||||||
|
(setq ci most-positive-fixnum))
|
||||||
|
(while (and (not (bobp)) (not found))
|
||||||
|
;; Treat bol at beginning of function as outside function so
|
||||||
|
;; that successive C-M-a makes progress backwards.
|
||||||
|
;;(setq def-line (looking-at def-re))
|
||||||
|
(unless (bolp) (end-of-line))
|
||||||
|
(setq lep (line-end-position))
|
||||||
|
(if (and (re-search-backward def-re nil 'move)
|
||||||
|
;; Must be less indented or matching top level, or
|
||||||
|
;; equally indented if we started on a definition line.
|
||||||
|
(let ((in (current-indentation)))
|
||||||
|
(or (and (zerop ci) (zerop in))
|
||||||
|
(= lep (line-end-position)) ; on initial line
|
||||||
|
;; Not sure why it was like this -- fails in case of
|
||||||
|
;; last internal function followed by first
|
||||||
|
;; non-def statement of the main body.
|
||||||
|
;;(and def-line (= in ci))
|
||||||
|
(= in ci)
|
||||||
|
(< in ci)))
|
||||||
|
(not (cython-in-string/comment)))
|
||||||
|
(setq found t)))))
|
||||||
|
|
||||||
|
(defun cython-end-of-defun ()
|
||||||
|
"`end-of-defun-function' for Cython.
|
||||||
|
Finds end of innermost nested class or method definition."
|
||||||
|
(let ((orig (point))
|
||||||
|
(pattern (rx line-start (0+ space) (or "def" "cdef" "cpdef" "class") space)))
|
||||||
|
;; Go to start of current block and check whether it's at top
|
||||||
|
;; level. If it is, and not a block start, look forward for
|
||||||
|
;; definition statement.
|
||||||
|
(when (cython-comment-line-p)
|
||||||
|
(end-of-line)
|
||||||
|
(forward-comment most-positive-fixnum))
|
||||||
|
(when (not (cython-open-block-statement-p))
|
||||||
|
(cython-beginning-of-block))
|
||||||
|
(if (zerop (current-indentation))
|
||||||
|
(unless (cython-open-block-statement-p)
|
||||||
|
(while (and (re-search-forward pattern nil 'move)
|
||||||
|
(cython-in-string/comment))) ; just loop
|
||||||
|
(unless (eobp)
|
||||||
|
(beginning-of-line)))
|
||||||
|
;; Don't move before top-level statement that would end defun.
|
||||||
|
(end-of-line)
|
||||||
|
(beginning-of-defun))
|
||||||
|
;; If we got to the start of buffer, look forward for
|
||||||
|
;; definition statement.
|
||||||
|
(when (and (bobp) (not (looking-at (rx (or "def" "cdef" "cpdef" "class")))))
|
||||||
|
(while (and (not (eobp))
|
||||||
|
(re-search-forward pattern nil 'move)
|
||||||
|
(cython-in-string/comment)))) ; just loop
|
||||||
|
;; We're at a definition statement (or end-of-buffer).
|
||||||
|
;; This is where we should have started when called from end-of-defun
|
||||||
|
(unless (eobp)
|
||||||
|
(let ((block-indentation (current-indentation)))
|
||||||
|
(python-nav-end-of-statement)
|
||||||
|
(while (and (forward-line 1)
|
||||||
|
(not (eobp))
|
||||||
|
(or (and (> (current-indentation) block-indentation)
|
||||||
|
(or (cython-end-of-statement) t))
|
||||||
|
;; comment or empty line
|
||||||
|
(looking-at (rx (0+ space) (or eol "#"))))))
|
||||||
|
(forward-comment -1))
|
||||||
|
;; Count trailing space in defun (but not trailing comments).
|
||||||
|
(skip-syntax-forward " >")
|
||||||
|
(unless (eobp) ; e.g. missing final newline
|
||||||
|
(beginning-of-line)))
|
||||||
|
;; Catch pathological cases like this, where the beginning-of-defun
|
||||||
|
;; skips to a definition we're not in:
|
||||||
|
;; if ...:
|
||||||
|
;; ...
|
||||||
|
;; else:
|
||||||
|
;; ... # point here
|
||||||
|
;; ...
|
||||||
|
;; def ...
|
||||||
|
(if (< (point) orig)
|
||||||
|
(goto-char (point-max)))))
|
||||||
|
|
||||||
|
(defun cython-current-defun ()
|
||||||
|
"`add-log-current-defun-function' for Cython."
|
||||||
|
(save-excursion
|
||||||
|
;; Move up the tree of nested `class' and `def' blocks until we
|
||||||
|
;; get to zero indentation, accumulating the defined names.
|
||||||
|
(let ((start t)
|
||||||
|
accum)
|
||||||
|
(while (or start (> (current-indentation) 0))
|
||||||
|
(setq start nil)
|
||||||
|
(cython-beginning-of-block)
|
||||||
|
(end-of-line)
|
||||||
|
(beginning-of-defun)
|
||||||
|
(if (looking-at (rx (0+ space) (or "def" "cdef" "cpdef" "class") (1+ space)
|
||||||
|
(group (1+ (or word (syntax symbol))))))
|
||||||
|
(push (match-string 1) accum)))
|
||||||
|
(if accum (mapconcat 'identity accum ".")))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(define-derived-mode cython-mode python-mode "Cython"
|
||||||
|
"Major mode for Cython development, derived from Python mode.
|
||||||
|
|
||||||
|
\\{cython-mode-map}"
|
||||||
|
(font-lock-add-keywords nil cython-font-lock-keywords)
|
||||||
|
(set (make-local-variable 'outline-regexp)
|
||||||
|
(rx (* space) (or "class" "def" "cdef" "cpdef" "elif" "else" "except" "finally"
|
||||||
|
"for" "if" "try" "while" "with")
|
||||||
|
symbol-end))
|
||||||
|
(set (make-local-variable 'beginning-of-defun-function)
|
||||||
|
#'cython-beginning-of-defun)
|
||||||
|
(set (make-local-variable 'end-of-defun-function)
|
||||||
|
#'cython-end-of-defun)
|
||||||
|
(set (make-local-variable 'compile-command)
|
||||||
|
(format cython-default-compile-format (shell-quote-argument (or buffer-file-name ""))))
|
||||||
|
(set (make-local-variable 'add-log-current-defun-function)
|
||||||
|
#'cython-current-defun)
|
||||||
|
(add-hook 'which-func-functions #'cython-current-defun nil t)
|
||||||
|
(add-to-list (make-local-variable 'compilation-finish-functions)
|
||||||
|
'cython-compilation-finish))
|
||||||
|
|
||||||
|
(provide 'cython-mode)
|
||||||
|
|
||||||
|
;;; cython-mode.el ends here
|
Binary file not shown.
|
@ -0,0 +1,2 @@
|
||||||
|
This should work with python-mode.el as well as either the new
|
||||||
|
python.el or the old.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,4 @@
|
||||||
|
;; -*- mode: emacs-lisp; coding: utf-8-unix -*-
|
||||||
|
;; Minibuffer history file, automatically generated by ‘savehist’.
|
||||||
|
|
||||||
|
(setq savehist-minibuffer-history-variables 'nil)
|
|
@ -0,0 +1,48 @@
|
||||||
|
(require 'package)
|
||||||
|
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
|
||||||
|
(not (gnutls-available-p))))
|
||||||
|
(proto (if no-ssl "http" "https")))
|
||||||
|
(when no-ssl (warn "\
|
||||||
|
Your version of Emacs does not support SSL connections,
|
||||||
|
which is unsafe because it allows man-in-the-middle attacks.
|
||||||
|
There are two things you can do about this warning:
|
||||||
|
1. Install an Emacs version that does support SSL and be safe.
|
||||||
|
2. Remove this warning from your init file so you won't see it again."))
|
||||||
|
(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
|
||||||
|
;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities`
|
||||||
|
;; and `package-pinned-packages`. Most users will not need or want to do this.
|
||||||
|
;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
|
||||||
|
)
|
||||||
|
(package-initialize)
|
||||||
|
(custom-set-variables
|
||||||
|
;; custom-set-variables was added by Custom.
|
||||||
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
|
;; Your init file should contain only one such instance.
|
||||||
|
;; If there is more than one, they won't work right.
|
||||||
|
'(ansi-color-faces-vector
|
||||||
|
[default default default italic underline success warning error])
|
||||||
|
'(ansi-color-names-vector
|
||||||
|
["black" "#d55e00" "#009e73" "#f8ec59" "#0072b2" "#cc79a7" "#56b4e9" "white"])
|
||||||
|
'(custom-enabled-themes (quote (alect-dark)))
|
||||||
|
'(custom-safe-themes
|
||||||
|
(quote
|
||||||
|
("7356632cebc6a11a87bc5fcffaa49bae528026a78637acd03cae57c091afd9b9" "ab04c00a7e48ad784b52f34aa6bfa1e80d0c3fcacc50e1189af3651013eb0d58" "04dd0236a367865e591927a3810f178e8d33c372ad5bfef48b5ce90d4b476481" "a0feb1322de9e26a4d209d1cfa236deaf64662bb604fa513cca6a057ddf0ef64" "72e619344d77a16ce6b9eab205e930e14f386609cd31b14844c441b4a811f415" "6b10da616c1024c23380a164e4b0d57c27aac098b8cce9e5c1f220437b6c94d7" "8bab01fcbe965cc2b81203623fc2d7c0bc7816d4475d1c7cb4834b55f9d58511" default)))
|
||||||
|
'(inhibit-startup-screen t)
|
||||||
|
'(package-selected-packages (quote (alect-themes cython-mode))))
|
||||||
|
(custom-set-faces
|
||||||
|
;; custom-set-faces was added by Custom.
|
||||||
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
|
;; Your init file should contain only one such instance.
|
||||||
|
;; If there is more than one, they won't work right.
|
||||||
|
)
|
||||||
|
|
||||||
|
;; To display line number
|
||||||
|
(when (version<= "26.0.50" emacs-version )
|
||||||
|
(global-display-line-numbers-mode))
|
||||||
|
|
||||||
|
;; To highlight current line
|
||||||
|
(global-hl-line-mode 1)
|
||||||
|
|
||||||
|
;; Default full screen
|
||||||
|
(custom-set-variables
|
||||||
|
'(initial-frame-alist (quote ((fullscreen . maximized)))))
|
|
@ -0,0 +1,48 @@
|
||||||
|
(require 'package)
|
||||||
|
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
|
||||||
|
(not (gnutls-available-p))))
|
||||||
|
(proto (if no-ssl "http" "https")))
|
||||||
|
(when no-ssl (warn "\
|
||||||
|
Your version of Emacs does not support SSL connections,
|
||||||
|
which is unsafe because it allows man-in-the-middle attacks.
|
||||||
|
There are two things you can do about this warning:
|
||||||
|
1. Install an Emacs version that does support SSL and be safe.
|
||||||
|
2. Remove this warning from your init file so you won't see it again."))
|
||||||
|
(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
|
||||||
|
;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities`
|
||||||
|
;; and `package-pinned-packages`. Most users will not need or want to do this.
|
||||||
|
;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
|
||||||
|
)
|
||||||
|
(package-initialize)
|
||||||
|
(custom-set-variables
|
||||||
|
;; custom-set-variables was added by Custom.
|
||||||
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
|
;; Your init file should contain only one such instance.
|
||||||
|
;; If there is more than one, they won't work right.
|
||||||
|
'(ansi-color-faces-vector
|
||||||
|
[default default default italic underline success warning error])
|
||||||
|
'(ansi-color-names-vector
|
||||||
|
["black" "#d55e00" "#009e73" "#f8ec59" "#0072b2" "#cc79a7" "#56b4e9" "white"])
|
||||||
|
'(custom-enabled-themes (quote (alect-dark)))
|
||||||
|
'(custom-safe-themes
|
||||||
|
(quote
|
||||||
|
("7356632cebc6a11a87bc5fcffaa49bae528026a78637acd03cae57c091afd9b9" "ab04c00a7e48ad784b52f34aa6bfa1e80d0c3fcacc50e1189af3651013eb0d58" "04dd0236a367865e591927a3810f178e8d33c372ad5bfef48b5ce90d4b476481" "a0feb1322de9e26a4d209d1cfa236deaf64662bb604fa513cca6a057ddf0ef64" "72e619344d77a16ce6b9eab205e930e14f386609cd31b14844c441b4a811f415" "6b10da616c1024c23380a164e4b0d57c27aac098b8cce9e5c1f220437b6c94d7" "8bab01fcbe965cc2b81203623fc2d7c0bc7816d4475d1c7cb4834b55f9d58511" default)))
|
||||||
|
'(inhibit-startup-screen t)
|
||||||
|
'(package-selected-packages (quote (alect-themes cython-mode))))
|
||||||
|
(custom-set-faces
|
||||||
|
;; custom-set-faces was added by Custom.
|
||||||
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
|
;; Your init file should contain only one such instance.
|
||||||
|
;; If there is more than one, they won't work right.
|
||||||
|
)
|
||||||
|
|
||||||
|
;; To display line number
|
||||||
|
(when (version<= "26.0.50" emacs-version )
|
||||||
|
(global-display-line-numbers-mode))
|
||||||
|
|
||||||
|
;; To highlight current line
|
||||||
|
(global-hl-line-mode 1)
|
||||||
|
|
||||||
|
;; Default full screen
|
||||||
|
(custom-set-variables
|
||||||
|
'(initial-frame-alist (quote (fullscreen . maximized))))
|
Loading…
Reference in New Issue