emacs-devel
[Top][All Lists]
Advanced

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

Emphasize the character to be typed next in *Completions*


From: Masatake YAMATO
Subject: Emphasize the character to be typed next in *Completions*
Date: Mon, 22 Mar 2004 00:13:21 +0900 (JST)

This patch improves visual feedback of *Completions* buffer. So 
the user can know the character to be typed next in mini buffer
more easily.

Consider you type "C-x C-f ChangeLog. tab tab" at emacs/lisp directory.
The minibuffer looks like:

    Find file: ~/hack/emacs/lisp/ChangeLog

and *Completions* buffer looks like:

    Click <mouse-2> on a completion to select it.
    In this buffer, type RET to select the completion near point.

    Possible completions are:
    ChangeLog.1                    ChangeLog.10
    ChangeLog.2                    ChangeLog.3
    ChangeLog.4                    ChangeLog.5
    ChangeLog.6                    ChangeLog.7
    ChangeLog.8                    ChangeLog.9

You will look into *Completions* buffer to find the file
name which you want to load into emacs.

My patch make the first different character in all completions
bold. In above example, characters marked by ^ is made bold.

    ChangeLog.1                    ChangeLog.10
              ^                              ^
    ChangeLog.2                    ChangeLog.3
              ^                              ^
    ChangeLog.4                    ChangeLog.5
              ^                              ^
    ChangeLog.6                    ChangeLog.7
              ^                              ^
    ChangeLog.8                    ChangeLog.9
              ^                              ^
So the user can know which key should be typed to choose
a completion easily.

Masatake YAMATO

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      21 Mar 2004 14:53:54 -0000
@@ -4145,6 +4145,19 @@
        (save-match-data
          (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) 
'mouse-face))
+               element-common-start)
+           (while element-start
+             (setq element-common-start (+ element-start common-string-length))
+             (when (and (get-char-property element-start 'mouse-face)
+                        (get-char-property element-common-start 'mouse-face))
+               (put-text-property element-common-start (+ element-common-start 
1) 'face 'bold))
+             (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




reply via email to

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