[Top][All Lists]

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

RE: propose adding Icicles to Emacs

From: Drew Adams
Subject: RE: propose adding Icicles to Emacs
Date: Tue, 19 Jun 2007 15:47:48 -0700

> >     I find it _very_ helpful. What you say is true for only a few corner
> >     cases, in general.
> > The current code handles all cases acceptably.  It sounds like your
> > method is better in most cases, but much worse in a few cases.
> > As it is, we cannot use it.
> Most like we'd want the list of faces to take the form of a list of
> face-names (displayed with the default face) together with a constant text
> (such as "sample") where that constant text is displayed with the face.

OK, here is what I've done, for Icicles (see attached screenshots) -

(defcustom icicle-WYSIWYG-Completions-flag 4
  "*Non-nil means to show candidates in *Completions* using WYSIWYG.
This means, for instance, showing face names using their own faces."
  :type '(choice
          (integer :tag "Show candidate plus a WYSIWYG swatch of \
                         width..." :value 4)
          (const   :tag "Show candidate itself using WYSIWYG" t)
          (const   :tag "Show candidate as is, with no text \
                         properties" nil))
  :group 'Icicles-Completions-Display)

By default, `read-face-name' shows the face name without a face, followed by
a small swatch in the face - per Stefan's suggestion. By customizing
`icicle-WYSIWYG-Completions-flag', you can alternatively remove the color
swatch (no WYSIWYG display) or show the face name itself using the face,

Here is the new definition of `icicle-make-face-candidate', which formats
the face-name candidates:

(defun icicle-make-face-candidate (face)
  "Return a completion candidate for FACE."
  (if (wholenump icicle-WYSIWYG-Completions-flag)
      (let ((swatch (make-string icicle-WYSIWYG-Completions-flag ?M)))
        (put-text-property 0 icicle-WYSIWYG-Completions-flag
                           'face face swatch)
        (list (list (symbol-name face) swatch)))
    (let ((face-name (copy-sequence (symbol-name face))))
      (when icicle-WYSIWYG-Completions-flag
        (put-text-property 0 (length face-name) 'face face face-name))
      (list face-name))))

FWIW, I think the `read-face-name' code for Emacs 22 is a bit of a mess. It
takes an optional MULTIPLE argument, but this option is not treated as a
separate case. Instead, all of the code acts as if MULTIPLE were non-nil,
and then things that are not needed are ignored or stripped away. I've
cleaned this up a bit in the Icicles version.

Note: Icicles makes no special use of the MULTIPLE case. In particular, no
WYSIWYG treatment is done when MULTIPLE is provided. This is partly because
I don't have the time or will to wade through the crm.el code and try to
figure out how Icicles might deal with trying to redefine
`completing-read-multiple' to take advantage of Icicles multi-completions.
Icicles doesn't need this, and, if Icicles-like behavior is added to Emacs
one day, it is unclear how and whether Richard will want to do that.

In the Icicles definition of `read-face-name' for Emacs 22, all I've done,
besides cleaning up the treatment of MULTIPLE a bit (which has nothing to do
with Icicles and should be done anyway, IMO), is (1) add Icicles bindings
for multi-completion treatment and (2) use `icicle-make-face-candidate' to
create the candidates. These are trivial changes. The rest is the same
(ugly) code. The code is here:

Attachment: read-face-name-swatch-4.png
Description: PNG image

Attachment: read-face-name-whole-face.png
Description: PNG image

reply via email to

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