📄 texinfmt.el
字号:
'enumerate (progn (skip-chars-forward " \t") (if (eolp) 1 (read (current-buffer))))) (if (and (symbolp (car (cdr (car texinfo-stack)))) (> 1 (length (symbol-name (car (cdr (car texinfo-stack))))))) (error "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." )) (texinfo-discard-line-with-args) (setq fill-column (- fill-column 5)))(put 'enumerate 'texinfo-end 'texinfo-end-enumerate)(defun texinfo-end-enumerate () (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack 'enumerate))) (texinfo-do-itemize (nth 1 stacktop))));; @alphaenumerate never became a standard part of Texinfo(put 'alphaenumerate 'texinfo-format 'texinfo-alphaenumerate)(defun texinfo-alphaenumerate () (texinfo-push-stack 'alphaenumerate (1- ?a)) (setq fill-column (- fill-column 5)) (texinfo-discard-line))(put 'alphaenumerate 'texinfo-end 'texinfo-end-alphaenumerate)(defun texinfo-end-alphaenumerate () (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack 'alphaenumerate))) (texinfo-do-itemize (nth 1 stacktop))));; @capsenumerate never became a standard part of Texinfo(put 'capsenumerate 'texinfo-format 'texinfo-capsenumerate)(defun texinfo-capsenumerate () (texinfo-push-stack 'capsenumerate (1- ?A)) (setq fill-column (- fill-column 5)) (texinfo-discard-line))(put 'capsenumerate 'texinfo-end 'texinfo-end-capsenumerate)(defun texinfo-end-capsenumerate () (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack 'capsenumerate))) (texinfo-do-itemize (nth 1 stacktop))));; At the @end, indent all the lines within the construct;; except those marked with backspace. FROM says where;; construct started.(defun texinfo-do-itemize (from) (save-excursion (while (progn (forward-line -1) (>= (point) from)) (if (= (following-char) ?\b) (save-excursion (delete-char 1) (end-of-line) (delete-char 6)) (if (not (looking-at "[ \t]*$")) (save-excursion (insert " ")))))))(put 'item 'texinfo-format 'texinfo-item)(put 'itemx 'texinfo-format 'texinfo-item)(defun texinfo-item () (funcall (get (car (car texinfo-stack)) 'texinfo-item)))(put 'itemize 'texinfo-item 'texinfo-itemize-item)(defun texinfo-itemize-item () ;; (texinfo-discard-line) ; Did not handle text on same line as @item. (delete-region (1+ (point)) (save-excursion (beginning-of-line) (point))) (if (looking-at "[ \t]*[^ \t\n]+") ;; Text on same line as @item command. (insert "\b " (nth 1 (car texinfo-stack)) " \n") ;; Else text on next line. (insert "\b " (nth 1 (car texinfo-stack)) " ")) (forward-line -1))(put 'enumerate 'texinfo-item 'texinfo-enumerate-item)(defun texinfo-enumerate-item () (texinfo-discard-line) (let (enumerating-symbol) (cond ((integerp (car (cdr (car texinfo-stack)))) (setq enumerating-symbol (car (cdr (car texinfo-stack)))) (insert ?\b (format "%3d. " enumerating-symbol) ?\n) (setcar (cdr (car texinfo-stack)) (1+ enumerating-symbol))) ((symbolp (car (cdr (car texinfo-stack)))) (setq enumerating-symbol (symbol-name (car (cdr (car texinfo-stack))))) (if (or (equal ?\[ (string-to-char enumerating-symbol)) (equal ?\{ (string-to-char enumerating-symbol))) (error "Too many items in enumerated list; alphabet ends at Z.")) (insert ?\b (format "%3s. " enumerating-symbol) ?\n) (setcar (cdr (car texinfo-stack)) (make-symbol (char-to-string (1+ (string-to-char enumerating-symbol)))))) (t (error "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." ))) (forward-line -1)))(put 'alphaenumerate 'texinfo-item 'texinfo-alphaenumerate-item)(defun texinfo-alphaenumerate-item () (texinfo-discard-line) (let ((next (1+ (car (cdr (car texinfo-stack)))))) (if (> next ?z) (error "More than 26 items in @alphaenumerate; get a bigger alphabet.")) (setcar (cdr (car texinfo-stack)) next) (insert "\b " next ". \n")) (forward-line -1))(put 'capsenumerate 'texinfo-item 'texinfo-capsenumerate-item)(defun texinfo-capsenumerate-item () (texinfo-discard-line) (let ((next (1+ (car (cdr (car texinfo-stack)))))) (if (> next ?Z) (error "More than 26 items in @capsenumerate; get a bigger alphabet.")) (setcar (cdr (car texinfo-stack)) next) (insert "\b " next ". \n")) (forward-line -1));;; @table;; The `@table' command produces two-column tables.(put 'table 'texinfo-format 'texinfo-table)(defun texinfo-table () (texinfo-push-stack 'table (progn (skip-chars-forward " \t") (if (eolp) "@asis" (texinfo-parse-line-arg)))) (texinfo-discard-line-with-args) (setq fill-column (- fill-column 5)))(put 'table 'texinfo-item 'texinfo-table-item)(defun texinfo-table-item () (let ((arg (texinfo-parse-arg-discard)) (itemfont (car (cdr (car texinfo-stack))))) (insert ?\b itemfont ?\{ arg "}\n \n")) (forward-line -2))(put 'table 'texinfo-end 'texinfo-end-table)(defun texinfo-end-table () (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack 'table))) (texinfo-do-itemize (nth 1 stacktop))));; @description appears to be an undocumented variant on @table that;; does not require an arg. It fails in texinfo.tex 2.58 and is not;; part of makeinfo.c The command appears to be a relic of the past.(put 'description 'texinfo-end 'texinfo-end-table)(put 'description 'texinfo-format 'texinfo-description)(defun texinfo-description () (texinfo-push-stack 'table "@asis") (setq fill-column (- fill-column 5)) (texinfo-discard-line));;; @ftable, @vtable;; The `@ftable' and `@vtable' commands are like the `@table' command;; but they also insert each entry in the first column of the table;; into the function or variable index.;; Handle the @ftable and @vtable commands:(put 'ftable 'texinfo-format 'texinfo-ftable)(put 'vtable 'texinfo-format 'texinfo-vtable)(defun texinfo-ftable () (texinfo-indextable 'ftable))(defun texinfo-vtable () (texinfo-indextable 'vtable))(defun texinfo-indextable (table-type) (texinfo-push-stack table-type (texinfo-parse-arg-discard)) (setq fill-column (- fill-column 5)));; Handle the @item commands within ftable and vtable:(put 'ftable 'texinfo-item 'texinfo-ftable-item)(put 'vtable 'texinfo-item 'texinfo-vtable-item)(defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex))(defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex))(defun texinfo-indextable-item (index-type) (let ((item (texinfo-parse-arg-discard)) (itemfont (car (cdr (car texinfo-stack)))) (indexvar index-type)) (insert ?\b itemfont ?\{ item "}\n \n") (set indexvar (cons (list item texinfo-last-node) (symbol-value indexvar))) (forward-line -2)));; Handle @end ftable, @end vtable(put 'ftable 'texinfo-end 'texinfo-end-ftable)(put 'vtable 'texinfo-end 'texinfo-end-vtable)(defun texinfo-end-ftable () (texinfo-end-indextable 'ftable))(defun texinfo-end-vtable () (texinfo-end-indextable 'vtable))(defun texinfo-end-indextable (table-type) (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack table-type))) (texinfo-do-itemize (nth 1 stacktop))));;; @multitable ... @end multitable;; Produce a multi-column table, with as many columns as desired.;;;; A multi-column table has this template:;;;; @multitable {A1} {A2} {A3};; @item A1 @tab A2 @tab A3;; @item B1 @tab B2 @tab B3;; @item C1 @tab C2 @tab C3;; @end multitable;;;; where the width of the text in brackets specifies the width of the;; respective column.;;;; Or else:;;;; @multitable @columnfractions .25 .3 .45;; @item A1 @tab A2 @tab A3;; @item B1 @tab B2 @tab B3;; @end multitable;;;; where the fractions specify the width of each column as a percent;; of the current width of the text (i.e., of the fill-column).;;;; Long lines of text are filled within columns.;;;; Using the Emacs Lisp formatter, texinfmt.el, ;; the whitespace between columns can be increased by setting;; `texinfo-extra-inter-column-width' to a value greater than 0. By default,;; there is at least one blank space between columns.;;;; The Emacs Lisp formatter, texinfmt.el, ignores the following four;; commands that are defined in texinfo.tex for printed output.;; ;; @multitableparskip,;; @multitableparindent,;; @multitablecolmargin,;; @multitablelinespace.;; How @multitable works.;; =====================;; ;; `texinfo-multitable' reads the @multitable line and determines from it;; how wide each column should be. ;; ;; Also, it pushes this information, along with an identifying symbol,;; onto the `texinfo-stack'. At the @end multitable command, the stack;; is checked for its matching @multitable command, and then popped, or;; else an error is signaled. Also, this command pushes the location of;; the start of the table onto the stack.;; ;; `texinfo-end-multitable' checks the `texinfo-stack' that the @end;; multitable truly is ending a corresponding beginning, and if it is,;; pops the stack.;; ;; `texinfo-multitable-widths' is called by `texinfo-multitable'. ;; The function returns a list of the widths of each column in a;; multi-column table, based on the information supplied by the arguments;; to the @multitable command (by arguments, I mean the text on the rest;; of the @multitable line, not the remainder of the multi-column table;; environment).;; ;; `texinfo-multitable-item' formats a row within a multicolumn table.;; This command is executed when texinfmt sees @item inside @multitable.;; Cells in row are separated by `@tab's. Widths of cells are specified;; by the arguments in the @multitable line. Cells are filled. All cells;; are made to be the same height by padding their bottoms, as needed,;; with blanks.;; ;; `texinfo-multitable-extract-row' is called by `texinfo-multitable-item'. ;; This function returns the text in a multitable row, as a string.;; The start of a row is marked by an @item and the end of row is the;; beginning of next @item or beginning of the @end multitable line.;; Cells within a row are separated by @tab.;; ;; Note that @tab, the cell separators, are not treated as independent;; Texinfo commands.(defvar texinfo-extra-inter-column-width 0 "*Number of extra spaces between entries (columns) in @multitable.")(defvar texinfo-multitable-buffer-name "*multitable-temporary-buffer*")(defvar texinfo-multitable-rectangle-name "texinfo-multitable-temp-");; These commands are defined in texinfo.tex for printed output.(put 'multitableparskip 'texinfo-format 'texinfo-discard-line-with-args)(put 'multitableparindent 'texinfo-format 'texinfo-discard-line-with-args)(put 'multitablecolmargin 'texinfo-format 'texinfo-discard-line-with-args)(put 'multitablelinespace 'texinfo-format 'texinfo-discard-line-with-args)(put 'multitable 'texinfo-format 'texinfo-multitable)(defun texinfo-multitable () "Produce multi-column tables.A multi-column table has this template: @multitable {A1} {A2} {A3} @item A1 @tab A2 @tab A3 @item B1 @tab B2 @tab B3 @item C1 @tab C2 @tab C3 @end multitablewhere the width of the text in brackets specifies the width of therespective column.Or else: @multitable @columnfractions .25 .3 .45 @item A1 @tab A2 @tab A3 @item B1 @tab B2 @tab B3 @end multitablewhere the fractions specify the width of each column as a percentof the current width of the text (i.e., of the fill-column).Long lines of text are filled within columns.Using the Emacs Lisp formatter, texinfmt.el, the whitespace between columns can be increased by setting`texinfo-extra-inter-column-width' to a value greater than 0. By default,there is at least one blank space between columns.The Emacs Lisp formatter, texinfmt.el, ignores the following fourcommands that are defined in texinfo.tex for printed output. @multitableparskip, @multitableparindent, @multitablecolmargin, @multitablelinespace.";; This function pushes information onto the `texinfo-stack'.;; A stack element consists of:;; - type-of-command, i.e., multitable;; - the information about column widths, and;; - the position of texinfo-command-start.;; e.g., ('multitable (1 2 3 4) 123);; The command line is then deleted. (texinfo-push-stack 'multitable ;; push width information on stack (texinfo-multitable-widths)) (texinfo-discard-line-with-args))(put 'multitable 'texinfo-end 'tex
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -