Touch up the previous commit
This commit is contained in:
parent
7226716739
commit
efddd76ae5
1 changed files with 20 additions and 11 deletions
|
@ -9,8 +9,10 @@
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
;; Some basic configuration for python.el (the latest and greatest
|
;; Enhanced configuration for python.el (the latest and greatest
|
||||||
;; Python mode Emacs has to offer).
|
;; Python mode Emacs has to offer). Most notably Prelude leverages
|
||||||
|
;; anaconda mode to provide code navigation, documentation lookup and
|
||||||
|
;; completion for Python.
|
||||||
|
|
||||||
;;; License:
|
;;; License:
|
||||||
|
|
||||||
|
@ -31,21 +33,26 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(defcustom prelude-python-mode-set-encoding-automatically nil
|
(require 'electric)
|
||||||
"Non-nil values enable auto insertion of '# coding: utf-8' on python buffers."
|
(require 'prelude-programming)
|
||||||
:type 'boolean
|
|
||||||
:group 'prelude)
|
|
||||||
|
|
||||||
|
;; Code navigation, documentation lookup and completion for Python
|
||||||
(prelude-require-package 'anaconda-mode)
|
(prelude-require-package 'anaconda-mode)
|
||||||
|
|
||||||
(when (boundp 'company-backends)
|
(when (boundp 'company-backends)
|
||||||
(prelude-require-package 'company-anaconda)
|
(prelude-require-package 'company-anaconda)
|
||||||
(add-to-list 'company-backends 'company-anaconda))
|
(add-to-list 'company-backends 'company-anaconda))
|
||||||
|
|
||||||
(require 'electric)
|
(defcustom prelude-python-mode-set-encoding-automatically nil
|
||||||
(require 'prelude-programming)
|
"Non-nil values enable auto insertion of '# coding: utf-8' on python buffers."
|
||||||
|
:type 'boolean
|
||||||
|
:group 'prelude)
|
||||||
|
|
||||||
;; Copy pasted from ruby-mode.el
|
;;; Encoding detection/insertion logic
|
||||||
|
;;
|
||||||
|
;; Adapted from ruby-mode.el
|
||||||
|
;;
|
||||||
|
;; This logic was useful in Python 2, but it's not really needed in Python 3.
|
||||||
(defun prelude-python--encoding-comment-required-p ()
|
(defun prelude-python--encoding-comment-required-p ()
|
||||||
(re-search-forward "[^\0-\177]" nil t))
|
(re-search-forward "[^\0-\177]" nil t))
|
||||||
|
|
||||||
|
@ -84,14 +91,16 @@
|
||||||
(when (buffer-modified-p)
|
(when (buffer-modified-p)
|
||||||
(basic-save-buffer-1)))))))
|
(basic-save-buffer-1)))))))
|
||||||
|
|
||||||
|
;;; python-mode setup
|
||||||
|
|
||||||
(when (fboundp 'exec-path-from-shell-copy-env)
|
(when (fboundp 'exec-path-from-shell-copy-env)
|
||||||
(exec-path-from-shell-copy-env "PYTHONPATH"))
|
(exec-path-from-shell-copy-env "PYTHONPATH"))
|
||||||
|
|
||||||
(defun prelude-python-mode-defaults ()
|
(defun prelude-python-mode-defaults ()
|
||||||
"Defaults for Python programming."
|
"Defaults for Python programming."
|
||||||
(subword-mode +1)
|
(subword-mode +1)
|
||||||
(anaconda-mode 1)
|
(anaconda-mode +1)
|
||||||
(eldoc-mode 1)
|
(eldoc-mode +1)
|
||||||
(setq-local electric-layout-rules
|
(setq-local electric-layout-rules
|
||||||
'((?: . (lambda ()
|
'((?: . (lambda ()
|
||||||
(and (zerop (first (syntax-ppss)))
|
(and (zerop (first (syntax-ppss)))
|
||||||
|
|
Loading…
Reference in a new issue