source: git/emacs/lib.pl @ 805d0b1

spielwiese
Last change on this file since 805d0b1 was 341696, checked in by Hans Schönemann <hannes@…>, 14 years ago
Adding Id property to all files git-svn-id: file:///usr/local/Singular/svn/trunk@12231 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.6 KB
Line 
1#!/usr/local/bin/perl
2# $Id$
3###################################################################
4#
5# FILE:    lib.pl
6# PURPOSE: generate template for library menu
7# AUTHOR: obachman
8####
9$Usage = <<EOT;
10$0 [-singular_dir singular_dir] libraries
11Generates template for library menu
12EOT
13 
14#
15# default settings of command-line arguments
16#
17# here I expect libparse and LIB/*.lib
18$Singular_Dir = "../Singular/";
19#
20# parse command line options
21#
22while (@ARGV && $ARGV[0] =~ /^-/)
23{
24  $_ = shift(@ARGV);
25  if (/^-s(ingular_dir)?$/)  { $Singular_Dir = shift(@ARGV); next;}
26  die "Unrecognized option: $_\n$Usage";
27}
28$libparse = "$Singular_Dir/libparse";
29die "Can not find $libparse" unless -x $libparse;
30$lib_dir = "$Singular_Dir/LIB";
31die "$Singular_Dir/LIB is not a directory" unless -d $lib_dir;
32
33for $lib (@ARGV)
34{
35  my $category;
36  die "Can not read $lib_dir/$lib" unless -r "$lib_dir/$lib";
37  open(CAT_PIPE, "$libparse -c -f $lib_dir/$lib|") || die "'$libparse -c -f $lib_dir/$lib' failed";
38 
39  while (<CAT_PIPE>)
40  {
41    $category = $_;
42    last;
43  }
44  close(CAT_PIPE);
45  $category = "Miscellaneous" unless $category;
46  $libraries{$category} .= ($libraries{$category} ? " $lib" : $lib);
47}
48
49print <<EOT;
50(setq singular-standard-libraries-with-categories
51  '(
52EOT
53# font-lock-trick '
54 
55for $cat (sort {($b cmp $a)} keys %libraries)
56{
57 
58  print <<EOT;
59     ("$cat"
60EOT
61      for $lib (sort {($b cmp $a)} split (/\s+/, $libraries{$cat}))
62      {
63        print <<EOT;
64       ("$lib")
65EOT
66      }
67  print <<EOT
68     )
69EOT
70}
71
72print "))\n";
73
74 
75__END__
76
77[1  <text/plain; us-ascii (7bit)>]
78Hallo Olaf!
79
80Probier' es mal hiermit...
81
82Das File lib-cmpl.el sollte jetzt folgendes Aussehen haben:
83
84----[ snip ]----
85; Do not edit this file: It was automatically generated by cmpl.pl
86(setq singular-standard-libraries-with-categories
87  '(
88    ("Category_z"
89     ("z_file_z")
90     ("z_file_y")
91     ...
92     ("z_file_a"))
93    ("Category_y"
94     ("y_file_z")
95     ("y_file_y")
96     ...
97     ("y_file_a"))
98    ...
99    ("Category_a"
100     ("a_file_z")
101     ("a_file_y")
102     ...
103     ("a_file_a"))
104    ("file_without_cat_z")
105    ("file_without_cat_y")
106    ...
107    ("file_without_cat_a")
108   )
109----[ snip ]----
110
111(beachte, dass sich der Name der lisp-Variablen geaendert hat!).  Wie
112bisher stehen die Filenamen in umgekehrter alphabetischer Reihenfolge,
113sowohl auf top-level, als auch in den sub-menues.  Das Menue wird im
114Emacs genau so aufgebaut, wie angeben, nur in umgekehrter Reihenfolge.
115Eintraege mit Categories und ohne koennen beliebig gemischt werden:
116
117----[ snip ]----
118(setq singular-standard-libraries-with-categories
119  '(
120    ("Category_z"
121     ("z_file_z")
122     ("z_file_y")
123     ("z_file_a"))
124    ("file_without_cat_z")
125    ("file_without_cat_y")
126    ("Category_y"
127     ("y_file_z")
128     ("y_file_y")
129     ("y_file_a"))
130    ("file_without_cat_a")
131   )
132----[ snip ]----
133
134Und, um dem ganzen noch eins draufzusetzen: man kann es sogar beliebig
135tief schachteln!
136
137----[ snip ]----
138(setq singular-standard-libraries-with-categories
139  '(
140    ("Category_z"
141     ("z_file_z")
142     ("Sub_Category_zz" ("zz_file1") ("zz_file2"))
143     ("z_file_y")
144     ("Sub_Category_aa" ("aa_file_a") ("aa_file_b")))
145    ("file_without_cat_z")
146    ("file_without_cat_y")
147    ("Category_y"
148     ("y_file_z")
149     ("y_file_y")
150     ("y_file_a"))
151    ("file_without_cat_a")
152   )
153----[ snip ]----
154
155Ich habe es auf emacs 20.4, xemacs 20.4 und xemacs 21.1-p3 getestet.
156Ich hoffe, dass alles funktioniert!
157
158Es sollte auch noch mit alten lib-cmpl.el-Datein funktionieren (obwohl
159sich der Variablen-Name geaendert hat)
160
161Kannst Dich ja mal melden, ob alles wie gewollt klappt.
162
163Viele Gruesse,
164  T.
165
166
167 
Note: See TracBrowser for help on using the repository browser.