* bug#32562: 26; `read-char(-exclusive)' and `characterp'
[not found] ` <<83d0tlpteu.fsf@gnu.org>
@ 2018-09-10 13:43 ` Drew Adams
2018-09-10 14:04 ` Eli Zaretskii
2018-09-10 14:29 ` Andreas Schwab
0 siblings, 2 replies; 20+ messages in thread
From: Drew Adams @ 2018-09-10 13:43 UTC (permalink / raw)
To: Eli Zaretskii, Drew Adams; +Cc: 32562
> > Perhaps there is no bug here, other than incomplete or insufficiently
> > clear doc. Dunno.
>
> It's a documentation bug.
>
> > 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'.
>
> What the documentation failed to make clear is that the value returned
> by these functions is an _event_, not a character. For ASCII
> characters, the event and the character are identical, but modifier
> bits that cannot be resolved to yield an ASCII character are left in
> the returned value, and that makes the value not a valid character
> code.
>
> I have now clarified this subtle point in the documentation (on the
> emacs-26 branch).
Thank you.
> > And what function reads a `characterp' character, either ignoring
> > anything else or raising an error for anything else?
>
> What do you mean by "reading a 'characterp'"?
I said "reads a `characterp' character", meaning reads an event
that satisfies `characterp'. Apparently the functions whose names
or doc suggests that they read a character do not necessarily
return something that satisfies `characterp'.
> E.g., if the user types
> C-% or M-a, what 'characterp' code would you expect to see?
I was asking for a function that insists on getting an event that
satisfies `characterp', i.e., that keeps reading events until it does.
> Also, does "reading a 'characterp'" include supporting input methods, if
> any?
Sorry, can't answer that. I know nothing about input methods.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#32562: 26; `read-char(-exclusive)' and `characterp'
2018-09-10 13:43 ` bug#32562: 26; `read-char(-exclusive)' and `characterp' Drew Adams
@ 2018-09-10 14:04 ` Eli Zaretskii
2018-09-10 14:29 ` Andreas Schwab
1 sibling, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2018-09-10 14:04 UTC (permalink / raw)
To: Drew Adams; +Cc: 32562
> Date: Mon, 10 Sep 2018 06:43:07 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> Cc: 32562@debbugs.gnu.org
>
> I was asking for a function that insists on getting an event that
> satisfies `characterp', i.e., that keeps reading events until it does.
Not sure we have such a beast, but wouldn't calling read-char in a
loop until you get something that passes the 'characterp' test do?
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#32562: 26; `read-char(-exclusive)' and `characterp'
2018-09-10 13:43 ` bug#32562: 26; `read-char(-exclusive)' and `characterp' Drew Adams
2018-09-10 14:04 ` Eli Zaretskii
@ 2018-09-10 14:29 ` Andreas Schwab
2018-09-10 15:01 ` Drew Adams
1 sibling, 1 reply; 20+ messages in thread
From: Andreas Schwab @ 2018-09-10 14:29 UTC (permalink / raw)
To: Drew Adams; +Cc: 32562
On Sep 10 2018, Drew Adams <drew.adams@oracle.com> wrote:
> I said "reads a `characterp' character", meaning reads an event
> that satisfies `characterp'. Apparently the functions whose names
> or doc suggests that they read a character do not necessarily
> return something that satisfies `characterp'.
A character with modifiers doesn't satisfy characterp, but it is still a
character (which read-char can return).
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#32562: 26; `read-char(-exclusive)' and `characterp'
2018-09-10 14:29 ` Andreas Schwab
@ 2018-09-10 15:01 ` Drew Adams
2018-09-10 17:22 ` Eli Zaretskii
0 siblings, 1 reply; 20+ messages in thread
From: Drew Adams @ 2018-09-10 15:01 UTC (permalink / raw)
To: Andreas Schwab; +Cc: 32562
> > I said "reads a `characterp' character", meaning reads an event
> > that satisfies `characterp'. Apparently the functions whose names
> > or doc suggests that they read a character do not necessarily
> > return something that satisfies `characterp'.
>
> A character with modifiers doesn't satisfy characterp, but it is still a
> character (which read-char can return).
Yes, well, that's what I found a bit confusing wrt the
doc and function names. It wasn't (isn't?) too clear
just what we mean by "character", in that case.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#32562: 26; `read-char(-exclusive)' and `characterp'
2018-09-10 15:01 ` Drew Adams
@ 2018-09-10 17:22 ` Eli Zaretskii
0 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2018-09-10 17:22 UTC (permalink / raw)
To: Drew Adams; +Cc: schwab, 32562
> Date: Mon, 10 Sep 2018 08:01:40 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, 32562@debbugs.gnu.org
>
> > A character with modifiers doesn't satisfy characterp, but it is still a
> > character (which read-char can return).
>
> Yes, well, that's what I found a bit confusing wrt the
> doc and function names. It wasn't (isn't?) too clear
> just what we mean by "character", in that case.
I made the documentation say "character event" where it matters.
^ permalink raw reply [flat|nested] 20+ messages in thread
[parent not found: <<<<3cce8b54-2e85-49a2-84d8-386ded864148@default>]
[parent not found: <<<3cce8b54-2e85-49a2-84d8-386ded864148@default>]
* bug#32562: 26; `read-char(-exclusive)' and `characterp'
@ 2018-08-28 20:39 Drew Adams
2018-08-28 20:51 ` Noam Postavsky
2018-09-10 9:56 ` Eli Zaretskii
0 siblings, 2 replies; 20+ messages in thread
From: Drew Adams @ 2018-08-28 20:39 UTC (permalink / raw)
To: 32562
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''
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#32562: 26; `read-char(-exclusive)' and `characterp'
2018-08-28 20:39 Drew Adams
@ 2018-08-28 20:51 ` Noam Postavsky
2018-08-28 21:24 ` Drew Adams
2018-09-10 9:56 ` Eli Zaretskii
1 sibling, 1 reply; 20+ messages in thread
From: Noam Postavsky @ 2018-08-28 20:51 UTC (permalink / raw)
To: Drew Adams; +Cc: 32562
forcemerge 13599 32562
quit
On 28 August 2018 at 16:39, Drew Adams <drew.adams@oracle.com> wrote:
> 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'.
This is bug#13599/1042
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#32562: 26; `read-char(-exclusive)' and `characterp'
2018-08-28 20:51 ` Noam Postavsky
@ 2018-08-28 21:24 ` Drew Adams
2018-08-28 22:27 ` Noam Postavsky
2018-09-10 10:01 ` Eli Zaretskii
0 siblings, 2 replies; 20+ messages in thread
From: Drew Adams @ 2018-08-28 21:24 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32562
> forcemerge 13599 32562
> quit
>
> > 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'.
>
> This is bug#13599/1042
Hm. Maybe it is. But is `read-char' necessarily about chars that satisfy `characterp'?
I would think so, but maybe not. And there are other "character" functions, which accept chars as args - `text-char-description', for example. (That's what I was passing the result of `read-char' to.)
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? Same thing as what `max-char' should recognize? Same thing as what `read-char' should consider a char? The Elisp manual (node Describing Characters) says it is "characters that appear in text—like ‘single-key-description’, except that..." It says nothing about "file characters". The doc is not too clear.
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)?
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?).
I think that "the bug" is not so clear cut as just adjusting `max-char'. I think the behavior of several functions that expect or return chars might deserve adjustment, and the doc might deserve some clarification/fixes. We might need to decide what the right behaviors are first.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#32562: 26; `read-char(-exclusive)' and `characterp'
2018-08-28 21:24 ` Drew Adams
@ 2018-08-28 22:27 ` Noam Postavsky
2018-09-10 10:01 ` Eli Zaretskii
1 sibling, 0 replies; 20+ messages in thread
From: Noam Postavsky @ 2018-08-28 22:27 UTC (permalink / raw)
To: Drew Adams; +Cc: 32562
Drew Adams <drew.adams@oracle.com> writes:
> I think that "the bug" is not so clear cut as just adjusting
> `max-char'.
No, of course not. It's discussed at length Bug#13599.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#32562: 26; `read-char(-exclusive)' and `characterp'
2018-08-28 21:24 ` Drew Adams
2018-08-28 22:27 ` Noam Postavsky
@ 2018-09-10 10:01 ` Eli Zaretskii
1 sibling, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2018-09-10 10:01 UTC (permalink / raw)
To: Drew Adams; +Cc: npostavs, 32562-done
> Date: Tue, 28 Aug 2018 14:24:36 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> Cc: 32562@debbugs.gnu.org
>
> 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.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#32562: 26; `read-char(-exclusive)' and `characterp'
2018-08-28 20:39 Drew Adams
2018-08-28 20:51 ` Noam Postavsky
@ 2018-09-10 9:56 ` Eli Zaretskii
1 sibling, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2018-09-10 9:56 UTC (permalink / raw)
To: Drew Adams; +Cc: 32562
> Date: Tue, 28 Aug 2018 13:39:20 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
>
> Perhaps there is no bug here, other than incomplete or insufficiently
> clear doc. Dunno.
It's a documentation bug.
> 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'.
What the documentation failed to make clear is that the value returned
by these functions is an _event_, not a character. For ASCII
characters, the event and the character are identical, but modifier
bits that cannot be resolved to yield an ASCII character are left in
the returned value, and that makes the value not a valid character
code.
I have now clarified this subtle point in the documentation (on the
emacs-26 branch).
> And what function reads a `characterp' character, either ignoring
> anything else or raising an error for anything else?
What do you mean by "reading a 'characterp'"? E.g., if the user types
C-% or M-a, what 'characterp' code would you expect to see? Also,
does "reading a 'characterp'" include supporting input methods, if
any?
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2018-09-11 19:03 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <<3cce8b54-2e85-49a2-84d8-386ded864148@default>
[not found] ` <<83d0tlpteu.fsf@gnu.org>
2018-09-10 13:43 ` bug#32562: 26; `read-char(-exclusive)' and `characterp' Drew Adams
2018-09-10 14:04 ` Eli Zaretskii
2018-09-10 14:29 ` Andreas Schwab
2018-09-10 15:01 ` Drew Adams
2018-09-10 17:22 ` Eli Zaretskii
[not found] <<<<3cce8b54-2e85-49a2-84d8-386ded864148@default>
[not found] ` <<<<83d0tlpteu.fsf@gnu.org>
[not found] ` <<<<5f51bd06-84dd-47f5-a7da-b0c5814a274c@default>
[not found] ` <<<<mvmtvmxctnm.fsf@suse.de>
[not found] ` <<<<3d6fb22f-de5a-4cce-bf49-023f2fc8388f@default>
[not found] ` <<<<83k1ntnu6l.fsf@gnu.org>
[not found] ` <<<4df2c3ce-9dcb-483c-b733-f91f54f33bce@default>
[not found] ` <<<831sa0o49d.fsf@gnu.org>
[not found] ` <<<4d4aa5cd-964c-41c5-ae72-24769afb0bd0@default>
[not found] ` <<<83in3cm08g.fsf@gnu.org>
[not found] ` <<eedf9125-6ece-44cb-a01b-b8da3d707e8c@default>
[not found] ` <<83ftyfnarp.fsf@gnu.org>
2018-09-11 18:58 ` Drew Adams
2018-09-11 19:03 ` Eli Zaretskii
[not found] <<<3cce8b54-2e85-49a2-84d8-386ded864148@default>
[not found] ` <<<83d0tlpteu.fsf@gnu.org>
[not found] ` <<5f51bd06-84dd-47f5-a7da-b0c5814a274c@default>
[not found] ` <<83r2i1o3dr.fsf@gnu.org>
2018-09-10 14:57 ` Drew Adams
[not found] ` <<mvmtvmxctnm.fsf@suse.de>
[not found] ` <<3d6fb22f-de5a-4cce-bf49-023f2fc8388f@default>
[not found] ` <<83k1ntnu6l.fsf@gnu.org>
2018-09-10 19:48 ` Drew Adams
2018-09-11 7:57 ` Eli Zaretskii
2018-09-11 15:30 ` Drew Adams
2018-09-11 17:07 ` Eli Zaretskii
[not found] ` <<<5f51bd06-84dd-47f5-a7da-b0c5814a274c@default>
[not found] ` <<<mvmtvmxctnm.fsf@suse.de>
[not found] ` <<<3d6fb22f-de5a-4cce-bf49-023f2fc8388f@default>
[not found] ` <<<83k1ntnu6l.fsf@gnu.org>
[not found] ` <<4df2c3ce-9dcb-483c-b733-f91f54f33bce@default>
[not found] ` <<831sa0o49d.fsf@gnu.org>
[not found] ` <<4d4aa5cd-964c-41c5-ae72-24769afb0bd0@default>
[not found] ` <<83in3cm08g.fsf@gnu.org>
2018-09-11 17:22 ` Drew Adams
2018-09-11 18:34 ` Eli Zaretskii
2018-08-28 20:39 Drew Adams
2018-08-28 20:51 ` Noam Postavsky
2018-08-28 21:24 ` Drew Adams
2018-08-28 22:27 ` Noam Postavsky
2018-09-10 10:01 ` Eli Zaretskii
2018-09-10 9:56 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.