]> code.delx.au - gnu-emacs/blobdiff - lisp/pcomplete.el
Merge changes from emacs-23 branch
[gnu-emacs] / lisp / pcomplete.el
index 65c05ae748710f9efa314245efb13a6365caaf96..0f4d5e42d78b6f12f08556715cbfe7993e69a739 100644 (file)
@@ -1,7 +1,6 @@
 ;;; pcomplete.el --- programmable completion
 
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2011 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Keywords: processes abbrev
@@ -444,12 +443,14 @@ in the same way as TABLE completes strings of the form (concat S2 S)."
 ;; I don't think such commands are usable before first setting up buffer-local
 ;; variables to parse args, so there's no point autoloading it.
 ;; ;;;###autoload
-(defun pcomplete-std-complete ()
+(defun pcomplete-completions-at-point ()
   "Provide standard completion using pcomplete's completion tables.
 Same as `pcomplete' but using the standard completion UI."
-  (interactive)
   ;; FIXME: it only completes the text before point, whereas the
   ;; standard UI may also consider text after point.
+  ;; FIXME: the `pcomplete' UI may be used internally during
+  ;; pcomplete-completions and then throw to `pcompleted', thus
+  ;; imposing the pcomplete UI over the standard UI.
   (catch 'pcompleted
     (let* ((pcomplete-stub)
            pcomplete-seen pcomplete-norm-func
@@ -516,7 +517,7 @@ Same as `pcomplete' but using the standard completion UI."
                                (directory-file-name f))
                       pcomplete-seen))))))
 
-      (completion-in-region
+      (list
        beg (point)
        ;; Add a space at the end of completion.  Use a terminator-regexp
        ;; that never matches since the terminator cannot appear
@@ -527,7 +528,14 @@ Same as `pcomplete' but using the standard completion UI."
                           (cons pcomplete-termination-string
                                 "\\`a\\`")
                           table))
-       pred))))
+       :predicate pred))))
+
+ ;; I don't think such commands are usable before first setting up buffer-local
+ ;; variables to parse args, so there's no point autoloading it.
+ ;; ;;;###autoload
+(defun pcomplete-std-complete ()
+  (let ((completion-at-point-functions '(pcomplete-completions-at-point)))
+    (completion-at-point)))
 
 ;;; Pcomplete's native UI.
 
@@ -544,7 +552,7 @@ completion functions list (it should occur fairly early in the list)."
                                pcomplete-expand-and-complete
                                pcomplete-reverse)))
       (progn
-       (delete-backward-char pcomplete-last-completion-length)
+       (delete-char (- pcomplete-last-completion-length))
        (if (eq this-command 'pcomplete-reverse)
            (progn
               (push (car (last pcomplete-current-completions))
@@ -607,7 +615,7 @@ This will modify the current buffer."
     (pcomplete)
     (when (and pcomplete-current-completions
               (> (length pcomplete-current-completions) 0)) ;??
-      (delete-backward-char pcomplete-last-completion-length)
+      (delete-char (- pcomplete-last-completion-length))
       (while pcomplete-current-completions
        (unless (pcomplete-insert-entry
                 "" (car pcomplete-current-completions) t
@@ -630,7 +638,7 @@ This will modify the current buffer."
   (when (and pcomplete-cycle-completions
             pcomplete-current-completions
             (eq last-command 'pcomplete-argument))
-    (delete-backward-char pcomplete-last-completion-length)
+    (delete-char (- pcomplete-last-completion-length))
     (setq pcomplete-current-completions nil
          pcomplete-last-completion-raw nil))
   (let ((pcomplete-show-list t))
@@ -1198,7 +1206,7 @@ Returns non-nil if a space was appended at the end."
       ;; FIXME: Here we presume that quoting `stub' gives us the exact
       ;; text in the buffer before point, which is not guaranteed;
       ;; e.g. it is not the case in eshell when completing ${FOO}tm[TAB].
-      (delete-backward-char (length (pcomplete-quote-argument stub)))
+      (delete-char (- (length (pcomplete-quote-argument stub))))
       ;; if there is already a backslash present to handle the first
       ;; character, don't bother quoting it
       (when (eq (char-before) ?\\)
@@ -1382,5 +1390,4 @@ Returns the resultant list."
 
 (provide 'pcomplete)
 
-;; arch-tag: ae32ef2d-dbed-4244-8b0f-cf5a2a3b07a4
 ;;; pcomplete.el ends here