* Request: Please add a prompt to read-event
@ 2021-12-17 16:30 T.V Raman
2021-12-18 7:39 ` Lars Ingebrigtsen
2021-12-19 5:00 ` Richard Stallman
0 siblings, 2 replies; 13+ messages in thread
From: T.V Raman @ 2021-12-17 16:30 UTC (permalink / raw)
To: emacs-devel
Emacspeak advices read-event and read-char to speak their
prompt. There are a few places in Emacs where read-event and/or
read-char are called without a prompt; e.g. disabled-command-function
Could we perhaps fix this?
(defun disabled-command-function (&optional cmd keys)
(unless cmd (setq cmd this-command))
(unless keys (setq keys (this-command-keys)))
(let (char)
(save-window-excursion
(with-output-to-temp-buffer "*Disabled Command*" ;; (help-buffer)
(if (or (eq (aref keys 0)
(if (stringp keys)
(aref "\M-x" 0)
?\M-x))
(and (>= (length keys) 2)
(eq (aref keys 0) meta-prefix-char)
(eq (aref keys 1) ?x)))
(princ (format "You have invoked the disabled command %s.\n" cmd))
(princ (format "You have typed %s, invoking disabled command %s.\n"
(key-description keys) cmd)))
;; Print any special message saying why the command is disabled.
(if (stringp (get cmd 'disabled))
(princ (get cmd 'disabled))
(princ "It is disabled because new users often find it confusing.\n")
(princ (substitute-command-keys
"Here's the first part of its description:\n\n"))
;; Keep only the first paragraph of the documentation.
(with-current-buffer "*Disabled Command*" ;; standard-output
(goto-char (point-max))
(let ((start (point)))
(save-excursion
(princ (or (condition-case ()
(documentation cmd)
(error nil))
"<< not documented >>")))
(if (search-forward "\n\n" nil t)
(delete-region (match-beginning 0) (point-max)))
(goto-char (point-max))
(indent-rigidly start (point) 3))))
(princ "\n\nDo you want to use this command anyway?\n\n")
(princ (substitute-command-keys "You can now type
y to try it and enable it (no questions if you use it again).
n to cancel--don't try the command, and it remains disabled.
SPC to try the command just this once, but leave it disabled.
! to try it, and enable all disabled commands for this session only."))
;; Redundant since with-output-to-temp-buffer will do it anyway.
;; (with-current-buffer standard-output
;; (help-mode))
)
(fit-window-to-buffer (get-buffer-window "*Disabled Command*"))
(message "Type y, n, ! or SPC (the space bar): ")
(let ((cursor-in-echo-area t))
(while (progn (setq char (read-event))
(or (not (numberp char))
(not (memq (downcase char)
'(?! ?y ?n ?\s ?\C-g)))))
(ding)
(message "Please type y, n, ! or SPC (the space bar): "))))
(setq char (downcase char))
(pcase char
(?\C-g (setq quit-flag t))
(?! (setq disabled-command-function nil))
(?y
(if (and user-init-file
(not (string= "" user-init-file))
(y-or-n-p "Enable command for future editing sessions also? "))
(enable-command cmd)
(put cmd 'disabled nil))))
(or (char-equal char ?n)
(call-interactively cmd))))
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Request: Please add a prompt to read-event
2021-12-17 16:30 Request: Please add a prompt to read-event T.V Raman
@ 2021-12-18 7:39 ` Lars Ingebrigtsen
2021-12-19 14:46 ` T.V Raman
2021-12-21 15:17 ` Stefan Monnier
2021-12-19 5:00 ` Richard Stallman
1 sibling, 2 replies; 13+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-18 7:39 UTC (permalink / raw)
To: T.V Raman; +Cc: emacs-devel
"T.V Raman" <raman@google.com> writes:
> Emacspeak advices read-event and read-char to speak their
> prompt. There are a few places in Emacs where read-event and/or
> read-char are called without a prompt; e.g. disabled-command-function
>
> Could we perhaps fix this?
[...]
> (message "Type y, n, ! or SPC (the space bar): ")
> (let ((cursor-in-echo-area t))
> (while (progn (setq char (read-event))
> (or (not (numberp char))
> (not (memq (downcase char)
> '(?! ?y ?n ?\s ?\C-g)))))
> (ding)
> (message "Please type y, n, ! or SPC (the space bar): "))))
Hm... that is pretty odd. Why is it using `message' here instead of
just using that string as the prompt to `read-event'?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Request: Please add a prompt to read-event
2021-12-17 16:30 Request: Please add a prompt to read-event T.V Raman
2021-12-18 7:39 ` Lars Ingebrigtsen
@ 2021-12-19 5:00 ` Richard Stallman
1 sibling, 0 replies; 13+ messages in thread
From: Richard Stallman @ 2021-12-19 5:00 UTC (permalink / raw)
To: T.V Raman; +Cc: emacs-devel
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
It's a general goal to reduce the need for advising for things
that Emacs intentionally supports.
Can you suggest any hooks we could add
that would reduce the need for Emacspeak to use advising?
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Request: Please add a prompt to read-event
2021-12-18 7:39 ` Lars Ingebrigtsen
@ 2021-12-19 14:46 ` T.V Raman
2021-12-21 15:17 ` Stefan Monnier
1 sibling, 0 replies; 13+ messages in thread
From: T.V Raman @ 2021-12-19 14:46 UTC (permalink / raw)
To: larsi; +Cc: raman, emacs-devel
I didn't write the code in novice.el:-)
Lars Ingebrigtsen writes:
> "T.V Raman" <raman@google.com> writes:
>
> > Emacspeak advices read-event and read-char to speak their
> > prompt. There are a few places in Emacs where read-event and/or
> > read-char are called without a prompt; e.g. disabled-command-function
> >
> > Could we perhaps fix this?
>
> [...]
>
> > (message "Type y, n, ! or SPC (the space bar): ")
> > (let ((cursor-in-echo-area t))
> > (while (progn (setq char (read-event))
> > (or (not (numberp char))
> > (not (memq (downcase char)
> > '(?! ?y ?n ?\s ?\C-g)))))
> > (ding)
> > (message "Please type y, n, ! or SPC (the space bar): "))))
>
> Hm... that is pretty odd. Why is it using `message' here instead of
> just using that string as the prompt to `read-event'?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
> bloggy blog: http://lars.ingebrigtsen.no
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Request: Please add a prompt to read-event
2021-12-18 7:39 ` Lars Ingebrigtsen
2021-12-19 14:46 ` T.V Raman
@ 2021-12-21 15:17 ` Stefan Monnier
2021-12-21 17:18 ` T.V Raman
` (2 more replies)
1 sibling, 3 replies; 13+ messages in thread
From: Stefan Monnier @ 2021-12-21 15:17 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: T.V Raman, emacs-devel
Lars Ingebrigtsen [2021-12-18 08:39:04] wrote:
> "T.V Raman" <raman@google.com> writes:
>
>> Emacspeak advices read-event and read-char to speak their
>> prompt. There are a few places in Emacs where read-event and/or
>> read-char are called without a prompt; e.g. disabled-command-function
>>
>> Could we perhaps fix this?
>
> [...]
>
>> (message "Type y, n, ! or SPC (the space bar): ")
>> (let ((cursor-in-echo-area t))
>> (while (progn (setq char (read-event))
>> (or (not (numberp char))
>> (not (memq (downcase char)
>> '(?! ?y ?n ?\s ?\C-g)))))
>> (ding)
>> (message "Please type y, n, ! or SPC (the space bar): "))))
>
> Hm... that is pretty odd. Why is it using `message' here instead of
> just using that string as the prompt to `read-event'?
This code dates back to 1989. It would benefit from a bit of
modernization, such as making it use `read-multiple-choice`.
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Request: Please add a prompt to read-event
2021-12-21 15:17 ` Stefan Monnier
@ 2021-12-21 17:18 ` T.V Raman
2021-12-22 12:36 ` Lars Ingebrigtsen
2021-12-26 16:22 ` Stefan Kangas
2 siblings, 0 replies; 13+ messages in thread
From: T.V Raman @ 2021-12-21 17:18 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Lars Ingebrigtsen, emacs-devel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 1483 bytes --]
Stefan Monnier <monnier@iro.umontreal.ca> writes:
:-) not surprizing -- as a long term emacs user -- coincidentally
started using emacs in 1990; I dont believe I've ever used the code in
novice.el since then either:-)
House-cleaning there would definitely help, though given how
controversial touching anything in Emacs can be, I'm certainly not
volunteering.
> Lars Ingebrigtsen [2021-12-18 08:39:04] wrote:
>
>> "T.V Raman" <raman@google.com> writes:
>>
>>> Emacspeak advices read-event and read-char to speak their
>>> prompt. There are a few places in Emacs where read-event and/or
>>> read-char are called without a prompt; e.g. disabled-command-function
>>>
>>> Could we perhaps fix this?
>>
>> [...]
>>
>>> (message "Type y, n, ! or SPC (the space bar): ")
>>> (let ((cursor-in-echo-area t))
>>> (while (progn (setq char (read-event))
>>> (or (not (numberp char))
>>> (not (memq (downcase char)
>>> '(?! ?y ?n ?\s ?\C-g)))))
>>> (ding)
>>> (message "Please type y, n, ! or SPC (the space bar): "))))
>>
>> Hm... that is pretty odd. Why is it using `message' here instead of
>> just using that string as the prompt to `read-event'?
>
> This code dates back to 1989. It would benefit from a bit of
> modernization, such as making it use `read-multiple-choice`.
>
>
> Stefan
>
>
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
7©4 Id: kg:/m/0285kf1 0Ü8
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Request: Please add a prompt to read-event
2021-12-21 15:17 ` Stefan Monnier
2021-12-21 17:18 ` T.V Raman
@ 2021-12-22 12:36 ` Lars Ingebrigtsen
2021-12-22 15:08 ` T.V Raman
2021-12-26 16:22 ` Stefan Kangas
2 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-22 12:36 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel, T.V Raman
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> This code dates back to 1989. It would benefit from a bit of
> modernization, such as making it use `read-multiple-choice`.
Yes, sounds like a good idea.
But meanwhile, I removed the odd message/read-event-without-a-prompt
thing, and just made read-event use a normal prompt, as requested.
Testing before/after doing that, I can't detect any differences, so
perhaps `read-event' just didn't take a prompt when this code was
written?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Request: Please add a prompt to read-event
2021-12-22 12:36 ` Lars Ingebrigtsen
@ 2021-12-22 15:08 ` T.V Raman
0 siblings, 0 replies; 13+ messages in thread
From: T.V Raman @ 2021-12-22 15:08 UTC (permalink / raw)
To: larsi; +Cc: monnier, raman, emacs-devel
Thanks Lars!
Suspect read-event didn't exist then, and it was likely an older
version of read-char.
Either way, thanks for the fix
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Request: Please add a prompt to read-event
2021-12-21 15:17 ` Stefan Monnier
2021-12-21 17:18 ` T.V Raman
2021-12-22 12:36 ` Lars Ingebrigtsen
@ 2021-12-26 16:22 ` Stefan Kangas
[not found] ` <p91v8zbi8fh.fsf@google.com>
2 siblings, 1 reply; 13+ messages in thread
From: Stefan Kangas @ 2021-12-26 16:22 UTC (permalink / raw)
To: Stefan Monnier, Lars Ingebrigtsen; +Cc: emacs-devel, T.V Raman
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> This code dates back to 1989. It would benefit from a bit of
> modernization, such as making it use `read-multiple-choice`.
Yup. I rewrote it to use `read-multiple-choice' so it should look
better now. See commits 68f15e815e..fa35723b32.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Request: Please add a prompt to read-event
[not found] ` <CAOySe-69oVWDEFjyvA=quJwj78PrwRPmCgALn=Ofr_OGtmAOsQ@mail.gmail.com>
@ 2021-12-26 20:58 ` Stefan Kangas
2021-12-27 12:09 ` Lars Ingebrigtsen
2021-12-27 14:45 ` T.V Raman
0 siblings, 2 replies; 13+ messages in thread
From: Stefan Kangas @ 2021-12-26 20:58 UTC (permalink / raw)
To: TV. Raman, emacs-devel
"TV. Raman" <raman@google.com> writes:
> Also, could we push this change to a Max 28 as opposed to just leaving it
> on master?
>
> Thanks!
I think we could cherry-pick Lars' fix, as it is small enough. That
change is enough to resolve the issue for emacspeak users, right?
My change goes further, and I don't think it's safe enough for emacs-28
this close to the release.
Eli and Lars, what do you think?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Request: Please add a prompt to read-event
2021-12-26 20:58 ` Stefan Kangas
@ 2021-12-27 12:09 ` Lars Ingebrigtsen
2021-12-27 15:00 ` Eli Zaretskii
2021-12-27 14:45 ` T.V Raman
1 sibling, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-27 12:09 UTC (permalink / raw)
To: Stefan Kangas; +Cc: emacs-devel, TV. Raman
Stefan Kangas <stefankangas@gmail.com> writes:
> I think we could cherry-pick Lars' fix, as it is small enough. That
> change is enough to resolve the issue for emacspeak users, right?
This code has basically been this way since 1989, so it can't be called
a regression. So even if it looks like a small change, I don't think it
should be backported to the release branch at this time.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Request: Please add a prompt to read-event
2021-12-26 20:58 ` Stefan Kangas
2021-12-27 12:09 ` Lars Ingebrigtsen
@ 2021-12-27 14:45 ` T.V Raman
1 sibling, 0 replies; 13+ messages in thread
From: T.V Raman @ 2021-12-27 14:45 UTC (permalink / raw)
To: stefankangas; +Cc: raman, emacs-devel
Emacspeak is happy either way, either with Lars' smaller fix or your
read-multiple-choice update
Stefan Kangas writes:
> "TV. Raman" <raman@google.com> writes:
>
> > Also, could we push this change to a Max 28 as opposed to just leaving it
> > on master?
> >
> > Thanks!
>
> I think we could cherry-pick Lars' fix, as it is small enough. That
> change is enough to resolve the issue for emacspeak users, right?
>
> My change goes further, and I don't think it's safe enough for emacs-28
> this close to the release.
>
> Eli and Lars, what do you think?
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Request: Please add a prompt to read-event
2021-12-27 12:09 ` Lars Ingebrigtsen
@ 2021-12-27 15:00 ` Eli Zaretskii
0 siblings, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2021-12-27 15:00 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: raman, stefankangas, emacs-devel
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Mon, 27 Dec 2021 13:09:05 +0100
> Cc: emacs-devel@gnu.org, "TV. Raman" <raman@google.com>
>
> Stefan Kangas <stefankangas@gmail.com> writes:
>
> > I think we could cherry-pick Lars' fix, as it is small enough. That
> > change is enough to resolve the issue for emacspeak users, right?
>
> This code has basically been this way since 1989, so it can't be called
> a regression. So even if it looks like a small change, I don't think it
> should be backported to the release branch at this time.
I agree.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-12-27 15:00 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-17 16:30 Request: Please add a prompt to read-event T.V Raman
2021-12-18 7:39 ` Lars Ingebrigtsen
2021-12-19 14:46 ` T.V Raman
2021-12-21 15:17 ` Stefan Monnier
2021-12-21 17:18 ` T.V Raman
2021-12-22 12:36 ` Lars Ingebrigtsen
2021-12-22 15:08 ` T.V Raman
2021-12-26 16:22 ` Stefan Kangas
[not found] ` <p91v8zbi8fh.fsf@google.com>
[not found] ` <CAOySe-69oVWDEFjyvA=quJwj78PrwRPmCgALn=Ofr_OGtmAOsQ@mail.gmail.com>
2021-12-26 20:58 ` Stefan Kangas
2021-12-27 12:09 ` Lars Ingebrigtsen
2021-12-27 15:00 ` Eli Zaretskii
2021-12-27 14:45 ` T.V Raman
2021-12-19 5:00 ` Richard Stallman
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).