source: git/emacs/cmpl.pl @ 0853c9e

fieker-DuValspielwiese
Last change on this file since 0853c9e was 1057a9e, checked in by Tim Wichmann <wichmann@…>, 25 years ago
*wichmann: Added constant hash for symbol names git-svn-id: file:///usr/local/Singular/svn/trunk@3470 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100755
File size: 2.0 KB
Line 
1#!/usr/local/bin/perl
2# $Id: cmpl.pl,v 1.5 1999-08-17 15:37:44 wichmann Exp $
3###################################################################
4#
5# FILE:    cmpl.pl
6# PURPOSE: generate completion strings for singular emacs mode
7# AUTHOR: obachman
8####
9$Usage = <<EOT;
10$0 [-Singular binary] [-hlp file] [cmpl 'hlp|cmd|lib'] [-help]
11Generates completion strings for singular emacs mode and prints it to STDOUT
12EOT
13 
14#
15# default settings of command-line arguments
16#
17$Singular = "../Singular/Singular";
18$hlp = "../doc/singular.hlp";
19$cmpl = "cmd";
20%symbol = (cmd=>"singular-commands-alist",
21           hlp=>"singular-help-topics-alist",
22           lib=>"singular-standard-libraries-alist");
23
24#
25# parse command line options
26#
27while (@ARGV && $ARGV[0] =~ /^-/)
28{
29  $_ = shift(@ARGV);
30  if (/^-S(ingular)?$/)  { $Singular = shift(@ARGV); next;}
31  if (/^-hlp$/)          { $hlp = shift(@ARGV); next;}
32  if (/^-c(mpl)?$/)      { $cmpl = shift(@ARGV); next;}
33  if (/^-h(elp)?$/)      { print $Usage; exit;}
34  die "Unrecognized option: $_\n$Usage";
35}
36
37#
38# get array of strings
39#
40if ($cmpl eq 'cmd')
41{
42  $strings = `$Singular -tq --exec='reservedName();\$'`;
43  die "Error in execution of: $Singular -tq --exec='reservedName();\$': $!\n"
44    if ($?);
45  @strings = split(/\s+/, $strings);
46}
47elsif ($cmpl eq 'lib')
48{
49  @strings = split(/\s+/, <>);
50}
51elsif ($cmpl eq 'hlp')
52{
53  open(FH, "<$hlp") || die "Can not open file $hlp: $!\n";
54  while (<FH>)
55  {
56    if (/Node: Index/)
57    {
58      while (<FH>)
59      {
60        last if /\* Menu:/;
61      }
62      <FH>;
63      while (<FH>)
64      {
65        last if /^\s*$/;
66        s/\* (.*):.*/$1/;
67        s/(.*) <\d+>$/$1/;
68        s/^\s*(.*)\s*/$1/;
69        s/([\\#"])/\\$1/g; #'
70        push @strings, $_ if $_ && $_ ne $prev;
71        $prev = $_;
72      }
73      last;
74    }
75  }
76  close(FH);
77}
78else
79{
80  die "Error: Can not make completion list for $cmpl\n $Usage";
81}
82print STDOUT <<EOT;
83; Do not edit this file: It was automatically generated by $0
84(setq $symbol{$cmpl}
85  '(
86EOT
87#' prevents breaking of fontification
88 
89foreach $string (@strings)
90{
91  print STDOUT qq[    ("$string")\n];
92}
93
94print STDOUT "))\n";
95
Note: See TracBrowser for help on using the repository browser.