aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2004-04-27 06:39:46 +0000
committerJuri Linkov2004-04-27 06:39:46 +0000
commit836bb4786678227f2bb50497250dd726e2db3653 (patch)
treef858c6767ba36a00b3be6acd75061bf5a0c482f2
parent5a2c89c3abd33ee8de4702ab7fe376ba642393a9 (diff)
downloademacs-836bb4786678227f2bb50497250dd726e2db3653.tar.gz
emacs-836bb4786678227f2bb50497250dd726e2db3653.zip
Add *info*<[0-9]+> to same-window-regexps instead of
same-window-buffer-names. (info): New arg `buffer'. Use it. Doc fix. Read file name for non-numeric prefix argument, append the number to the buffer name for numeric prefix argument. (info-other-window): Bind same-window-regexps to nil. (Info-reference-name): Rename to Info-point-loc. (Info-find-node-2): Call forward-line for numeric Info-point-loc, and Info-find-index-name for stringy Info-point-loc. (Info-extract-menu-node-name): New arg `index-node'. Use regexp without middle `.', but with final `.' and optional line number for it. Set Info-point-loc for index nodes. (Info-index): Remove middle `.' from index entry regexp. Modify line number regexp. (Info-index-next): Decrement line number. (info-apropos): Remove middle `.' from index entry regexp. Add optional line number regexp at the end. Add matched value for line number to the result list and insert it to the buffer. (Info-fontify-node): Hide index line numbers. (Info-goto-node): Replace "\\s *\\'" by "\\s +\\'" to not trim empty matches. (Info-follow-reference): Use `str' instead of Info-following-node-name-re. (Info-toc): Use full file names. Set Info-current-node to "Top". (Info-fontify-node): Compare file names without directory name. (Info-try-follow-nearest-node): Don't set Info-reference-name. Set second arg of Info-extract-menu-node-name for index nodes. (info-xref-visited): Use magenta3 instead of magenta4. (Info-mode): Add info-apropos to docstring.
-rw-r--r--lisp/info.el120
1 files changed, 79 insertions, 41 deletions
diff --git a/lisp/info.el b/lisp/info.el
index 58690deb198..a57078d5e2d 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -88,7 +88,7 @@ The Lisp code is executed when the node is selected.")
88(defface info-xref-visited 88(defface info-xref-visited
89 '((t :inherit info-xref) 89 '((t :inherit info-xref)
90 (((class color) (background light)) :foreground "magenta4") 90 (((class color) (background light)) :foreground "magenta4")
91 (((class color) (background dark)) :foreground "magenta4")) 91 (((class color) (background dark)) :foreground "magenta3")) ;"violet"?
92 "Face for visited Info cross-references." 92 "Face for visited Info cross-references."
93 :group 'info) 93 :group 'info)
94 94
@@ -239,10 +239,11 @@ Marker points nowhere if file has no tag table.")
239(defvar Info-index-alternatives nil 239(defvar Info-index-alternatives nil
240 "List of possible matches for last `Info-index' command.") 240 "List of possible matches for last `Info-index' command.")
241 241
242(defvar Info-reference-name nil 242(defvar Info-point-loc nil
243 "Name of the selected cross-reference. 243 "Point location within a selected node.
244Point is moved to the proper occurrence of this name within a node 244If string, the point is moved to the proper occurrence of the
245after selecting it.") 245name of the followed cross reference within a selected node.
246If number, the point is moved to the corresponding line.")
246 247
247(defvar Info-standalone nil 248(defvar Info-standalone nil
248 "Non-nil if Emacs was started solely as an Info browser.") 249 "Non-nil if Emacs was started solely as an Info browser.")
@@ -449,28 +450,38 @@ Do the right thing if the file has been compressed or zipped."
449 "Like `info' but show the Info buffer in another window." 450 "Like `info' but show the Info buffer in another window."
450 (interactive (if current-prefix-arg 451 (interactive (if current-prefix-arg
451 (list (read-file-name "Info file name: " nil nil t)))) 452 (list (read-file-name "Info file name: " nil nil t))))
452 (let (same-window-buffer-names) 453 (let (same-window-buffer-names same-window-regexps)
453 (info file))) 454 (info file)))
454 455
455;;;###autoload (add-hook 'same-window-buffer-names "*info*") 456;;;###autoload (add-hook 'same-window-regexps "\\*info\\*\\(\\|<[0-9]+>\\)")
456 457
457;;;###autoload 458;;;###autoload
458(defun info (&optional file) 459(defun info (&optional file buffer)
459 "Enter Info, the documentation browser. 460 "Enter Info, the documentation browser.
460Optional argument FILE specifies the file to examine; 461Optional argument FILE specifies the file to examine;
461the default is the top-level directory of Info. 462the default is the top-level directory of Info.
462Called from a program, FILE may specify an Info node of the form 463Called from a program, FILE may specify an Info node of the form
463`(FILENAME)NODENAME'. 464`(FILENAME)NODENAME'.
465Optional argument BUFFER specifies the Info buffer name;
466the default buffer name is *info*. If BUFFER exists,
467just switch to BUFFER. Otherwise, create a new buffer
468with the top-level Info directory.
464 469
465In interactive use, a prefix argument directs this command 470In interactive use, a non-numeric prefix argument directs
466to read a file name from the minibuffer. 471this command to read a file name from the minibuffer.
472A numeric prefix argument appends the number to the buffer name.
467 473
468The search path for Info files is in the variable `Info-directory-list'. 474The search path for Info files is in the variable `Info-directory-list'.
469The top-level Info directory is made by combining all the files named `dir' 475The top-level Info directory is made by combining all the files named `dir'
470in all the directories in that path." 476in all the directories in that path."
471 (interactive (if current-prefix-arg 477 (interactive (list
472 (list (read-file-name "Info file name: " nil nil t)))) 478 (if (and current-prefix-arg (not (numberp current-prefix-arg)))
473 (pop-to-buffer "*info*") 479 (read-file-name "Info file name: " nil nil t))
480 (if (numberp current-prefix-arg)
481 (format "*info*<%s>" current-prefix-arg))))
482 (pop-to-buffer (or buffer "*info*"))
483 (if (and buffer (not (eq major-mode 'Info-mode)))
484 (Info-mode))
474 (if file 485 (if file
475 ;; If argument already contains parentheses, don't add another set 486 ;; If argument already contains parentheses, don't add another set
476 ;; since the argument will then be parsed improperly. This also 487 ;; since the argument will then be parsed improperly. This also
@@ -866,9 +877,12 @@ a case-insensitive match is tried."
866 (cons new-history 877 (cons new-history
867 (delete new-history Info-history-list)))) 878 (delete new-history Info-history-list))))
868 (goto-char anchorpos)) 879 (goto-char anchorpos))
869 (Info-reference-name 880 ((numberp Info-point-loc)
870 (Info-find-index-name Info-reference-name) 881 (forward-line (1- Info-point-loc))
871 (setq Info-reference-name nil)))))) 882 (setq Info-point-loc nil))
883 ((stringp Info-point-loc)
884 (Info-find-index-name Info-point-loc)
885 (setq Info-point-loc nil))))))
872 ;; If we did not finish finding the specified node, 886 ;; If we did not finish finding the specified node,
873 ;; go back to the previous one. 887 ;; go back to the previous one.
874 (or Info-current-node no-going-back (null Info-history) 888 (or Info-current-node no-going-back (null Info-history)
@@ -1313,9 +1327,9 @@ If FORK is a string, it is the name to use for the new buffer."
1313 "" 1327 ""
1314 (match-string 2 nodename)) 1328 (match-string 2 nodename))
1315 nodename (match-string 3 nodename)) 1329 nodename (match-string 3 nodename))
1316 (let ((trim (string-match "\\s *\\'" filename))) 1330 (let ((trim (string-match "\\s +\\'" filename)))
1317 (if trim (setq filename (substring filename 0 trim)))) 1331 (if trim (setq filename (substring filename 0 trim))))
1318 (let ((trim (string-match "\\s *\\'" nodename))) 1332 (let ((trim (string-match "\\s +\\'" nodename)))
1319 (if trim (setq nodename (substring nodename 0 trim)))) 1333 (if trim (setq nodename (substring nodename 0 trim))))
1320 (if transient-mark-mode (deactivate-mark)) 1334 (if transient-mark-mode (deactivate-mark))
1321 (Info-find-node (if (equal filename "") nil filename) 1335 (Info-find-node (if (equal filename "") nil filename)
@@ -1664,10 +1678,11 @@ If SAME-FILE is non-nil, do not move to a different Info file."
1664 (insert "*Note Top::\n") 1678 (insert "*Note Top::\n")
1665 (Info-insert-toc 1679 (Info-insert-toc
1666 (nth 2 (assoc "Top" node-list)) ; get Top nodes 1680 (nth 2 (assoc "Top" node-list)) ; get Top nodes
1667 node-list 0 (file-name-nondirectory curr-file))) 1681 node-list 0 curr-file))
1668 (if (not (bobp)) 1682 (if (not (bobp))
1669 (let ((Info-hide-note-references 'hide) 1683 (let ((Info-hide-note-references 'hide)
1670 (Info-fontify-visited-nodes nil)) 1684 (Info-fontify-visited-nodes nil))
1685 (setq Info-current-node "Top")
1671 (Info-fontify-node))) 1686 (Info-fontify-node)))
1672 (goto-char (point-min)) 1687 (goto-char (point-min))
1673 (if (setq p (search-forward (concat "*Note " curr-node ":") nil t)) 1688 (if (setq p (search-forward (concat "*Note " curr-node ":") nil t))
@@ -1829,8 +1844,7 @@ new buffer."
1829 (if (and (save-excursion 1844 (if (and (save-excursion
1830 (goto-char (+ (point) 5)) ; skip a possible *note 1845 (goto-char (+ (point) 5)) ; skip a possible *note
1831 (re-search-backward "\\*note[ \n\t]+" nil t) 1846 (re-search-backward "\\*note[ \n\t]+" nil t)
1832 (looking-at (concat "\\*note[ \n\t]+" 1847 (looking-at str))
1833 (Info-following-node-name-re "^.,\t"))))
1834 (<= (point) (match-end 0))) 1848 (<= (point) (match-end 0)))
1835 (goto-char (match-beginning 0)))) 1849 (goto-char (match-beginning 0))))
1836 ;; Go to the reference closest to point 1850 ;; Go to the reference closest to point
@@ -1858,11 +1872,27 @@ new buffer."
1858Because of ambiguities, this should be concatenated with something like 1872Because of ambiguities, this should be concatenated with something like
1859`:' and `Info-following-node-name-re'.") 1873`:' and `Info-following-node-name-re'.")
1860 1874
1861(defun Info-extract-menu-node-name (&optional multi-line) 1875(defun Info-extract-menu-node-name (&optional multi-line index-node)
1862 (skip-chars-forward " \t\n") 1876 (skip-chars-forward " \t\n")
1863 (when (looking-at (concat Info-menu-entry-name-re ":\\(:\\|" 1877 (when (looking-at (concat Info-menu-entry-name-re ":\\(:\\|"
1864 (Info-following-node-name-re 1878 (Info-following-node-name-re
1865 (if multi-line "^.,\t" "^.,\t\n")) "\\)")) 1879 (cond
1880 (index-node "^,\t\n")
1881 (multi-line "^.,\t")
1882 (t "^.,\t\n")))
1883 "\\)"
1884 (if index-node
1885 "\\.\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"
1886 "")))
1887 (if index-node
1888 (setq Info-point-loc
1889 (if (match-beginning 5)
1890 (string-to-number (match-string 5))
1891 (buffer-substring (match-beginning 0) (1- (match-beginning 1)))))
1892;;; Comment out the next line to use names of cross-references:
1893;;; (setq Info-point-loc
1894;;; (buffer-substring (match-beginning 0) (1- (match-beginning 1))))
1895 )
1866 (replace-regexp-in-string 1896 (replace-regexp-in-string
1867 "[ \n]+" " " 1897 "[ \n]+" " "
1868 (or (match-string 2) 1898 (or (match-string 2)
@@ -2327,7 +2357,7 @@ Give a blank topic name to go to the Index node itself."
2327 (if (equal Info-current-file "dir") 2357 (if (equal Info-current-file "dir")
2328 (error "The Info directory node has no index; use m to select a manual")) 2358 (error "The Info directory node has no index; use m to select a manual"))
2329 (let ((orignode Info-current-node) 2359 (let ((orignode Info-current-node)
2330 (pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)" 2360 (pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2331 (regexp-quote topic))) 2361 (regexp-quote topic)))
2332 node 2362 node
2333 (case-fold-search t)) 2363 (case-fold-search t))
@@ -2379,7 +2409,7 @@ Give a blank topic name to go to the Index node itself."
2379 num (1- num))) 2409 num (1- num)))
2380 (Info-goto-node (nth 1 (car Info-index-alternatives))) 2410 (Info-goto-node (nth 1 (car Info-index-alternatives)))
2381 (if (> (nth 3 (car Info-index-alternatives)) 0) 2411 (if (> (nth 3 (car Info-index-alternatives)) 0)
2382 (forward-line (nth 3 (car Info-index-alternatives))) 2412 (forward-line (1- (nth 3 (car Info-index-alternatives))))
2383 (forward-line 3) ; don't search in headers 2413 (forward-line 3) ; don't search in headers
2384 (let ((name (car (car Info-index-alternatives)))) 2414 (let ((name (car (car Info-index-alternatives))))
2385 (Info-find-index-name name))) 2415 (Info-find-index-name name)))
@@ -2418,7 +2448,7 @@ Give a blank topic name to go to the Index node itself."
2418Build a menu of the possible matches." 2448Build a menu of the possible matches."
2419 (interactive "sIndex apropos: ") 2449 (interactive "sIndex apropos: ")
2420 (unless (string= string "") 2450 (unless (string= string "")
2421 (let ((pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^.]+\\)." 2451 (let ((pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]+\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2422 (regexp-quote string))) 2452 (regexp-quote string)))
2423 (ohist Info-history) 2453 (ohist Info-history)
2424 (ohist-list Info-history-list) 2454 (ohist-list Info-history-list)
@@ -2447,9 +2477,10 @@ Build a menu of the possible matches."
2447 (goto-char (point-min)) 2477 (goto-char (point-min))
2448 (while (re-search-forward pattern nil t) 2478 (while (re-search-forward pattern nil t)
2449 (add-to-list 'matches 2479 (add-to-list 'matches
2450 (list (match-string 1) 2480 (list manual
2451 (match-string 2) 2481 (match-string-no-properties 1)
2452 manual))) 2482 (match-string-no-properties 2)
2483 (match-string-no-properties 3))))
2453 (and (setq node (Info-extract-pointer "next" t)) 2484 (and (setq node (Info-extract-pointer "next" t))
2454 (string-match "\\<Index\\>" node))) 2485 (string-match "\\<Index\\>" node)))
2455 (Info-goto-node node)))) 2486 (Info-goto-node node))))
@@ -2465,8 +2496,10 @@ Build a menu of the possible matches."
2465 (insert "\n\nFile: apropos, Node: Top, Up: (dir)\n") 2496 (insert "\n\nFile: apropos, Node: Top, Up: (dir)\n")
2466 (insert "* Menu: \nNodes whose indices contain \"" string "\"\n\n") 2497 (insert "* Menu: \nNodes whose indices contain \"" string "\"\n\n")
2467 (dolist (entry matches) 2498 (dolist (entry matches)
2468 (insert "* " (car entry) " [" (nth 2 entry) 2499 (insert "* " (nth 1 entry) " [" (nth 0 entry)
2469 "]: (" (nth 2 entry) ")" (nth 1 entry) ".\n"))) 2500 "]: (" (nth 0 entry) ")" (nth 2 entry) "."
2501 (if (nth 3 entry) (concat " (line " (nth 3 entry) ")") "")
2502 "\n")))
2470 (Info-find-node "apropos" "top") 2503 (Info-find-node "apropos" "top")
2471 (setq Info-complete-cache nil))))) 2504 (setq Info-complete-cache nil)))))
2472 2505
@@ -2584,21 +2617,16 @@ if point is in a menu item description, follow that menu item."
2584 (browse-url (browse-url-url-at-point))) 2617 (browse-url (browse-url-url-at-point)))
2585 ((setq node (Info-get-token (point) "\\*note[ \n\t]+" 2618 ((setq node (Info-get-token (point) "\\*note[ \n\t]+"
2586 "\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?")) 2619 "\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?"))
2587;;; (or (match-string 2)
2588;;; (setq Info-reference-name
2589;;; (replace-regexp-in-string
2590;;; "[ \n\t]+" " " (match-string-no-properties 1))))
2591 (Info-follow-reference node fork)) 2620 (Info-follow-reference node fork))
2592 ;; menu item: node name 2621 ;; menu item: node name
2593 ((setq node (Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::")) 2622 ((setq node (Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))
2594 (Info-goto-node node fork)) 2623 (Info-goto-node node fork))
2595 ;; menu item: index entry 2624 ;; menu item: node name or index entry
2596 ((Info-get-token (point) "\\* +" "\\* +\\(.*\\): ") 2625 ((Info-get-token (point) "\\* +" "\\* +\\(.*\\): ")
2597 (if (save-match-data (string-match "\\<index\\>" Info-current-node))
2598 (setq Info-reference-name (match-string-no-properties 1)))
2599 (beginning-of-line) 2626 (beginning-of-line)
2600 (forward-char 2) 2627 (forward-char 2)
2601 (setq node (Info-extract-menu-node-name)) 2628 (setq node (Info-extract-menu-node-name
2629 nil (string-match "\\<index\\>" Info-current-node)))
2602 (Info-goto-node node fork)) 2630 (Info-goto-node node fork))
2603 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)")) 2631 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
2604 (Info-goto-node node fork)) 2632 (Info-goto-node node fork))
@@ -2848,6 +2876,7 @@ Selecting other nodes:
2848\\[Info-toc] Go to the buffer with a table of contents. 2876\\[Info-toc] Go to the buffer with a table of contents.
2849\\[Info-index] Look up a topic in this file's Index and move to that node. 2877\\[Info-index] Look up a topic in this file's Index and move to that node.
2850\\[Info-index-next] (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command. 2878\\[Info-index-next] (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command.
2879\\[info-apropos] Look for a string in the indices of all manuals.
2851\\[Info-top-node] Go to the Top node of this file. 2880\\[Info-top-node] Go to the Top node of this file.
2852\\[Info-final-node] Go to the final node in this file. 2881\\[Info-final-node] Go to the final node in this file.
2853\\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence. 2882\\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
@@ -3352,7 +3381,8 @@ Preserve text properties."
3352 (hl Info-history-list) 3381 (hl Info-history-list)
3353 res) 3382 res)
3354 (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node) 3383 (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
3355 (setq file (match-string 1 node) 3384 (setq file (file-name-nondirectory
3385 (match-string 1 node))
3356 node (if (equal (match-string 2 node) "") 3386 node (if (equal (match-string 2 node) "")
3357 "Top" 3387 "Top"
3358 (match-string 2 node)))) 3388 (match-string 2 node))))
@@ -3452,7 +3482,8 @@ Preserve text properties."
3452 (hl Info-history-list) 3482 (hl Info-history-list)
3453 res) 3483 res)
3454 (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node) 3484 (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
3455 (setq file (match-string 1 node) 3485 (setq file (file-name-nondirectory
3486 (match-string 1 node))
3456 node (if (equal (match-string 2 node) "") 3487 node (if (equal (match-string 2 node) "")
3457 "Top" 3488 "Top"
3458 (match-string 2 node)))) 3489 (match-string 2 node))))
@@ -3500,6 +3531,13 @@ Preserve text properties."
3500 (put-text-property (match-beginning 1) (match-end 1) 3531 (put-text-property (match-beginning 1) (match-end 1)
3501 'font-lock-face 'info-menu-header))) 3532 'font-lock-face 'info-menu-header)))
3502 3533
3534 ;; Hide index line numbers
3535 (goto-char (point-min))
3536 (when (and not-fontified-p (string-match "\\<Index\\>" Info-current-node))
3537 (while (re-search-forward "[ \t\n]*(line +[0-9]+)" nil t)
3538 (put-text-property (match-beginning 0) (match-end 0)
3539 'invisible t)))
3540
3503 ;; Fontify http and ftp references 3541 ;; Fontify http and ftp references
3504 (goto-char (point-min)) 3542 (goto-char (point-min))
3505 (when not-fontified-p 3543 (when not-fontified-p