🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.help
Article #189066

isearch eating initial ESC generated by cursor keys

#189066
From: Joe Wells
Date: Sun, 12 May 1991 03:43
45 lines
2830 bytes
In article <1991Apr29.204040.14429@jato.jpl.nasa.gov> dave@jato.jpl.nasa.gov (Dave Hayes) writes:

   I have one HOWEVER I am reluctant to release it for general use until I
   find out exactly how to stop an ESC from being eaten by a search command.

   The problem is, let's say you do a search...and then failing to find 
   anything you want to use the cursor keys. The darn thing eats the ESC
   character (I think it wants to use that character to signify end of 
   searching) and then the rest of the keycode shows gleefully up in
   your edited file. 

Here's the fix I use.  Apply the diff to the source or to your own private
copy of isearch.el.

----------------------------------------------------------------------
--- /usr/local/src/emacs-18.57/lisp/isearch.el	Wed Jan  9 22:01:00 1991
+++ isearch.el	Sun May 12 03:35:48 1991
@@ -117,5 +117,13 @@
 		  ;; Except, if first thing typed, it means do nonincremental
 		  (if (= 0 (length search-string))
-		      (nonincremental-search forward regexp))
+		      (nonincremental-search forward regexp)
+		    ;; jbw: added support for unreading ESC if it might be
+		    ;; part of a character sequence generated by a
+		    ;; function key.  This is timing dependent and will
+		    ;; not always work.
+		    (if (and (input-pending-p)
+			     (not (or executing-macro
+				      defining-kbd-macro)))
+			(setq unread-command-char char)))
 		  (throw 'search-done t))
 		 ((= char ?\C-g)
----------------------------------------------------------------------

(Yes, I know that it is not guaranteed to work every single f*cking time,
but it is still useful and gets rid of a lot of frustration.  So, flames
may kindly be sent to your neighborhood recycling center.  In other words,
if you send or post a message pointing out that this solution is a hack,
I'll fill your mailbox with csh coredumps (which are particularly easy to
generate).  Anyway, vi uses this method so it must be a good idea.  :-)

-- 
Enjoy,

Joe Wells <jbw@cs.bu.edu>
Technical Details
Message-ID: <JBW.91May11234311@bigbird.bu.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!emory!samsung!olivea!bu.edu!nntp-read!jbw
References: <1991Apr27.191020.500@vax1.mankato.msus.edu> <1991Apr29.204040.14429@jato.jpl.nasa.gov>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 103b8b,7d961eb936261ec0
X-Google-Attributes: gid103b8b,public
X-Google-ArrivalTime: 1991-05-12 03:19:54 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!emory!samsung!olivea!bu.edu!nntp-read!jbw
From: jbw@bigbird.bu.edu (Joe Wells)
Newsgroups: gnu.emacs.help
Subject: isearch eating initial ESC generated by cursor keys
Message-ID: <JBW.91May11234311@bigbird.bu.edu>
Date: 12 May 91 03:43:11 GMT
References: <1991Apr27.191020.500@vax1.mankato.msus.edu>
 <1991Apr29.204040.14429@jato.jpl.nasa.gov>
Sender: news@bu.edu.bu.edu
Followup-To: gnu.emacs.help
Organization: Boston University Computer Science Department
Lines: 45
In-reply-to: dave@jato.jpl.nasa.gov's message of 29 Apr 91 20:40:40 GMT