diff options
Diffstat (limited to 'lisp/info.el')
| -rw-r--r-- | lisp/info.el | 116 |
1 files changed, 95 insertions, 21 deletions
diff --git a/lisp/info.el b/lisp/info.el index 3792857d47a..4679b51b999 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -158,6 +158,12 @@ A header-line does not scroll with the rest of the buffer." | |||
| 158 | "Face for Info nodes in a node header." | 158 | "Face for Info nodes in a node header." |
| 159 | :group 'info) | 159 | :group 'info) |
| 160 | 160 | ||
| 161 | (defface info-index-match | ||
| 162 | '((t :inherit match)) | ||
| 163 | "Face used to highlight matches in an index entry." | ||
| 164 | :group 'info | ||
| 165 | :version "24.4") | ||
| 166 | |||
| 161 | ;; This is a defcustom largely so that we can get the benefit | 167 | ;; This is a defcustom largely so that we can get the benefit |
| 162 | ;; of custom-initialize-delay. Perhaps it would work to make it a | 168 | ;; of custom-initialize-delay. Perhaps it would work to make it a |
| 163 | ;; defvar and explicitly give it a standard-value property, and | 169 | ;; defvar and explicitly give it a standard-value property, and |
| @@ -3057,6 +3063,38 @@ See `Info-scroll-down'." | |||
| 3057 | (select-window (posn-window (event-start e)))) | 3063 | (select-window (posn-window (event-start e)))) |
| 3058 | (Info-scroll-down))) | 3064 | (Info-scroll-down))) |
| 3059 | 3065 | ||
| 3066 | (defun Info-next-reference-or-link (pat prop) | ||
| 3067 | "Move point to the next pattern-based cross-reference or property-based link. | ||
| 3068 | The next cross-reference is searched using the regexp PAT, and the next link | ||
| 3069 | is searched using the text property PROP. Move point to the closest found position | ||
| 3070 | of either a cross-reference found by `re-search-forward' or a link found by | ||
| 3071 | `next-single-char-property-change'. Return the new position of point, or nil." | ||
| 3072 | (let ((pxref (save-excursion (re-search-forward pat nil t))) | ||
| 3073 | (plink (next-single-char-property-change (point) prop))) | ||
| 3074 | (when (and (< plink (point-max)) (not (get-char-property plink prop))) | ||
| 3075 | (setq plink (next-single-char-property-change plink prop))) | ||
| 3076 | (if (< plink (point-max)) | ||
| 3077 | (if (and pxref (<= pxref plink)) | ||
| 3078 | (goto-char (or (match-beginning 1) (match-beginning 0))) | ||
| 3079 | (goto-char plink)) | ||
| 3080 | (if pxref (goto-char (or (match-beginning 1) (match-beginning 0))))))) | ||
| 3081 | |||
| 3082 | (defun Info-prev-reference-or-link (pat prop) | ||
| 3083 | "Move point to the previous pattern-based cross-reference or property-based link. | ||
| 3084 | The previous cross-reference is searched using the regexp PAT, and the previous link | ||
| 3085 | is searched using the text property PROP. Move point to the closest found position | ||
| 3086 | of either a cross-reference found by `re-search-backward' or a link found by | ||
| 3087 | `previous-single-char-property-change'. Return the new position of point, or nil." | ||
| 3088 | (let ((pxref (save-excursion (re-search-backward pat nil t))) | ||
| 3089 | (plink (previous-single-char-property-change (point) prop))) | ||
| 3090 | (when (and (> plink (point-min)) (not (get-char-property plink prop))) | ||
| 3091 | (setq plink (previous-single-char-property-change plink prop))) | ||
| 3092 | (if (> plink (point-min)) | ||
| 3093 | (if (and pxref (>= pxref plink)) | ||
| 3094 | (goto-char (or (match-beginning 1) (match-beginning 0))) | ||
| 3095 | (goto-char plink)) | ||
| 3096 | (if pxref (goto-char (or (match-beginning 1) (match-beginning 0))))))) | ||
| 3097 | |||
| 3060 | (defun Info-next-reference (&optional recur count) | 3098 | (defun Info-next-reference (&optional recur count) |
| 3061 | "Move cursor to the next cross-reference or menu item in the node. | 3099 | "Move cursor to the next cross-reference or menu item in the node. |
| 3062 | If COUNT is non-nil (interactively with a prefix arg), jump over | 3100 | If COUNT is non-nil (interactively with a prefix arg), jump over |
| @@ -3071,14 +3109,13 @@ COUNT cross-references." | |||
| 3071 | (old-pt (point)) | 3109 | (old-pt (point)) |
| 3072 | (case-fold-search t)) | 3110 | (case-fold-search t)) |
| 3073 | (or (eobp) (forward-char 1)) | 3111 | (or (eobp) (forward-char 1)) |
| 3074 | (or (re-search-forward pat nil t) | 3112 | (or (Info-next-reference-or-link pat 'link) |
| 3075 | (progn | 3113 | (progn |
| 3076 | (goto-char (point-min)) | 3114 | (goto-char (point-min)) |
| 3077 | (or (re-search-forward pat nil t) | 3115 | (or (Info-next-reference-or-link pat 'link) |
| 3078 | (progn | 3116 | (progn |
| 3079 | (goto-char old-pt) | 3117 | (goto-char old-pt) |
| 3080 | (user-error "No cross references in this node"))))) | 3118 | (user-error "No cross references in this node"))))) |
| 3081 | (goto-char (or (match-beginning 1) (match-beginning 0))) | ||
| 3082 | (if (looking-at "\\* Menu:") | 3119 | (if (looking-at "\\* Menu:") |
| 3083 | (if recur | 3120 | (if recur |
| 3084 | (user-error "No cross references in this node") | 3121 | (user-error "No cross references in this node") |
| @@ -3099,14 +3136,13 @@ COUNT cross-references." | |||
| 3099 | (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tps?://") | 3136 | (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tps?://") |
| 3100 | (old-pt (point)) | 3137 | (old-pt (point)) |
| 3101 | (case-fold-search t)) | 3138 | (case-fold-search t)) |
| 3102 | (or (re-search-backward pat nil t) | 3139 | (or (Info-prev-reference-or-link pat 'link) |
| 3103 | (progn | 3140 | (progn |
| 3104 | (goto-char (point-max)) | 3141 | (goto-char (point-max)) |
| 3105 | (or (re-search-backward pat nil t) | 3142 | (or (Info-prev-reference-or-link pat 'link) |
| 3106 | (progn | 3143 | (progn |
| 3107 | (goto-char old-pt) | 3144 | (goto-char old-pt) |
| 3108 | (user-error "No cross references in this node"))))) | 3145 | (user-error "No cross references in this node"))))) |
| 3109 | (goto-char (or (match-beginning 1) (match-beginning 0))) | ||
| 3110 | (if (looking-at "\\* Menu:") | 3146 | (if (looking-at "\\* Menu:") |
| 3111 | (if recur | 3147 | (if recur |
| 3112 | (user-error "No cross references in this node") | 3148 | (user-error "No cross references in this node") |
| @@ -3246,7 +3282,7 @@ Give an empty topic name to go to the Index node itself." | |||
| 3246 | (= (aref topic 0) ?:)) | 3282 | (= (aref topic 0) ?:)) |
| 3247 | (setq topic (substring topic 1))) | 3283 | (setq topic (substring topic 1))) |
| 3248 | (let ((orignode Info-current-node) | 3284 | (let ((orignode Info-current-node) |
| 3249 | (pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?" | 3285 | (pattern (format "\n\\* +\\([^\n]*\\(%s\\)[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?" |
| 3250 | (regexp-quote topic))) | 3286 | (regexp-quote topic))) |
| 3251 | node (nodes (Info-index-nodes)) | 3287 | node (nodes (Info-index-nodes)) |
| 3252 | (ohist-list Info-history-list) | 3288 | (ohist-list Info-history-list) |
| @@ -3265,12 +3301,14 @@ Give an empty topic name to go to the Index node itself." | |||
| 3265 | (progn | 3301 | (progn |
| 3266 | (goto-char (point-min)) | 3302 | (goto-char (point-min)) |
| 3267 | (while (re-search-forward pattern nil t) | 3303 | (while (re-search-forward pattern nil t) |
| 3268 | (push (list (match-string-no-properties 1) | 3304 | (let ((entry (match-string-no-properties 1)) |
| 3269 | (match-string-no-properties 2) | 3305 | (nodename (match-string-no-properties 3)) |
| 3270 | Info-current-node | 3306 | (line (string-to-number (concat "0" (match-string 4))))) |
| 3271 | (string-to-number (concat "0" | 3307 | (add-text-properties |
| 3272 | (match-string 3)))) | 3308 | (- (match-beginning 2) (match-beginning 1)) |
| 3273 | matches)) | 3309 | (- (match-end 2) (match-beginning 1)) |
| 3310 | '(face info-index-match) entry) | ||
| 3311 | (push (list entry nodename Info-current-node line) matches))) | ||
| 3274 | (setq nodes (cdr nodes) node (car nodes))) | 3312 | (setq nodes (cdr nodes) node (car nodes))) |
| 3275 | (Info-goto-node node)) | 3313 | (Info-goto-node node)) |
| 3276 | (or matches | 3314 | (or matches |
| @@ -3496,7 +3534,7 @@ MATCHES is a list of index matches found by `Info-apropos-matches'.") | |||
| 3496 | Return a list of matches where each element is in the format | 3534 | Return a list of matches where each element is in the format |
| 3497 | \((FILENAME INDEXTEXT NODENAME LINENUMBER))." | 3535 | \((FILENAME INDEXTEXT NODENAME LINENUMBER))." |
| 3498 | (unless (string= string "") | 3536 | (unless (string= string "") |
| 3499 | (let ((pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]+\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?" | 3537 | (let ((pattern (format "\n\\* +\\([^\n]*\\(%s\\)[^\n]*\\):[ \t]+\\([^\n]+\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?" |
| 3500 | (regexp-quote string))) | 3538 | (regexp-quote string))) |
| 3501 | (ohist Info-history) | 3539 | (ohist Info-history) |
| 3502 | (ohist-list Info-history-list) | 3540 | (ohist-list Info-history-list) |
| @@ -3529,12 +3567,15 @@ Return a list of matches where each element is in the format | |||
| 3529 | (progn | 3567 | (progn |
| 3530 | (goto-char (point-min)) | 3568 | (goto-char (point-min)) |
| 3531 | (while (re-search-forward pattern nil t) | 3569 | (while (re-search-forward pattern nil t) |
| 3532 | (setq matches | 3570 | (let ((entry (match-string-no-properties 1)) |
| 3533 | (cons (list manual | 3571 | (nodename (match-string-no-properties 3)) |
| 3534 | (match-string-no-properties 1) | 3572 | (line (match-string-no-properties 4))) |
| 3535 | (match-string-no-properties 2) | 3573 | (add-text-properties |
| 3536 | (match-string-no-properties 3)) | 3574 | (- (match-beginning 2) (match-beginning 1)) |
| 3537 | matches))) | 3575 | (- (match-end 2) (match-beginning 1)) |
| 3576 | '(face info-index-match) entry) | ||
| 3577 | (setq matches (cons (list manual entry nodename line) | ||
| 3578 | matches)))) | ||
| 3538 | (setq nodes (cdr nodes) node (car nodes))) | 3579 | (setq nodes (cdr nodes) node (car nodes))) |
| 3539 | (Info-goto-node node)))) | 3580 | (Info-goto-node node)))) |
| 3540 | (error | 3581 | (error |
| @@ -3840,7 +3881,25 @@ If FORK is non-nil, it is passed to `Info-goto-node'." | |||
| 3840 | ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)")) | 3881 | ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)")) |
| 3841 | (Info-goto-node "Top" fork)) | 3882 | (Info-goto-node "Top" fork)) |
| 3842 | ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)")) | 3883 | ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)")) |
| 3843 | (Info-goto-node node fork))) | 3884 | (Info-goto-node node fork)) |
| 3885 | ;; footnote | ||
| 3886 | ((setq node (Info-get-token (point) "(" "\\(([0-9]+)\\)")) | ||
| 3887 | (let ((old-point (point)) new-point) | ||
| 3888 | (save-excursion | ||
| 3889 | (goto-char (point-min)) | ||
| 3890 | (when (re-search-forward "^[ \t]*-+ Footnotes -+$" nil t) | ||
| 3891 | (setq new-point (if (< old-point (point)) | ||
| 3892 | ;; Go to footnote reference | ||
| 3893 | (and (search-forward node nil t) | ||
| 3894 | ;; Put point at beginning of link | ||
| 3895 | (match-beginning 0)) | ||
| 3896 | ;; Go to footnote definition | ||
| 3897 | (search-backward node nil t))))) | ||
| 3898 | (if new-point | ||
| 3899 | (progn | ||
| 3900 | (goto-char new-point) | ||
| 3901 | (setq node t)) | ||
| 3902 | (setq node nil))))) | ||
| 3844 | node)) | 3903 | node)) |
| 3845 | 3904 | ||
| 3846 | (defun Info-mouse-follow-link (click) | 3905 | (defun Info-mouse-follow-link (click) |
| @@ -4896,6 +4955,21 @@ first line or header line, and for breadcrumb links.") | |||
| 4896 | mouse-face highlight | 4955 | mouse-face highlight |
| 4897 | help-echo "mouse-2: go to this URL")))) | 4956 | help-echo "mouse-2: go to this URL")))) |
| 4898 | 4957 | ||
| 4958 | ;; Fontify footnotes | ||
| 4959 | (goto-char (point-min)) | ||
| 4960 | (when (and not-fontified-p (re-search-forward "^[ \t]*-+ Footnotes -+$" nil t)) | ||
| 4961 | (let ((limit (point))) | ||
| 4962 | (goto-char (point-min)) | ||
| 4963 | (while (re-search-forward "\\(([0-9]+)\\)" nil t) | ||
| 4964 | (add-text-properties (match-beginning 0) (match-end 0) | ||
| 4965 | `(font-lock-face info-xref | ||
| 4966 | link t | ||
| 4967 | mouse-face highlight | ||
| 4968 | help-echo | ||
| 4969 | ,(if (< (point) limit) | ||
| 4970 | "mouse-2: go to footnote definition" | ||
| 4971 | "mouse-2: go to footnote reference")))))) | ||
| 4972 | |||
| 4899 | ;; Hide empty lines at the end of the node. | 4973 | ;; Hide empty lines at the end of the node. |
| 4900 | (goto-char (point-max)) | 4974 | (goto-char (point-max)) |
| 4901 | (skip-chars-backward "\n") | 4975 | (skip-chars-backward "\n") |