Commit f6b293e3 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(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.
parent 78b19c2c
...@@ -2480,10 +2480,15 @@ it were the arg to `interactive' (which see) to interactively read the value." ...@@ -2480,10 +2480,15 @@ it were the arg to `interactive' (which see) to interactively read the value."
;; Record the buffer that was current when the completion list was requested. ;; Record the buffer that was current when the completion list was requested.
(defvar completion-reference-buffer) (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 () (defun choose-completion ()
"Choose the completion that point is in or next to." "Choose the completion that point is in or next to."
(interactive) (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)) (if (and (not (eobp)) (get-text-property (point) 'mouse-face))
(setq end (point) beg (1+ (point)))) (setq end (point) beg (1+ (point))))
(if (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face)) (if (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face))
...@@ -2501,7 +2506,7 @@ it were the arg to `interactive' (which see) to interactively read the value." ...@@ -2501,7 +2506,7 @@ it were the arg to `interactive' (which see) to interactively read the value."
(or (window-dedicated-p (selected-window)) (or (window-dedicated-p (selected-window))
(bury-buffer))) (bury-buffer)))
(select-window owindow)) (select-window owindow))
(choose-completion-string completion buffer))) (choose-completion-string completion buffer base-size)))
;; Delete the longest partial match for STRING ;; Delete the longest partial match for STRING
;; that can be found before POINT. ;; that can be found before POINT.
...@@ -2522,7 +2527,7 @@ it were the arg to `interactive' (which see) to interactively read the value." ...@@ -2522,7 +2527,7 @@ it were the arg to `interactive' (which see) to interactively read the value."
(forward-char 1)) (forward-char 1))
(delete-char len))) (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))) (let ((buffer (or buffer completion-reference-buffer)))
;; If BUFFER is a minibuffer, barf unless it's the currently ;; If BUFFER is a minibuffer, barf unless it's the currently
;; active minibuffer. ;; active minibuffer.
...@@ -2532,7 +2537,9 @@ it were the arg to `interactive' (which see) to interactively read the value." ...@@ -2532,7 +2537,9 @@ it were the arg to `interactive' (which see) to interactively read the value."
(error "Minibuffer is not active for completion") (error "Minibuffer is not active for completion")
;; Insert the completion into the buffer where completion was requested. ;; Insert the completion into the buffer where completion was requested.
(set-buffer buffer) (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) (insert choice)
(remove-text-properties (- (point) (length choice)) (point) (remove-text-properties (- (point) (length choice)) (point)
'(mouse-face nil)) '(mouse-face nil))
...@@ -2554,6 +2561,8 @@ Use \\<completion-list-mode-map>\\[mouse-choose-completion] to select one\ ...@@ -2554,6 +2561,8 @@ Use \\<completion-list-mode-map>\\[mouse-choose-completion] to select one\
(use-local-map completion-list-mode-map) (use-local-map completion-list-mode-map)
(setq mode-name "Completion List") (setq mode-name "Completion List")
(setq major-mode 'completion-list-mode) (setq major-mode 'completion-list-mode)
(make-local-variable 'completion-base-size)
(setq completion-base-size nil)
(run-hooks 'completion-list-mode-hook)) (run-hooks 'completion-list-mode-hook))
(defvar completion-fixup-function nil) (defvar completion-fixup-function nil)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment