[gnu.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))))

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

kayvan@APPLE.COM (Kayvan Sylvan) (05/09/89)

> Date: 7 May 89 17:27:04 GMT
> From: apple!bingvaxu.cc.binghamton.edu!consp04  (Daniel F. Boyd)
> Organization: SUNY Binghamton, NY
> 
> > Randal L. Schwartz @ Stonehenge - writes:
> > [description of see-chars deleted]
> 
> How do you like my version?  It's not as pretty, but it's a
> lot better!
> [basically, advice about 'view-lossage' deleted]
> 	You reinvented the wheel.

Yes! Your version is a lot better!!! Especially if I have a terminal which
sends function key sequences like ^X^C or ^Xky ... I really like losing
my work or having to do 'undo' a few times!

A re-invented wheel can be an improved wheel.

			---Kayvan

Kayvan Sylvan @ Transact Software, Inc. -*-  Mountain View, CA (415) 961-6112
Internet: mrspoc!kayvan@apple.com UUCP: ...!{apple,pyramid,mips}!mrspoc!kayvan