diff options
| author | Juri Linkov | 2010-04-06 01:15:04 +0300 |
|---|---|---|
| committer | Juri Linkov | 2010-04-06 01:15:04 +0300 |
| commit | 3c5d6dfba6b06cddc0aa672488c0aa69d491f24f (patch) | |
| tree | 6ce53b32d36076c6582cbae88998325ec903873c | |
| parent | 84257d9314ac231a44eaa5f93b0247bedead1171 (diff) | |
| download | emacs-3c5d6dfba6b06cddc0aa672488c0aa69d491f24f.tar.gz emacs-3c5d6dfba6b06cddc0aa672488c0aa69d491f24f.zip | |
Put breadcrumbs on overlay instead of inserting to buffer (bug#5809).
* info.el (Info-find-node-2): Comment out code that skips
breadcrumbs line.
(Info-mouse-follow-link): New command.
(Info-link-keymap): New keymap.
(Info-breadcrumbs): Rename from `Info-insert-breadcrumbs'.
Return a string with links instead of inserting breadcrumbs
to the Info buffer.
(Info-fontify-node): Comment out code that inserts breadcrumbs.
Instead of putting the `invisible' text property over the Info
header, make an overlay over the Info header with the `invisible'
property and `after-string' set to the string returned by
`Info-breadcrumbs'.
| -rw-r--r-- | lisp/ChangeLog | 17 | ||||
| -rw-r--r-- | lisp/info.el | 69 |
2 files changed, 70 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ee9c8997b83..6c4eac186b3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,20 @@ | |||
| 1 | 2010-04-05 Juri Linkov <juri@jurta.org> | ||
| 2 | |||
| 3 | Put breadcrumbs on overlay instead of inserting to buffer (bug#5809). | ||
| 4 | |||
| 5 | * info.el (Info-find-node-2): Comment out code that skips | ||
| 6 | breadcrumbs line. | ||
| 7 | (Info-mouse-follow-link): New command. | ||
| 8 | (Info-link-keymap): New keymap. | ||
| 9 | (Info-breadcrumbs): Rename from `Info-insert-breadcrumbs'. | ||
| 10 | Return a string with links instead of inserting breadcrumbs | ||
| 11 | to the Info buffer. | ||
| 12 | (Info-fontify-node): Comment out code that inserts breadcrumbs. | ||
| 13 | Instead of putting the `invisible' text property over the Info | ||
| 14 | header, make an overlay over the Info header with the `invisible' | ||
| 15 | property and `after-string' set to the string returned by | ||
| 16 | `Info-breadcrumbs'. | ||
| 17 | |||
| 1 | 2010-04-03 Chong Yidong <cyd@stupidchicken.com> | 18 | 2010-04-03 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 19 | ||
| 3 | * help.el (help-window-setup-finish): Doc fix (Bug#5830). | 20 | * help.el (help-window-setup-finish): Doc fix (Bug#5830). |
diff --git a/lisp/info.el b/lisp/info.el index a1ce05d6292..c4b942bf8a1 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -1053,8 +1053,8 @@ a case-insensitive match is tried." | |||
| 1053 | (Info-select-node) | 1053 | (Info-select-node) |
| 1054 | (goto-char (point-min)) | 1054 | (goto-char (point-min)) |
| 1055 | (forward-line 1) ; skip header line | 1055 | (forward-line 1) ; skip header line |
| 1056 | (when (> Info-breadcrumbs-depth 0) ; skip breadcrumbs line | 1056 | ;; (when (> Info-breadcrumbs-depth 0) ; skip breadcrumbs line |
| 1057 | (forward-line 1)) | 1057 | ;; (forward-line 1)) |
| 1058 | 1058 | ||
| 1059 | (cond (anchorpos | 1059 | (cond (anchorpos |
| 1060 | (let ((new-history (list Info-current-file | 1060 | (let ((new-history (list Info-current-file |
| @@ -3551,6 +3551,19 @@ If FORK is non-nil, it is passed to `Info-goto-node'." | |||
| 3551 | ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)")) | 3551 | ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)")) |
| 3552 | (Info-goto-node node fork))) | 3552 | (Info-goto-node node fork))) |
| 3553 | node)) | 3553 | node)) |
| 3554 | |||
| 3555 | (defun Info-mouse-follow-link (click) | ||
| 3556 | "Follow a link where you click." | ||
| 3557 | (interactive "e") | ||
| 3558 | (let* ((position (event-start click)) | ||
| 3559 | (posn-string (and position (posn-string position))) | ||
| 3560 | (string (car-safe posn-string)) | ||
| 3561 | (string-pos (cdr-safe posn-string)) | ||
| 3562 | (link-args (and string string-pos | ||
| 3563 | (get-text-property string-pos 'link-args string)))) | ||
| 3564 | (when link-args | ||
| 3565 | (Info-goto-node link-args)))) | ||
| 3566 | |||
| 3554 | 3567 | ||
| 3555 | (defvar Info-mode-map | 3568 | (defvar Info-mode-map |
| 3556 | (let ((map (make-keymap))) | 3569 | (let ((map (make-keymap))) |
| @@ -4141,11 +4154,22 @@ the variable `Info-file-list-for-emacs'." | |||
| 4141 | keymap) | 4154 | keymap) |
| 4142 | "Keymap to put on the Up link in the text or the header line.") | 4155 | "Keymap to put on the Up link in the text or the header line.") |
| 4143 | 4156 | ||
| 4144 | (defun Info-insert-breadcrumbs () | 4157 | (defvar Info-link-keymap |
| 4158 | (let ((keymap (make-sparse-keymap))) | ||
| 4159 | (define-key keymap [header-line mouse-1] 'Info-mouse-follow-link) | ||
| 4160 | (define-key keymap [header-line mouse-2] 'Info-mouse-follow-link) | ||
| 4161 | (define-key keymap [header-line down-mouse-1] 'ignore) | ||
| 4162 | (define-key keymap [mouse-2] 'Info-mouse-follow-link) | ||
| 4163 | (define-key keymap [follow-link] 'mouse-face) | ||
| 4164 | keymap) | ||
| 4165 | "Keymap to put on the link in the text or the header line.") | ||
| 4166 | |||
| 4167 | (defun Info-breadcrumbs () | ||
| 4145 | (let ((nodes (Info-toc-nodes Info-current-file)) | 4168 | (let ((nodes (Info-toc-nodes Info-current-file)) |
| 4146 | (node Info-current-node) | 4169 | (node Info-current-node) |
| 4147 | (crumbs ()) | 4170 | (crumbs ()) |
| 4148 | (depth Info-breadcrumbs-depth)) | 4171 | (depth Info-breadcrumbs-depth) |
| 4172 | line) | ||
| 4149 | 4173 | ||
| 4150 | ;; Get ancestors from the cached parent-children node info | 4174 | ;; Get ancestors from the cached parent-children node info |
| 4151 | (while (and (not (equal "Top" node)) (> depth 0)) | 4175 | (while (and (not (equal "Top" node)) (> depth 0)) |
| @@ -4172,15 +4196,25 @@ the variable `Info-file-list-for-emacs'." | |||
| 4172 | (file-name-nondirectory Info-current-file) | 4196 | (file-name-nondirectory Info-current-file) |
| 4173 | ;; Some legacy code can still use a symbol. | 4197 | ;; Some legacy code can still use a symbol. |
| 4174 | Info-current-file))))) | 4198 | Info-current-file))))) |
| 4175 | (insert (if (bolp) "" " > ") | 4199 | (setq line (concat |
| 4176 | (cond | 4200 | line |
| 4177 | ((null node) "...") | 4201 | (if (null line) "" " > ") |
| 4178 | ((equal node Info-current-node) | 4202 | (cond |
| 4179 | ;; No point linking to ourselves. | 4203 | ((null node) "...") |
| 4180 | (propertize text 'font-lock-face 'info-header-node)) | 4204 | ((equal node Info-current-node) |
| 4181 | (t | 4205 | ;; No point linking to ourselves. |
| 4182 | (concat "*Note " text "::")))))) | 4206 | (propertize text 'font-lock-face 'info-header-node)) |
| 4183 | (insert "\n")))) | 4207 | (t |
| 4208 | (propertize text | ||
| 4209 | 'mouse-face 'highlight | ||
| 4210 | 'font-lock-face 'info-header-xref | ||
| 4211 | 'help-echo "mouse-2: Go to node" | ||
| 4212 | 'keymap Info-link-keymap | ||
| 4213 | 'link-args text))))))) | ||
| 4214 | (setq line (concat line "\n"))) | ||
| 4215 | ;; (font-lock-append-text-property 0 (length line) | ||
| 4216 | ;; 'font-lock-face 'header-line line) | ||
| 4217 | line)) | ||
| 4184 | 4218 | ||
| 4185 | (defun Info-fontify-node () | 4219 | (defun Info-fontify-node () |
| 4186 | "Fontify the node." | 4220 | "Fontify the node." |
| @@ -4227,8 +4261,8 @@ the variable `Info-file-list-for-emacs'." | |||
| 4227 | ((string-equal (downcase tag) "next") Info-next-link-keymap) | 4261 | ((string-equal (downcase tag) "next") Info-next-link-keymap) |
| 4228 | ((string-equal (downcase tag) "up" ) Info-up-link-keymap)))))) | 4262 | ((string-equal (downcase tag) "up" ) Info-up-link-keymap)))))) |
| 4229 | 4263 | ||
| 4230 | (when (> Info-breadcrumbs-depth 0) | 4264 | ;; (when (> Info-breadcrumbs-depth 0) |
| 4231 | (Info-insert-breadcrumbs)) | 4265 | ;; (insert (Info-breadcrumbs))) |
| 4232 | 4266 | ||
| 4233 | ;; Treat header line. | 4267 | ;; Treat header line. |
| 4234 | (when Info-use-header-line | 4268 | (when Info-use-header-line |
| @@ -4260,7 +4294,10 @@ the variable `Info-file-list-for-emacs'." | |||
| 4260 | ;; that is in the header, if it is just part. | 4294 | ;; that is in the header, if it is just part. |
| 4261 | (cond | 4295 | (cond |
| 4262 | ((> Info-breadcrumbs-depth 0) | 4296 | ((> Info-breadcrumbs-depth 0) |
| 4263 | (put-text-property (point-min) (1+ header-end) 'invisible t)) | 4297 | (let ((ov (make-overlay (point-min) (1+ header-end)))) |
| 4298 | (overlay-put ov 'invisible t) | ||
| 4299 | (overlay-put ov 'after-string (Info-breadcrumbs)) | ||
| 4300 | (overlay-put ov 'evaporate t))) | ||
| 4264 | ((not (bobp)) | 4301 | ((not (bobp)) |
| 4265 | ;; Hide the punctuation at the end, too. | 4302 | ;; Hide the punctuation at the end, too. |
| 4266 | (skip-chars-backward " \t,") | 4303 | (skip-chars-backward " \t,") |