Article View: gnu.epoch.misc
Article #1946How to abort an isearch on window de-focus
From: Bob Doolittle
Date: Tue, 23 Jul 1991 18:01
Date: Tue, 23 Jul 1991 18:01
38 lines
2002 bytes
2002 bytes
I've answered my own question, and thought I'd share with the list the code
needed to handle it. These two routines cause an isearch to be aborted on
window unfocus events (i.e. when the mouse cursor leaves the epoch screen).
For me, this avoids all sorts of unpleasant surprises :-) I've seen code on
this list to terminate searches for click-to-type interfaces, but I prefer
focus to follow the mouse cursor, and I hadn't seen any code to handle this
too. This handler does both. It overrides pieces of code in epoch.el.
;
; From the epoch list - Ken Laprade, Harris Corp.,
; ringworld!laprade@trantor.harris-atd.com
; Modified by garyo and rad@think.com
;
(defun abort-isearch () "Abort any isearch in progress."
(let ((epoch::event-handler-abort nil)) ; hide search errors from
(condition-case err ; focus handler
(throw 'search-done t)
(no-catch nil))))
;
; From rad@think.com (and garyo) - abort an isearch on window de-focus
; Push a new handler for focus and de-focus events
; Down with anonymous handlers! :-)
;
(defun focus-handler (type new-focus-state scr) "Handle (un)focus events."
(if new-focus-state
(select-screen scr) ; on window focus events
(abort-isearch) ; on window de-focus events
))
(push-event 'focus (function focus-handler))
--------
Bob Doolittle
Thinking Machines Corporation
rad@think.com
(617)234-2734
Technical Details
Message-ID:
<9107231801.AA02528@avenger.think.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!think.com!radShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc7ee,58e74d57412ae65f,start X-Google-Attributes: gidfc7ee,public X-Google-ArrivalTime: 1991-07-23 22:27:53 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!think.com!rad From: rad@think.com (Bob Doolittle) Newsgroups: gnu.epoch.misc Subject: How to abort an isearch on window de-focus Message-ID: <9107231801.AA02528@avenger.think.com> Date: 23 Jul 91 18:01:16 GMT Sender: daemon@cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 38