changeset 8203:7f13bc5470d9

(completion-setup-function): Put on mouse-face prop 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.
author Richard M. Stallman <rms@gnu.org>
date Mon, 11 Jul 1994 21:25:19 +0000
parents 80350a95921a
children f5c8a4e8c4a5
files lisp/simple.el
diffstat 1 files changed, 17 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/simple.el	Mon Jul 11 20:36:53 1994 +0000
+++ b/lisp/simple.el	Mon Jul 11 21:25:19 1994 +0000
@@ -2477,18 +2477,14 @@
   "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 @@
   (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 @@
 	       "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)