?? texnfo-upd.el
字號:
;;; Determining the hierarchical level in the texinfo file(defun texinfo-specific-section-type () "Return the specific type of next section, as a string.For example, \"unnumberedsubsec\". Return \"top\" for top node.Searches forward for a section. Hence, point must be before thesection whose type will be found. Does not move point. Signal anerror if the node is not the top node and a section is not found." (let ((case-fold-search t)) (save-excursion (cond ((re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)";;; Following search limit by cph but causes a bug;;; (save-excursion;;; (end-of-line);;; (point)) nil t) "top") ((re-search-forward texinfo-section-types-regexp nil t) (buffer-substring-no-properties (progn (beginning-of-line) ; copy its name (1+ (point))) (progn (forward-word 1) (point)))) (t (error "texinfo-specific-section-type: Chapter or section not found."))))))(defun texinfo-hierarchic-level () "Return the general hierarchal level of the next node in a texinfo file.Thus, a subheading or appendixsubsec is of type subsection." (let ((case-fold-search t)) (cdr (assoc (texinfo-specific-section-type) texinfo-section-to-generic-alist))));;; Locating the major positions(defun texinfo-update-menu-region-beginning (level) "Locate beginning of higher level section this section is within.Return position of the beginning of the node line; do not move point.Thus, if this level is subsection, searches backwards for section node.Only argument is a string of the general type of section." (let ((case-fold-search t)) ;; !! Known bug: if section immediately follows top node, this ;; returns the beginning of the buffer as the beginning of the ;; higher level section. (cond ((or (string-equal "top" level) (string-equal "chapter" level)) (save-excursion (goto-char (point-min)) (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t) (beginning-of-line) (point))) (t (save-excursion (re-search-backward (concat "\\(^@node\\).*\n" ; match node line "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any "\\|" ; or "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any (eval (cdr (assoc level texinfo-update-menu-higher-regexps)))) nil 'goto-beginning) (point))))))(defun texinfo-update-menu-region-end (level) "Locate end of higher level section this section is within.Return position; do not move point. Thus, if this level is asubsection, find the node for the section this subsection is within.If level is top or chapter, returns end of file. Only argument is astring of the general type of section." (let ((case-fold-search t)) (save-excursion (if (re-search-forward (concat "\\(^@node\\).*\n" ; match node line "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any "\\|" ; or "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any (eval ;; Never finds end of level above chapter so goes to end. (cdr (assoc level texinfo-update-menu-higher-regexps)))) nil 'goto-end) (match-beginning 1) (point-max)))))(defun texinfo-menu-first-node (beginning end) "Locate first node of the section the menu will be placed in. Return position; do not move point.The menu will be located just before this position. First argument is the position of the beginning of the section inwhich the menu will be located; second argument is the position of theend of that region; it limits the search." (save-excursion (goto-char beginning) (forward-line 1) (re-search-forward "^@node" end t) (beginning-of-line) (point)));;; Alists and regular expressions for defining hierarchical levels(defvar texinfo-section-to-generic-alist '(("top" . "top") ("chapter" . "chapter") ("unnumbered" . "chapter") ("majorheading" . "chapter") ("chapheading" . "chapter") ("appendix" . "chapter") ("section" . "section") ("unnumberedsec" . "section") ("heading" . "section") ("appendixsec" . "section") ("subsection" . "subsection") ("unnumberedsubsec" . "subsection") ("subheading" . "subsection") ("appendixsubsec" . "subsection") ("subsubsection" . "subsubsection") ("unnumberedsubsubsec" . "subsubsection") ("subsubheading" . "subsubsection") ("appendixsubsubsec" . "subsubsection")) "*An alist of specific and corresponding generic Texinfo section types.The keys are strings specifying specific types of section; the valuesare strings of their corresponding general types.");; We used to look for just sub, but that found @subtitle.(defvar texinfo-section-types-regexp "^@\\(chapter \\|sect\\|subs\\|subh\\|unnum\\|major\\|chapheading \\|heading \\|appendix\\)" "Regexp matching chapter, section, other headings (but not the top node).")(defvar texinfo-chapter-level-regexp "chapter\\|unnumbered \\|appendix \\|majorheading\\|chapheading" "Regular expression matching just the Texinfo chapter level headings.")(defvar texinfo-section-level-regexp "section\\|unnumberedsec\\|heading \\|appendixsec" "Regular expression matching just the Texinfo section level headings.")(defvar texinfo-subsection-level-regexp "subsection\\|unnumberedsubsec\\|subheading\\|appendixsubsec" "Regular expression matching just the Texinfo subsection level headings.")(defvar texinfo-subsubsection-level-regexp "subsubsection\\|unnumberedsubsubsec\\|subsubheading\\|appendixsubsubsec" "Regular expression matching just the Texinfo subsubsection level headings.")(defvar texinfo-update-menu-same-level-regexps '(("top" . "top[ \t]+") ("chapter" . (concat "\\(^@\\)\\(" texinfo-chapter-level-regexp "\\)[ \t]*")) ("section" . (concat "\\(^@\\)\\(" texinfo-section-level-regexp "\\)[ \t]*")) ("subsection" . (concat "\\(^@\\)\\(" texinfo-subsection-level-regexp "\\)[ \t]+")) ("subsubsection" . (concat "\\(^@\\)\\(" texinfo-subsubsection-level-regexp "\\)[ \t]+"))) "*Regexps for searching for same level sections in a Texinfo file.The keys are strings specifying the general hierarchical level in thedocument; the values are regular expressions.")(defvar texinfo-update-menu-higher-regexps '(("top" . "^@node [ \t]*DIR") ("chapter" . "^@node [ \t]*top[ \t]*\\(,\\|$\\)") ("section" . (concat "\\(^@\\(" texinfo-chapter-level-regexp "\\)[ \t]*\\)")) ("subsection" . (concat "\\(^@\\(" texinfo-section-level-regexp "\\|" texinfo-chapter-level-regexp "\\)[ \t]*\\)")) ("subsubsection" . (concat "\\(^@\\(" texinfo-subsection-level-regexp "\\|" texinfo-section-level-regexp "\\|" texinfo-chapter-level-regexp "\\)[ \t]*\\)"))) "*Regexps for searching for higher level sections in a Texinfo file.The keys are strings specifying the general hierarchical level in thedocument; the values are regular expressions.")(defvar texinfo-update-menu-lower-regexps '(("top" . (concat "\\(^@\\(" texinfo-chapter-level-regexp "\\|" texinfo-section-level-regexp "\\|" texinfo-subsection-level-regexp "\\|" texinfo-subsubsection-level-regexp "\\)[ \t]*\\)")) ("chapter" . (concat "\\(^@\\(" texinfo-section-level-regexp "\\|" texinfo-subsection-level-regexp "\\|" texinfo-subsubsection-level-regexp "\\)[ \t]*\\)")) ("section" . (concat "\\(^@\\(" texinfo-subsection-level-regexp "\\|" texinfo-subsubsection-level-regexp "\\)[ \t]+\\)")) ("subsection" . (concat "\\(^@\\(" texinfo-subsubsection-level-regexp "\\)[ \t]+\\)")) ("subsubsection" . "nothing lower")) "*Regexps for searching for lower level sections in a Texinfo file.The keys are strings specifying the general hierarchical level in thedocument; the values are regular expressions.");;; Updating a node;;;###autoload(defun texinfo-update-node (&optional beginning end) "Without any prefix argument, update the node in which point is located.Interactively, a prefix argument means to operate on the region.The functions for creating or updating nodes and menus, and theirkeybindings, are: texinfo-update-node (&optional beginning end) \\[texinfo-update-node] texinfo-every-node-update () \\[texinfo-every-node-update] texinfo-sequential-node-update (&optional region-p) texinfo-make-menu (&optional region-p) \\[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. Its default value is 32." (interactive (if prefix-arg (list (point) (mark)))) (if (null beginning) ;; Update a single node. (let ((auto-fill-function nil) (auto-fill-hook nil)) (if (not (re-search-backward "^@node" (point-min) t)) (error "Node line not found before this position")) (texinfo-update-the-node) (message "Done...updated the node. You may save the buffer.")) ;; else (let ((auto-fill-function nil) (auto-fill-hook nil)) (save-excursion (save-restriction (narrow-to-region beginning end) (goto-char (point-min)) (while (re-search-forward "^@node" (point-max) t) (beginning-of-line) (texinfo-update-the-node)) (goto-char (point-max)) (message "Done...nodes updated in region. You may save the buffer."))))));;;###autoload(defun texinfo-every-node-update () "Update every node in a Texinfo file." (interactive) (save-excursion (texinfo-update-node (point-min) (point-max)) (message "Done...updated every node. You may save the buffer.")))(defun texinfo-update-the-node () "Update one node. Point must be at the beginning of node line. Leave point at the end of the node line." (texinfo-check-for-node-name) (texinfo-delete-existing-pointers) (message "Updating node: %s ... " (texinfo-copy-node-name)) (save-restriction (widen) (let* ((case-fold-search t) (level (texinfo-hierarchic-level)) (beginning (texinfo-update-menu-region-beginning level)) (end (texinfo-update-menu-region-end level))) (if (string-equal level "top") (texinfo-top-pointer-case) ;; else (texinfo-insert-pointer beginning end level 'next) (texinfo-insert-pointer beginning end level 'previous) (texinfo-insert-pointer beginning end level 'up) (texinfo-clean-up-node-line)))))(defun texinfo-top-pointer-case () "Insert pointers in the Top node. This is a special case.The `Next' pointer is a pointer to a chapter or section at a lowerhierarchical level in the file. The `Previous' and `Up' pointers areto `(dir)'. Point must be at the beginning of the node line, and isleft at the end of the node line." (texinfo-clean-up-node-line) (insert ", " (save-excursion ;; There may be an @chapter or other such command between ;; the top node line and the next node line, as a title ;; for an `ifinfo' section. This @chapter command must ;; must be skipped. So the procedure is to search for ;; the next `@node' line, and then copy its name.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -