* [matt@mundell.ukfsn.org: momentary-string-display input passing]
@ 2004-02-21 14:56 Richard Stallman
2004-03-26 21:51 ` Matthew Mundell
0 siblings, 1 reply; 3+ messages in thread
From: Richard Stallman @ 2004-02-21 14:56 UTC (permalink / raw)
This change looks basically reasonable to me, except I don't think
that an error is the right thing to do when the user types a function
key or clicks the mouse instead of typing the specified key. I think
those should just be ignored, the way other input characters are
ignored.
Would someone like to make that change and install this?
------- Start of forwarded message -------
To: emacs-pretest-bug <emacs-pretest-bug@gnu.org>
From: Matthew Mundell <matt@mundell.ukfsn.org>
Date: 17 Feb 2004 23:15:12 +0000
Subject: momentary-string-display input passing
Sender: emacs-pretest-bug-bounces+rms=gnu.org@gnu.org
The CVS Elisp manual has the following example for
momentary-string-display.
(momentary-string-display
"**** Important Message! ****"
(point) ?\r
"Type RET when done reading")
The idea seems to be that an Enter in response will only remove the
message. However, evaluating the form (in the CVS Emacs) and pressing
Enter in response also results in the insertion of a newline.
The Enter key press is read with `read-event', which returns the
symbol `return', which is different from ?\r.
Perhaps the following change to momentary-string-display will be of
help. It uses read-char when the parameter to be matched, EXIT-CHAR,
is a character. It would need additions to handle mouse events.
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/subr.el,v
retrieving revision 1.379
diff -c -r1.379 subr.el
*** subr.el 16 Feb 2004 19:40:07 -0000 1.379
- --- subr.el 17 Feb 2004 18:34:04 -0000
***************
*** 1455,1463 ****
(recenter 0))))
(message (or message "Type %s to continue editing.")
(single-key-description exit-char))
! (let ((char (read-event)))
! (or (eq char exit-char)
! (setq unread-command-events (list char)))))
(if insert-end
(save-excursion
(delete-region pos insert-end)))
- --- 1455,1475 ----
(recenter 0))))
(message (or message "Type %s to continue editing.")
(single-key-description exit-char))
! (let (char)
! (if (integerp exit-char)
! (condition-case nil
! (progn
! (setq char (read-char))
! (or (eq char exit-char)
! (setq unread-command-events (list char))))
! (error "Non-character input-event"
! ;; character type exit-char will differ from this event
! (setq unread-command-events (list char))))
! ;; assume exit-char an event
! (setq char (read-event))
! (or (eq char exit-char)
! (eq char (event-convert-list exit-char))
! (setq unread-command-events (list char))))))
(if insert-end
(save-excursion
(delete-region pos insert-end)))
_______________________________________________
Emacs-pretest-bug mailing list
Emacs-pretest-bug@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-pretest-bug
------- End of forwarded message -------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [matt@mundell.ukfsn.org: momentary-string-display input passing]
2004-02-21 14:56 [matt@mundell.ukfsn.org: momentary-string-display input passing] Richard Stallman
@ 2004-03-26 21:51 ` Matthew Mundell
2004-03-28 1:36 ` Richard Stallman
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Mundell @ 2004-03-26 21:51 UTC (permalink / raw)
Cc: emacs-devel
Richard Stallman <rms@gnu.org> writes:
> This change looks basically reasonable to me, except I don't think
> that an error is the right thing to do when the user types a function
> key or clicks the mouse instead of typing the specified key. I think
> those should just be ignored, the way other input characters are
> ignored.
>
> Would someone like to make that change and install this?
The change does ignore such errors. They are caught by the
condition-case around read-char. A stray string in the condition case
handler's body makes the handler look like a call to error. It may be
that I left the string there when turning an older call to error into
the condition case.
A new patch and a change log are below.
> From: Matthew Mundell <matt@mundell.ukfsn.org>
> Subject: momentary-string-display input passing
> To: emacs-pretest-bug <emacs-pretest-bug@gnu.org>
> Date: 17 Feb 2004 23:15:12 +0000
>
> The CVS Elisp manual has the following example for
> momentary-string-display.
>
> (momentary-string-display
> "**** Important Message! ****"
> (point) ?\r
> "Type RET when done reading")
>
> The idea seems to be that an Enter in response will only remove the
> message. However, evaluating the form (in the CVS Emacs) and pressing
> Enter in response also results in the insertion of a newline.
>
> The Enter key press is read with `read-event', which returns the
> symbol `return', which is different from ?\r.
>
> Perhaps the following change to momentary-string-display will be of
> help. It uses read-char when the parameter to be matched, EXIT-CHAR,
> is a character. It would need additions to handle mouse events.
>
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/lisp/subr.el,v
> retrieving revision 1.379
> diff -c -r1.379 subr.el
> *** subr.el 16 Feb 2004 19:40:07 -0000 1.379
> - --- subr.el 17 Feb 2004 18:34:04 -0000
> ***************
> *** 1455,1463 ****
> (recenter 0))))
> (message (or message "Type %s to continue editing.")
> (single-key-description exit-char))
> ! (let ((char (read-event)))
> ! (or (eq char exit-char)
> ! (setq unread-command-events (list char)))))
> (if insert-end
> (save-excursion
> (delete-region pos insert-end)))
> - --- 1455,1475 ----
> (recenter 0))))
> (message (or message "Type %s to continue editing.")
> (single-key-description exit-char))
> ! (let (char)
> ! (if (integerp exit-char)
> ! (condition-case nil
> ! (progn
> ! (setq char (read-char))
> ! (or (eq char exit-char)
> ! (setq unread-command-events (list char))))
> ! (error "Non-character input-event"
> ! ;; character type exit-char will differ from this event
> ! (setq unread-command-events (list char))))
> ! ;; assume exit-char an event
> ! (setq char (read-event))
> ! (or (eq char exit-char)
> ! (eq char (event-convert-list exit-char))
> ! (setq unread-command-events (list char))))))
> (if insert-end
> (save-excursion
> (delete-region pos insert-end)))
>
2004-03-26 Matthew Mundell <matt@mundell.ukfsn.org>
* subr.el (momentary-string-display): If EXIT-CHAR is a character
then read input using read-char, catching any error resulting from
the input of an event. Otherwise read with read-event, comparing
EXIT-CHAR to the input both as a character and an event
description list. Doc updated to match.
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/subr.el,v
diff -u -r1.379 subr.el
--- lisp/subr.el 16 Feb 2004 19:40:07 -0000 1.379
+++ lisp/subr.el 26 Mar 2004 17:08:41 -0000
@@ -1423,9 +1423,11 @@
(defun momentary-string-display (string pos &optional exit-char message)
"Momentarily display STRING in the buffer at POS.
-Display remains until next character is typed.
-If the char is EXIT-CHAR (optional third arg, default is SPC) it is swallowed;
-otherwise it is then available as input (as a command if nothing else).
+Display remains until next event is input.
+Optional third arg EXIT-CHAR can be a character, event or event
+description list. EXIT-CHAR defaults to SPC. If the input is
+EXIT-CHAR it is swallowed; otherwise it is then available as
+input (as a command if nothing else).
Display MESSAGE (optional fourth arg) in the echo area.
If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there."
(or exit-char (setq exit-char ?\ ))
@@ -1455,9 +1457,23 @@
(recenter 0))))
(message (or message "Type %s to continue editing.")
(single-key-description exit-char))
- (let ((char (read-event)))
- (or (eq char exit-char)
- (setq unread-command-events (list char)))))
+ (let (char)
+ (if (integerp exit-char)
+ (condition-case nil
+ (progn
+ (setq char (read-char))
+ (or (eq char exit-char)
+ (setq unread-command-events (list char))))
+ (error
+ ;; `exit-char' is a character, hence it differs
+ ;; from char, which is an event.
+ (setq unread-command-events (list char))))
+ ;; `exit-char' can be an event, or an event description
+ ;; list.
+ (setq char (read-event))
+ (or (eq char exit-char)
+ (eq char (event-convert-list exit-char))
+ (setq unread-command-events (list char))))))
(if insert-end
(save-excursion
(delete-region pos insert-end)))
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-03-28 1:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-21 14:56 [matt@mundell.ukfsn.org: momentary-string-display input passing] Richard Stallman
2004-03-26 21:51 ` Matthew Mundell
2004-03-28 1:36 ` 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).