Mercurial > emacs
comparison lisp/simple.el @ 54554:f1717549fabe
(completion-setup-function): Emphasize the first uncommon characters in the completions;and de-emphasize the common prefix substrings.
(completion-emphasis): New face.
(completion-de-emphasis): New face.
author | Masatake YAMATO <jet@gyve.org> |
---|---|
date | Thu, 25 Mar 2004 16:01:38 +0000 |
parents | 37dfb033f901 |
children | 2a24736eb420 0d3eea319893 |
comparison
equal
deleted
inserted
replaced
54553:c862ab7552a4 | 54554:f1717549fabe |
---|---|
4114 command to display the completion list buffer was run. | 4114 command to display the completion list buffer was run. |
4115 The completion list buffer is available as the value of `standard-output'.") | 4115 The completion list buffer is available as the value of `standard-output'.") |
4116 | 4116 |
4117 ;; This function goes in completion-setup-hook, so that it is called | 4117 ;; This function goes in completion-setup-hook, so that it is called |
4118 ;; after the text of the completion list buffer is written. | 4118 ;; after the text of the completion list buffer is written. |
4119 (defface completion-emphasis | |
4120 '((t (:inherit bold))) | |
4121 "Face put on the first uncommon character in completions in *Completions* buffer." | |
4122 :group 'completion) | |
4123 | |
4124 (defface completion-de-emphasis | |
4125 '((t (:inherit default))) | |
4126 "Face put on the common prefix substring in completions in *Completions* buffer." | |
4127 :group 'completion) | |
4119 | 4128 |
4120 (defun completion-setup-function () | 4129 (defun completion-setup-function () |
4121 (save-excursion | 4130 (save-excursion |
4122 (let ((mainbuf (current-buffer)) | 4131 (let ((mainbuf (current-buffer)) |
4123 (mbuf-contents (minibuffer-contents))) | 4132 (mbuf-contents (minibuffer-contents))) |
4143 (- (point) (minibuffer-prompt-end)))) | 4152 (- (point) (minibuffer-prompt-end)))) |
4144 ;; Otherwise, in minibuffer, the whole input is being completed. | 4153 ;; Otherwise, in minibuffer, the whole input is being completed. |
4145 (save-match-data | 4154 (save-match-data |
4146 (if (minibufferp mainbuf) | 4155 (if (minibufferp mainbuf) |
4147 (setq completion-base-size 0)))) | 4156 (setq completion-base-size 0)))) |
4157 ;; Put emphasis and de-emphasis faces on completions. | |
4158 (when completion-base-size | |
4159 (let ((common-string-length (length | |
4160 (substring mbuf-contents | |
4161 completion-base-size))) | |
4162 (element-start (next-single-property-change | |
4163 (point-min) | |
4164 'mouse-face)) | |
4165 element-common-end) | |
4166 (while element-start | |
4167 (setq element-common-end (+ element-start common-string-length)) | |
4168 (when (and (get-char-property element-start 'mouse-face) | |
4169 (get-char-property element-common-end 'mouse-face)) | |
4170 (put-text-property element-start element-common-end | |
4171 'font-lock-face 'completion-de-emphasis) | |
4172 (put-text-property element-common-end (1+ element-common-end) | |
4173 'font-lock-face 'completion-emphasis)) | |
4174 (setq element-start (next-single-property-change | |
4175 element-start | |
4176 'mouse-face))))) | |
4177 ;; Insert help string. | |
4148 (goto-char (point-min)) | 4178 (goto-char (point-min)) |
4149 (if (display-mouse-p) | 4179 (if (display-mouse-p) |
4150 (insert (substitute-command-keys | 4180 (insert (substitute-command-keys |
4151 "Click \\[mouse-choose-completion] on a completion to select it.\n"))) | 4181 "Click \\[mouse-choose-completion] on a completion to select it.\n"))) |
4152 (insert (substitute-command-keys | 4182 (insert (substitute-command-keys |