Skip to content

Instantly share code, notes, and snippets.

@nnja
Forked from nyergler/kenobi.el
Last active August 29, 2015 14:17
Show Gist options
  • Save nnja/6cd7d70e4f9155c7128c to your computer and use it in GitHub Desktop.
Save nnja/6cd7d70e4f9155c7128c to your computer and use it in GitHub Desktop.
(add-hook 'hack-local-variables-hook 'run-local-vars-mode-hook)
(defun run-local-vars-mode-hook ()
"Run a hook for the major-mode after the local variables have been processed."
(run-hooks (intern (concat (symbol-name major-mode) "-local-vars-hook"))))
(defun detect_buffer_venv (buffer-name)
(let ((buffer-dir (file-name-directory buffer-name)))
(while (and (not (file-exists-p
(concat buffer-dir "bin/activate")))
buffer-dir)
(setq buffer-dir
(if (equal buffer-dir "/")
nil
(file-name-directory (directory-file-name buffer-dir))
))
)
;; return the buffer-dir (or nil)
buffer-dir
)
)
(setq additional_paths nil)
(defun setup-jedi-extra-args ()
(let (
(venv (detect_buffer_venv buffer-file-name))
)
(make-local-variable 'jedi:server-args)
(when venv (set 'jedi:server-args (list "--virtual-env" venv)))
(when egg-dirs
(dolist (egg egg-dirs)
(set 'jedi:server-args (append jedi:server-args (list "--sys-path" egg))))
)
)
(make-local-variable 'additional_paths)
(when additional_paths
(dolist (path additional_paths)
(set 'jedi:server-args (append jedi:server-args (list "--sys-path" path)))
))
)
(setq jedi:setup-keys t)
(add-hook 'python-mode-local-vars-hook 'setup-jedi-extra-args)
(add-hook 'python-mode-local-vars-hook 'jedi:setup)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment