[comp.emacs] see-chars for GNU

merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) (05/02/89)

Ever wonder what characters a function key sends out, or one of those
other "unknown" keys like "scroll right"?  Well, even if you don't
have one of those problems today, tuck this little goody away, 'cause
it'll help you figure that out when the time comes.

`see-chars' accepts *any* characters (including a C-g) until a
three-second timeout has passed.  It then tosses up a human-readable
display of the characters entered.

/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095===\
{ on contract to BiiN, Hillsboro, Oregon, USA, until 30 May 1989     }
{ <merlyn@intelob.intel.com> ...!uunet!tektronix!biin!merlyn         }
{ or try <merlyn@agora.hf.intel.com> after 30 May 1989               }
\=Cute quote: "Welcome to Oregon... home of the California Raisins!"=/

================================================== snip snip ==========
;;; original by merlyn -- LastEditDate = "Mon Apr 10 15:45:46 1989"

(defun see-chars ()
  "Displays characters typed, terminated by a 3-second timeout."
  (interactive)
  (let ((chars "")
	(inhibit-quit t))
    (message "Enter characters, terminated by 3-second timeout...")
    (while (not (sit-for 3))
      (setq chars (concat chars (list (read-char)))
	    quit-flag nil))		; quit-flag maybe set by C-g
    (message "Characters entered: %s" (key-description chars))))

rbj@dsys.icst.nbs.GOV (Root Boy Jim) (05/03/89)

? From: "Randal L. Schwartz @ Stonehenge" <littlei!omepd!merlyn@uunet.uu.net>

? Ever wonder what characters a function key sends out, or one of those
? other "unknown" keys like "scroll right"?  Well, even if you don't
? have one of those problems today, tuck this little goody away, 'cause
? it'll help you figure that out when the time comes.

? `see-chars' accepts *any* characters (including a C-g) until a
? three-second timeout has passed.  It then tosses up a human-readable
? display of the characters entered.

[elisp deleted]

That ought to do the trick, but is overkill for most keys, which usually
send out either an escape (or perhaps some other control character)
followed by printable characters.

When I want to find out what a key types I just precede it with ^Q.

	Root Boy Jim is what I am
	Are you what you are or what?

consp04@bingvaxu.cc.binghamton.edu (Daniel F. Boyd) (05/08/89)

In article <4362@omepd.UUCP>, merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) writes:
> Ever wonder what characters a function key sends out, or one of those
> other "unknown" keys like "scroll right"?  Well, even if you don't
> have one of those problems today, tuck this little goody away, 'cause
> it'll help you figure that out when the time comes.

[description deleted]
[actual Emacs lisp code about this stuff deleted - 11 lines worth]

How do you like my version?  It's not as pretty, but it's a
lot better!

Press C-h l to run the command 'view-lossage' which shows
you, in the buffer, a list of the last 100 or so characters
entered.
	You reinvented the wheel.

-- 
Daniel F. Boyd 				    | Senator, I served with a
[consp04|vu0823]@bingvaxu.cc.binghamton.edu | LaserWriter. LaserWriter
Work with a UNIX workstation too long, you  | was a friend of mine. LN03,
get a SUNburn.... #include <disclaimer.h>   | you're no LaserWriter.

lawrence@its.rpi.edu (David Lawrence) (05/08/89)

In <4362@omepd.UUCP>, merlyn@intelob.intel.com (Randal L. Schwartz) writes:
RLS> Ever wonder what characters a function key sends out, or one of those
RLS> other "unknown" keys like "scroll right"?  Well, even if you don't
RLS> have one of those problems today, tuck this little goody away, 'cause
RLS> it'll help you figure that out when the time comes.

In <2122@bingvaxu.cc.binghamton.edu> consp04@bingvaxu.cc.binghamton.edu
   (Daniel F. Boyd) writes:
DFB> Press C-h l to run the command 'view-lossage' which shows
DFB> you, in the buffer, a list of the last 100 or so characters
DFB> entered.
DFB> 	You reinvented the wheel.

I disagree.  Say I want to find out what F5 is on a Sun keyboard.
Poking at F5 and then typing C-h l will certainly tell me what was
typed, but it also will insert "28z" into my buffer after beeping at
me because M-[ 2 is undefined.  For people with default bindings, it
will skip them back a paragraph before inserting 228z handily.

For a wide variety of terminals you can switch to the scratch buffer
and type C-q <KEY>, but that doesn't work for those demented sequences
which have more than one escape/control character in them.  I was
doing ESC <KEY> for a while until I had difficulty with the darned
disabled command buffer popping up if I did it in someone else's
Emacs or tried to explain it to them over the phone/ether/etc.

Randal's function is handy; it's not a reinvention of the wheel.  I'll
stick with polluting my scratch buffer with random characters, but I
don't expect everyone else to.

Dave
--
      tale@rpitsmts.bitnet, tale%mts@itsgw.rpi.edu, tale@pawl.rpi.edu

pjw@uk.ac.warwick.cs (Phil Wilkins) (05/08/89)

In article <2122@bingvaxu.cc.binghamton.edu> consp04@bingvaxu.cc.binghamton.edu (Daniel F. Boyd) writes:
> In article <4362@omepd.UUCP>, merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) writes:
> > Ever wonder what characters a function key sends out, or one of those
> > other "unknown" keys like "scroll right"?  Well, even if you don't
> > have one of those problems today, tuck this little goody away, 'cause
> > it'll help you figure that out when the time comes.
> How do you like my version?  It's not as pretty, but it's a
> lot better!
> 
> Press C-h l to run the command 'view-lossage' which shows
> you, in the buffer, a list of the last 100 or so characters
> entered.
Just hope that the keysequence does nothing too destructive ...
> 	You reinvented the wheel.
well, it did have a kink in it :-)

Phil
--
         (__)
         (o-)  Phil Wilkins, friend of cows and rainforests
  /-------\/   Internet: pjw@cs.warwick.ac.uk@nsfnet-relay.ac.uk
 / |     ||    UUCP: ...!mcvax!ukc!warwick!pjw
*  ||----||    JANET: pjw@uk.ac.warwick.cs
   ~~    ~~    BITNET: pjw@uk.ac.warwick.cs@ukacrl

ian@sibyl.eleceng.ua.OZ (Ian Dall) (05/10/89)

In article <LAWRENCE.89May7173829@consult1.its.rpi.edu> tale@pawl.rpi.edu writes:
->In <4362@omepd.UUCP>, merlyn@intelob.intel.com (Randal L. Schwartz) writes:
->RLS> Ever wonder what characters a function key sends out, or one of those
->RLS> other "unknown" keys like "scroll right"?
->In <2122@bingvaxu.cc.binghamton.edu> consp04@bingvaxu.cc.binghamton.edu
->   (Daniel F. Boyd) writes:
->DFB> Press C-h l to run the command 'view-lossage' which shows
->DFB> you, in the buffer, a list of the last 100 or so characters
->DFB> entered.
->DFB> 	You reinvented the wheel.
->
->I disagree.  Say I want to find out what F5 is on a Sun keyboard.
->Poking at F5 and then typing C-h l will certainly tell me what was
->typed, but it also will insert "28z" into my buffer after beeping at
->me because M-[ 2 is undefined.

C-h k does the trick pretty much if you don't mind being told whether or
not the key is bound to anything.
-- 
Ian Dall     life (n). A sexually transmitted disease which afflicts
                       some people more severely than others.       

tale@pawl.rpi.edu (David C Lawrence) (05/11/89)

In <LAWRENCE.89May7173829@consult1.its.rpi.edu> I wrote:
Dave>I disagree.  Say I want to find out what F5 is on a Sun keyboard.
Dave>Poking at F5 and then typing C-h l will certainly tell me what was
Dave>typed, but it also will insert "28z" into my buffer after beeping at
Dave>me because M-[ 2 is undefined.

In <189@sibyl.eleceng.ua.OZ> ian@sibyl.eleceng.ua.OZ (Ian Dall) responded:
Ian> C-h k does the trick pretty much if you don't mind being told whether or
Ian> not the key is bound to anything.

I disagree again ... the exact same thing would happen again.  It
would tell me that M-[ 2 is undefined and then spit 28z into my
buffer.  Whoa, says the novice, where did that 28z come from?  Heck,
I'd be wondering where it came from too if I stumbled over the key
accidentally and had my audible bell disabled.  Randal's function is
just fine for finding out the key sequence of unknown keys ... it is
not a reinvention of the wheel to make the determining of key
sequences more direct rather than kludgy, indirect and unobvious (as
the two other methods I use are).

Dave
--
      tale@rpitsmts.bitnet, tale%mts@itsgw.rpi.edu, tale@pawl.rpi.edu