]> code.delx.au - gnu-emacs/blobdiff - lisp/complete.el
(rlogin): Use format, not concat, to generate numeric buffer names.
[gnu-emacs] / lisp / complete.el
index daeac1f3bfdef55a05808f8e51f3fd2fa33917d9..fa559e91395c223ddaadc5254daf2d30698e15f8 100644 (file)
@@ -228,7 +228,7 @@ See `PC-complete' for details."
           (if (or (eq flag 'complete)
                   (not minibuffer-completion-confirm))
               (exit-minibuffer)
-            (PC-temp-minibuffer-message " (Confirm)"))))))
+            (PC-temp-minibuffer-message " [Confirm]"))))))
 
 
 (defun PC-completion-help ()
@@ -263,6 +263,7 @@ See `PC-complete' for details."
         (filename (memq table '(read-file-name-internal
                                 read-directory-name-internal)))
         (dirname nil)
+        dirlength
         (str (buffer-substring beg end))
         (incname (and filename (string-match "<\\([^\"<>]*\\)>?$" str)))
         (ambig nil)
@@ -278,6 +279,13 @@ See `PC-complete' for details."
             (PC-is-complete-p str table pred))
        'complete
 
+      ;; Record how many characters at the beginning are not included
+      ;; in completion.
+      (setq dirlength
+           (if filename
+               (length (file-name-directory str))
+             0))
+
       ;; Do substitutions in directory names
       (and filename
           (not (equal str (setq p (substitute-in-file-name str))))
@@ -392,10 +400,10 @@ See `PC-complete' for details."
              (PC-do-completion 'word))
          (beep)
          (PC-temp-minibuffer-message (if ambig
-                                         " (Ambiguous dir name)"
+                                         " [Ambiguous dir name]"
                                        (if (eq mode 'help)
-                                           " (No completions)"
-                                         " (No match)")))
+                                           " [No completions]"
+                                         " [No match]")))
          nil))
 
        ;; More than one valid completion found
@@ -433,12 +441,12 @@ See `PC-complete' for details."
        (while (and p
                    (not (equal (car p) basestr)))
          (setq p (cdr p)))
-       (if p
-
-           (progn
-             (if (null mode)
-                 (PC-temp-minibuffer-message " (Complete, but not unique)"))
-             t)
+       (and p (null mode)
+            (PC-temp-minibuffer-message " [Complete, but not unique]"))
+       (if (and p
+                (not (and (null mode)
+                          (eq this-command last-command))))
+           t
 
          ;; If ambiguous, try for a partial completion
          (let ((improved nil)
@@ -524,15 +532,21 @@ See `PC-complete' for details."
                (if (or completion-auto-help
                        (eq mode 'help))
                    (with-output-to-temp-buffer "*Completions*"
-                     (display-completion-list (sort helpposs 'string-lessp)))
-                 (PC-temp-minibuffer-message " (Next char not unique)"))
+                     (display-completion-list (sort helpposs 'string-lessp))
+                     (save-excursion
+                       (set-buffer standard-output)
+                       ;; Record which part of the buffer we are completing
+                       ;; so that choosing a completion from the list
+                       ;; knows how much old text to replace.
+                       (setq completion-base-size dirlength)))
+                 (PC-temp-minibuffer-message " [Next char not unique]"))
                nil)))))
 
        ;; Only one possible completion
        (t
        (if (equal basestr (car poss))
            (if (null mode)
-               (PC-temp-minibuffer-message " (Sole completion)"))
+               (PC-temp-minibuffer-message " [Sole completion]"))
          (delete-region beg end)
          (insert (format "%s"
                          (if filename