unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Γιώργος Κεραμίδας" <gkeramidas@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Roland Winkler <winkler@gnu.org>, emacs-devel@gnu.org
Subject: Re: Recent read-face patch breaks `M-x customize-face'
Date: Sat, 06 Apr 2013 17:50:46 +0200	[thread overview]
Message-ID: <87obdr1wvd.fsf@kobe.laptop> (raw)
In-Reply-To: <jwv4nfj69lx.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 06 Apr 2013 10:02:52 -0400")

On Sat, 06 Apr 2013 10:02:52 -0400, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>> It would be safer to simply turn any non-list value of `default' into
>>> a one-element list.
>> Makes sense.  Yet the problem here is that customize-face calls
>> read-face-name with DEFAULT having the bogus value "all faces".
>> So customize-face should still be fixed.
>
> Just for the record: the reason for this "all faces" argument is so that
> M-x customize-face prompts with "Customize face (default `all faces'):"

Ah, that's where that message came from!  I see now that no message
about (default `xxx') is displayed at the M-x prompt.  Maybe we have to
change read-face-name a bit.

Right now the doc string of read-face-name says things in two places
that when combined together seem to imply that what customize-face
expects is ok:

    (read-face-name PROMPT &optional DEFAULT MULTIPLE)

    Read one or more face names, defaulting to the face(s) at point.
    PROMPT should be a prompt string; it should not end in a space or
    a colon.

  : The optional argument DEFAULT specifies the default face name(s)
  : to return if the user just types RET.  If its value is non-nil,
  : it should be a list of face names (symbols or strings); in that case,
  : the default return value is the `car' of DEFAULT (if the argument
  : MULTIPLE is non-nil), or DEFAULT (if MULTIPLE is nil).  See below
  : for the meaning of MULTIPLE.

    If DEFAULT is nil, the list of default face names is taken from
    the symbol at point and the `read-face-name' property of the text at point,
    or, if that is nil, from the `face' property of the text at point.

    This function uses `completing-read-multiple' with "[ \t]*,[ \t]*"
    as the separator regexp.  Thus, the user may enter multiple face
  : names, separated by commas.  The optional argument MULTIPLE
  : specifies the form of the return value.  If MULTIPLE is non-nil,
  : return a list of face names; if the user entered just one face
  : name, the return value would be a list of one face name.
  : Otherwise, return a single face name; if the user entered more
  : than one face name, return only the first one.

If we read together the two marked parts they seem to translate to what
customize-face expects, that when DEFAULT is nil and, at the same time,
MULTIPLE is non-nil, a list of all faces is returned.

What `read-face-name' does when DEFAULT is non-nil makes, of course,
sense: display the current value of DEFAULT in the prompt.  But maybe we
should change it to also work correctly if MULTIPLE is non-nil and
DEFAULT is not the name of a symbol.

What was failing was this part of `read-face-name':

  : ;; If we only want one, and the default is more than one,
  : ;; discard the unwanted ones now.
  : (if (and default (not multiple))
  :     (setq default (list (car default))))
  :
  : (if default
  :     (setq default (mapconcat (lambda (f)
  :                                (if (symbolp f) (symbol-name f) f))
  :                              default ", ")))

Maybe we just need to account for the case of:

    (if (and multiple default (not (symbolp default)) (not (consp default)))
      just-use-default-value-as-prompt)

Because what happened here was that `default' was passed as "all faces",
and mapconcat happily tried to filter the string through the lambda
function, resulting in a list of character values, resulting in a call
like this:

  (mapconcat (lambda (x) x)
    (list 97 108 108 32 102 97 99 101 115)
    ", ")

Which of course throws a traceback, when mapconcat tries to look at the
character value `97' as a sequence to concatenate it with the rest.




  reply	other threads:[~2013-04-06 15:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-05 17:50 Recent read-face patch breaks `M-x customize-face' Giorgos Keramidas
2013-04-05 17:52 ` Giorgos Keramidas
2013-04-05 18:56 ` Roland Winkler
2013-04-05 19:00   ` Roland Winkler
2013-04-05 19:04     ` Giorgos Keramidas
2013-04-05 21:40   ` Stefan Monnier
2013-04-06 11:55     ` Roland Winkler
2013-04-06 14:02       ` Stefan Monnier
2013-04-06 15:50         ` Γιώργος Κεραμίδας [this message]
2013-04-06 21:22         ` Roland Winkler
2013-04-07  0:29           ` Stefan Monnier
2013-04-07 21:15             ` Roland Winkler
2013-04-13  1:15         ` Roland Winkler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87obdr1wvd.fsf@kobe.laptop \
    --to=gkeramidas@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=winkler@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).