[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emphasize the character to be typed next in *Completions*

From: Masatake YAMATO
Subject: Re: Emphasize the character to be typed next in *Completions*
Date: Tue, 23 Mar 2004 19:43:06 +0900 (JST)

>     Putting bold face on a character has good balance between too much
>     highlighting and indistinct representation.
>     >From my view, Using box face property or underline face property may
>     be good...but I have not tried yet.
>     Should I provide all versions and make them choose-able?
> Please implement the ideas that you think might be good to use,
> then try them and see if they are good.

I tried box face property and underline face property, but bold was better
than them. With the attached patch, You can try another face.

cvs diff: warning: unrecognized response `access control disabled, clients can 
connect from any host' from cvs server
Index: lisp/simple.el
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.633
diff -u -r1.633 simple.el
--- lisp/simple.el      18 Mar 2004 02:57:32 -0000      1.633
+++ lisp/simple.el      23 Mar 2004 10:37:30 -0000
@@ -4117,6 +4117,16 @@
 ;; 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 used to emphasis the completions in *Completions*.")
+(defcustom completion-emphasis-region 'first-different-character
+  "Region emphasized in the completions in *Completions*."
+  :type '(choice (const first-different-character)
+                (const common-prefix)))
 (defun completion-setup-function ()
     (let ((mainbuf (current-buffer))
@@ -4145,6 +4155,26 @@
          (if (minibufferp mainbuf)
              (setq completion-base-size 0))))
+       ;; Emphasis the first uncommon character in completions.
+      (if completion-base-size
+         (let ((common-string-length (length
+                                      (substring mbuf-contents 
+                                                 completion-base-size)))
+               (element-start (next-single-property-change (point-min) 
+               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))
+               (case completion-emphasis-region
+                 (common-prefix
+                  (put-text-property element-start element-common-end
+                                     'font-lock-face 'completion-emphasis))
+                 (first-different-character
+                  (put-text-property element-common-end (1+ element-common-end)
+                                     'font-lock-face 'completion-emphasis))))
+             (setq element-start (next-single-property-change element-start 
+      ;; Insert help string.
       (goto-char (point-min))
       (if (display-mouse-p)
          (insert (substitute-command-keys

reply via email to

[Prev in Thread] Current Thread [Next in Thread]