diff options
| author | Richard M. Stallman | 1994-08-07 18:11:58 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-08-07 18:11:58 +0000 |
| commit | f6b293e3de75211a29c22dff96fefb68d3e2240b (patch) | |
| tree | 2d1b5ac271704f9c1a2cb2a96bc9969d9aa9b281 | |
| parent | 78b19c2c143f4c812a2dbae041e68d7a83eea46c (diff) | |
| download | emacs-f6b293e3de75211a29c22dff96fefb68d3e2240b.tar.gz emacs-f6b293e3de75211a29c22dff96fefb68d3e2240b.zip | |
(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.
| -rw-r--r-- | lisp/simple.el | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 1b384bee41a..02e8f8cef26 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -2480,10 +2480,15 @@ it were the arg to `interactive' (which see) to interactively read the value." | |||
| 2480 | ;; Record the buffer that was current when the completion list was requested. | 2480 | ;; Record the buffer that was current when the completion list was requested. |
| 2481 | (defvar completion-reference-buffer) | 2481 | (defvar completion-reference-buffer) |
| 2482 | 2482 | ||
| 2483 | ;; This records the length of the text at the beginning of the buffer | ||
| 2484 | ;; which was not included in the completion. | ||
| 2485 | (defvar completion-base-size nil) | ||
| 2486 | |||
| 2483 | (defun choose-completion () | 2487 | (defun choose-completion () |
| 2484 | "Choose the completion that point is in or next to." | 2488 | "Choose the completion that point is in or next to." |
| 2485 | (interactive) | 2489 | (interactive) |
| 2486 | (let (beg end completion (buffer completion-reference-buffer)) | 2490 | (let (beg end completion (buffer completion-reference-buffer) |
| 2491 | (base-size completion-base-size)) | ||
| 2487 | (if (and (not (eobp)) (get-text-property (point) 'mouse-face)) | 2492 | (if (and (not (eobp)) (get-text-property (point) 'mouse-face)) |
| 2488 | (setq end (point) beg (1+ (point)))) | 2493 | (setq end (point) beg (1+ (point)))) |
| 2489 | (if (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face)) | 2494 | (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 | (or (window-dedicated-p (selected-window)) | 2506 | (or (window-dedicated-p (selected-window)) |
| 2502 | (bury-buffer))) | 2507 | (bury-buffer))) |
| 2503 | (select-window owindow)) | 2508 | (select-window owindow)) |
| 2504 | (choose-completion-string completion buffer))) | 2509 | (choose-completion-string completion buffer base-size))) |
| 2505 | 2510 | ||
| 2506 | ;; Delete the longest partial match for STRING | 2511 | ;; Delete the longest partial match for STRING |
| 2507 | ;; that can be found before POINT. | 2512 | ;; that can be found before POINT. |
| @@ -2522,7 +2527,7 @@ it were the arg to `interactive' (which see) to interactively read the value." | |||
| 2522 | (forward-char 1)) | 2527 | (forward-char 1)) |
| 2523 | (delete-char len))) | 2528 | (delete-char len))) |
| 2524 | 2529 | ||
| 2525 | (defun choose-completion-string (choice &optional buffer) | 2530 | (defun choose-completion-string (choice &optional buffer base-size) |
| 2526 | (let ((buffer (or buffer completion-reference-buffer))) | 2531 | (let ((buffer (or buffer completion-reference-buffer))) |
| 2527 | ;; If BUFFER is a minibuffer, barf unless it's the currently | 2532 | ;; If BUFFER is a minibuffer, barf unless it's the currently |
| 2528 | ;; active minibuffer. | 2533 | ;; active minibuffer. |
| @@ -2532,7 +2537,9 @@ it were the arg to `interactive' (which see) to interactively read the value." | |||
| 2532 | (error "Minibuffer is not active for completion") | 2537 | (error "Minibuffer is not active for completion") |
| 2533 | ;; Insert the completion into the buffer where completion was requested. | 2538 | ;; Insert the completion into the buffer where completion was requested. |
| 2534 | (set-buffer buffer) | 2539 | (set-buffer buffer) |
| 2535 | (choose-completion-delete-max-match choice) | 2540 | (if base-size |
| 2541 | (delete-region (+ base-size (point-min)) (point)) | ||
| 2542 | (choose-completion-delete-max-match choice)) | ||
| 2536 | (insert choice) | 2543 | (insert choice) |
| 2537 | (remove-text-properties (- (point) (length choice)) (point) | 2544 | (remove-text-properties (- (point) (length choice)) (point) |
| 2538 | '(mouse-face nil)) | 2545 | '(mouse-face nil)) |
| @@ -2554,6 +2561,8 @@ Use \\<completion-list-mode-map>\\[mouse-choose-completion] to select one\ | |||
| 2554 | (use-local-map completion-list-mode-map) | 2561 | (use-local-map completion-list-mode-map) |
| 2555 | (setq mode-name "Completion List") | 2562 | (setq mode-name "Completion List") |
| 2556 | (setq major-mode 'completion-list-mode) | 2563 | (setq major-mode 'completion-list-mode) |
| 2564 | (make-local-variable 'completion-base-size) | ||
| 2565 | (setq completion-base-size nil) | ||
| 2557 | (run-hooks 'completion-list-mode-hook)) | 2566 | (run-hooks 'completion-list-mode-hook)) |
| 2558 | 2567 | ||
| 2559 | (defvar completion-fixup-function nil) | 2568 | (defvar completion-fixup-function nil) |