?? texnfo-upd.el
字號:
(if (re-search-forward "^@node" nil t) (progn (beginning-of-line) (texinfo-copy-node-name)) " ")) ", (dir), (dir)"))(defun texinfo-check-for-node-name () "Determine whether the node has a node name. Prompt for one if not.Point must be at beginning of node line. Does not move point." (save-excursion (let ((initial (texinfo-copy-next-section-title))) ;; This is not clean. Use `interactive' to read the arg. (forward-word 1) ; skip over node command (skip-chars-forward " \t") ; and over spaces (if (not (looking-at "[^,\t\n ]+")) ; regexp based on what Info looks for ; alternatively, use "[a-zA-Z]+" (let ((node-name (read-from-minibuffer "Node name (use no @, commas, colons, or apostrophes): " initial))) (insert " " node-name))))))(defun texinfo-delete-existing-pointers () "Delete `Next', `Previous', and `Up' pointers. Starts from the current position of the cursor, and searches forwardon the line for a comma and if one is found, deletes the rest of theline, including the comma. Leaves point at beginning of line." (let ((eol-point (save-excursion (end-of-line) (point)))) (if (search-forward "," eol-point t) (delete-region (1- (point)) eol-point))) (beginning-of-line))(defun texinfo-find-pointer (beginning end level direction) "Move point to section associated with next, previous, or up pointer.Return type of pointer (either `normal' or `no-pointer').The first and second arguments bound the search for a pointer to thebeginning and end, respectively, of the enclosing higher levelsection. The third argument is a string specifying the general kindof section such as \"chapter\" or \"section\". When looking for the`Next' pointer, the section found will be at the same hierarchicallevel in the Texinfo file; when looking for the `Previous' pointer,the section found will be at the same or higher hierarchical level inthe Texinfo file; when looking for the `Up' pointer, the section foundwill be at some level higher in the Texinfo file. The fourth argument\(one of 'next, 'previous, or 'up\) specifies whether to find the`Next', `Previous', or `Up' pointer." (let ((case-fold-search t)) (cond ((eq direction 'next) (forward-line 3) ; skip over current node ;; Search for section commands accompanied by node lines; ;; ignore section commands in the middle of nodes. (if (re-search-forward ;; A `Top' node is never a next pointer, so won't find it. (concat ;; Match node line. "\\(^@node\\).*\n" ;; Match comment or ifinfo line, if any "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" (eval (cdr (assoc level texinfo-update-menu-same-level-regexps)))) end t) 'normal 'no-pointer)) ((eq direction 'previous) (if (re-search-backward (concat "\\(" ;; Match node line. "\\(^@node\\).*\n" ;; Match comment or ifinfo line, if any "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" (eval (cdr (assoc level texinfo-update-menu-same-level-regexps))) "\\|" ;; Match node line. "\\(^@node\\).*\n" ;; Match comment or ifinfo line, if any "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) "\\|" ;; Handle `Top' node specially. "^@node [ \t]*top[ \t]*\\(,\\|$\\)" "\\)") beginning t) 'normal 'no-pointer)) ((eq direction 'up) (if (re-search-backward (concat "\\(" ;; Match node line. "\\(^@node\\).*\n" ;; Match comment or ifinfo line, if any "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) "\\|" ;; Handle `Top' node specially. "^@node [ \t]*top[ \t]*\\(,\\|$\\)" "\\)") (save-excursion (goto-char beginning) (beginning-of-line) (point)) t) 'normal 'no-pointer)) (t (error "texinfo-find-pointer: lack proper arguments")))))(defun texinfo-pointer-name (kind) "Return the node name preceding the section command.The argument is the kind of section, either `normal' or `no-pointer'." (let (name) (cond ((eq kind 'normal) (end-of-line) ; this handles prev node top case (re-search-backward ; when point is already "^@node" ; at the beginning of @node line (save-excursion (forward-line -3)) t) (setq name (texinfo-copy-node-name))) ((eq kind 'no-pointer) ;; Don't need to put a blank in the pointer slot, ;; since insert "' " always has a space (setq name " "))) ; put a blank in the pointer slot name))(defun texinfo-insert-pointer (beginning end level direction) "Insert the `Next', `Previous' or `Up' node name at point.Move point forward. The first and second arguments bound the search for a pointer to thebeginning and end, respectively, of the enclosing higher levelsection. The third argument is the hierarchical level of the Texinfofile, a string such as \"section\". The fourth argument is directiontowards which the pointer is directed, one of `next', `previous', or `up'." (end-of-line) (insert ", " (save-excursion (texinfo-pointer-name (texinfo-find-pointer beginning end level direction)))))(defun texinfo-clean-up-node-line () "Remove extra commas, if any, at end of node line." (end-of-line) (skip-chars-backward ", ") (delete-region (point) (save-excursion (end-of-line) (point))));;; Updating nodes sequentially;; These sequential update functions insert `Next' or `Previous';; pointers that point to the following or preceding nodes even if they;; are at higher or lower hierarchical levels. This means that if a;; section contains one or more subsections, the section's `Next';; pointer will point to the subsection and not the following section.;; (The subsection to which `Next' points will most likely be the first;; item on the section's menu.);;;###autoload(defun texinfo-sequential-node-update (&optional region-p) "Update one node (or many) in a Texinfo file with sequential pointers.This function causes the `Next' or `Previous' pointer to point to theimmediately preceding or following node, even if it is at a higher orlower hierarchical level in the document. Continually pressing `n' or`p' takes you straight through the file.Without any prefix argument, update the node in which point is located.Non-nil argument (prefix, if interactive) means update the nodes in themarked region.This command makes it awkward to navigate among sections andsubsections; it should be used only for those documents that are meantto be read like a novel rather than a reference, and for which theInfo `g*' command is inadequate." (interactive "P") (if (not region-p) ;; 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-sequentially-update-the-node) (message "Done...sequentially updated the node . You may save the buffer.")) ;; else (let ((auto-fill-function nil) (auto-fill-hook nil) (beginning (region-beginning)) (end (region-end))) (if (= end beginning) (error "Please mark a region!")) (save-restriction (narrow-to-region beginning end) (goto-char beginning) (push-mark (point) t) (while (re-search-forward "^@node" (point-max) t) (beginning-of-line) (texinfo-sequentially-update-the-node)) (message "Done...updated the nodes in sequence. You may save the buffer.")))))(defun texinfo-sequentially-update-the-node () "Update one node such that the pointers are sequential. A `Next' or `Previous' pointer points to any preceding or following node,regardless of its hierarchical level." (texinfo-check-for-node-name) (texinfo-delete-existing-pointers) (message "Sequentially updating node: %s ... " (texinfo-copy-node-name)) (save-restriction (widen) (let* ((case-fold-search t) (level (texinfo-hierarchic-level))) (if (string-equal level "top") (texinfo-top-pointer-case) ;; else (texinfo-sequentially-insert-pointer level 'next) (texinfo-sequentially-insert-pointer level 'previous) (texinfo-sequentially-insert-pointer level 'up) (texinfo-clean-up-node-line)))))(defun texinfo-sequentially-find-pointer (level direction) "Find next or previous pointer sequentially in Texinfo file, or up pointer.Move point to section associated with the pointer. Find point even ifit is in a different section.Return type of pointer (either `normal' or `no-pointer').The first argument is a string specifying the general kind of sectionsuch as \"chapter\" or \"section\". The section found will be at thesame hierarchical level in the Texinfo file, or, in the case of the uppointer, some level higher. The second argument (one of `next',`previous', or `up') specifies whether to find the `Next', `Previous',or `Up' pointer." (let ((case-fold-search t)) (cond ((eq direction 'next) (forward-line 3) ; skip over current node (if (re-search-forward texinfo-section-types-regexp (point-max) t) 'normal 'no-pointer)) ((eq direction 'previous) (if (re-search-backward texinfo-section-types-regexp (point-min) t) 'normal 'no-pointer)) ((eq direction 'up) (if (re-search-backward (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) beginning t) 'normal 'no-pointer)) (t (error "texinfo-sequential-find-pointer: lack proper arguments")))))(defun texinfo-sequentially-insert-pointer (level direction) "Insert the `Next', `Previous' or `Up' node name at point.Move point forward. The first argument is the hierarchical level of the Texinfo file, astring such as \"section\". The second argument is direction, one of`next', `previous', or `up'." (end-of-line) (insert ", " (save-excursion (texinfo-pointer-name (texinfo-sequentially-find-pointer level direction)))));;; Inserting `@node' lines;; The `texinfo-insert-node-lines' function inserts `@node' lines as needed;; before the `@chapter', `@section', and such like lines of a region;; in a Texinfo file.(defun texinfo-insert-node-lines (beginning end &optional title-p) "Insert missing `@node' lines in region of Texinfo file.Non-nil argument (prefix, if interactive) means also to insert thesection titles as node names; and also to insert the section titles asnode names in pre-existing `@node' lines that lack names." (interactive "r\nP") ;; Use marker; after inserting node lines, leave point at end of ;; region and mark at beginning. (let (beginning-marker end-marker title last-section-position) ;; Save current position on mark ring and set mark to end. (push-mark end t) (setq end-marker (mark-marker)) (goto-char beginning) (while (re-search-forward texinfo-section-types-regexp end-marker 'end) ;; Copy title if desired. (if title-p (progn (beginning-of-line) (forward-word 1) (skip-chars-forward " \t") (setq title (buffer-substring (point) (save-excursion (end-of-line) (point)))))) ;; Insert node line if necessary. (if (re-search-backward "^@node" ;; Avoid finding previous node line if node lines are close. (or last-section-position (save-excursion (forward-line -2) (point))) t) ;; @node is present, and point at beginning of that line (forward-word 1) ; Leave point just after @node. ;; Else @node missing; insert one
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -