Subject: bug#32562: closed (Re: bug#32562: 26; `read-char(-exclusive)' and `characterp')

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 10 Sep 2018 10:02:02 +0000

Your bug report

#32562: 26; `read-char(-exclusive)' and `characterp'

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
32562: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=32562
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#32562: 26; `read-char(-exclusive)' and `characterp'
From: Eli Zaretskii <[email-masked]>
To: Drew Adams <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Mon, 10 Sep 2018 13:01:11 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Tue, 28 Aug 2018 14:24:36 -0700 (PDT)
> From: Drew Adams <[email-masked]>
> Cc: [email-masked]
> 
> is `read-char' necessarily about chars that satisfy `characterp'?

No.  It returns a character event, not a character.

> The doc string of `text-char-description' says "file-character CHARACTER". What's a "file character"? A character that can appear in a file name?

No, text-char-description accepts only valid character codes, those
which satisfy the 'characterp' test.  This is unlike
single-key-description, which accepts _events_, and thus will happily
process character input events that are not valid character codes,
i.e. fail the 'characterp' test.  I've now made that clear in the
respective doc strings.

> This stuff is not clear more generally, I think - beyond the max value of `max-char'. Do we have or want to have different kinds of "characters" returned from or passed as args to different "character" functions? Why (or why not)?

The basic difference is between a character code and a character input
event.

> Wrt my original problem: taking a value of `M-:' from `read-char' and passing it to `text-char-description', Emacs has a regression of sorts. Older Emacs versions "work", whereas recent versions raise an error. E.g. Emacs 20 `read-char' returns -134217670, and passing that to `text-char-description' gives "\272". Whatever `read-char' can read, it seems, `text-char-description' can describe (perhaps imperfectly?).

It's not a regression: text-char-description wants a valid character
code.

I'm closing this bug, as I think this is a documentation issue which
is now fixed.

Thanks.

Subject: 26; `read-char(-exclusive)' and `characterp'
From: Drew Adams <[email-masked]>
To: [email-masked]
Date: Tue, 28 Aug 2018 13:39:20 -0700 (PDT)
List-Id: <debbugs-submit.debbugs.gnu.org>

Perhaps there is no bug here, other than incomplete or insufficiently
clear doc.  Dunno.

emacs -Q
M-: (setq foo (read-char "Char: "))
M-:

shows: 134217786 (#o1000000072, #x800003a), a number too large
to be `characterp'.  And M-: (characterp foo) ; returns nil.

Same thing for `read-char-exclusive'.

Something seems wrong.  The doc for `read-char(-exclusive)' talks about
reading a character. For `read-char' it says that it raises an error for
a non-char event.  And for `read-char-exclusive' it says that it ignores
non-char events that it reads.

But they both seem to read the event from `M-:' and return its value
(a number). And it is not a character, according to `characterp'.

I'm confused.  Please consider fixing this, at least by clarifying the doc.

Why should a function that reads a character, and either ignores a
non-char or raises an error for a non-char, return a non-character?
And what function reads a `characterp' character, either ignoring
anything else or raising an error for anything else?

In GNU Emacs 26.1 (build 1, x86_64-w64-mingw32)
 of 2018-05-30
Repository revision: 07f8f9bc5a51f5aa94eb099f3e15fbe0c20ea1ea
Windowing system distributor `Microsoft Corp.', version 10.0.16299
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''