Skip to content

Commit

Permalink
Add helm/anything-jedi-importable-modules
Browse files Browse the repository at this point in the history
List all importable Python modules by pkgutil.iter_modules.
  • Loading branch information
tkf committed Mar 8, 2013
1 parent cb95e80 commit a054657
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
27 changes: 27 additions & 0 deletions jedi.el
Expand Up @@ -694,6 +694,33 @@ See also: `jedi:server-args'."
(run-hooks 'jedi:doc-hook)
(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

Expand Down
6 changes: 6 additions & 0 deletions jediepcserver.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a054657

Please sign in to comment.