Skip to content
Browse files

Add helm/anything-jedi-importable-modules

List all importable Python modules by pkgutil.iter_modules.
  • Loading branch information...
1 parent cb95e80 commit a054657ceac6af170afa3d94f68481523e092088 @tkf committed Mar 8, 2013
Showing with 33 additions and 0 deletions.
  1. +27 −0 jedi.el
  2. +6 −0 jediepcserver.py
View
27 jedi.el
@@ -695,6 +695,33 @@ See also: `jedi:server-args'."
(funcall jedi:doc-display-buffer (current-buffer)))))))))
+;;; All Python modules
+
+(defvar jedi:all-modules--value)
+
+(defun jedi:all-modules--get ()
+ (mapcar #'car (epc:call-sync (jedi:get-epc) 'get_all_modules nil)))
+
+(defvar jedi:module-names--source
+ '((name . "Jedi Python modules")
+ (candidates . jedi:all-modules--value)
+ (action . insert)))
+
+(defun jedi:importable-modules--helm (helm)
+ (let ((jedi:all-modules--value (jedi:all-modules--get)))
+ (funcall helm
+ :sources 'jedi:module-names--source
+ :buffer (format "*%s jedi:importable-modules*" helm))))
+
+(defun helm-jedi-importable-modules ()
+ (interactive)
+ (jedi:importable-modules--helm 'helm))
+
+(defun anything-jedi-importable-modules ()
+ (interactive)
+ (jedi:importable-modules--helm 'anything))
+
+
;;; Meta info
(defun jedi:get-jedi-version-request ()
View
6 jediepcserver.py
@@ -156,6 +156,11 @@ def get_module_version(module):
return version
+def get_all_modules():
+ import pkgutil
+ return [(name, ispkg) for (_, name, ispkg) in pkgutil.iter_modules()]
+
+
def get_jedi_version():
import epc
import sexpdata
@@ -185,6 +190,7 @@ def jedi_epc_server(address='localhost', port=0, port_file=sys.stdout,
server.register_function(goto)
server.register_function(related_names)
server.register_function(get_definition)
+ server.register_function(get_all_modules)
server.register_function(get_jedi_version)
port_file.write(str(server.server_address[1])) # needed for Emacs client

0 comments on commit a054657

Please sign in to comment.
Something went wrong with that request. Please try again.