🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Bob Doolittle Tue, 23 Jul 1991 15:15
How to abort I-search on window focus change
#1942
Author: Bob Doolittle
Date: Tue, 23 Jul 1991 15:15
28 lines
1726 bytes
I quite often have two epoch screens and while doing an I-search in one
screen absent-mindedly move my mouse cursor into the other and type
something, expecting it to be inserted in the text.  Instead, it winds up
continuing my search.  Or, I'll sometimes issue a command intended for the
new screen, which is worse yet, because instead of terminating my I-search
where it was in the first screen, it aborts the I-search, yanking my point
back to the start of the search, which is hardly ever what I wanted.

I've been trying to modify my epoch behavior so that when a new screen is
selected any outstanding I-search is terminated, but so far haven't had any
luck.  I *think* the best way to do what I want is by changing the focus
handler so that when focus is changed into a new screen, the screen is
selected and any searches are terminated.  I've tried doing this via the
*select-screen-hook*, but I must not be doing it right because my
auto-focus behavior changes...

I'd be grateful if somebody could offer a suggestion (or elisp code!) as to
how to do this.

Thanks,
	Bob

--------
Bob Doolittle
Thinking Machines Corporation
rad@think.com
(617)234-2734
Re: How to abort I-search on window focus change
#1947
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads