]> git.eshelyaron.com Git - emacs.git/commitdiff
(completion-setup-function): Put on mouse-face prop
authorRichard M. Stallman <rms@gnu.org>
Mon, 11 Jul 1994 21:25:19 +0000 (21:25 +0000)
committerRichard M. Stallman <rms@gnu.org>
Mon, 11 Jul 1994 21:25:19 +0000 (21:25 +0000)
even if no window-system.  Call completion-fixup-function if not nil.
(completion-fixup-function): New variable.
(choose-completion): Use mouse-face properties to find string to use.

lisp/simple.el

index 5302b27dfb26396975f95cd2345d5ec895d94a2e..015074bc6fa7c7c3cea16cab10f9be670f217b51 100644 (file)
@@ -2477,18 +2477,14 @@ it were the arg to `interactive' (which see) to interactively read the value."
   "Choose the completion that point is in or next to."
   (interactive)
   (let (beg end)
-    (skip-chars-forward "^ \t\n")
-    (while (looking-at " [^ \n\t]")
-      (forward-char 1)
-      (skip-chars-forward "^ \t\n"))
-    (setq end (point))
-    (skip-chars-backward "^ \t\n")
-    (while (and (= (preceding-char) ?\ )
-               (not (and (> (point) (1+ (point-min)))
-                         (= (char-after (- (point) 2)) ?\ ))))
-      (backward-char 1)
-      (skip-chars-backward "^ \t\n"))
-    (setq beg (point))
+    (if (and (not (eobp)) (get-text-property (point) 'mouse-face))
+       (setq end (point) beg (1+ (point))))
+    (if (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face))
+       (setq end (1- (point)) beg(point)))
+    (if (null beg)
+       (error "No completion here"))
+    (setq beg (previous-single-property-change beg 'mouse-face))
+    (setq end (next-single-property-change end 'mouse-face))
     (choose-completion-string (buffer-substring beg end))))
 
 ;; Delete the longest partial match for STRING
@@ -2544,6 +2540,8 @@ Use \\<completion-list-mode-map>\\[mouse-choose-completion] to select one\
   (setq major-mode 'completion-list-mode)
   (run-hooks 'completion-list-mode-hook))
 
+(defvar completion-fixup-function nil)
+
 (defun completion-setup-function ()
   (save-excursion
     (let ((mainbuf (current-buffer)))
@@ -2559,10 +2557,13 @@ Use \\<completion-list-mode-map>\\[mouse-choose-completion] to select one\
               "In this buffer, type \\[choose-completion] to \
 select the completion near point.\n\n"))
       (forward-line 1)
-      (if window-system
-         (while (re-search-forward "[^ \t\n]+\\( [^ \t\n]+\\)*" nil t)
-           (put-text-property (match-beginning 0) (point)
-                              'mouse-face 'highlight))))))
+      (while (re-search-forward "[^ \t\n]+\\( [^ \t\n]+\\)*" nil t)
+       (let ((beg (match-beginning 0))
+             (end (point)))
+         (if completion-fixup-function
+             (funcall completion-fixup-function))
+         (put-text-property beg (point) 'mouse-face 'highlight)
+         (goto-char end))))))
 
 (add-hook 'completion-setup-hook 'completion-setup-function)
 \f