summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ravi-init-python.el22
1 files changed, 18 insertions, 4 deletions
diff --git a/lisp/ravi-init-python.el b/lisp/ravi-init-python.el
index 201369b..36bc489 100644
--- a/lisp/ravi-init-python.el
+++ b/lisp/ravi-init-python.el
@@ -24,6 +24,7 @@
;;; Code:
+(setq load-prefer-newer t)
(use-package python
:mode ("\\.py\\'" . python-mode)
:commands python-shell-switch-to-shell
@@ -97,11 +98,24 @@
(use-package jedi-core
:config
(progn
+ (defun ravi/add-to-path-list (paths new-path-list)
+ (let* ((old-paths (and paths (split-string paths ":" t)))
+ (all-paths (-concat (and paths (list paths)) (-difference new-path-list old-paths)))
+ (new-path (and all-paths (-reduce (lambda (lhs rhs) (concat lhs ":" rhs)) all-paths))))
+ new-path))
+ (defun ravi/add-epc-sexpdata-to-pythonpath (orig-fun &rest args)
+ "Add paths to python-epc and sexpdata to pythonpath"
+ (let ((process-environment
+ (cons
+ (concat "PYTHONPATH="
+ (ravi/add-to-path-list
+ (getenv "PYTHONPATH")
+ (mapcar (lambda (x) (ravi/emacs-file x)) '("site-lisp/python-epc" "site-lisp/sexpdata"))))
+ process-environment)))
+ (apply orig-fun args)))
+ (advice-add 'jedi:start-server :around #'ravi/add-epc-sexpdata-to-pythonpath)
(defun ravi/jedi-setup ()
- (let ((basic-server-args (list
- "--sys-path" (ravi/emacs-file "site-lisp/python-epc")
- "--sys-path" (ravi/emacs-file "site-lisp/sexpdata"))
- ))
+ (let ((basic-server-args '()))
(set (make-local-variable 'jedi:server-args)
(if (and (boundp 'extra-jedi-args)
(listp extra-jedi-args))