📄 texinfo.el
字号:
) "Additional expressions to highlight in TeXinfo mode.")(defvar texinfo-section-list '(("top" 1) ("majorheading" 1) ("chapter" 2) ("unnumbered" 2) ("appendix" 2) ("chapheading" 2) ("section" 3) ("unnumberedsec" 3) ("appendixsec" 3) ("heading" 3) ("subsection" 4) ("unnumberedsubsec" 4) ("appendixsubsec" 4) ("subheading" 4) ("subsubsection" 5) ("unnumberedsubsubsec" 5) ("appendixsubsubsec" 5) ("subsubheading" 5)) "Alist of sectioning commands and their relative level.")(defun texinfo-outline-level () ;; Calculate level of current texinfo outline heading. (save-excursion (if (bobp) 0 (forward-char 1) (let* ((word (buffer-substring-no-properties (point) (progn (forward-word 1) (point)))) (entry (assoc word texinfo-section-list))) (if entry (nth 1 entry) 5)))));;; Keybindings(defvar texinfo-mode-map nil);;; Keys common both to Texinfo mode and to TeX shell.(defun texinfo-define-common-keys (keymap) "Define the keys both in Texinfo mode and in the texinfo-tex-shell." (define-key keymap "\C-c\C-t\C-k" 'tex-kill-job) (define-key keymap "\C-c\C-t\C-x" 'texinfo-quit-job) (define-key keymap "\C-c\C-t\C-l" 'tex-recenter-output-buffer) (define-key keymap "\C-c\C-t\C-d" 'texinfo-delete-from-print-queue) (define-key keymap "\C-c\C-t\C-q" 'tex-show-print-queue) (define-key keymap "\C-c\C-t\C-p" 'texinfo-tex-print) (define-key keymap "\C-c\C-t\C-v" 'texinfo-tex-view) (define-key keymap "\C-c\C-t\C-i" 'texinfo-texindex) (define-key keymap "\C-c\C-t\C-r" 'texinfo-tex-region) (define-key keymap "\C-c\C-t\C-b" 'texinfo-tex-buffer));; Mode documentation displays commands in reverse order;; from how they are listed in the texinfo-mode-map.(if texinfo-mode-map nil (setq texinfo-mode-map (make-sparse-keymap)) ;; bindings for `texnfo-tex.el' (texinfo-define-common-keys texinfo-mode-map) ;; bindings for `makeinfo.el' (define-key texinfo-mode-map "\C-c\C-m\C-k" 'kill-compilation) (define-key texinfo-mode-map "\C-c\C-m\C-l" 'makeinfo-recenter-compilation-buffer) (define-key texinfo-mode-map "\C-c\C-m\C-r" 'makeinfo-region) (define-key texinfo-mode-map "\C-c\C-m\C-b" 'makeinfo-buffer) ;; bindings for `texinfmt.el' (define-key texinfo-mode-map "\C-c\C-e\C-r" 'texinfo-format-region) (define-key texinfo-mode-map "\C-c\C-e\C-b" 'texinfo-format-buffer) ;; bindings for updating nodes and menus (define-key texinfo-mode-map "\C-c\C-um" 'texinfo-master-menu) (define-key texinfo-mode-map "\C-c\C-u\C-m" 'texinfo-make-menu) (define-key texinfo-mode-map "\C-c\C-u\C-n" 'texinfo-update-node) (define-key texinfo-mode-map "\C-c\C-u\C-e" 'texinfo-every-node-update) (define-key texinfo-mode-map "\C-c\C-u\C-a" 'texinfo-all-menus-update) (define-key texinfo-mode-map "\C-c\C-s" 'texinfo-show-structure) (define-key texinfo-mode-map "\C-c}" 'up-list) (define-key texinfo-mode-map "\C-c]" 'up-list) (define-key texinfo-mode-map "\C-c{" 'texinfo-insert-braces) ;; bindings for inserting strings (define-key texinfo-mode-map "\C-c\C-c\C-d" 'texinfo-start-menu-description) (define-key texinfo-mode-map "\C-c\C-cv" 'texinfo-insert-@var) (define-key texinfo-mode-map "\C-c\C-ct" 'texinfo-insert-@table) (define-key texinfo-mode-map "\C-c\C-cs" 'texinfo-insert-@samp) (define-key texinfo-mode-map "\C-c\C-co" 'texinfo-insert-@noindent) (define-key texinfo-mode-map "\C-c\C-cn" 'texinfo-insert-@node) (define-key texinfo-mode-map "\C-c\C-ck" 'texinfo-insert-@kbd) (define-key texinfo-mode-map "\C-c\C-ci" 'texinfo-insert-@item) (define-key texinfo-mode-map "\C-c\C-cf" 'texinfo-insert-@file) (define-key texinfo-mode-map "\C-c\C-cx" 'texinfo-insert-@example) (define-key texinfo-mode-map "\C-c\C-ce" 'texinfo-insert-@end) (define-key texinfo-mode-map "\C-c\C-cd" 'texinfo-insert-@dfn) (define-key texinfo-mode-map "\C-c\C-cc" 'texinfo-insert-@code));;; Texinfo mode(defvar texinfo-chapter-level-regexp "chapter\\|unnumbered \\|appendix \\|majorheading\\|chapheading" "Regular expression matching Texinfo chapter-level headings.This does not match `@node' and does not match the `@top' command.");;;###autoload(defun texinfo-mode () "Major mode for editing Texinfo files. It has these extra commands:\\{texinfo-mode-map} These are files that are used as input for TeX to make printed manualsand also to be turned into Info files with \\[makeinfo-buffer] orthe `makeinfo' program. These files must be written in a very restricted andmodified version of TeX input format. Editing commands are like text-mode except that the syntax table isset up so expression commands skip Texinfo bracket groups. To seewhat the Info version of a region of the Texinfo file will look like,use \\[makeinfo-region], which runs `makeinfo' on the current region. You can show the structure of a Texinfo file with \\[texinfo-show-structure].This command shows the structure of a Texinfo file by listing thelines with the @-sign commands for @chapter, @section, and the like.These lines are displayed in another window called the *Occur* window.In that window, you can position the cursor over one of the lines anduse \\[occur-mode-goto-occurrence], to jump to the corresponding spotin the Texinfo file. In addition, Texinfo mode provides commands that insert variousfrequently used @-sign commands into the buffer. You can use thesecommands to save keystrokes. And you can insert balanced braces with\\[texinfo-insert-braces] and later use the command \\[up-list] tomove forward past the closing brace.Also, Texinfo mode provides functions for automatically creating orupdating menus and node pointers. These functions * insert the `Next', `Previous' and `Up' pointers of a node, * insert or update the menu for a section, and * create a master menu for a Texinfo source file.Here are the functions: texinfo-update-node \\[texinfo-update-node] texinfo-every-node-update \\[texinfo-every-node-update] texinfo-sequential-node-update texinfo-make-menu \\[texinfo-make-menu] texinfo-all-menus-update \\[texinfo-all-menus-update] texinfo-master-menu texinfo-indent-menu-description (column &optional region-p)The `texinfo-column-for-description' variable specifies the column towhich menu descriptions are indented.Passed an argument (a prefix argument, if interactive), the`texinfo-update-node' and `texinfo-make-menu' functions do their jobsin the region.To use the updating commands, you must structure your Texinfo filehierarchically, such that each `@node' line, with the exception of theTop node, is accompanied by some kind of section line, such as an`@chapter' or `@section' line.If the file has a `top' node, it must be called `top' or `Top' andbe the first node in the file.Entering Texinfo mode calls the value of text-mode-hook, and then thevalue of texinfo-mode-hook." (interactive) (text-mode) (setq mode-name "Texinfo") (setq major-mode 'texinfo-mode) (use-local-map texinfo-mode-map) (set-syntax-table texinfo-mode-syntax-table) (make-local-variable 'page-delimiter) (setq page-delimiter (concat "^@node [ \t]*[Tt]op\\|^@\\(" texinfo-chapter-level-regexp "\\)")) (make-local-variable 'require-final-newline) (setq require-final-newline t) (make-local-variable 'indent-tabs-mode) (setq indent-tabs-mode nil) (make-local-variable 'paragraph-separate) (setq paragraph-separate (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-separate)) (make-local-variable 'paragraph-start) (setq paragraph-start (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-start)) (make-local-variable 'fill-column) (setq fill-column 72) (make-local-variable 'comment-start) (setq comment-start "@c ") (make-local-variable 'comment-start-skip) (setq comment-start-skip "@c +") (make-local-variable 'words-include-escapes) (setq words-include-escapes t) (make-local-variable 'imenu-generic-expression) (setq imenu-generic-expression texinfo-imenu-generic-expression) (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(texinfo-font-lock-keywords t)) (make-local-variable 'outline-regexp) (setq outline-regexp (concat "@\\(" (mapconcat 'car texinfo-section-list "\\>\\|") "\\>\\)")) (make-local-variable 'outline-level) (setq outline-level 'texinfo-outline-level) (make-local-variable 'tex-start-of-header) (setq tex-start-of-header "%\\*\\*start") (make-local-variable 'tex-end-of-header) (setq tex-end-of-header "%\\*\\*end") (make-local-variable 'tex-first-line-header-regexp) (setq tex-first-line-header-regexp "^\\\\input") (make-local-variable 'tex-trailer) (setq tex-trailer "@bye\n") (run-hooks 'text-mode-hook 'texinfo-mode-hook));;; Insert string commands;; Keep as concatinated lists for ease of maintenance(defconst texinfo-environment-regexp (concat "^@" "\\(" "cartouche\\|" "display\\|" "end\\|" "enumerate\\|" "example\\|" "f?table\\|" "flushleft\\|" "flushright\\|" "format\\|" "group\\|" "ifhtml\\|" "ifinfo\\|" "iftex\\|" "ignore\\|" "itemize\\|" "lisp\\|" "macro\\|" "multitable\\|" "quotation\\|" "smallexample\\|" "smalllisp\\|" "tex" "\\)") "Regexp for environment-like TexInfo list commands. Subexpression 1 is what goes into the corresponding `@end' statement.");; The following texinfo-insert-@end command not only inserts a SPC;; after the @end, but tries to find out what belongs there. It is;; not very smart: it does not understand nested lists.(defun texinfo-insert-@end () "Insert the matching `@end' for the last Texinfo command that needs one." (interactive) (let ((depth 1) string) (save-excursion (while (and (> depth 0) (re-search-backward texinfo-environment-regexp nil t)) (if (looking-at "@end") (setq depth (1+ depth)) (setq depth (1- depth)))) (looking-at texinfo-environment-regexp) (if (zerop depth) (setq string (buffer-substring (match-beginning 1) (match-end 1))))) (insert "@end ") (if string (insert string "\n"))));; The following insert commands accept a prefix arg N, which is the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -