# HG changeset patch # User Masatake YAMATO # Date 1080230498 0 # Node ID f1717549fabeed3c4ff7b57fc0578e3b219d8021 # Parent c862ab7552a433de8d687145fc17a19bb49c518c (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. diff -r c862ab7552a4 -r f1717549fabe lisp/ChangeLog --- a/lisp/ChangeLog Thu Mar 25 15:39:03 2004 +0000 +++ b/lisp/ChangeLog Thu Mar 25 16:01:38 2004 +0000 @@ -1,3 +1,11 @@ +2004-03-26 Masatake YAMATO + + * simple.el (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. + 2004-03-25 Sam Steingold * vc.el (vc-print-log): Fixed a bug in the last patch: diff -r c862ab7552a4 -r f1717549fabe lisp/simple.el --- a/lisp/simple.el Thu Mar 25 15:39:03 2004 +0000 +++ b/lisp/simple.el Thu Mar 25 16:01:38 2004 +0000 @@ -4116,6 +4116,15 @@ ;; This function goes in completion-setup-hook, so that it is called ;; after the text of the completion list buffer is written. +(defface completion-emphasis + '((t (:inherit bold))) + "Face put on the first uncommon character in completions in *Completions* buffer." + :group 'completion) + +(defface completion-de-emphasis + '((t (:inherit default))) + "Face put on the common prefix substring in completions in *Completions* buffer." + :group 'completion) (defun completion-setup-function () (save-excursion @@ -4145,6 +4154,27 @@ (save-match-data (if (minibufferp mainbuf) (setq completion-base-size 0)))) + ;; Put emphasis and de-emphasis faces on completions. + (when completion-base-size + (let ((common-string-length (length + (substring mbuf-contents + completion-base-size))) + (element-start (next-single-property-change + (point-min) + 'mouse-face)) + element-common-end) + (while element-start + (setq element-common-end (+ element-start common-string-length)) + (when (and (get-char-property element-start 'mouse-face) + (get-char-property element-common-end 'mouse-face)) + (put-text-property element-start element-common-end + 'font-lock-face 'completion-de-emphasis) + (put-text-property element-common-end (1+ element-common-end) + 'font-lock-face 'completion-emphasis)) + (setq element-start (next-single-property-change + element-start + 'mouse-face))))) + ;; Insert help string. (goto-char (point-min)) (if (display-mouse-p) (insert (substitute-command-keys