]> Dogcows Code - chaz/tar/blob - doc/mastermenu.el
Use AT_DATA for sample output.
[chaz/tar] / doc / mastermenu.el
1 ;;; mastermenu.el --- Redefinition of texinfo-master-menu-list
2
3 ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
4
5 ;; Author: Sergey Poznyakoff
6 ;; Maintainer: bug-tar@gnu.org
7 ;; Keywords: maint, tex, docs
8
9 ;; This file is part of GNU tar documentation suite
10
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; any later version.
15
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, write to the Free Software Foundation,
23 ;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
25 ;;; Commentary:
26
27 ;; This file redefines texinfo-master-menu-list so that it takes into
28 ;; account included files.
29
30 ;; Known bugs: @menu without previous sectioning command will inherit
31 ;; documentation string from the previous menu. However, since such a
32 ;; menu is illegal in a texinfo file, we can live with it.
33
34 (require 'texinfo)
35 (require 'texnfo-upd)
36
37 (defun texinfo-master-menu-list-recursive (title)
38 "Auxiliary function used by `texinfo-master-menu-list'."
39 (save-excursion
40 (let (master-menu-list)
41 (while (re-search-forward "\\(^@menu\\|^@include\\)" nil t)
42 (cond
43 ((string= (match-string 0) "@include")
44 (skip-chars-forward " \t")
45 (let ((included-name (let ((start (point)))
46 (end-of-line)
47 (skip-chars-backward " \t")
48 (buffer-substring start (point)))))
49 (end-of-line)
50 (let ((prev-title (texinfo-copy-menu-title)))
51 (save-excursion
52 (set-buffer (find-file-noselect included-name))
53 (setq master-menu-list
54 (append (texinfo-master-menu-list-recursive prev-title)
55 master-menu-list))))))
56 (t
57 (setq master-menu-list
58 (cons (list
59 (texinfo-copy-menu)
60 (let ((menu-title (texinfo-copy-menu-title)))
61 (if (string= menu-title "")
62 title
63 menu-title)))
64 master-menu-list)))))
65 master-menu-list)))
66
67 (defun texinfo-master-menu-list ()
68 "Return a list of menu entries and header lines for the master menu,
69 recursing into included files.
70
71 Start with the menu for chapters and indices and then find each
72 following menu and the title of the node preceding that menu.
73
74 The master menu list has this form:
75
76 \(\(\(... \"entry-1-2\" \"entry-1\"\) \"title-1\"\)
77 \(\(... \"entry-2-2\" \"entry-2-1\"\) \"title-2\"\)
78 ...\)
79
80 However, there does not need to be a title field."
81
82 (reverse (texinfo-master-menu-list-recursive "")))
83
84 (defun make-master-menu ()
85 "Create master menu in the first Emacs argument."
86 (find-file (car command-line-args-left))
87 (texinfo-master-menu nil)
88 (save-buffer))
89
90
91 ;;; mastermenu.el ends here
This page took 0.038636 seconds and 4 git commands to generate.