changeset 8479:582ac9a744c4

(completion-base-size): New variable. (completion-list-mode): Make it local. (choose-completion): Pass its value to choose-completion-string. (choose-completion-string): New arg base-size. Use that when deciding how much to delete.
author Richard M. Stallman <rms@gnu.org>
date Sun, 07 Aug 1994 18:11:58 +0000
parents 9d3d84a3c3fa
children 7f28030d9529
files lisp/simple.el
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/simple.el	Sun Aug 07 18:10:48 1994 +0000
+++ b/lisp/simple.el	Sun Aug 07 18:11:58 1994 +0000
@@ -2480,10 +2480,15 @@
 ;; Record the buffer that was current when the completion list was requested.
 (defvar completion-reference-buffer)
 
+;; This records the length of the text at the beginning of the buffer
+;; which was not included in the completion.
+(defvar completion-base-size nil)
+
 (defun choose-completion ()
   "Choose the completion that point is in or next to."
   (interactive)
-  (let (beg end completion (buffer completion-reference-buffer))
+  (let (beg end completion (buffer completion-reference-buffer)
+	(base-size completion-base-size))
     (if (and (not (eobp)) (get-text-property (point) 'mouse-face))
 	(setq end (point) beg (1+ (point))))
     (if (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face))
@@ -2501,7 +2506,7 @@
 	(or (window-dedicated-p (selected-window))
 	    (bury-buffer)))
       (select-window owindow))
-    (choose-completion-string completion buffer)))
+    (choose-completion-string completion buffer base-size)))
 
 ;; Delete the longest partial match for STRING
 ;; that can be found before POINT.
@@ -2522,7 +2527,7 @@
       (forward-char 1))
     (delete-char len)))
 
-(defun choose-completion-string (choice &optional buffer)
+(defun choose-completion-string (choice &optional buffer base-size)
   (let ((buffer (or buffer completion-reference-buffer)))
     ;; If BUFFER is a minibuffer, barf unless it's the currently
     ;; active minibuffer.
@@ -2532,7 +2537,9 @@
 	(error "Minibuffer is not active for completion")
       ;; Insert the completion into the buffer where completion was requested.
       (set-buffer buffer)
-      (choose-completion-delete-max-match choice)
+      (if base-size
+	  (delete-region (+ base-size (point-min)) (point))
+	(choose-completion-delete-max-match choice))
       (insert choice)
       (remove-text-properties (- (point) (length choice)) (point)
 			      '(mouse-face nil))
@@ -2554,6 +2561,8 @@
   (use-local-map completion-list-mode-map)
   (setq mode-name "Completion List")
   (setq major-mode 'completion-list-mode)
+  (make-local-variable 'completion-base-size)
+  (setq completion-base-size nil)
   (run-hooks 'completion-list-mode-hook))
 
 (defvar completion-fixup-function nil)