From f936ae0677ebd55a815643f3803e85c4c24f06a5 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Tue, 13 Jul 1993 21:33:17 +0000 Subject: [PATCH] (mouse-choose-completion): New function. --- lisp/mouse.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lisp/mouse.el b/lisp/mouse.el index 592d2b7945..868018436f 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -840,6 +840,29 @@ and selects that window." ;;;!! (- (car relative-coordinate) (current-column)) " ")) ;;;!! ((= (current-column) (car relative-coordinate)) (ding)))))) +;; Choose a completion with the mouse. + +(defun mouse-choose-completion (event) + (interactive "e") + (let (choice) + (save-excursion + (set-buffer (window-buffer (posn-window (event-start event)))) + (save-excursion + (goto-char (posn-point (event-start event))) + (skip-chars-backward "^ \t\n") + (let ((beg (point))) + (skip-chars-forward "^ \t\n") + (setq choice (buffer-substring beg (point)))))) + (save-excursion + (set-buffer (window-buffer (minibuffer-window))) + (goto-char (max (point-min) (- (point-max) (length choice)))) + (while (and (not (eobp)) + (let ((tail (buffer-substring (point) (point-max)))) + (not (string= tail (substring choice 0 (length tail)))))) + (forward-char 1)) + (insert choice) + (delete-region (point) (point-max))))) + ;; Font selection. (defvar x-fixed-font-alist -- 2.20.1