Mercurial > emacs
comparison lisp/info.el @ 64812:0d6aa987778c
Replace `info' with upper-case `Info' where appropriate.
(info-title-1, info-title-2, info-title-3, info-title-4)
(info-menu-header): Move up face definitions.
(info-menu-star): Rename from `info-menu-5'.
(Info-fontify-node): Replace `info-menu-5' with `info-menu-star'.
(Info-fontify-visited-nodes): Fix docstring.
(Info-hide-note-references): Fix docstring.
(Info-up, Info-next-reference, Info-prev-reference): Put cursor on
menu items in the same way as on cross-references.
(info-apropos): Fix sorting order and formatting to be like in the
stand-alone Info browser. Display error messages for 1 sec.
(Info-mode-map): Move down `c' key binding. Bind `^' to `Info-up'.
(Info-mode-menu): Remove item for `Info-search-case-sensitively'
from the menu bar.
(Info-insert-dir): Restore point after calling `insert-buffer-substring'.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Tue, 09 Aug 2005 08:43:02 +0000 |
parents | 153c52bc9ad4 |
children | a7d19794a559 |
comparison
equal
deleted
inserted
replaced
64811:f2d8d2c65b14 | 64812:0d6aa987778c |
---|---|
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | 24 ;; Boston, MA 02110-1301, USA. |
25 | 25 |
26 ;;; Commentary: | 26 ;;; Commentary: |
27 | 27 |
28 ;; Note that nowadays we expect info files to be made using makeinfo. | 28 ;; Note that nowadays we expect Info files to be made using makeinfo. |
29 ;; In particular we make these assumptions: | 29 ;; In particular we make these assumptions: |
30 ;; - a menu item MAY contain colons but not colon-space ": " | 30 ;; - a menu item MAY contain colons but not colon-space ": " |
31 ;; - a menu item ending with ": " (but not ":: ") is an index entry | 31 ;; - a menu item ending with ": " (but not ":: ") is an index entry |
32 ;; - a node name MAY NOT contain a colon | 32 ;; - a node name MAY NOT contain a colon |
33 ;; This distinction is to support indexing of computer programming | 33 ;; This distinction is to support indexing of computer programming |
42 :group 'help | 42 :group 'help |
43 :group 'docs) | 43 :group 'docs) |
44 | 44 |
45 | 45 |
46 (defvar Info-history nil | 46 (defvar Info-history nil |
47 "Stack of info nodes user has visited. | 47 "Stack of Info nodes user has visited. |
48 Each element of the stack is a list (FILENAME NODENAME BUFFERPOS).") | 48 Each element of the stack is a list (FILENAME NODENAME BUFFERPOS).") |
49 | 49 |
50 (defvar Info-history-forward nil | 50 (defvar Info-history-forward nil |
51 "Stack of info nodes user has visited with `Info-history-back' command. | 51 "Stack of Info nodes user has visited with `Info-history-back' command. |
52 Each element of the stack is a list (FILENAME NODENAME BUFFERPOS).") | 52 Each element of the stack is a list (FILENAME NODENAME BUFFERPOS).") |
53 | 53 |
54 (defvar Info-history-list nil | 54 (defvar Info-history-list nil |
55 "List of all info nodes user has visited. | 55 "List of all Info nodes user has visited. |
56 Each element of the list is a list (FILENAME NODENAME).") | 56 Each element of the list is a list (FILENAME NODENAME).") |
57 | 57 |
58 (defcustom Info-enable-edit nil | 58 (defcustom Info-enable-edit nil |
59 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node. | 59 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node. |
60 This is convenient if you want to write info files by hand. | 60 This is convenient if you want to write Info files by hand. |
61 However, we recommend that you not do this. | 61 However, we recommend that you not do this. |
62 It is better to write a Texinfo file and generate the Info file from that, | 62 It is better to write a Texinfo file and generate the Info file from that, |
63 because that gives you a printed manual as well." | 63 because that gives you a printed manual as well." |
64 :type 'boolean | 64 :type 'boolean |
65 :group 'info) | 65 :group 'info) |
74 (((class color) (background dark)) :foreground "white" :weight bold :slant italic) | 74 (((class color) (background dark)) :foreground "white" :weight bold :slant italic) |
75 (t :weight bold :slant italic)) | 75 (t :weight bold :slant italic)) |
76 "Face for Info node names." | 76 "Face for Info node names." |
77 :group 'info) | 77 :group 'info) |
78 | 78 |
79 (defface info-menu-5 | 79 (defface info-title-1 |
80 '((((type tty pc) (class color) (background light)) | |
81 :foreground "green" :weight bold) | |
82 (((type tty pc) (class color) (background dark)) | |
83 :foreground "yellow" :weight bold) | |
84 (t :height 1.2 :inherit info-title-2)) | |
85 "Face for info titles at level 1." | |
86 :group 'info) | |
87 ;; backward-compatibility alias | |
88 (put 'Info-title-1-face 'face-alias 'info-title-1) | |
89 | |
90 (defface info-title-2 | |
91 '((((type tty pc) (class color)) :foreground "lightblue" :weight bold) | |
92 (t :height 1.2 :inherit info-title-3)) | |
93 "Face for info titles at level 2." | |
94 :group 'info) | |
95 ;; backward-compatibility alias | |
96 (put 'Info-title-2-face 'face-alias 'info-title-2) | |
97 | |
98 (defface info-title-3 | |
99 '((((type tty pc) (class color)) :weight bold) | |
100 (t :height 1.2 :inherit info-title-4)) | |
101 "Face for info titles at level 3." | |
102 :group 'info) | |
103 ;; backward-compatibility alias | |
104 (put 'Info-title-3-face 'face-alias 'info-title-3) | |
105 | |
106 (defface info-title-4 | |
107 '((((type tty pc) (class color)) :weight bold) | |
108 (t :weight bold :inherit variable-pitch)) | |
109 "Face for info titles at level 4." | |
110 :group 'info) | |
111 ;; backward-compatibility alias | |
112 (put 'Info-title-4-face 'face-alias 'info-title-4) | |
113 | |
114 (defface info-menu-header | |
115 '((((type tty pc)) | |
116 :underline t | |
117 :weight bold) | |
118 (t | |
119 :inherit variable-pitch | |
120 :weight bold)) | |
121 "Face for headers in Info menus." | |
122 :group 'info) | |
123 | |
124 (defface info-menu-star | |
80 '((((class color)) :foreground "red1") | 125 '((((class color)) :foreground "red1") |
81 (t :underline t)) | 126 (t :underline t)) |
82 "Face for every third `*' in an Info menu." | 127 "Face for every third `*' in an Info menu." |
83 :group 'info) | 128 :group 'info) |
129 (put 'info-menu-5 'face-alias 'info-menu-star) | |
84 | 130 |
85 (defface info-xref | 131 (defface info-xref |
86 '((((min-colors 88) | 132 '((((min-colors 88) |
87 (class color) (background light)) :foreground "blue1" :underline t) | 133 (class color) (background light)) :foreground "blue1" :underline t) |
88 (((class color) (background light)) :foreground "blue" :underline t) | 134 (((class color) (background light)) :foreground "blue" :underline t) |
99 (((class color) (background dark)) :foreground "violet")) | 145 (((class color) (background dark)) :foreground "violet")) |
100 "Face for visited Info cross-references." | 146 "Face for visited Info cross-references." |
101 :group 'info) | 147 :group 'info) |
102 | 148 |
103 (defcustom Info-fontify-visited-nodes t | 149 (defcustom Info-fontify-visited-nodes t |
104 "*Non-nil means to fontify visited nodes in a different face." | 150 "*Non-nil to fontify references to visited nodes in `info-xref-visited' face." |
105 :version "22.1" | 151 :version "22.1" |
106 :type 'boolean | 152 :type 'boolean |
107 :group 'info) | 153 :group 'info) |
108 | 154 |
109 (defcustom Info-fontify-maximum-menu-size 100000 | 155 (defcustom Info-fontify-maximum-menu-size 100000 |
163 :type '(repeat directory) | 209 :type '(repeat directory) |
164 :group 'info) | 210 :group 'info) |
165 | 211 |
166 (defcustom Info-scroll-prefer-subnodes nil | 212 (defcustom Info-scroll-prefer-subnodes nil |
167 "*If non-nil, \\<Info-mode-map>\\[Info-scroll-up] in a menu visits subnodes. | 213 "*If non-nil, \\<Info-mode-map>\\[Info-scroll-up] in a menu visits subnodes. |
214 | |
168 If this is non-nil, and you scroll far enough in a node that its menu | 215 If this is non-nil, and you scroll far enough in a node that its menu |
169 appears on the screen, the next \\<Info-mode-map>\\[Info-scroll-up] | 216 appears on the screen, the next \\<Info-mode-map>\\[Info-scroll-up] |
170 moves to a subnode indicated by the following menu item. This means | 217 moves to a subnode indicated by the following menu item. This means |
171 that you visit a subnode before getting to the end of the menu. | 218 that you visit a subnode before getting to the end of the menu. |
172 | 219 |
178 :group 'info) | 225 :group 'info) |
179 | 226 |
180 (defcustom Info-hide-note-references t | 227 (defcustom Info-hide-note-references t |
181 "*If non-nil, hide the tag and section reference in *note and * menu items. | 228 "*If non-nil, hide the tag and section reference in *note and * menu items. |
182 If value is non-nil but not `hide', also replaces the \"*note\" with \"see\". | 229 If value is non-nil but not `hide', also replaces the \"*note\" with \"see\". |
183 If value is non-nil but not t or `hide', the reference section is still shown." | 230 If value is non-nil but not t or `hide', the reference section is still shown. |
231 `nil' completely disables this feature." | |
184 :version "22.1" | 232 :version "22.1" |
185 :type '(choice (const :tag "No hiding" nil) | 233 :type '(choice (const :tag "No hiding" nil) |
186 (const :tag "Replace tag and hide reference" t) | 234 (const :tag "Replace tag and hide reference" t) |
187 (const :tag "Hide tag and reference" hide) | 235 (const :tag "Hide tag and reference" hide) |
188 (other :tag "Only replace tag" tag)) | 236 (other :tag "Only replace tag" tag)) |
189 :group 'info) | 237 :group 'info) |
190 | 238 |
191 (defcustom Info-refill-paragraphs nil | 239 (defcustom Info-refill-paragraphs nil |
192 "*If non-nil, attempt to refill paragraphs with hidden references. | 240 "*If non-nil, attempt to refill paragraphs with hidden references. |
193 This refilling may accidentally remove explicit line breaks in the info | 241 This refilling may accidentally remove explicit line breaks in the Info |
194 file, so be prepared for a few surprises if you enable this feature." | 242 file, so be prepared for a few surprises if you enable this feature." |
195 :version "22.1" | 243 :version "22.1" |
196 :type 'boolean | 244 :type 'boolean |
197 :group 'info) | 245 :group 'info) |
198 | 246 |
245 It doesn't contain directory names or file name extensions added by Info. | 293 It doesn't contain directory names or file name extensions added by Info. |
246 Can also be t when using `Info-on-current-buffer'.") | 294 Can also be t when using `Info-on-current-buffer'.") |
247 | 295 |
248 (defvar Info-current-subfile nil | 296 (defvar Info-current-subfile nil |
249 "Info subfile that is actually in the *info* buffer now. | 297 "Info subfile that is actually in the *info* buffer now. |
250 nil if current info file is not split into subfiles.") | 298 nil if current Info file is not split into subfiles.") |
251 | 299 |
252 (defvar Info-current-node nil | 300 (defvar Info-current-node nil |
253 "Name of node that Info is now looking at, or nil.") | 301 "Name of node that Info is now looking at, or nil.") |
254 | 302 |
255 (defvar Info-tag-table-marker nil | 303 (defvar Info-tag-table-marker nil |
355 (defun info-file-exists-p (filename) | 403 (defun info-file-exists-p (filename) |
356 (and (file-exists-p filename) | 404 (and (file-exists-p filename) |
357 (not (file-directory-p filename)))) | 405 (not (file-directory-p filename)))) |
358 | 406 |
359 (defun info-insert-file-contents (filename &optional visit) | 407 (defun info-insert-file-contents (filename &optional visit) |
360 "Insert the contents of an info file in the current buffer. | 408 "Insert the contents of an Info file in the current buffer. |
361 Do the right thing if the file has been compressed or zipped." | 409 Do the right thing if the file has been compressed or zipped." |
362 (let* ((tail Info-suffix-list) | 410 (let* ((tail Info-suffix-list) |
363 (lfn (if (fboundp 'msdos-long-file-names) | 411 (lfn (if (fboundp 'msdos-long-file-names) |
364 (msdos-long-file-names) | 412 (msdos-long-file-names) |
365 t)) | 413 t)) |
630 (setq filename nil) | 678 (setq filename nil) |
631 (error "Info file %s does not exist" filename))) | 679 (error "Info file %s does not exist" filename))) |
632 filename))) | 680 filename))) |
633 | 681 |
634 (defun Info-find-node (filename nodename &optional no-going-back) | 682 (defun Info-find-node (filename nodename &optional no-going-back) |
635 "Go to an info node specified as separate FILENAME and NODENAME. | 683 "Go to an Info node specified as separate FILENAME and NODENAME. |
636 NO-GOING-BACK is non-nil if recovering from an error in this function; | 684 NO-GOING-BACK is non-nil if recovering from an error in this function; |
637 it says do not attempt further (recursive) error recovery." | 685 it says do not attempt further (recursive) error recovery." |
638 (info-initialize) | 686 (info-initialize) |
639 (setq filename (Info-find-file filename)) | 687 (setq filename (Info-find-file filename)) |
640 ;; Go into info buffer. | 688 ;; Go into Info buffer. |
641 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*")) | 689 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*")) |
642 ;; Record the node we are leaving. | 690 ;; Record the node we are leaving. |
643 (if (and Info-current-file (not no-going-back)) | 691 (if (and Info-current-file (not no-going-back)) |
644 (setq Info-history | 692 (setq Info-history |
645 (cons (list Info-current-file Info-current-node (point)) | 693 (cons (list Info-current-file Info-current-node (point)) |
646 Info-history))) | 694 Info-history))) |
647 (Info-find-node-2 filename nodename no-going-back)) | 695 (Info-find-node-2 filename nodename no-going-back)) |
648 | 696 |
649 (defun Info-on-current-buffer (&optional nodename) | 697 (defun Info-on-current-buffer (&optional nodename) |
650 "Use the `Info-mode' to browse the current info buffer. | 698 "Use the `Info-mode' to browse the current Info buffer. |
651 If a prefix arg is provided, it queries for the NODENAME which | 699 If a prefix arg is provided, it queries for the NODENAME which |
652 else defaults to \"Top\"." | 700 else defaults to \"Top\"." |
653 (interactive | 701 (interactive |
654 (list (if current-prefix-arg | 702 (list (if current-prefix-arg |
655 (completing-read "Node name: " (Info-build-node-completions) | 703 (completing-read "Node name: " (Info-build-node-completions) |
663 ;; It's perhaps a bit nasty to kill the *info* buffer to force a re-read, | 711 ;; It's perhaps a bit nasty to kill the *info* buffer to force a re-read, |
664 ;; but at least it keeps this routine (which is only for the benefit of | 712 ;; but at least it keeps this routine (which is only for the benefit of |
665 ;; makeinfo-buffer) out of the way of normal operations. | 713 ;; makeinfo-buffer) out of the way of normal operations. |
666 ;; | 714 ;; |
667 (defun Info-revert-find-node (filename nodename) | 715 (defun Info-revert-find-node (filename nodename) |
668 "Go to an info node FILENAME and NODENAME, re-reading disk contents. | 716 "Go to an Info node FILENAME and NODENAME, re-reading disk contents. |
669 When *info* is already displaying FILENAME and NODENAME, the window position | 717 When *info* is already displaying FILENAME and NODENAME, the window position |
670 is preserved, if possible." | 718 is preserved, if possible." |
671 (pop-to-buffer "*info*") | 719 (pop-to-buffer "*info*") |
672 (let ((old-filename Info-current-file) | 720 (let ((old-filename Info-current-file) |
673 (old-nodename Info-current-node) | 721 (old-nodename Info-current-node) |
1026 others (delq buffer buffers)) | 1074 others (delq buffer buffers)) |
1027 | 1075 |
1028 ;; Insert the entire original dir file as a start; note that we've | 1076 ;; Insert the entire original dir file as a start; note that we've |
1029 ;; already saved its default directory to use as the default | 1077 ;; already saved its default directory to use as the default |
1030 ;; directory for the whole concatenation. | 1078 ;; directory for the whole concatenation. |
1031 (insert-buffer-substring buffer) | 1079 (goto-char (prog1 (point) (insert-buffer-substring buffer))) |
1032 | 1080 |
1033 ;; Look at each of the other buffers one by one. | 1081 ;; Look at each of the other buffers one by one. |
1034 (dolist (other others) | 1082 (dolist (other others) |
1035 (let (this-buffer-nodes) | 1083 (let (this-buffer-nodes) |
1036 ;; In each, find all the menus. | 1084 ;; In each, find all the menus. |
1285 (if (not (get-text-property start 'invisible)) | 1333 (if (not (get-text-property start 'invisible)) |
1286 (put-text-property start (point) 'invisible t))))) | 1334 (put-text-property start (point) 'invisible t))))) |
1287 (set-buffer-modified-p nil))) | 1335 (set-buffer-modified-p nil))) |
1288 | 1336 |
1289 (defun Info-select-node () | 1337 (defun Info-select-node () |
1290 "Select the info node that point is in." | 1338 "Select the Info node that point is in." |
1291 ;; Bind this in case the user sets it to nil. | 1339 ;; Bind this in case the user sets it to nil. |
1292 (let ((case-fold-search t)) | 1340 (let ((case-fold-search t)) |
1293 (save-excursion | 1341 (save-excursion |
1294 ;; Find beginning of node. | 1342 ;; Find beginning of node. |
1295 (if (search-backward "\n\^_" nil 'move) | 1343 (if (search-backward "\n\^_" nil 'move) |
1341 Info-current-file | 1389 Info-current-file |
1342 (or buffer-file-name ""))) | 1390 (or buffer-file-name ""))) |
1343 ") " | 1391 ") " |
1344 (or Info-current-node "")))))) | 1392 (or Info-current-node "")))))) |
1345 | 1393 |
1346 ;; Go to an info node specified with a filename-and-nodename string | 1394 ;; Go to an Info node specified with a filename-and-nodename string |
1347 ;; of the sort that is found in pointers in nodes. | 1395 ;; of the sort that is found in pointers in nodes. |
1348 | 1396 |
1349 ;; Don't autoload this function: the correct entry point for other packages | 1397 ;; Don't autoload this function: the correct entry point for other packages |
1350 ;; to use is `info'. --Stef | 1398 ;; to use is `info'. --Stef |
1351 ;; ;;;###autoload | 1399 ;; ;;;###autoload |
1352 (defun Info-goto-node (nodename &optional fork) | 1400 (defun Info-goto-node (nodename &optional fork) |
1353 "Go to info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME. | 1401 "Go to Info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME. |
1354 If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file | 1402 If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file |
1355 FILENAME; otherwise, NODENAME should be in the current Info file (or one of | 1403 FILENAME; otherwise, NODENAME should be in the current Info file (or one of |
1356 its sub-files). | 1404 its sub-files). |
1357 Completion is available, but only for node names in the current Info file. | 1405 Completion is available, but only for node names in the current Info file. |
1358 If FORK is non-nil (interactively with a prefix arg), show the node in | 1406 If FORK is non-nil (interactively with a prefix arg), show the node in |
1359 a new info buffer. | 1407 a new Info buffer. |
1360 If FORK is a string, it is the name to use for the new buffer." | 1408 If FORK is a string, it is the name to use for the new buffer." |
1361 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg)) | 1409 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg)) |
1362 (info-initialize) | 1410 (info-initialize) |
1363 (if fork | 1411 (if fork |
1364 (set-buffer | 1412 (set-buffer |
1400 (file-name-nondirectory string) dir)) | 1448 (file-name-nondirectory string) dir)) |
1401 ;; If the file name has no suffix or a standard suffix, | 1449 ;; If the file name has no suffix or a standard suffix, |
1402 ;; include it. | 1450 ;; include it. |
1403 (and (or (null (file-name-extension file)) | 1451 (and (or (null (file-name-extension file)) |
1404 (string-match suffix file)) | 1452 (string-match suffix file)) |
1405 ;; But exclude subfiles of split info files. | 1453 ;; But exclude subfiles of split Info files. |
1406 (not (string-match "-[0-9]+\\'" file)) | 1454 (not (string-match "-[0-9]+\\'" file)) |
1407 ;; And exclude backup files. | 1455 ;; And exclude backup files. |
1408 (not (string-match "~\\'" file)) | 1456 (not (string-match "~\\'" file)) |
1409 (push (if string-dir (concat string-dir file) file) names)) | 1457 (push (if string-dir (concat string-dir file) file) names)) |
1410 ;; If the file name ends in a standard suffix, | 1458 ;; If the file name ends in a standard suffix, |
1820 (if (string-equal old-node "Top") | 1868 (if (string-equal old-node "Top") |
1821 (concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file) ")") | 1869 (concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file) ")") |
1822 (concat "\n\\* +\\(" (regexp-quote old-node) | 1870 (concat "\n\\* +\\(" (regexp-quote old-node) |
1823 ":\\|[^:]+: +" (regexp-quote old-node) "\\)")) | 1871 ":\\|[^:]+: +" (regexp-quote old-node) "\\)")) |
1824 nil t)) | 1872 nil t)) |
1825 (beginning-of-line) | 1873 (progn (beginning-of-line) (if (looking-at "^\\* ") (forward-char 2))) |
1826 (goto-char p) | 1874 (goto-char p) |
1827 (Info-restore-point Info-history)))) | 1875 (Info-restore-point Info-history)))) |
1828 | 1876 |
1829 (defun Info-history-back () | 1877 (defun Info-history-back () |
1830 "Go back in the history to the last node visited." | 1878 "Go back in the history to the last node visited." |
2009 | 2057 |
2010 (defun Info-follow-reference (footnotename &optional fork) | 2058 (defun Info-follow-reference (footnotename &optional fork) |
2011 "Follow cross reference named FOOTNOTENAME to the node it refers to. | 2059 "Follow cross reference named FOOTNOTENAME to the node it refers to. |
2012 FOOTNOTENAME may be an abbreviation of the reference name. | 2060 FOOTNOTENAME may be an abbreviation of the reference name. |
2013 If FORK is non-nil (interactively with a prefix arg), show the node in | 2061 If FORK is non-nil (interactively with a prefix arg), show the node in |
2014 a new info buffer. If FORK is a string, it is the name to use for the | 2062 a new Info buffer. If FORK is a string, it is the name to use for the |
2015 new buffer." | 2063 new buffer." |
2016 (interactive | 2064 (interactive |
2017 (let ((completion-ignore-case t) | 2065 (let ((completion-ignore-case t) |
2018 (case-fold-search t) | 2066 (case-fold-search t) |
2019 completions default alt-default (start-point (point)) str i bol eol) | 2067 completions default alt-default (start-point (point)) str i bol eol) |
2220 (defun Info-menu (menu-item &optional fork) | 2268 (defun Info-menu (menu-item &optional fork) |
2221 "Go to the node pointed to by the menu item named (or abbreviated) MENU-ITEM. | 2269 "Go to the node pointed to by the menu item named (or abbreviated) MENU-ITEM. |
2222 The menu item should one of those listed in the current node's menu. | 2270 The menu item should one of those listed in the current node's menu. |
2223 Completion is allowed, and the default menu item is the one point is on. | 2271 Completion is allowed, and the default menu item is the one point is on. |
2224 If FORK is non-nil (interactively with a prefix arg), show the node in | 2272 If FORK is non-nil (interactively with a prefix arg), show the node in |
2225 a new info buffer. If FORK is a string, it is the name to use for the | 2273 a new Info buffer. If FORK is a string, it is the name to use for the |
2226 new buffer." | 2274 new buffer." |
2227 (interactive | 2275 (interactive |
2228 (let ((completions '()) | 2276 (let ((completions '()) |
2229 ;; If point is within a menu item, use that item as the default | 2277 ;; If point is within a menu item, use that item as the default |
2230 (default nil) | 2278 (default nil) |
2545 (error "No cross references in this node"))))) | 2593 (error "No cross references in this node"))))) |
2546 (goto-char (or (match-beginning 1) (match-beginning 0))) | 2594 (goto-char (or (match-beginning 1) (match-beginning 0))) |
2547 (if (looking-at "\\* Menu:") | 2595 (if (looking-at "\\* Menu:") |
2548 (if recur | 2596 (if recur |
2549 (error "No cross references in this node") | 2597 (error "No cross references in this node") |
2550 (Info-next-reference t))))) | 2598 (Info-next-reference t)) |
2599 (if (looking-at "^\\* ") | |
2600 (forward-char 2))))) | |
2551 | 2601 |
2552 (defun Info-prev-reference (&optional recur) | 2602 (defun Info-prev-reference (&optional recur) |
2553 "Move cursor to the previous cross-reference or menu item in the node." | 2603 "Move cursor to the previous cross-reference or menu item in the node." |
2554 (interactive) | 2604 (interactive) |
2555 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tp://") | 2605 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tp://") |
2564 (error "No cross references in this node"))))) | 2614 (error "No cross references in this node"))))) |
2565 (goto-char (or (match-beginning 1) (match-beginning 0))) | 2615 (goto-char (or (match-beginning 1) (match-beginning 0))) |
2566 (if (looking-at "\\* Menu:") | 2616 (if (looking-at "\\* Menu:") |
2567 (if recur | 2617 (if recur |
2568 (error "No cross references in this node") | 2618 (error "No cross references in this node") |
2569 (Info-prev-reference t))))) | 2619 (Info-prev-reference t)) |
2620 (if (looking-at "^\\* ") | |
2621 (forward-char 2))))) | |
2570 | 2622 |
2571 (defvar Info-index-nodes nil | 2623 (defvar Info-index-nodes nil |
2572 "Alist of cached index node names of visited Info files. | 2624 "Alist of cached index node names of visited Info files. |
2573 Each element has the form (INFO-FILE INDEX-NODE-NAMES-LIST).") | 2625 Each element has the form (INFO-FILE INDEX-NODE-NAMES-LIST).") |
2574 | 2626 |
2798 (Info-directory) | 2850 (Info-directory) |
2799 (message "Searching indices...") | 2851 (message "Searching indices...") |
2800 (goto-char (point-min)) | 2852 (goto-char (point-min)) |
2801 (re-search-forward "\\* Menu: *\n" nil t) | 2853 (re-search-forward "\\* Menu: *\n" nil t) |
2802 (while (re-search-forward "\\*.*: *(\\([^)]+\\))" nil t) | 2854 (while (re-search-forward "\\*.*: *(\\([^)]+\\))" nil t) |
2803 (add-to-list 'manuals (match-string 1))) | 2855 (setq manuals (cons (match-string 1) manuals))) |
2804 (dolist (manual manuals) | 2856 (dolist (manual (nreverse manuals)) |
2805 (message "Searching %s" manual) | 2857 (message "Searching %s" manual) |
2806 (if (setq nodes (Info-index-nodes (Info-find-file manual))) | 2858 (condition-case err |
2807 (condition-case nil | 2859 (if (setq nodes (Info-index-nodes (Info-find-file manual))) |
2808 (save-excursion | 2860 (save-excursion |
2809 (Info-find-node manual (car nodes)) | 2861 (Info-find-node manual (car nodes)) |
2810 (while | 2862 (while |
2811 (progn | 2863 (progn |
2812 (goto-char (point-min)) | 2864 (goto-char (point-min)) |
2813 (while (re-search-forward pattern nil t) | 2865 (while (re-search-forward pattern nil t) |
2814 (add-to-list 'matches | 2866 (setq matches |
2815 (list manual | 2867 (cons (list manual |
2816 (match-string-no-properties 1) | 2868 (match-string-no-properties 1) |
2817 (match-string-no-properties 2) | 2869 (match-string-no-properties 2) |
2818 (match-string-no-properties 3)))) | 2870 (match-string-no-properties 3)) |
2871 matches))) | |
2819 (setq nodes (cdr nodes) node (car nodes))) | 2872 (setq nodes (cdr nodes) node (car nodes))) |
2820 (Info-goto-node node))) | 2873 (Info-goto-node node)))) |
2821 (error nil))))) | 2874 (error |
2875 (message "%s" (if (eq (car-safe err) 'error) | |
2876 (nth 1 err) err)) | |
2877 (sit-for 1 t))))) | |
2822 (Info-goto-node (concat "(" current-file ")" current-node)) | 2878 (Info-goto-node (concat "(" current-file ")" current-node)) |
2823 (setq Info-history ohist | 2879 (setq Info-history ohist |
2824 Info-history-list ohist-list) | 2880 Info-history-list ohist-list) |
2825 (message "Searching indices...done") | 2881 (message "Searching indices...done") |
2826 (if (null matches) | 2882 (if (null matches) |
2827 (message "No matches found") | 2883 (message "No matches found") |
2828 (with-current-buffer (get-buffer-create " *info-apropos*") | 2884 (with-current-buffer (get-buffer-create " *info-apropos*") |
2829 (erase-buffer) | 2885 (erase-buffer) |
2830 (insert "\n\^_\nFile: apropos, Node: Index, Up: (dir)\n") | 2886 (insert "\n\^_\nFile: apropos, Node: Index, Up: (dir)\n") |
2831 (insert "* Menu: \nNodes whose indices contain \"" string "\"\n\n") | 2887 (insert "* Menu: \nNodes whose indices contain `" string "':\n\n") |
2832 (dolist (entry matches) | 2888 (dolist (entry (nreverse matches)) |
2833 (insert | 2889 (insert |
2834 (format "* %-38s (%s)%s.%s\n" | 2890 (format "* %-38s (%s)%s.%s\n" |
2835 (concat (nth 1 entry) " [" (nth 0 entry) "]:") | 2891 (concat (nth 1 entry) " [" (nth 0 entry) "]:") |
2836 (nth 0 entry) | 2892 (nth 0 entry) |
2837 (nth 2 entry) | 2893 (nth 2 entry) |
3000 (define-key Info-mode-map "]" 'Info-forward-node) | 3056 (define-key Info-mode-map "]" 'Info-forward-node) |
3001 (define-key Info-mode-map "[" 'Info-backward-node) | 3057 (define-key Info-mode-map "[" 'Info-backward-node) |
3002 (define-key Info-mode-map "<" 'Info-top-node) | 3058 (define-key Info-mode-map "<" 'Info-top-node) |
3003 (define-key Info-mode-map ">" 'Info-final-node) | 3059 (define-key Info-mode-map ">" 'Info-final-node) |
3004 (define-key Info-mode-map "b" 'beginning-of-buffer) | 3060 (define-key Info-mode-map "b" 'beginning-of-buffer) |
3005 (define-key Info-mode-map "c" 'Info-copy-current-node-name) | |
3006 (define-key Info-mode-map "d" 'Info-directory) | 3061 (define-key Info-mode-map "d" 'Info-directory) |
3007 (define-key Info-mode-map "e" 'Info-edit) | 3062 (define-key Info-mode-map "e" 'Info-edit) |
3008 (define-key Info-mode-map "f" 'Info-follow-reference) | 3063 (define-key Info-mode-map "f" 'Info-follow-reference) |
3009 (define-key Info-mode-map "g" 'Info-goto-node) | 3064 (define-key Info-mode-map "g" 'Info-goto-node) |
3010 (define-key Info-mode-map "h" 'Info-help) | 3065 (define-key Info-mode-map "h" 'Info-help) |
3022 (define-key Info-mode-map "\M-s" 'Info-search) | 3077 (define-key Info-mode-map "\M-s" 'Info-search) |
3023 (define-key Info-mode-map "\M-n" 'clone-buffer) | 3078 (define-key Info-mode-map "\M-n" 'clone-buffer) |
3024 (define-key Info-mode-map "t" 'Info-top-node) | 3079 (define-key Info-mode-map "t" 'Info-top-node) |
3025 (define-key Info-mode-map "T" 'Info-toc) | 3080 (define-key Info-mode-map "T" 'Info-toc) |
3026 (define-key Info-mode-map "u" 'Info-up) | 3081 (define-key Info-mode-map "u" 'Info-up) |
3027 ;; For consistency with dired-copy-filename-as-kill. | 3082 ;; `w' for consistency with `dired-copy-filename-as-kill'. |
3028 (define-key Info-mode-map "w" 'Info-copy-current-node-name) | 3083 (define-key Info-mode-map "w" 'Info-copy-current-node-name) |
3084 (define-key Info-mode-map "c" 'Info-copy-current-node-name) | |
3085 ;; `^' for consistency with `dired-up-directory'. | |
3086 (define-key Info-mode-map "^" 'Info-up) | |
3029 (define-key Info-mode-map "," 'Info-index-next) | 3087 (define-key Info-mode-map "," 'Info-index-next) |
3030 (define-key Info-mode-map "\177" 'Info-scroll-down) | 3088 (define-key Info-mode-map "\177" 'Info-scroll-down) |
3031 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node) | 3089 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node) |
3032 (define-key Info-mode-map [follow-link] 'mouse-face) | 3090 (define-key Info-mode-map [follow-link] 'mouse-face) |
3033 ) | 3091 ) |
3038 (Info-extract-pointer item) | 3096 (Info-extract-pointer item) |
3039 (error nil))) | 3097 (error nil))) |
3040 | 3098 |
3041 (easy-menu-define | 3099 (easy-menu-define |
3042 Info-mode-menu Info-mode-map | 3100 Info-mode-menu Info-mode-map |
3043 "Menu for info files." | 3101 "Menu for Info files." |
3044 '("Info" | 3102 '("Info" |
3045 ["Up" Info-up :active (Info-check-pointer "up") | 3103 ["Up" Info-up :active (Info-check-pointer "up") |
3046 :help "Go up in the Info tree"] | 3104 :help "Go up in the Info tree"] |
3047 ["Next" Info-next :active (Info-check-pointer "next") | 3105 ["Next" Info-next :active (Info-check-pointer "next") |
3048 :help "Go to the next node"] | 3106 :help "Go to the next node"] |
3060 :help "Go to final node in this file"] | 3118 :help "Go to final node in this file"] |
3061 ("Menu Item" ["You should never see this" report-emacs-bug t]) | 3119 ("Menu Item" ["You should never see this" report-emacs-bug t]) |
3062 ("Reference" ["You should never see this" report-emacs-bug t]) | 3120 ("Reference" ["You should never see this" report-emacs-bug t]) |
3063 ["Search..." Info-search | 3121 ["Search..." Info-search |
3064 :help "Search for regular expression in this Info file"] | 3122 :help "Search for regular expression in this Info file"] |
3065 ["Search Case-Sensitively..." Info-search-case-sensitively | |
3066 :help "Search for regular expression case sensitively"] | |
3067 ["Search Next" Info-search-next | 3123 ["Search Next" Info-search-next |
3068 :help "Search for another occurrence of regular expression"] | 3124 :help "Search for another occurrence of regular expression"] |
3069 ["Go to Node..." Info-goto-node | 3125 ["Go to Node..." Info-goto-node |
3070 :help "Go to a named node"] | 3126 :help "Go to a named node"] |
3071 ["Back in history" Info-history-back :active Info-history | 3127 ["Back in history" Info-history-back :active Info-history |
3173 ;; Try to avoid entering infinite beep mode in case of errors. | 3229 ;; Try to avoid entering infinite beep mode in case of errors. |
3174 (error (ding)))) | 3230 (error (ding)))) |
3175 | 3231 |
3176 | 3232 |
3177 (defun Info-copy-current-node-name (&optional arg) | 3233 (defun Info-copy-current-node-name (&optional arg) |
3178 "Put the name of the current info node into the kill ring. | 3234 "Put the name of the current Info node into the kill ring. |
3179 The name of the info file is prepended to the node name in parentheses. | 3235 The name of the Info file is prepended to the node name in parentheses. |
3180 With a zero prefix arg, put the name inside a function call to `info'." | 3236 With a zero prefix arg, put the name inside a function call to `info'." |
3181 (interactive "P") | 3237 (interactive "P") |
3182 (unless Info-current-node | 3238 (unless Info-current-node |
3183 (error "No current info node")) | 3239 (error "No current Info node")) |
3184 (let ((node (concat "(" (file-name-nondirectory | 3240 (let ((node (concat "(" (file-name-nondirectory |
3185 (or (and (stringp Info-current-file) | 3241 (or (and (stringp Info-current-file) |
3186 Info-current-file) | 3242 Info-current-file) |
3187 buffer-file-name | 3243 buffer-file-name |
3188 "")) | 3244 "")) |
3244 already visible, try to go to the previous menu entry, or up | 3300 already visible, try to go to the previous menu entry, or up |
3245 if there is none. | 3301 if there is none. |
3246 \\[beginning-of-buffer] Go to beginning of node. | 3302 \\[beginning-of-buffer] Go to beginning of node. |
3247 | 3303 |
3248 Advanced commands: | 3304 Advanced commands: |
3249 \\[Info-copy-current-node-name] Put name of current info node in the kill ring. | 3305 \\[Info-copy-current-node-name] Put name of current Info node in the kill ring. |
3250 \\[clone-buffer] Select a new cloned Info buffer in another window. | 3306 \\[clone-buffer] Select a new cloned Info buffer in another window. |
3251 \\[Info-edit] Edit contents of selected node. | 3307 \\[Info-edit] Edit contents of selected node. |
3252 1 .. 9 Pick first ... ninth item in node's menu. | 3308 1 .. 9 Pick first ... ninth item in node's menu. |
3253 Every third `*' is highlighted to help pick the right number. | 3309 Every third `*' is highlighted to help pick the right number. |
3254 \\[Info-goto-node] Move to node specified by name. | 3310 \\[Info-goto-node] Move to node specified by name. |
3354 (defun Info-edit () | 3410 (defun Info-edit () |
3355 "Edit the contents of this Info node. | 3411 "Edit the contents of this Info node. |
3356 Allowed only if variable `Info-enable-edit' is non-nil." | 3412 Allowed only if variable `Info-enable-edit' is non-nil." |
3357 (interactive) | 3413 (interactive) |
3358 (or Info-enable-edit | 3414 (or Info-enable-edit |
3359 (error "Editing info nodes is not enabled")) | 3415 (error "Editing Info nodes is not enabled")) |
3360 (Info-edit-mode) | 3416 (Info-edit-mode) |
3361 (message "%s" (substitute-command-keys | 3417 (message "%s" (substitute-command-keys |
3362 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info"))) | 3418 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info"))) |
3363 | 3419 |
3364 (defun Info-cease-edit () | 3420 (defun Info-cease-edit () |
3416 (let ((where '()) line-number | 3472 (let ((where '()) line-number |
3417 (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command)) | 3473 (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command)) |
3418 "\\( <[0-9]+>\\)?:\\s *\\(.*\\)\\." | 3474 "\\( <[0-9]+>\\)?:\\s *\\(.*\\)\\." |
3419 "\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?")) | 3475 "\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?")) |
3420 (info-file "emacs")) ;default | 3476 (info-file "emacs")) ;default |
3421 ;; Determine which info file this command is documented in. | 3477 ;; Determine which Info file this command is documented in. |
3422 (if (get command 'info-file) | 3478 (if (get command 'info-file) |
3423 (setq info-file (get command 'info-file)) | 3479 (setq info-file (get command 'info-file)) |
3424 ;; If it doesn't say explicitly, test its name against | 3480 ;; If it doesn't say explicitly, test its name against |
3425 ;; various prefixes that we know. | 3481 ;; various prefixes that we know. |
3426 (let ((file-list Info-file-list-for-emacs)) | 3482 (let ((file-list Info-file-list-for-emacs)) |
3525 (Info-goto-emacs-command-node | 3581 (Info-goto-emacs-command-node |
3526 (read-command "Find documentation for command: "))) | 3582 (read-command "Find documentation for command: "))) |
3527 (t | 3583 (t |
3528 (Info-goto-emacs-command-node command))))) | 3584 (Info-goto-emacs-command-node command))))) |
3529 | 3585 |
3530 (defface info-title-1 | |
3531 '((((type tty pc) (class color) (background light)) | |
3532 :foreground "green" :weight bold) | |
3533 (((type tty pc) (class color) (background dark)) | |
3534 :foreground "yellow" :weight bold) | |
3535 (t :height 1.2 :inherit info-title-2)) | |
3536 "Face for info titles at level 1." | |
3537 :group 'info) | |
3538 ;; backward-compatibility alias | |
3539 (put 'Info-title-1-face 'face-alias 'info-title-1) | |
3540 | |
3541 (defface info-title-2 | |
3542 '((((type tty pc) (class color)) :foreground "lightblue" :weight bold) | |
3543 (t :height 1.2 :inherit info-title-3)) | |
3544 "Face for info titles at level 2." | |
3545 :group 'info) | |
3546 ;; backward-compatibility alias | |
3547 (put 'Info-title-2-face 'face-alias 'info-title-2) | |
3548 | |
3549 (defface info-title-3 | |
3550 '((((type tty pc) (class color)) :weight bold) | |
3551 (t :height 1.2 :inherit info-title-4)) | |
3552 "Face for info titles at level 3." | |
3553 :group 'info) | |
3554 ;; backward-compatibility alias | |
3555 (put 'Info-title-3-face 'face-alias 'info-title-3) | |
3556 | |
3557 (defface info-title-4 | |
3558 '((((type tty pc) (class color)) :weight bold) | |
3559 (t :weight bold :inherit variable-pitch)) | |
3560 "Face for info titles at level 4." | |
3561 :group 'info) | |
3562 ;; backward-compatibility alias | |
3563 (put 'Info-title-4-face 'face-alias 'info-title-4) | |
3564 | |
3565 (defface info-menu-header | |
3566 '((((type tty pc)) | |
3567 :underline t | |
3568 :weight bold) | |
3569 (t | |
3570 :inherit variable-pitch | |
3571 :weight bold)) | |
3572 "Face for headers in Info menus." | |
3573 :group 'info) | |
3574 | |
3575 (defun Info-escape-percent (string) | 3586 (defun Info-escape-percent (string) |
3576 "Double all occurrences of `%' in STRING. | 3587 "Double all occurrences of `%' in STRING. |
3577 | 3588 |
3578 Return a new string with all `%' characters replaced by `%%'. | 3589 Return a new string with all `%' characters replaced by `%%'. |
3579 Preserve text properties." | 3590 Preserve text properties." |
3866 (when not-fontified-p | 3877 (when not-fontified-p |
3867 (setq n (1+ n)) | 3878 (setq n (1+ n)) |
3868 (if (and (<= n 9) (zerop (% n 3))) ; visual aids to help with 1-9 keys | 3879 (if (and (<= n 9) (zerop (% n 3))) ; visual aids to help with 1-9 keys |
3869 (put-text-property (match-beginning 0) | 3880 (put-text-property (match-beginning 0) |
3870 (1+ (match-beginning 0)) | 3881 (1+ (match-beginning 0)) |
3871 'font-lock-face 'info-menu-5))) | 3882 'font-lock-face 'info-menu-star))) |
3872 (when not-fontified-p | 3883 (when not-fontified-p |
3873 (add-text-properties | 3884 (add-text-properties |
3874 (match-beginning 1) (match-end 1) | 3885 (match-beginning 1) (match-end 1) |
3875 (list | 3886 (list |
3876 'help-echo (if (and (match-end 3) | 3887 'help-echo (if (and (match-end 3) |
3960 | 3971 |
3961 (set-buffer-modified-p nil)))) | 3972 (set-buffer-modified-p nil)))) |
3962 | 3973 |
3963 ;;; Speedbar support: | 3974 ;;; Speedbar support: |
3964 ;; These functions permit speedbar to display the "tags" in the | 3975 ;; These functions permit speedbar to display the "tags" in the |
3965 ;; current info node. | 3976 ;; current Info node. |
3966 (eval-when-compile (require 'speedbar)) | 3977 (eval-when-compile (require 'speedbar)) |
3967 | 3978 |
3968 (defvar Info-speedbar-key-map nil | 3979 (defvar Info-speedbar-key-map nil |
3969 "Keymap used when in the info display mode.") | 3980 "Keymap used when in the info display mode.") |
3970 | 3981 |
4002 (add-hook 'speedbar-load-hook 'Info-install-speedbar-variables)) | 4013 (add-hook 'speedbar-load-hook 'Info-install-speedbar-variables)) |
4003 | 4014 |
4004 ;;; Info hierarchy display method | 4015 ;;; Info hierarchy display method |
4005 ;;;###autoload | 4016 ;;;###autoload |
4006 (defun Info-speedbar-browser () | 4017 (defun Info-speedbar-browser () |
4007 "Initialize speedbar to display an info node browser. | 4018 "Initialize speedbar to display an Info node browser. |
4008 This will add a speedbar major display mode." | 4019 This will add a speedbar major display mode." |
4009 (interactive) | 4020 (interactive) |
4010 (require 'speedbar) | 4021 (require 'speedbar) |
4011 ;; Make sure that speedbar is active | 4022 ;; Make sure that speedbar is active |
4012 (speedbar-frame-mode 1) | 4023 (speedbar-frame-mode 1) |
4143 | 4154 |
4144 (dolist (mess '("^First node in file$" | 4155 (dolist (mess '("^First node in file$" |
4145 "^No `.*' in index$" | 4156 "^No `.*' in index$" |
4146 "^No cross-reference named" | 4157 "^No cross-reference named" |
4147 "^No cross.references in this node$" | 4158 "^No cross.references in this node$" |
4148 "^No current info node$" | 4159 "^No current Info node$" |
4149 "^No menu in this node$" | 4160 "^No menu in this node$" |
4150 "^No more items in menu$" | 4161 "^No more items in menu$" |
4151 "^No more nodes$" | 4162 "^No more nodes$" |
4152 "^No pointer \\(?:forward\\|backward\\) from this node$" | 4163 "^No pointer \\(?:forward\\|backward\\) from this node$" |
4153 "^No previous `i' command$" | 4164 "^No previous `i' command$" |
4170 | 4181 |
4171 ;;;###autoload | 4182 ;;;###autoload |
4172 (defun Info-restore-desktop-buffer (desktop-buffer-file-name | 4183 (defun Info-restore-desktop-buffer (desktop-buffer-file-name |
4173 desktop-buffer-name | 4184 desktop-buffer-name |
4174 desktop-buffer-misc) | 4185 desktop-buffer-misc) |
4175 "Restore an info buffer specified in a desktop file." | 4186 "Restore an Info buffer specified in a desktop file." |
4176 (let ((first (nth 0 desktop-buffer-misc)) | 4187 (let ((first (nth 0 desktop-buffer-misc)) |
4177 (second (nth 1 desktop-buffer-misc))) | 4188 (second (nth 1 desktop-buffer-misc))) |
4178 (when (and first second) | 4189 (when (and first second) |
4179 (when desktop-buffer-name | 4190 (when desktop-buffer-name |
4180 (set-buffer (get-buffer-create desktop-buffer-name)) | 4191 (set-buffer (get-buffer-create desktop-buffer-name)) |