File: get_menu_part.in

package info (click to toggle)
xemacs21 21.4.24-11
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 34,212 kB
  • sloc: ansic: 243,882; lisp: 94,071; cpp: 5,726; sh: 4,406; perl: 1,096; cs: 775; makefile: 761; python: 279; asm: 248; lex: 119; yacc: 95; sed: 22; csh: 9
file content (80 lines) | stat: -rw-r--r-- 1,579 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/perl -w

use strict;
use diagnostics;

my $top_file = shift(@ARGV);
my $output_file = shift(@ARGV);

die "No menu file given" if(not defined($top_file));

my $top = '\input texinfo
@c -*-texinfo-*-
@c Copyright (C) 1997 Free Software Foundation, Inc.
@c overall xemacs@MAJVERSION@ pointers for debian info abstraction
@settitle Overall XEmacs @VERSION@ documentation
@setfilename xemacs@MAJVERSION@.info

@ifinfo
This file documents XEmacs @VERSION@
@end ifinfo

@direntry
* XEmacs21: (xemacs21/xemacs21). Documentation for XEmacs @VERSION@
@end direntry

@ifinfo
@node Top
@top XEmacs @MAJVERSION@ Documentation
@end ifinfo

Here is all the documentation for XEmacs version @VERSION@.

@menu

XEmacs Docs

';

my $bottom = '
@end menu
';

open(TOP_FILE, $top_file);

my $menu_text = "";
my $getting_menu = 0;

my $header_format = "%-30s %s\n";

while(<TOP_FILE>) {
  $getting_menu = not $getting_menu
    if(m/^\s*\* Menu:\s*$/ or m/^\s*\* Locals:\s*/);

  next if not $getting_menu;
  next if m/\* Menu:/;

  if(m/^\s*\* (.*):(:|\s*\(.*\)\.)\s*(.*)/) {
    my $info_file = "xemacs@MAJVERSION@/\L$1";
    my $first_part = "* $1: ($info_file).";
    my $second_part = $3 || "";
    $first_part .= "\n" if((length($first_part) > 30)
                           and ($second_part !~ m/\s*/));
    $_ = sprintf($header_format, $first_part, $second_part);
  }

  if(m/^\s+(.*)$/) {
    $_ = sprintf($header_format, "", $1);
  }
  $menu_text .= $_;
}

close(TOP_FILE);

open(OUT_FILE, "> $output_file");

print OUT_FILE $top, $menu_text, $bottom;

close(OUT_FILE);

exit 0;