Unable to see errebepe's patch, but here's my attempt
following IPython's implemention. It's like other
completions in Emacs:
- No completion: ring bell and display in echo area "Can't
find completion for 'foo'"
- Sole completion: complete
- Multiple completion: open a window with mouse-clickable
entries
[pycomplete.py]
--- pycomplete.py.old Wed Jan 11 21:07:19 2006
+++ pycomplete.py Sun Feb 26 23:49:19 2006
@@ -74,12 +74,21 @@
def pycomplete(s, imports=None):
completions = get_all_completions(s, imports)
+ if len(completions) == 0:
+ return None
+
dots = s.split(".")
- return os.path.commonprefix([k[len(dots[-1]):] for k
in completions])
+ prefix = os.path.commonprefix([k for k in completions])
+ if len(completions)==1 or len(prefix)>len(dots[-1]):
+ return [prefix[len(dots[-1]):]]
+
+ return completions
[pycomplete.el]
--- pycomplete.el.old Sat Dec 3 00:30:11 2005
+++ pycomplete.el Sun Feb 26 23:51:16 2006
@@ -10,9 +10,21 @@
Unable to see errebepe's patch, but here's my attempt
following IPython's implemention. It's like other
completions in Emacs:
- No completion: ring bell and display in echo area "Can't
find completion for 'foo'"
- Sole completion: complete
- Multiple completion: open a window with mouse-clickable
entries
[pycomplete.py]
--- pycomplete.py.old Wed Jan 11 21:07:19 2006
+++ pycomplete.py Sun Feb 26 23:49:19 2006
@@ -74,12 +74,21 @@
def pycomplete(s, imports=None): completions( s, imports) commonprefix( [k[len( dots[-1] ):] for k commonprefix( [k for k in completions]) >len(dots[ -1]): len(dots[ -1]):]]
completions = get_all_
+ if len(completions) == 0:
+ return None
+
dots = s.split(".")
- return os.path.
in completions])
+ prefix = os.path.
+ if len(completions)==1 or len(prefix)
+ return [prefix[
+
+ return completions
[pycomplete.el]
--- pycomplete.el.old Sat Dec 3 00:30:11 2005
+++ pycomplete.el Sun Feb 26 23:51:16 2006
@@ -10,9 +10,21 @@
(defun py-complete () forget- mutability t)) pycomplete (py-symbol- near-point) forget- mutability t) near-point) ) pycomplete symbol to-temp- buffer "*Python completion- list completions))
(interactive)
- (let ((pymacs-
- (insert (pycomplete-
- (py-find-global-
imports)))))
+ (let* ((pymacs-
+ (symbol (py-symbol-
+ (completions
+ (pycomplete-
+ (py-find-global-
imports))))
+ (cond ((null completions) ; no matching
symbol
+ (message "Can't find completion for \"%s\""
symbol)
+ (ding))
+ ((null (cdr completions)) ; sole completion
+ (insert (car completions)))
+ (t
+ (message "Making completion list...")
+ (with-output-
Completions*"
+ (display-
+ (message "Making completion list...%
s" "done")))))
(defun py-find- global- imports ()
(save-excursion