diff options
Diffstat (limited to 'lisp/+Info.el')
-rw-r--r-- | lisp/+Info.el | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/lisp/+Info.el b/lisp/+Info.el index a3c2fcd..46bd5f8 100644 --- a/lisp/+Info.el +++ b/lisp/+Info.el | |||
@@ -13,5 +13,72 @@ arg reversed." | |||
13 | (interactive "P" Info-mode) | 13 | (interactive "P" Info-mode) |
14 | (Info-copy-current-node-name (unless arg 0))) | 14 | (Info-copy-current-node-name (unless arg 0))) |
15 | 15 | ||
16 | (defun +Info-modeline-breadcrumbs () | ||
17 | (let ((nodes (Info-toc-nodes Info-current-file)) | ||
18 | (node Info-current-node) | ||
19 | (crumbs ()) | ||
20 | (depth Info-breadcrumbs-depth-internal) | ||
21 | (text "")) | ||
22 | ;; Get ancestors from the cached parent-children node info | ||
23 | (while (and (not (equal "Top" node)) (> depth 0)) | ||
24 | (setq node (nth 1 (assoc node nodes))) | ||
25 | (when node (push node crumbs)) | ||
26 | (setq depth (1- depth))) | ||
27 | ;; Add bottom node. | ||
28 | (setq crumbs (nconc crumbs (list Info-current-node))) | ||
29 | (when crumbs | ||
30 | ;; Add top node (and continuation if needed). | ||
31 | (setq crumbs (cons "Top" (if (member (pop crumbs) '(nil "Top")) | ||
32 | crumbs | ||
33 | (cons nil crumbs)))) | ||
34 | (dolist (node crumbs) | ||
35 | (let ((crumbs-map (make-sparse-keymap)) | ||
36 | (menu-map (make-sparse-keymap "Breadcrumbs in Mode Line"))) | ||
37 | (define-key crumbs-map [mode-line mouse-3] menu-map) | ||
38 | (when node | ||
39 | (define-key menu-map [Info-prev] | ||
40 | `(menu-item "Previous Node" Info-prev | ||
41 | :visible ,(Info-check-pointer "prev[ious]*") :help "Go to the previous node")) | ||
42 | (define-key menu-map [Info-next] | ||
43 | `(menu-item "Next Node" Info-next | ||
44 | :visible ,(Info-check-pointer "next") :help "Go to the next node")) | ||
45 | (define-key menu-map [separator] '("--")) | ||
46 | (define-key menu-map [Info-breadcrumbs-in-mode-line-mode] | ||
47 | `(menu-item "Toggle Breadcrumbs" Info-breadcrumbs-in-mode-line-mode | ||
48 | :help "Toggle displaying breadcrumbs in the Info mode-line" | ||
49 | :button (:toggle . Info-breadcrumbs-in-mode-line-mode))) | ||
50 | (define-key menu-map [Info-set-breadcrumbs-depth] | ||
51 | `(menu-item "Set Breadcrumbs Depth" Info-set-breadcrumbs-depth | ||
52 | :help "Set depth of breadcrumbs to show in the mode-line")) | ||
53 | (setq node (if (equal node Info-current-node) | ||
54 | (propertize | ||
55 | (replace-regexp-in-string "%" "%%" Info-current-node) | ||
56 | 'face 'mode-line-buffer-id | ||
57 | 'help-echo "mouse-1: Scroll back, mouse-2: Scroll forward, mouse-3: Menu" | ||
58 | 'mouse-face 'mode-line-highlight | ||
59 | 'local-map | ||
60 | (progn | ||
61 | (define-key crumbs-map [mode-line mouse-1] 'Info-mouse-scroll-down) | ||
62 | (define-key crumbs-map [mode-line mouse-2] 'Info-mouse-scroll-up) | ||
63 | crumbs-map)) | ||
64 | (propertize | ||
65 | node | ||
66 | 'local-map (progn (define-key crumbs-map [mode-line mouse-1] | ||
67 | `(lambda () (interactive) (Info-goto-node ,node))) | ||
68 | (define-key crumbs-map [mode-line mouse-2] | ||
69 | `(lambda () (interactive) (Info-goto-node ,node))) | ||
70 | crumbs-map) | ||
71 | 'mouse-face 'mode-line-highlight | ||
72 | 'help-echo "mouse-1, mouse-2: Go to this node; mouse-3: Menu"))))) | ||
73 | (let ((nodetext (if (not (equal node "Top")) | ||
74 | node | ||
75 | (concat (format "(%s)" (if (stringp Info-current-file) | ||
76 | (file-name-nondirectory Info-current-file) | ||
77 | ;; Some legacy code can still use a symbol. | ||
78 | Info-current-file)) | ||
79 | node)))) | ||
80 | (setq text (concat text (if (equal node "Top") "" " > ") (if node nodetext "..."))))) | ||
81 | text))) | ||
82 | |||
16 | (provide '+Info) | 83 | (provide '+Info) |
17 | ;;; +Info.el ends here | 84 | ;;; +Info.el ends here |