📄 texinfmt.el
字号:
(if up (insert ", Up: " up)) (insert ?\n) (setq texinfo-last-node-pos (point))))(put 'menu 'texinfo-format 'texinfo-format-menu)(defun texinfo-format-menu () (texinfo-discard-line) (insert "* Menu:\n\n"))(put 'menu 'texinfo-end 'texinfo-discard-command);; The @detailmenu should be removed eventually.;; According to Karl Berry, 31 August 1996:;; ;; You don't like, I don't like it. I agree, it would be better just to;; fix the bug [in `makeinfo']. .. At this point, since inserting those;; two commands in the Elisp fn is trivial, I don't especially want to;; expend more effort...;; ;; I added a couple sentences of documentation to the manual (putting the;; blame on makeinfo where it belongs :-().(put 'detailmenu 'texinfo-format 'texinfo-discard-line)(put 'detailmenu 'texinfo-end 'texinfo-discard-command);; (Also see `texnfo-upd.el');;; Cross references;; @xref {NODE, FNAME, NAME, FILE, DOCUMENT};; -> *Note FNAME: (FILE)NODE;; If FILE is missing,;; *Note FNAME: NODE;; If FNAME is empty and NAME is present;; *Note NAME: Node;; If both NAME and FNAME are missing;; *Note NODE::;; texinfo ignores the DOCUMENT argument.;; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>;; If FILE is specified, (FILE)NODE is used for xrefs.;; If fifth argument DOCUMENT is specified, produces;; See section <xref to NODE> [NAME, else NODE], page <xref to NODE>;; of DOCUMENT;; @ref a reference that does not put `See' or `see' in;; the hardcopy and is the same as @xref in Info(put 'ref 'texinfo-format 'texinfo-format-xref)(put 'xref 'texinfo-format 'texinfo-format-xref)(defun texinfo-format-xref () (let ((args (texinfo-format-parse-args))) (texinfo-discard-command) (insert "*Note ") (let ((fname (or (nth 1 args) (nth 2 args)))) (if (null (or fname (nth 3 args))) (insert (car args) "::") (insert (or fname (car args)) ": ") (if (nth 3 args) (insert "(" (nth 3 args) ")")) (insert (car args))))))(put 'pxref 'texinfo-format 'texinfo-format-pxref)(defun texinfo-format-pxref () (texinfo-format-xref) (or (save-excursion (forward-char -2) (looking-at "::")) (insert ".")));; @inforef{NODE, FNAME, FILE};; Like @xref{NODE, FNAME,,FILE} in texinfo.;; In Tex, generates "See Info file FILE, node NODE"(put 'inforef 'texinfo-format 'texinfo-format-inforef)(defun texinfo-format-inforef () (let ((args (texinfo-format-parse-args))) (texinfo-discard-command) (if (nth 1 args) (insert "*Note " (nth 1 args) ": (" (nth 2 args) ")" (car args)) (insert "*Note " "(" (nth 2 args) ")" (car args) "::"))));;; Section headings(put 'majorheading 'texinfo-format 'texinfo-format-chapter)(put 'chapheading 'texinfo-format 'texinfo-format-chapter)(put 'ichapter 'texinfo-format 'texinfo-format-chapter)(put 'chapter 'texinfo-format 'texinfo-format-chapter)(put 'iappendix 'texinfo-format 'texinfo-format-chapter)(put 'appendix 'texinfo-format 'texinfo-format-chapter)(put 'iunnumbered 'texinfo-format 'texinfo-format-chapter)(put 'top 'texinfo-format 'texinfo-format-chapter)(put 'unnumbered 'texinfo-format 'texinfo-format-chapter)(put 'centerchap 'texinfo-format 'texinfo-format-chapter)(defun texinfo-format-chapter () (texinfo-format-chapter-1 ?*))(put 'heading 'texinfo-format 'texinfo-format-section)(put 'isection 'texinfo-format 'texinfo-format-section)(put 'section 'texinfo-format 'texinfo-format-section)(put 'iappendixsection 'texinfo-format 'texinfo-format-section)(put 'appendixsection 'texinfo-format 'texinfo-format-section)(put 'iappendixsec 'texinfo-format 'texinfo-format-section)(put 'appendixsec 'texinfo-format 'texinfo-format-section)(put 'iunnumberedsec 'texinfo-format 'texinfo-format-section)(put 'unnumberedsec 'texinfo-format 'texinfo-format-section)(defun texinfo-format-section () (texinfo-format-chapter-1 ?=))(put 'subheading 'texinfo-format 'texinfo-format-subsection)(put 'isubsection 'texinfo-format 'texinfo-format-subsection)(put 'subsection 'texinfo-format 'texinfo-format-subsection)(put 'iappendixsubsec 'texinfo-format 'texinfo-format-subsection)(put 'appendixsubsec 'texinfo-format 'texinfo-format-subsection)(put 'iunnumberedsubsec 'texinfo-format 'texinfo-format-subsection)(put 'unnumberedsubsec 'texinfo-format 'texinfo-format-subsection)(defun texinfo-format-subsection () (texinfo-format-chapter-1 ?-))(put 'subsubheading 'texinfo-format 'texinfo-format-subsubsection)(put 'isubsubsection 'texinfo-format 'texinfo-format-subsubsection)(put 'subsubsection 'texinfo-format 'texinfo-format-subsubsection)(put 'iappendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)(put 'appendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)(put 'iunnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)(put 'unnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)(defun texinfo-format-subsubsection () (texinfo-format-chapter-1 ?.))(defun texinfo-format-chapter-1 (belowchar) (let ((arg (texinfo-parse-arg-discard))) (message "Formatting: %s ... " arg) ; So we can see where we are. (insert ?\n arg ?\n "@SectionPAD " belowchar ?\n) (forward-line -2)))(put 'SectionPAD 'texinfo-format 'texinfo-format-sectionpad)(defun texinfo-format-sectionpad () (let ((str (texinfo-parse-arg-discard))) (forward-char -1) (let ((column (current-column))) (forward-char 1) (while (> column 0) (insert str) (setq column (1- column)))) (insert ?\n)));;; Space controlling commands: @. and @:, and the soft hyphen.(put '\. 'texinfo-format 'texinfo-format-\.)(defun texinfo-format-\. () (texinfo-discard-command) (insert "."))(put '\: 'texinfo-format 'texinfo-format-\:)(defun texinfo-format-\: () (texinfo-discard-command))(put '\- 'texinfo-format 'texinfo-format-soft-hyphen)(defun texinfo-format-soft-hyphen () (texinfo-discard-command));;; @center, @sp, and @br(put 'center 'texinfo-format 'texinfo-format-center)(defun texinfo-format-center () (let ((arg (texinfo-parse-expanded-arg))) (texinfo-discard-command) (insert arg) (insert ?\n) (save-restriction (goto-char (1- (point))) (let ((indent-tabs-mode nil)) (center-line)))))(put 'sp 'texinfo-format 'texinfo-format-sp)(defun texinfo-format-sp () (let* ((arg (texinfo-parse-arg-discard)) (num (read arg))) (insert-char ?\n num)))(put 'br 'texinfo-format 'texinfo-format-paragraph-break)(defun texinfo-format-paragraph-break () "Force a paragraph break.If used within a line, follow `@br' with braces." (texinfo-optional-braces-discard) ;; insert one return if at end of line; ;; else insert two returns, to generate a blank line. (if (= (following-char) ?\n) (insert ?\n) (insert-char ?\n 2)));;; @footnote and @footnotestyle;; In Texinfo, footnotes are created with the `@footnote' command.;; This command is followed immediately by a left brace, then by the text of;; the footnote, and then by a terminating right brace. The;; template for a footnote is:;; ;; @footnote{TEXT};;;; Info has two footnote styles:;; ;; * In the End of node style, all the footnotes for a single node;; are placed at the end of that node. The footnotes are;; separated from the rest of the node by a line of dashes with;; the word `Footnotes' within it.;; ;; * In the Separate node style, all the footnotes for a single node;; are placed in an automatically constructed node of their own.;; Footnote style is specified by the @footnotestyle command, either;; @footnotestyle separate;; or;; @footnotestyle end;; ;; The default is separate(defvar texinfo-footnote-style "separate" "Footnote style, either separate or end.")(put 'footnotestyle 'texinfo-format 'texinfo-footnotestyle)(defun texinfo-footnotestyle () "Specify whether footnotes are at end of node or in separate nodes.Argument is either end or separate." (setq texinfo-footnote-style (texinfo-parse-arg-discard)))(defvar texinfo-footnote-number)(put 'footnote 'texinfo-format 'texinfo-format-footnote)(defun texinfo-format-footnote () "Format a footnote in either end of node or separate node style.The texinfo-footnote-style variable controls which style is used." (setq texinfo-footnote-number (1+ texinfo-footnote-number)) (cond ((string= texinfo-footnote-style "end") (texinfo-format-end-node)) ((string= texinfo-footnote-style "separate") (texinfo-format-separate-node))))(defun texinfo-format-separate-node () "Format footnote in Separate node style, with notes in own node.The node is constructed automatically." (let* (start (arg (texinfo-parse-line-arg)) (node-name-beginning (save-excursion (re-search-backward "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:") (match-end 0))) (node-name (save-excursion (buffer-substring (progn (goto-char node-name-beginning) ; skip over node command (skip-chars-forward " \t") ; and over spaces (point)) (if (search-forward "," (save-excursion (end-of-line) (point)) t) ; bound search (1- (point)) (end-of-line) (point)))))) (texinfo-discard-command) ; remove or insert whitespace, as needed (delete-region (save-excursion (skip-chars-backward " \t\n") (point)) (point)) (insert (format " (%d) (*Note %s-Footnotes::)" texinfo-footnote-number node-name)) (fill-paragraph nil) (save-excursion (if (re-search-forward "^@node" nil 'move) (forward-line -1)) ;; two cases: for the first footnote, we must insert a node header; ;; for the second and subsequent footnotes, we need only insert ;; the text of the footnote. (if (save-excursion (re-search-backward (concat node-name "-Footnotes, Up: ") node-name-beginning t)) (progn ; already at least one footnote (setq start (point)) (insert (format "\n(%d) %s\n" texinfo-footnote-number arg)) (fill-region start (point))) ;; else not yet a footnote (insert "\n\^_\nFile: " texinfo-format-filename " Node: " node-name "-Footnotes, Up: " node-name "\n") (setq start (point)) (insert (format "\n(%d) %s\n" texinfo-footnote-number arg)) (fill-region start (point))))))(defun texinfo-format-end-node () "Format footnote in the End of node style, with notes at end of node." (let (start (arg (texinfo-parse-line-arg))) (texinfo-discard-command) ; remove or insert whitespace, as needed (delete-region (save-excursion (skip-chars-backward " \t\n") (point)) (point)) (insert (format " (%d) " texinfo-footnote-number)) (fill-paragraph nil) (save-excursion (if (search-forward "\n--------- Footnotes ---------\n" nil t) (progn ; already have footnote, put new one before end of node (if (re-search-forward "^@node" nil 'move) (forward-line -1)) (setq start (point)) (insert (format "\n(%d) %s\n" texinfo-footnote-number arg)) (fill-region start (point))) ;; else no prior footnote (if (re-search-forward "^@node" nil 'move) (forward-line -1)) (insert "\n--------- Footnotes ---------\n") (setq start (point)) (insert (format "\n(%d) %s\n" texinfo-footnote-number arg))))));;; @itemize, @enumerate, and similar commands;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.;; @enumerate pushes (enumerate 0 STARTPOS).;; @item dispatches to the texinfo-item prop of the first elt of the list.;; For itemize, this puts in and rescans the COMMANDS.;; For enumerate, this increments the number and puts it in.;; In either case, it puts a Backspace at the front of the line;; which marks it not to be indented later.;; All other lines get indented by 5 when the @end is reached.(defvar texinfo-stack-depth 0 "Count of number of unpopped texinfo-push-stack calls.Used by @refill indenting command to avoid indenting within lists, etc.")(defun texinfo-push-stack (check arg) (setq texinfo-stack-depth (1+ texinfo-stack-depth)) (setq texinfo-stack (cons (list check arg texinfo-command-start) texinfo-stack)))(defun texinfo-pop-stack (check) (setq texinfo-stack-depth (1- texinfo-stack-depth)) (if (null texinfo-stack) (error "Unmatched @end %s" check)) (if (not (eq (car (car texinfo-stack)) check)) (error "@end %s matches @%s" check (car (car texinfo-stack)))) (prog1 (cdr (car texinfo-stack)) (setq texinfo-stack (cdr texinfo-stack))))(put 'itemize 'texinfo-format 'texinfo-itemize)(defun texinfo-itemize () (texinfo-push-stack 'itemize (progn (skip-chars-forward " \t") (if (eolp) "@bullet" (texinfo-parse-line-arg)))) (texinfo-discard-line-with-args) (setq fill-column (- fill-column 5)))(put 'itemize 'texinfo-end 'texinfo-end-itemize)(defun texinfo-end-itemize () (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack 'itemize))) (texinfo-do-itemize (nth 1 stacktop))))(put 'enumerate 'texinfo-format 'texinfo-enumerate)(defun texinfo-enumerate () (texinfo-push-stack
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -