|
|
1.1 root 1: ;; Major mode for editing texinfo files.
2: ;; Copyright (C) 1985, 1988 Free Software Foundation, Inc.
3:
4: ;; This file is part of GNU Emacs.
5:
6: ;; GNU Emacs is free software; you can redistribute it and/or modify
7: ;; it under the terms of the GNU General Public License as published by
8: ;; the Free Software Foundation; either version 1, or (at your option)
9: ;; any later version.
10:
11: ;; GNU Emacs is distributed in the hope that it will be useful,
12: ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13: ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: ;; GNU General Public License for more details.
15:
16: ;; You should have received a copy of the GNU General Public License
17: ;; along with GNU Emacs; see the file COPYING. If not, write to
18: ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19:
20:
21: (defvar texinfo-mode-syntax-table nil)
22:
23: (if texinfo-mode-syntax-table
24: nil
25: (setq texinfo-mode-syntax-table (make-syntax-table))
26: (modify-syntax-entry ?\" " " texinfo-mode-syntax-table)
27: (modify-syntax-entry ?\\ " " texinfo-mode-syntax-table)
28: (modify-syntax-entry ?@ "\\" texinfo-mode-syntax-table)
29: (modify-syntax-entry ?\^q "\\" texinfo-mode-syntax-table)
30: (modify-syntax-entry ?\[ "(]" texinfo-mode-syntax-table)
31: (modify-syntax-entry ?\] ")[" texinfo-mode-syntax-table)
32: (modify-syntax-entry ?{ "(}" texinfo-mode-syntax-table)
33: (modify-syntax-entry ?} "){" texinfo-mode-syntax-table)
34: (modify-syntax-entry ?\' "w" texinfo-mode-syntax-table))
35:
36: (defvar texinfo-mode-map nil)
37:
38: (if texinfo-mode-map
39: nil
40: (setq texinfo-mode-map (make-sparse-keymap))
41: (define-key texinfo-mode-map "\C-c\C-f" 'texinfo-format-region)
42: (define-key texinfo-mode-map "\C-c\C-s" 'texinfo-show-structure)
43: (define-key texinfo-mode-map "\e}" 'up-list)
44: (define-key texinfo-mode-map "\e{" 'texinfo-insert-braces)
45: (define-key texinfo-mode-map "\C-c\C-cv" 'texinfo-insert-@var)
46: (define-key texinfo-mode-map "\C-c\C-cs" 'texinfo-insert-@samp)
47: (define-key texinfo-mode-map "\C-c\C-cn" 'texinfo-insert-@node)
48: (define-key texinfo-mode-map "\C-c\C-ci" 'texinfo-insert-@item)
49: (define-key texinfo-mode-map "\C-c\C-ce" 'texinfo-insert-@end)
50: (define-key texinfo-mode-map "\C-c\C-cd" 'texinfo-insert-@dfn)
51: (define-key texinfo-mode-map "\C-c\C-cc" 'texinfo-insert-@code))
52:
53: (defun texinfo-insert-@var ()
54: "Insert the string @var in a texinfo buffer."
55: (interactive)
56: (insert "@var{}")
57: (backward-char))
58:
59: (defun texinfo-insert-@samp ()
60: "Insert the string @samp in a texinfo buffer."
61: (interactive)
62: (insert "@samp{}")
63: (backward-char))
64:
65: (defun texinfo-insert-@node ()
66: "Insert the string @node in a texinfo buffer,
67: along with a comment indicating the arguments to @node."
68: (interactive)
69: (insert "@node \n@comment node-name, next, previous, up")
70: (forward-line -1)
71: (forward-char 6))
72:
73: (defun texinfo-insert-@item ()
74: "Insert the string @item in a texinfo buffer."
75: (interactive)
76: (insert "@item")
77: (newline))
78:
79: (defun texinfo-insert-@end ()
80: "Insert the string @end in a texinfo buffer."
81: (interactive)
82: (insert "@end "))
83:
84: (defun texinfo-insert-@dfn ()
85: "Insert the string @dfn in a texinfo buffer."
86: (interactive)
87: (insert "@dfn{}")
88: (backward-char))
89:
90: (defun texinfo-insert-@code ()
91: "Insert the string @code in a texinfo buffer."
92: (interactive)
93: (insert "@code{}")
94: (backward-char))
95:
96: (defun texinfo-insert-braces ()
97: "Make a pair of braces and be poised to type inside of them.
98: Use \\[up-list] to move forward out of the braces."
99: (interactive)
100: (insert "{}")
101: (backward-char))
102:
103: (defun texinfo-mode ()
104: "Major mode for editing texinfo files.
105:
106: It has these extra commands:
107: \\{texinfo-mode-map}
108:
109: These are files that are used as input for TeX to make printed manuals
110: and also to be turned into Info files by \\[texinfo-format-buffer].
111: These files must be written in a very restricted and modified version
112: of TeX input format.
113:
114: Editing commands are like text-mode except that the syntax table is
115: set up so expression commands skip Texinfo bracket groups. To see
116: what the Info version of a region of the Texinfo file will look like,
117: use \\[texinfo-format-region]. This command runs Info on the current region
118: of the Texinfo file and formats it properly.
119:
120: You can show the structure of a Texinfo file with \\[texinfo-show-structure].
121: This command shows the structure of a Texinfo file by listing the
122: lines with the @-sign commands for @node, @chapter, @section and the
123: like. These lines are displayed in another window called the *Occur*
124: window. In that window, you can position the cursor over one of the
125: lines and use \\[occur-mode-goto-occurrence], to jump to the
126: corresponding spot in the Texinfo file.
127:
128: In addition, Texinfo mode provides commands that insert various
129: frequently used @-sign commands into the buffer. You can use these
130: commands to save keystrokes. And you can insert balanced braces with
131: \\[texinfo-insert-braces] and later use the command \\[up-list] to
132: move forward past the closing brace.
133:
134: Entering Texinfo mode calls the value of text-mode-hook, and then the
135: value of texinfo-mode-hook."
136: (interactive)
137: (kill-all-local-variables)
138: (setq mode-name "Texinfo")
139: (setq major-mode 'texinfo-mode)
140: (use-local-map texinfo-mode-map)
141: (set-syntax-table texinfo-mode-syntax-table)
142: (setq local-abbrev-table text-mode-abbrev-table)
143: (make-local-variable 'require-final-newline)
144: (setq require-final-newline t)
145: (make-local-variable 'paragraph-separate)
146: (setq paragraph-separate (concat "^\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-separate))
147: (make-local-variable 'paragraph-start)
148: (setq paragraph-start (concat "^\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-start))
149: (make-local-variable 'fill-column)
150: (setq fill-column 72)
151: (make-local-variable 'comment-start)
152: (setq comment-start "@c ")
153: (make-local-variable 'comment-start-skip)
154: (setq comment-start-skip "@c +")
155: (run-hooks 'text-mode-hook 'texinfo-mode-hook))
156:
157: (defvar texinfo-heading-pattern
158: "^@\\(chapter\\|unnum\\|appendix\\|sect\\|sub\\|heading\\|major\\|node\\)"
159: "This is a regular expression to match Texinfo lines that are chapter
160: or sections headings or like such.")
161:
162: (defun texinfo-show-structure ()
163: "Show the structure of a Texinfo file by listing the lines with the
164: @-sign commands for @node, @chapter, @section and the like. Lines
165: with structuring commands in them are displayed in another window
166: called the *Occur* window. In that window, you can position the
167: cursor over one of the lines and use \\[occur-mode-goto-occurrence],
168: to jump to the corresponding spot in the Texinfo file."
169: (interactive)
170: (save-excursion
171: (goto-char (point-min))
172: (occur texinfo-heading-pattern))
173: (pop-to-buffer "*Occur*")
174: (goto-char (point-min))
175: (flush-lines "-----"))
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.