/* allx -- Macro from FW-Macros for THE (The Hessling Editor) * Copyright (C) 1997-1998 Franz-Josef Wirtz * * This macro is free software; see the files README and COPYING for details * about refusing any warranty and the GNU General Public License. */ /* PURPOSE: simulates the 'all' command from 'the' while using GNU regular expressions (via external command grep) All non matching lines are hidden, focus moves to first match */ parse arg regexpargs if (length(regexpargs) = 0) then do 'emsg ALL command with GNU regexps, pass parameters in grep style (without file)' exit end 'save' /* assure to act on what we actually see */ rc = run_os( "grep -n "regexpargs" "fpath.1()filename.1(), ,"stdout.","stderr.") if (rc <> 0) then do /* this happens also when grep failes to find a line */ 'emsg grep failed (rc='rc')' if (stderr.1 == 0) then 'msg nothing matches' else do i_err = 1 to stderr.0 'msg 'stderr.i_err end exit end 'all' /* clear all selection levels */ 'set display 0 255' /* this is necessary, else all set select don't change anything */ do i_out = stdout.0 to 1 by -1 parse value stdout.i_out with lineno":"content 'locate :'lineno 'set select 1' /* marks line for inclusion */ end 'set display 1 1' /* finally show only marked lines */ 'msg 'stdout.0' lines out of 'size.1()' match' 'msg show all non matching lines: set display 0 0' 'msg show all matching lines: set display 1 1' 'msg show all lines: set display 0 1'