source: git/emacs/lib.pl @ 6ce030f

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