Skip to content

Latest commit

 

History

History
62 lines (49 loc) · 1.8 KB

starter-kit-python.org

File metadata and controls

62 lines (49 loc) · 1.8 KB

Starter Kit Python

This is part of the Emacs Starter Kit.

Starter kit Python

Support for the Python programming language.

Check Dependencies

Determine whether required packages are installed. If not, use ELPA to install them.

(dolist (package '(python-mode ipython))
  (unless (package-installed-p package)
    (package-install package)))

Use Python’s python-mode.el instead of Emacs’ python.el

Replace the Python mode that comes with Emacs by the Python mode supplied by the Python distribution itself.
  
(autoload 'python-mode "python-mode" "Python Mode." t)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(add-to-list 'interpreter-mode-alist '("python" . python-mode))
  
(setq
 python-shell-interpreter "ipython"
 python-shell-interpreter-args ""
 python-shell-prompt-regexp "In \\[[0-9]+\\]: "
 python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
 python-shell-completion-setup-code
   "from IPython.core.completerlib import module_completion"
 python-shell-completion-module-string-code
 "';'.join(module_completion('''%s'''))\n"
 python-shell-completion-string-code
   "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
  
  
  

Use Cython mode

(when (require 'cython-mode nil 'no-error)
  (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)))
(message "Starter Kit Python loaded.")