🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.epoch.misc
Article #1947

Re: How to abort I-search on window focus change

#1947
From: Hamish Macdonald
Date: Tue, 23 Jul 1991 18:57
39 lines
2635 bytes
>>>>> On 23 Jul 91 15:15:20 GMT,
>>>>> In message <9107231515.AA02379@avenger.think.com>,
>>>>> rad@think.com (Bob Doolittle) wrote:

Bob> I quite often have two epoch screens and while doing an I-search in one
Bob> screen absent-mindedly move my mouse cursor into the other and type
Bob> something, expecting it to be inserted in the text.  Instead, it winds up
Bob> continuing my search.  Or, I'll sometimes issue a command intended for the
Bob> new screen, which is worse yet, because instead of terminating my I-search
Bob> where it was in the first screen, it aborts the I-search, yanking my point
Bob> back to the start of the search, which is hardly ever what I wanted.

I think the following does what you want...  It is quite hackish.

(defun terminate-search ()
  (if (boundp 'search-message)            ; search in progress ?
      (progn
	(if (= (length search-string) 0)  ; search-exit-char switches
                                          ; to normal search if length 0..
	    (cond (regexp                 ; so set it to something w/ length > 0
		   (if (> (length search-last-regexp) 0)
		       (setq search-string search-last-regexp)
		     (setq search-string "surprise!")))
		  (t
		   (if (> (length search-last-string) 0)
		       (setq search-string search-last-string)
		     (setq search-string "surprise!")))))
        ;; make the unread-command-char the search-exit-char...
	(setq unread-command-char search-exit-char))))
(add-hook '*select-screen-hook* 'terminate-search)

;;; If you don't have add-hook, the following should suffice:

(if (boundp '*select-screen-hook*)
    (setq *select-screen-hook* (cons 'terminate-search *select-screen-hook*))
  (setq *select-screen-hook* (list 'terminate-search)))
--
--------------------------------------------------------------
himacdonald@plg.uwaterloo.ca           watmath!plg!himacdonald
Technical Details
Message-ID: <1991Jul23.185732.17699@watmath.waterloo.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cs.utexas.edu!utgpu!watserv1!watmath!watmath!himacdon
References: <9107231515.AA02379@avenger.think.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc7ee,324ac71c69a2b7d
X-Google-Attributes: gidfc7ee,public
X-Google-ArrivalTime: 1991-07-23 22:36:16 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cs.utexas.edu!utgpu!watserv1!watmath!watmath!himacdon
From: himacdon@plg.uwaterloo.ca (Hamish Macdonald)
Newsgroups: gnu.epoch.misc
Subject: Re: How to abort I-search on window focus change
Message-ID: <1991Jul23.185732.17699@watmath.waterloo.edu>
Date: 23 Jul 91 18:57:32 GMT
References: <9107231515.AA02379@avenger.think.com>
Sender: news@watmath.waterloo.edu (News Owner)
Distribution: gnu
Organization: University of Waterloo, Waterloo, Ontario
Lines: 39
In-Reply-To: rad@think.com's message of 23 Jul 91 15: 15:20 GMT