blob: ffcaa2cd0f84873bd164c837098895fc26b134e9 (
plain) (
blame)
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
|
;;; init-python.el --- configure python language support -*- lexical-binding:t -*-
;;; Commentary:
;;; Code:
(defun mpolden/python-mode-buffer-local-variables ()
"Set buffer-local variables for `python-mode'."
;; highlight lines longer than 88 characters
(setq-local fill-column 88)
;; use flat index in imenu
(setq-local imenu-create-index-function
'python-imenu-create-flat-index)
;; use virtualenv if it exists
(let ((venv-parent (locate-dominating-file default-directory "venv")))
(setq-local python-shell-virtualenv-root (expand-file-name "venv" venv-parent))))
(use-package python
:mode ("\\.py\\'" . python-mode)
:hook (python-mode . mpolden/python-mode-buffer-local-variables)
:config
;; set prefered interpreter
(setq python-shell-interpreter (cond ((executable-find "ipython3") "ipython3")
((executable-find "python3") "python3")
t "python"))
;; ipython needs --simple-prompt for emacs compatibility
;; https://emacs.stackexchange.com/a/24572
(when (equal python-shell-interpreter "ipython3")
(setq python-shell-interpreter-args "-i --simple-prompt")))
(provide 'init-python)
;;; init-python.el ends here
|