|
|
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 distributed in the hope that it will be useful, ! 7: ;; but WITHOUT ANY WARRANTY. No author or distributor ! 8: ;; accepts responsibility to anyone for the consequences of using it ! 9: ;; or for whether it serves any particular purpose or works at all, ! 10: ;; unless he says so in writing. Refer to the GNU Emacs General Public ! 11: ;; License for full details. ! 12: ! 13: ;; Everyone is granted permission to copy, modify and redistribute ! 14: ;; GNU Emacs, but only under the conditions described in the ! 15: ;; GNU Emacs General Public License. A copy of this license is ! 16: ;; supposed to have been given to you along with GNU Emacs so you ! 17: ;; can know your rights and responsibilities. It should be in a ! 18: ;; file named COPYING. Among other things, the copyright notice ! 19: ;; and this notice must be preserved on all copies. ! 20: ! 21: ! 22: (defvar texinfo-mode-syntax-table nil) ! 23: ! 24: (if texinfo-mode-syntax-table ! 25: nil ! 26: (setq texinfo-mode-syntax-table (make-syntax-table)) ! 27: (modify-syntax-entry ?\" " " texinfo-mode-syntax-table) ! 28: (modify-syntax-entry ?\\ " " texinfo-mode-syntax-table) ! 29: (modify-syntax-entry ?@ "\\" texinfo-mode-syntax-table) ! 30: (modify-syntax-entry ?\^q "\\" 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 ?} "){" texinfo-mode-syntax-table) ! 35: (modify-syntax-entry ?\' "w" texinfo-mode-syntax-table)) ! 36: ! 37: (defvar texinfo-mode-map nil) ! 38: ! 39: (if texinfo-mode-map ! 40: nil ! 41: (setq texinfo-mode-map (make-sparse-keymap)) ! 42: (define-key texinfo-mode-map "\C-c\C-f" 'texinfo-format-region) ! 43: (define-key texinfo-mode-map "\C-c\C-s" 'texinfo-show-structure) ! 44: (define-key texinfo-mode-map "\e}" 'up-list) ! 45: (define-key texinfo-mode-map "\e{" 'texinfo-insert-braces) ! 46: (define-key texinfo-mode-map "\C-c\C-cv" 'texinfo-insert-@var) ! 47: (define-key texinfo-mode-map "\C-c\C-cs" 'texinfo-insert-@samp) ! 48: (define-key texinfo-mode-map "\C-c\C-cn" 'texinfo-insert-@node) ! 49: (define-key texinfo-mode-map "\C-c\C-ci" 'texinfo-insert-@item) ! 50: (define-key texinfo-mode-map "\C-c\C-ce" 'texinfo-insert-@end) ! 51: (define-key texinfo-mode-map "\C-c\C-cd" 'texinfo-insert-@dfn) ! 52: (define-key texinfo-mode-map "\C-c\C-cc" 'texinfo-insert-@code)) ! 53: ! 54: (defun texinfo-insert-@var () ! 55: "Insert the string @var in a texinfo buffer." ! 56: (interactive) ! 57: (insert "@var{}") ! 58: (backward-char)) ! 59: ! 60: (defun texinfo-insert-@samp () ! 61: "Insert the string @samp in a texinfo buffer." ! 62: (interactive) ! 63: (insert "@samp{}") ! 64: (backward-char)) ! 65: ! 66: (defun texinfo-insert-@node () ! 67: "Insert the string @node in a texinfo buffer, ! 68: along with a comment indicating the arguments to @node." ! 69: (interactive) ! 70: (insert "@node \n@comment node-name, next, previous, up") ! 71: (forward-line -1) ! 72: (forward-char 6)) ! 73: ! 74: (defun texinfo-insert-@item () ! 75: "Insert the string @item in a texinfo buffer." ! 76: (interactive) ! 77: (insert "@item") ! 78: (newline)) ! 79: ! 80: (defun texinfo-insert-@end () ! 81: "Insert the string @end in a texinfo buffer." ! 82: (interactive) ! 83: (insert "@end ")) ! 84: ! 85: (defun texinfo-insert-@dfn () ! 86: "Insert the string @dfn in a texinfo buffer." ! 87: (interactive) ! 88: (insert "@dfn{}") ! 89: (backward-char)) ! 90: ! 91: (defun texinfo-insert-@code () ! 92: "Insert the string @code in a texinfo buffer." ! 93: (interactive) ! 94: (insert "@code{}") ! 95: (backward-char)) ! 96: ! 97: (defun texinfo-insert-braces () ! 98: "Make a pair of braces and be poised to type inside of them. ! 99: Use \\[up-list] to move forward out of the braces." ! 100: (interactive) ! 101: (insert "{}") ! 102: (backward-char)) ! 103: ! 104: (defun texinfo-mode () ! 105: "Major mode for editing texinfo files. ! 106: ! 107: It has these extra commands: ! 108: \\{texinfo-mode-map} ! 109: ! 110: These are files that are used as input for TeX to make printed manuals ! 111: and also to be turned into Info files by \\[texinfo-format-buffer]. ! 112: These files must be written in a very restricted and modified version ! 113: of TeX input format. ! 114: ! 115: Editing commands are like text-mode except that the syntax table is ! 116: set up so expression commands skip Texinfo bracket groups. To see ! 117: what the Info version of a region of the Texinfo file will look like, ! 118: use \\[texinfo-format-region]. This command runs Info on the current region ! 119: of the Texinfo file and formats it properly. ! 120: ! 121: You can show the structure of a Texinfo file with \\[texinfo-show-structure]. ! 122: This command shows the structure of a Texinfo file by listing the ! 123: lines with the @-sign commands for @node, @chapter, @section and the ! 124: like. These lines are displayed in another window called the *Occur* ! 125: window. In that window, you can position the cursor over one of the ! 126: lines and use \\[occur-mode-goto-occurrence], to jump to the ! 127: corresponding spot in the Texinfo file. ! 128: ! 129: In addition, Texinfo mode provides commands that insert various ! 130: frequently used @-sign commands into the buffer. You can use these ! 131: commands to save keystrokes. And you can insert balanced braces with ! 132: \\[texinfo-insert-braces] and later use the command \\[up-list] to ! 133: move forward past the closing brace. ! 134: ! 135: Entering Texinfo mode calls the value of text-mode-hook, and then the ! 136: value of texinfo-mode-hook." ! 137: (interactive) ! 138: (text-mode) ! 139: (setq mode-name "Texinfo") ! 140: (setq major-mode 'texinfo-mode) ! 141: (use-local-map texinfo-mode-map) ! 142: (set-syntax-table texinfo-mode-syntax-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.