HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/share/ircII/script/history-match
# history-match
# This is basically an attempt to emulate the behavior of tcsh's ESC-p
# eg.. /partcom^Xp  looks for the completion to the command in the
#        command history
# and  /command partword^Xp  finds the match to the partial word in the
#      command history.. Try it twice as it may miss it the first time
# The other feature is that if there are several matches in the history
# you can hit ^Xp several times to move through the choices.. if you 
# modify the pattern or hit return it will reset the search to something
# new.. 

@ RCS.ircIId = [$$Header: /local/cvs/ircii/script/history-match,v 1.2 2001/08/12 15:44:17 mrg Exp $$]

bind meta2-p parse history.expn $L

# clearing out a null pattern is tough.. so I do it any time a line is
# sent
on #-input 765 * @ history.pat = [xxnomatchxx]

alias history.expn {
	if ([$0] != history.key)
	{
		# again, trying to get rid of a 'short' or null pattern
		@ history.pat = [xxnomatchxx]
		@ history.key = [$0]
	}
	if (history.nomatch == []) {@ history.nomatch = 1}
	if (!match($(history.pat)* $1)) {@ history.pat = [$1]}
	@ history.found = 0
	while (!history.found)
	{
		if ((history.search = [$(!$(0)!)]) != []) 
		{
			if (match($(history.pat)* $word(1 $history.search)))
			{
				parsekey erase_to_beg_of_line
				xtype -literal $history.search
				@ history.found = 1
				@ history.nomatch = 0
			}
		}
		{
			# we hit the top of the history.. drop out of the while loop
			@ history.found = 1
			@ history.nomatch = 1
		}
	}
}