summaryrefslogtreecommitdiff
path: root/macros/texinfo/texinfo/contrib/infosrch
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/texinfo/texinfo/contrib/infosrch
Initial commit
Diffstat (limited to 'macros/texinfo/texinfo/contrib/infosrch')
-rw-r--r--macros/texinfo/texinfo/contrib/infosrch103
1 files changed, 103 insertions, 0 deletions
diff --git a/macros/texinfo/texinfo/contrib/infosrch b/macros/texinfo/texinfo/contrib/infosrch
new file mode 100644
index 0000000000..c9f64b414a
--- /dev/null
+++ b/macros/texinfo/texinfo/contrib/infosrch
@@ -0,0 +1,103 @@
+#!/usr/local/bin/perl -w
+# infosrch does a regex search on an info manual.
+# By Harry Putnam <reader@newsguy.com>.
+
+($myscript = $0) =~ s:^.*/::;
+$six = '';
+
+if($ARGV[0] eq "help"){
+ &usage;
+ exit;
+}
+if($ARGV[0] eq "-e"){
+ shift;
+ $six = "true";
+}
+if(!$ARGV[1]){
+ &usage;
+ exit;
+}
+
+$target = shift;
+$regex = shift;
+
+$shell_proc = "info --output - --subnodes 2>/dev/null $target";
+
+open(SHELL_PROC," $shell_proc|");
+while(<SHELL_PROC>){
+ chomp;
+ push @lines,$_;
+}
+close(SHELL_PROC);
+$cnt = 0;
+for(@lines){
+ if(/$regex/ && !$six){
+ print "$target\n $lines[($cnt-1)]\n<$cnt> $lines[$cnt]\n $lines[($cnt+1)]\n";
+ print "-- \n";
+ }elsif(/$regex/ && $six){
+ print "$target\n";
+ if($lines[($cnt-6)]){
+ print " $lines[($cnt-6)]\n";
+ }
+ if($lines[($cnt-5)]){
+ print " $lines[($cnt-5)]\n";
+ }
+ if($lines[($cnt-4)]){
+ print " $lines[($cnt-4)]\n";
+ }
+ if($lines[($cnt-3)]){
+ print " $lines[($cnt-3)]\n";
+ }
+ if($lines[($cnt-2)]){
+ print " $lines[($cnt-2)]\n";
+ }
+ if($lines[($cnt-1)]){
+ print " $lines[($cnt-1)]\n";
+ }
+ if($lines[$cnt]){
+ print "$cnt $lines[$cnt]\n";
+ }
+ if($lines[($cnt+1)]){
+ print " $lines[($cnt+1)]\n";
+ }
+ if($lines[($cnt+2)]){
+ print " $lines[($cnt+2)]\n";
+ }
+ if($lines[($cnt+3)]){
+ print " $lines[($cnt+3)]\n";
+ }
+ if($lines[($cnt+4)]){
+ print " $lines[($cnt+4)]\n";
+ }
+ if($lines[($cnt+5)]){
+ print " $lines[($cnt+5)]\n";
+ }
+ if($lines[($cnt+6)]){
+ print " $lines[($cnt+6)]\n";
+ }
+ print "-- \n";
+ }
+ $cnt++;
+}
+
+sub usage {
+ print <<EOM;
+
+Purpose: Extract full text from info node and search it by regex
+Usage: $myscript [-e] TARGET REGEX
+
+Where TARGET is an info node such as `emacs', `bash' etc, and
+REGEX is what you want to find in it.
+
+The -e flag is not required but if used then 6 lines preceding and six
+lines following any hits will be printed. The default (with no -e flag)
+is to print one line before and after.
+
+The output has the line number prepended to the line containing the
+actual regex.
+
+Info command used:
+ info --output - --subnodes 2>/dev/null TARGET
+
+EOM
+}