]> git.eshelyaron.com Git - emacs.git/commitdiff
(mouse-choose-completion): New function.
authorRichard M. Stallman <rms@gnu.org>
Tue, 13 Jul 1993 21:33:17 +0000 (21:33 +0000)
committerRichard M. Stallman <rms@gnu.org>
Tue, 13 Jul 1993 21:33:17 +0000 (21:33 +0000)
lisp/mouse.el

index 592d2b794589847ff72790391385c5b83d540b8e..868018436fbc479030e01fa75a749280b9ff20d0 100644 (file)
@@ -840,6 +840,29 @@ and selects that window."
 ;;;!!          (- (car relative-coordinate) (current-column)) " "))
 ;;;!!        ((= (current-column) (car relative-coordinate)) (ding))))))
 \f
+;; 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)))))
+\f
 ;; Font selection.
 
 (defvar x-fixed-font-alist