[comp.emacs] meta keys and esc prefixing

mazer@bek-owl.caltech.edu (Jamie Mazer) (09/06/89)

 Now that I've got access to a keyboard with a real meta key (NCD X-term),
I've noticed something wierd with gnuemacs 18.52. If I type:
	"C-S <search-string> M-V" (C-S bound to forward-i-search)\
 The i-search proceeds normally, but instead of M-V terminating the search
and moving forward a screen - it gets read as <esc>V - in which case the esc
terminates and the V gets inserted into the buffer - even though I use the
meta key on the keyboard. I noticed this problem previously with non-meta
terminals (vt100s), but figured it would be fixed on a "nice" terminal which
sends eigth-bit info.
 Is this a known bug? (Or perhaps feature ;-) Does anyone have a workaround?
It would be nice if i-search were smarter about gobbling the esc so quickly..

Just wonderin'
/Jamie
  UUCP: {rutgers,ames}!cit-vax!bek-owl!mazer
  ARPA: mazer@bek-owl.caltech.edu  "It's a fine line between line between
BITNET: jmazer@caltech.bitnet       clever and stupid" -- Spinal Tap

jbw@bucsf.bu.edu (Joe Wells) (09/07/89)

In article <11826@cit-vax.Caltech.Edu> mazer@bek-owl.caltech.edu (Jamie Mazer) writes:

    Now that I've got access to a keyboard with a real meta key (NCD X-term),
   I've noticed something wierd with gnuemacs 18.52. If I type:
	   "C-S <search-string> M-V" (C-S bound to forward-i-search)\
    The i-search proceeds normally, but instead of M-V terminating the search
   and moving forward a screen - it gets read as <esc>V - in which case the esc
   terminates and the V gets inserted into the buffer - even though I use the
   meta key on the keyboard. I noticed this problem previously with non-meta
   terminals (vt100s), but figured it would be fixed on a "nice" terminal which
   sends eigth-bit info.
    Is this a known bug? (Or perhaps feature ;-) Does anyone have a workaround?
   It would be nice if i-search were smarter about gobbling the esc so quickly.

According to the comments in various places in the source code, isearch
should handle this correctly.  If you can use the lisp debugger, you might
want to check what values isearch is getting from read-char.

However, I am including fix that handles (on my machine) the general
problem of ESC being both the isearch terminator and a prefix for function
keys.  Apply this fix and isearch will divine whether you typed a single
ESC character, or a function key that generates ESC as a prefix.

Enjoy!

--
Joe Wells <jbw@bucsf.bu.edu>
jbw%bucsf.bu.edu@bu-it.bu.edu
...!harvard!bu-cs!bucsf!jbw
----------------------------------------------------------------------
*** /usr14/gnu/dist-18.52/lisp/isearch.el	Tue Dec  8 18:11:03 1987
--- new-isearch.el	Wed Sep  6 19:50:24 1989
***************
*** 117,123 ****
  		  ;; Esc means exit search normally.
  		  ;; Except, if first thing typed, it means do nonincremental
  		  (if (= 0 (length search-string))
! 		      (nonincremental-search forward regexp))
  		  (throw 'search-done t))
  		 ((= char ?\C-g)
  		  ;; ^G means the user tried to quit.
--- 117,125 ----
  		  ;; Esc means exit search normally.
  		  ;; Except, if first thing typed, it means do nonincremental
  		  (if (= 0 (length search-string))
! 		      (nonincremental-search forward regexp)
! 		    (if (input-pending-p)
! 			(setq unread-command-char char)))
  		  (throw 'search-done t))
  		 ((= char ?\C-g)
  		  ;; ^G means the user tried to quit.

rbj@dsys.ncsl.nist.GOV (Root Boy Jim) (09/08/89)

? From: Jamie Mazer <bek-owl!mazer@csvax.caltech.edu>

?  Now that I've got access to a keyboard with a real meta key (NCD
? X-term), I've noticed something wierd with gnuemacs 18.52. If I
? type: 	"C-S <search-string> M-V" (C-S bound to
? forward-i-search)\ The i-search proceeds normally, but instead of
? M-V terminating the search and moving forward a screen - it gets
? read as <esc>V - in which case the esc terminates and the V gets
? inserted into the buffer - even though I use the meta key on the
? keyboard. I noticed this problem previously with non-meta terminals
? (vt100s), but figured it would be fixed on a "nice" terminal which
? sends eigth-bit info.  Is this a known bug? (Or perhaps feature ;-)
? Does anyone have a workaround?  It would be nice if i-search were
? smarter about gobbling the esc so quickly..

A simpler fix (than Joe Wells') is just to (setq search-exit-char 13)
to make RET exit searches. How often do you want to search across
lines anyway? If you do, you can use ^Q ^J.

Joe, I would remove the input-pending-p from your solution. Just make
ESC always terminate the search and restuff it. It's less confusing
that way, and avoids a slight race condition.

? Just wonderin'
? /Jamie
?   UUCP: {rutgers,ames}!cit-vax!bek-owl!mazer
?   ARPA: mazer@bek-owl.caltech.edu  "It's a fine line between line between
? BITNET: jmazer@caltech.bitnet       clever and stupid" -- Spinal Tap

	Root Boy Jim and
	the GNU Bohemians