unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Completion of face names
@ 2005-06-10 13:29 Kim F. Storm
  2005-06-10 14:09 ` Miles Bader
  2005-06-11 12:18 ` Richard Stallman
  0 siblings, 2 replies; 7+ messages in thread
From: Kim F. Storm @ 2005-06-10 13:29 UTC (permalink / raw)



With the recent addition of zillions of face aliases to 
fix the inappropriate "-face" suffixes, face name completion
now shows twice as many entries as before.

Try this:

M-x customize-face RET custom TAB


What about adding a predicate to face name completion
that ignores face aliases, and thus presents only
the proper names without the "-face" suffix?

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Completion of face names
  2005-06-10 13:29 Completion of face names Kim F. Storm
@ 2005-06-10 14:09 ` Miles Bader
  2005-06-10 15:58   ` Stefan Monnier
  2005-06-11 12:18 ` Richard Stallman
  1 sibling, 1 reply; 7+ messages in thread
From: Miles Bader @ 2005-06-10 14:09 UTC (permalink / raw)
  Cc: emacs-devel

On 6/10/05, Kim F. Storm <storm@cua.dk> wrote:
> What about adding a predicate to face name completion
> that ignores face aliases, and thus presents only
> the proper names without the "-face" suffix?

My thought that was it might be good to have it only complete to
"real" names, but accept aliases if you typed them explicitly; can
completion do this sort of thing?

-Miles
-- 
Do not taunt Happy Fun Ball.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Completion of face names
  2005-06-10 14:09 ` Miles Bader
@ 2005-06-10 15:58   ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2005-06-10 15:58 UTC (permalink / raw)
  Cc: Kim F. Storm, emacs-devel, miles

>> What about adding a predicate to face name completion
>> that ignores face aliases, and thus presents only
>> the proper names without the "-face" suffix?

> My thought that was it might be good to have it only complete to
> "real" names, but accept aliases if you typed them explicitly; can
> completion do this sort of thing?

There's the REQUIRE-MATCH argument to completing read.
But if you mean not just to accept but to even complete aliases (if typed
explicitly), then, yes, you can also do that:

(defmacro complete-in-turn (a b)
  "Create a completion table that first tries completion in A and then in B.
A and B should not be costly (or side-effecting) expressions."
  `(lambda (string predicate mode)
     (cond
      ((eq mode t)
       (or (all-completions string ,a predicate)
	   (all-completions string ,b predicate)))
      ((eq mode nil)
       (or (try-completion string ,a predicate)
	   (try-completion string ,b predicate)))
      (t
       (or (test-completion string ,a predicate)
	   (test-completion string ,b predicate))))))

(completing-read "prompt"
                 (complete-in-turn <non-alias-table> <complete-table>)
                 ...)

I'm using it right now in the interactive spec of
set-buffer-file-coding-system (see below).


        Stefan


  ;; FIXME: provide a useful default (e.g. the one that
  ;; select-safe-coding-system would have chosen, or the next best one if
  ;; it's already the current coding system).
  (interactive
   (let* ((bcss (find-coding-systems-region (point-min) (point-max)))
          (bcss-table (append '("dos" "unix" "mac")
                              (unless (equal bcss '(undecided))
                                (mapcar 'symbol-name
                                        (sanitize-coding-system-list bcss)))))
          (css-table
           (unless (equal bcss '(undecided))
             (delq nil (mapcar (lambda (cs)
                                 (if (memq (coding-system-base cs) bcss)
                                     (symbol-name cs)))
                               coding-system-list))))
          (combined-table (complete-in-turn css-table coding-system-alist))
          (auto-cs
           (unless find-file-literally
             (save-excursion
               (save-restriction
                 (widen)
                 (goto-char (point-min))
                 (set-auto-coding buffer-file-name (buffer-size))))))
          (cs (completing-read (format "Coding system for saving file (default, %s): " auto-cs)
                               (complete-in-turn bcss-table combined-table)
                               nil t nil 'coding-system-history
                               (if auto-cs (symbol-name auto-cs)))))
     (list (unless (zerop (length cs)) (intern cs))
           current-prefix-arg)))

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Completion of face names
  2005-06-10 13:29 Completion of face names Kim F. Storm
  2005-06-10 14:09 ` Miles Bader
@ 2005-06-11 12:18 ` Richard Stallman
  2005-06-12 16:58   ` Stefan Monnier
  1 sibling, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2005-06-11 12:18 UTC (permalink / raw)
  Cc: emacs-devel

    What about adding a predicate to face name completion
    that ignores face aliases, and thus presents only
    the proper names without the "-face" suffix?

That would be a good idea.  Even better--if there is at least one
completion that is a real face name, it would ignore aliases,
but if there are no completions that are real face names, it would
consider aliases.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Completion of face names
  2005-06-11 12:18 ` Richard Stallman
@ 2005-06-12 16:58   ` Stefan Monnier
  2005-06-13 15:02     ` Richard Stallman
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2005-06-12 16:58 UTC (permalink / raw)
  Cc: emacs-devel, Kim F. Storm

>     What about adding a predicate to face name completion
>     that ignores face aliases, and thus presents only
>     the proper names without the "-face" suffix?

> That would be a good idea.  Even better--if there is at least one
> completion that is a real face name, it would ignore aliases,
> but if there are no completions that are real face names, it would
> consider aliases.

That's exactly what my complete-in-turn macro does.


        Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Completion of face names
  2005-06-12 16:58   ` Stefan Monnier
@ 2005-06-13 15:02     ` Richard Stallman
  2005-06-13 20:48       ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2005-06-13 15:02 UTC (permalink / raw)
  Cc: emacs-devel, storm

    > That would be a good idea.  Even better--if there is at least one
    > completion that is a real face name, it would ignore aliases,
    > but if there are no completions that are real face names, it would
    > consider aliases.

    That's exactly what my complete-in-turn macro does.

That's good.  Would you please install it?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Completion of face names
  2005-06-13 15:02     ` Richard Stallman
@ 2005-06-13 20:48       ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2005-06-13 20:48 UTC (permalink / raw)
  Cc: emacs-devel, storm

>> That would be a good idea.  Even better--if there is at least one
>> completion that is a real face name, it would ignore aliases,
>> but if there are no completions that are real face names, it would
>> consider aliases.

>     That's exactly what my complete-in-turn macro does.

> That's good.  Would you please install it?

Done,


        Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-06-13 20:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-10 13:29 Completion of face names Kim F. Storm
2005-06-10 14:09 ` Miles Bader
2005-06-10 15:58   ` Stefan Monnier
2005-06-11 12:18 ` Richard Stallman
2005-06-12 16:58   ` Stefan Monnier
2005-06-13 15:02     ` Richard Stallman
2005-06-13 20:48       ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).