aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-07-11 21:25:19 +0000
committerRichard M. Stallman1994-07-11 21:25:19 +0000
commit6096f3628616096e895dd4b78ccbd613ff937e6f (patch)
tree211b61364a467f7f134143ab15ddd107160973c6
parente89da28d298a5382772fef9707e82dca07a71ed1 (diff)
downloademacs-6096f3628616096e895dd4b78ccbd613ff937e6f.tar.gz
emacs-6096f3628616096e895dd4b78ccbd613ff937e6f.zip
(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.
-rw-r--r--lisp/simple.el33
1 files changed, 17 insertions, 16 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 5302b27dfb2..015074bc6fa 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2477,18 +2477,14 @@ it were the arg to `interactive' (which see) to interactively read the value."
2477 "Choose the completion that point is in or next to." 2477 "Choose the completion that point is in or next to."
2478 (interactive) 2478 (interactive)
2479 (let (beg end) 2479 (let (beg end)
2480 (skip-chars-forward "^ \t\n") 2480 (if (and (not (eobp)) (get-text-property (point) 'mouse-face))
2481 (while (looking-at " [^ \n\t]") 2481 (setq end (point) beg (1+ (point))))
2482 (forward-char 1) 2482 (if (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face))
2483 (skip-chars-forward "^ \t\n")) 2483 (setq end (1- (point)) beg(point)))
2484 (setq end (point)) 2484 (if (null beg)
2485 (skip-chars-backward "^ \t\n") 2485 (error "No completion here"))
2486 (while (and (= (preceding-char) ?\ ) 2486 (setq beg (previous-single-property-change beg 'mouse-face))
2487 (not (and (> (point) (1+ (point-min))) 2487 (setq end (next-single-property-change end 'mouse-face))
2488 (= (char-after (- (point) 2)) ?\ ))))
2489 (backward-char 1)
2490 (skip-chars-backward "^ \t\n"))
2491 (setq beg (point))
2492 (choose-completion-string (buffer-substring beg end)))) 2488 (choose-completion-string (buffer-substring beg end))))
2493 2489
2494;; Delete the longest partial match for STRING 2490;; Delete the longest partial match for STRING
@@ -2544,6 +2540,8 @@ Use \\<completion-list-mode-map>\\[mouse-choose-completion] to select one\
2544 (setq major-mode 'completion-list-mode) 2540 (setq major-mode 'completion-list-mode)
2545 (run-hooks 'completion-list-mode-hook)) 2541 (run-hooks 'completion-list-mode-hook))
2546 2542
2543(defvar completion-fixup-function nil)
2544
2547(defun completion-setup-function () 2545(defun completion-setup-function ()
2548 (save-excursion 2546 (save-excursion
2549 (let ((mainbuf (current-buffer))) 2547 (let ((mainbuf (current-buffer)))
@@ -2559,10 +2557,13 @@ Use \\<completion-list-mode-map>\\[mouse-choose-completion] to select one\
2559 "In this buffer, type \\[choose-completion] to \ 2557 "In this buffer, type \\[choose-completion] to \
2560select the completion near point.\n\n")) 2558select the completion near point.\n\n"))
2561 (forward-line 1) 2559 (forward-line 1)
2562 (if window-system 2560 (while (re-search-forward "[^ \t\n]+\\( [^ \t\n]+\\)*" nil t)
2563 (while (re-search-forward "[^ \t\n]+\\( [^ \t\n]+\\)*" nil t) 2561 (let ((beg (match-beginning 0))
2564 (put-text-property (match-beginning 0) (point) 2562 (end (point)))
2565 'mouse-face 'highlight)))))) 2563 (if completion-fixup-function
2564 (funcall completion-fixup-function))
2565 (put-text-property beg (point) 'mouse-face 'highlight)
2566 (goto-char end))))))
2566 2567
2567(add-hook 'completion-setup-hook 'completion-setup-function) 2568(add-hook 'completion-setup-hook 'completion-setup-function)
2568 2569