comparison lisp/simple.el @ 7333:7a0395228878

(choose-completion-string): Barf if completing into a minibuffer but it's not now active.
author Richard M. Stallman <rms@gnu.org>
date Thu, 05 May 1994 05:27:59 +0000
parents 3497b7f6f0e7
children 451602bf12e4
comparison
equal deleted inserted replaced
7332:e30a34bfc536 7333:7a0395228878
2459 (forward-char 1)) 2459 (forward-char 1))
2460 (delete-char len))) 2460 (delete-char len)))
2461 2461
2462 (defun choose-completion-string (choice &optional buffer) 2462 (defun choose-completion-string (choice &optional buffer)
2463 (let ((buffer (or buffer completion-reference-buffer))) 2463 (let ((buffer (or buffer completion-reference-buffer)))
2464 (set-buffer buffer) 2464 ;; If BUFFER is a minibuffer, barf unless it's the currently
2465 (choose-completion-delete-max-match choice) 2465 ;; active minibuffer.
2466 (insert choice) 2466 (if (and (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name buffer))
2467 ;; Update point in the window that BUFFER is showing in. 2467 (or (not (minibuffer-window-active-p (minibuffer-window)))
2468 (let ((window (get-buffer-window buffer t))) 2468 (not (equal buffer (window-buffer (minibuffer-window))))))
2469 (set-window-point window (point))) 2469 (error "Minibuffer is not active for completion")
2470 (and (equal buffer (window-buffer (minibuffer-window))) 2470 ;; Insert the completion into the buffer where completion was requested.
2471 (minibuffer-complete-and-exit)))) 2471 (set-buffer buffer)
2472 (choose-completion-delete-max-match choice)
2473 (insert choice)
2474 ;; Update point in the window that BUFFER is showing in.
2475 (let ((window (get-buffer-window buffer t)))
2476 (set-window-point window (point)))
2477 ;; If completing for the minibuffer, exit it with this choice.
2478 (and (equal buffer (window-buffer (minibuffer-window)))
2479 (minibuffer-complete-and-exit)))))
2472 2480
2473 (defun completion-list-mode () 2481 (defun completion-list-mode ()
2474 "Major mode for buffers showing lists of possible completions. 2482 "Major mode for buffers showing lists of possible completions.
2475 Type \\<completion-list-mode-map>\\[choose-completion] in the completion list\ 2483 Type \\<completion-list-mode-map>\\[choose-completion] in the completion list\
2476 to select the completion near point. 2484 to select the completion near point.