[Python-mode] patch for pycomplete.py

Alex Polite m4 at polite.se
Sat Oct 29 15:42:39 CEST 2005


Hi there.

I just found out about pycomplete. I've been missing this in emacs for
a long time. Very nice.


I've modified pycomplete.py put some stuff in the message area when
there's no completion or to many possible completions. It's pretty
unobtrusive.

Here's the patch. I hope you integrate it.

regards alex


-- 
Alex Polite
http://flosspick.org
-------------- next part --------------
*** /tmp/python-mode-1.0alpha/pycomplete.py	2004-10-21 23:27:30.000000000 +0200
--- /usr/lib/python2.3/site-packages/pycomplete.py	2005-10-29 15:12:46.000000000 +0200
***************
*** 23,28 ****
--- 23,31 ----
  
  import sys
  import os.path
+ import string
+ 
+ from Pymacs import lisp
  
  try:
      x = set
***************
*** 75,81 ****
  def pycomplete(s, imports=None):
      completions = get_all_completions(s, imports)
      dots = s.split(".")
!     return os.path.commonprefix([k[len(dots[-1]):] for k in completions])
  
  if __name__ == "__main__":
      print "<empty> ->", pycomplete("")
--- 78,94 ----
  def pycomplete(s, imports=None):
      completions = get_all_completions(s, imports)
      dots = s.split(".")
!     result = os.path.commonprefix([k[len(dots[-1]):] for k in completions])
!     if result == "":
!         if completions:
!             width = lisp.window_width() - 2
!             msg = "completions: %s" % (string.join(completions," "),)
!             if len(msg) > width:
!                 msg = msg[:width - 4] + " ..."
!         else:
!             msg = "no completions!"
!         lisp.message(msg)
!     return  result
  
  if __name__ == "__main__":
      print "<empty> ->", pycomplete("")


More information about the Python-mode mailing list