📄 info.el
字号:
(save-restriction (if (marker-buffer Info-tag-table-marker) (let ((marker Info-tag-table-marker)) (set-buffer (marker-buffer marker)) (widen) (goto-char marker) (while (re-search-forward "\nNode: \\(.*\\)\177" nil t) (setq compl (cons (list (buffer-substring (match-beginning 1) (match-end 1))) compl)))) (widen) (goto-char (point-min)) (while (search-forward "\n\^_" nil t) (forward-line 1) (let ((beg (point))) (forward-line 1) (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]" beg t) (setq compl (cons (list (buffer-substring (match-beginning 1) (match-end 1))) compl)))))))) (setq Info-current-file-completions compl))))(defun Info-restore-point (hl) "If this node has been visited, restore the point value when we left." (while hl (if (and (equal (nth 0 (car hl)) Info-current-file) ;; Use string-equal, not equal, to ignore text props. (string-equal (nth 1 (car hl)) Info-current-node)) (progn (goto-char (nth 2 (car hl))) (setq hl nil)) ;terminate the while at next iter (setq hl (cdr hl)))))(defvar Info-last-search nil "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.")(defun Info-search (regexp) "Search for REGEXP, starting from point, and select node it's found in." (interactive "sSearch (regexp): ") (if transient-mark-mode (deactivate-mark)) (if (equal regexp "") (setq regexp Info-last-search) (setq Info-last-search regexp)) (let ((found ()) current (onode Info-current-node) (ofile Info-current-file) (opoint (point)) (ostart (window-start)) (osubfile Info-current-subfile)) (save-excursion (save-restriction (widen) (if (null Info-current-subfile) (progn (re-search-forward regexp) (setq found (point))) (condition-case err (progn (re-search-forward regexp) (setq found (point))) (search-failed nil))))) (if (not found) ;can only happen in subfile case -- else would have erred (unwind-protect (let ((list ())) (save-excursion (set-buffer (marker-buffer Info-tag-table-marker)) (goto-char (point-min)) (search-forward "\n\^_\nIndirect:") (save-restriction (narrow-to-region (point) (progn (search-forward "\n\^_") (1- (point)))) (goto-char (point-min)) (search-forward (concat "\n" osubfile ": ")) (beginning-of-line) (while (not (eobp)) (re-search-forward "\\(^.*\\): [0-9]+$") (goto-char (+ (match-end 1) 2)) (setq list (cons (cons (read (current-buffer)) (buffer-substring (match-beginning 1) (match-end 1))) list)) (goto-char (1+ (match-end 0)))) (setq list (nreverse list) current (car (car list)) list (cdr list)))) (while list (message "Searching subfile %s..." (cdr (car list))) (Info-read-subfile (car (car list))) (setq list (cdr list));; (goto-char (point-min)) (if (re-search-forward regexp nil t) (setq found (point) list ()))) (if found (message "") (signal 'search-failed (list regexp)))) (if (not found) (progn (Info-read-subfile osubfile) (goto-char opoint) (Info-select-node) (set-window-start (selected-window) ostart))))) (widen) (goto-char found) (Info-select-node) ;; Use string-equal, not equal, to ignore text props. (or (and (string-equal onode Info-current-node) (equal ofile Info-current-file)) (setq Info-history (cons (list ofile onode opoint) Info-history)))));; Extract the value of the node-pointer named NAME.;; If there is none, use ERRORNAME in the error message; ;; if ERRORNAME is nil, just return nil.(defun Info-extract-pointer (name &optional errorname) (save-excursion (goto-char (point-min)) (forward-line 1) (if (re-search-backward (concat name ":") nil t) (progn (goto-char (match-end 0)) (Info-following-node-name)) (if (eq errorname t) nil (error "Node has no %s" (capitalize (or errorname name)))))));; Return the node name in the buffer following point.;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp;; saying which chars may appear in the node name.(defun Info-following-node-name (&optional allowedchars) (skip-chars-forward " \t") (buffer-substring-no-properties (point) (progn (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]")) (skip-chars-forward (concat (or allowedchars "^,\t\n") "(")) (if (looking-at "(") (skip-chars-forward "^)"))) (skip-chars-backward " ") (point))))(defun Info-next () "Go to the next node of this node." (interactive) (Info-goto-node (Info-extract-pointer "next")))(defun Info-prev () "Go to the previous node of this node." (interactive) (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))(defun Info-up () "Go to the superior node of this node." (interactive) (Info-goto-node (Info-extract-pointer "up")) (Info-restore-point Info-history))(defun Info-last () "Go back to the last node visited." (interactive) (or Info-history (error "This is the first Info node you looked at")) (let (filename nodename opoint) (setq filename (car (car Info-history))) (setq nodename (car (cdr (car Info-history)))) (setq opoint (car (cdr (cdr (car Info-history))))) (setq Info-history (cdr Info-history)) (Info-find-node filename nodename) (setq Info-history (cdr Info-history)) (goto-char opoint)))(defun Info-directory () "Go to the Info directory node." (interactive) (Info-find-node "dir" "top"))(defun Info-follow-reference (footnotename) "Follow cross reference named NAME to the node it refers to.NAME may be an abbreviation of the reference name." (interactive (let ((completion-ignore-case t) completions default alt-default (start-point (point)) str i bol eol) (save-excursion ;; Store end and beginning of line. (end-of-line) (setq eol (point)) (beginning-of-line) (setq bol (point)) (goto-char (point-min)) (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t) (setq str (buffer-substring (match-beginning 1) (1- (point)))) ;; See if this one should be the default. (and (null default) (<= (match-beginning 0) start-point) (<= start-point (point)) (setq default t)) ;; See if this one should be the alternate default. (and (null alt-default) (and (<= bol (match-beginning 0)) (<= (point) eol)) (setq alt-default t)) (setq i 0) (while (setq i (string-match "[ \n\t]+" str i)) (setq str (concat (substring str 0 i) " " (substring str (match-end 0)))) (setq i (1+ i))) ;; Record as a completion and perhaps as default. (if (eq default t) (setq default str)) (if (eq alt-default t) (setq alt-default str)) ;; Don't add this string if it's a duplicate. ;; We use a loop instead of "(assoc str completions)" because ;; we want to do a case-insensitive compare. (let ((tail completions) (tem (downcase str))) (while (and tail (not (string-equal tem (downcase (car (car tail)))))) (setq tail (cdr tail))) (or tail (setq completions (cons (cons str nil) completions)))))) ;; If no good default was found, try an alternate. (or default (setq default alt-default)) ;; If only one cross-reference found, then make it default. (if (eq (length completions) 1) (setq default (car (car completions)))) (if completions (let ((input (completing-read (if default (concat "Follow reference named: (" default ") ") "Follow reference named: ") completions nil t))) (list (if (equal input "") default input))) (error "No cross-references in this node")))) (let (target beg i (str (concat "\\*note " (regexp-quote footnotename)))) (while (setq i (string-match " " str i)) (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i)))) (setq i (+ i 6))) (save-excursion (goto-char (point-min)) (or (re-search-forward str nil t) (error "No cross-reference named %s" footnotename)) (goto-char (+ (match-beginning 0) 5)) (setq target (Info-extract-menu-node-name "Bad format cross reference" t))) (while (setq i (string-match "[ \t\n]+" target i)) (setq target (concat (substring target 0 i) " " (substring target (match-end 0)))) (setq i (+ i 1))) (Info-goto-node target)))(defun Info-extract-menu-node-name (&optional errmessage multi-line) (skip-chars-forward " \t\n") (let ((beg (point)) str i) (skip-chars-forward "^:") (forward-char 1) (setq str (if (looking-at ":") (buffer-substring-no-properties beg (1- (point))) (skip-chars-forward " \t\n") (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n")))) (while (setq i (string-match "\n" str i)) (aset str i ?\ )) ;; Collapse multiple spaces. (while (string-match " +" str) (setq str (replace-match " " t t str))) str));; No one calls this.;;(defun Info-menu-item-sequence (list);; (while list;; (Info-menu (car list));; (setq list (cdr list))))(defun Info-complete-menu-item (string predicate action) (let ((case-fold-search t)) (cond ((eq action nil) (let (completions (pattern (concat "\n\\* \\(" (regexp-quote string) "[^:\t\n]*\\):"))) (save-excursion (set-buffer Info-complete-menu-buffer) (goto-char (point-min)) (search-forward "\n* Menu:") (while (re-search-forward pattern nil t) (setq completions (cons (cons (format "%s" (buffer-substring (match-beginning 1) (match-end 1))) (match-beginning 1)) completions)))) (try-completion string completions predicate))) ((eq action t) (let (completions (pattern (concat "\n\\* \\(" (regexp-quote string) "[^:\t\n]*\\):"))) (save-excursion (set-buffer Info-complete-menu-buffer) (goto-char (point-min)) (search-forward "\n* Menu:") (while (re-search-forward pattern nil t) (setq completions (cons (cons (format "%s" (buffer-substring (match-beginning 1) (match-end 1))) (match-beginning 1)) completions)))) (all-completions string completions predicate))) (t (save-excursion (set-buffer Info-complete-menu-buffer) (goto-char (point-min)) (search-forward "\n* Menu:") (re-search-forward (concat "\n\\* " (regexp-quote string) ":") nil t))))))(defun Info-menu (menu-item) "Go to node for menu item named (or abbreviated) NAME.Completion is allowed, and the menu item point is on is the default." (interactive (let ((completions '()) ;; If point is within a menu item, use that item as the default (default nil) (p (point)) beg (last nil)) (save-excursion (goto-char (point-min)) (if (not (search-forward "\n* menu:" nil t)) (error "No menu in this node")) (setq beg (point)) (and (< (point) p) (save-excursion (goto-char p) (end-of-line) (re-search-backward "\n\\* \\([^:\t\n]*\\):" beg t) (setq default (format "%s" (buffer-substring (match-beginning 1) (match-end 1))))))) (let ((item nil)) (while (null item) (setq item (let ((completion-ignore-case t) (Info-complete-menu-buffer (current-buffer))) (completing-read (if default (format "Menu item (default %s): " default) "Menu item: ") 'Info-complete-menu-item nil t))) ;; we rely on the fact that completing-read accepts an input ;; of "" even when the require-match argument is true and "" ;; is not a valid possibility (if (string= item "") (if default (setq item default) ;; ask again (setq item nil)))) (list item))))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -