aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2000-09-17 16:21:42 +0000
committerMiles Bader2000-09-17 16:21:42 +0000
commit50ac70af8aeca33b8240f0c6c70b3e7f5a4882bc (patch)
tree2642dc5a3b00c0f7367d4d18313e2381841de5ba
parent729927ff5e82848396cbf59139bf0ce64bc52804 (diff)
downloademacs-50ac70af8aeca33b8240f0c6c70b3e7f5a4882bc.tar.gz
emacs-50ac70af8aeca33b8240f0c6c70b3e7f5a4882bc.zip
(Info-fontify-node):
Make a few cleanups. Add extra `help-echo' and `local-map' props to node xrefs. Use header-specific faces for node-names & xrefs. (Info-use-header-line, Info-header-line): New variables. (info-header, info-header-xref, info-header-node): New faces. (Info-setup-header-line): New function. (Info-select-node): Call Info-setup-header-line when enabled. (Info-extract-pointer): Work even if the header line is hidden.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/info.el85
2 files changed, 79 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d3ca3d3f00a..f8f1059b30e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12000-09-18 Miles Bader <miles@gnu.org>
2
3 * info.el (Info-fontify-node): Make a few cleanups.
4 Add extra `help-echo' and `local-map' props to node xrefs.
5 Use header-specific faces for node-names & xrefs.
6 (Info-use-header-line): New variable.
7 (info-header, info-header-xref, info-header-node): New faces.
8 (Info-setup-header-line): New function.
9 (Info-select-node): Call Info-setup-header-line when enabled.
10 (Info-extract-pointer): Work even if the header line is hidden.
11 (Info-header-line): New variable.
12
12000-09-16 Stefan Monnier <monnier@cs.yale.edu> 132000-09-16 Stefan Monnier <monnier@cs.yale.edu>
2 14
3 * vms-patch.el (print-region-function): Don't quote lambda. 15 * vms-patch.el (print-region-function): Don't quote lambda.
diff --git a/lisp/info.el b/lisp/info.el
index cd9f86384bb..dd1a5490e29 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -83,6 +83,22 @@ The Lisp code is executed when the node is selected.")
83 :type 'integer 83 :type 'integer
84 :group 'info) 84 :group 'info)
85 85
86(defcustom Info-use-header-line t
87 "*Non-nil means to put the beginning-of-node links in an emacs header-line.
88A header-line does not scroll with the rest of the buffer."
89 :type 'boolean
90 :group 'info)
91
92(defface info-header-xref
93 '((t (:weight bold)))
94 "Face for Info cross-references in a node header."
95 :group 'info)
96
97(defface info-header-node
98 '((t (:weight bold :slant italic)))
99 "Face for Info nodes in a node header."
100 :group 'info)
101
86(defvar Info-directory-list nil 102(defvar Info-directory-list nil
87 "List of directories to search for Info documentation files. 103 "List of directories to search for Info documentation files.
88nil means not yet initialized. In this case, Info uses the environment 104nil means not yet initialized. In this case, Info uses the environment
@@ -873,6 +889,9 @@ a case-insensitive match is tried."
873 (if (numberp nodepos) 889 (if (numberp nodepos)
874 (+ (- nodepos lastfilepos) (point))))) 890 (+ (- nodepos lastfilepos) (point)))))
875 891
892(defvar Info-header-line nil
893 "If the info node header is hidden, the text of the header.")
894
876(defun Info-select-node () 895(defun Info-select-node ()
877"Select the info node that point is in. 896"Select the info node that point is in.
878Bind this in case the user sets it to nil." 897Bind this in case the user sets it to nil."
@@ -895,6 +914,7 @@ Bind this in case the user sets it to nil."
895 ;; Find the end of it, and narrow. 914 ;; Find the end of it, and narrow.
896 (beginning-of-line) 915 (beginning-of-line)
897 (let (active-expression) 916 (let (active-expression)
917 ;; Narrow to the node contents
898 (narrow-to-region (point) 918 (narrow-to-region (point)
899 (if (re-search-forward "\n[\^_\f]" nil t) 919 (if (re-search-forward "\n[\^_\f]" nil t)
900 (prog1 920 (prog1
@@ -907,6 +927,9 @@ Bind this in case the user sets it to nil."
907 (point-max))) 927 (point-max)))
908 (if Info-enable-active-nodes (eval active-expression)) 928 (if Info-enable-active-nodes (eval active-expression))
909 (if Info-fontify (Info-fontify-node)) 929 (if Info-fontify (Info-fontify-node))
930 (if Info-use-header-line
931 (Info-setup-header-line)
932 (setq Info-header-line nil))
910 (run-hooks 'Info-selection-hook))))) 933 (run-hooks 'Info-selection-hook)))))
911 934
912(defun Info-set-mode-line () 935(defun Info-set-mode-line ()
@@ -919,6 +942,16 @@ Bind this in case the user sets it to nil."
919 ") " 942 ") "
920 (or Info-current-node "")))) 943 (or Info-current-node ""))))
921 944
945;; Skip the node header and make it into a header-line. This function
946;; should be called when the node is already narrowed.
947(defun Info-setup-header-line ()
948 (goto-char (point-min))
949 (forward-line 1)
950 (set (make-local-variable 'Info-header-line)
951 (buffer-substring (point-min) (1- (point))))
952 (setq header-line-format 'Info-header-line)
953 (narrow-to-region (point) (point-max)))
954
922;; Go to an info node specified with a filename-and-nodename string 955;; Go to an info node specified with a filename-and-nodename string
923;; of the sort that is found in pointers in nodes. 956;; of the sort that is found in pointers in nodes.
924 957
@@ -1101,15 +1134,20 @@ if ERRORNAME is nil, just return nil.
1101Bind this in case the user sets it to nil." 1134Bind this in case the user sets it to nil."
1102 (let ((case-fold-search t)) 1135 (let ((case-fold-search t))
1103 (save-excursion 1136 (save-excursion
1104 (goto-char (point-min)) 1137 (save-restriction
1105 (forward-line 1) 1138 (goto-char (point-min))
1106 (if (re-search-backward (concat name ":") nil t) 1139 (when Info-header-line
1107 (progn 1140 ;; expose the header line in the buffer
1141 (widen)
1142 (forward-line -1))
1143 (let ((bound (point)))
1144 (forward-line 1)
1145 (cond ((re-search-backward (concat name ":") nil bound)
1108 (goto-char (match-end 0)) 1146 (goto-char (match-end 0))
1109 (Info-following-node-name)) 1147 (Info-following-node-name))
1110 (if (eq errorname t) 1148 ((not (eq errorname t))
1111 nil 1149 (error "Node has no %s"
1112 (error "Node has no %s" (capitalize (or errorname name)))))))) 1150 (capitalize (or errorname name))))))))))
1113 1151
1114(defun Info-following-node-name (&optional allowedchars) 1152(defun Info-following-node-name (&optional allowedchars)
1115 "Return the node name in the buffer following point. 1153 "Return the node name in the buffer following point.
@@ -2321,18 +2359,29 @@ the variable `Info-file-list-for-emacs'."
2321 (goto-char (point-min)) 2359 (goto-char (point-min))
2322 (when (looking-at "^File: [^,: \t]+,?[ \t]+") 2360 (when (looking-at "^File: [^,: \t]+,?[ \t]+")
2323 (goto-char (match-end 0)) 2361 (goto-char (match-end 0))
2324 (while 2362 (while (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
2325 (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
2326 (goto-char (match-end 0)) 2363 (goto-char (match-end 0))
2327 (if (save-excursion 2364 (let* ((nbeg (match-beginning 2))
2328 (goto-char (match-beginning 1)) 2365 (nend (match-end 2))
2329 (save-match-data (looking-at "Node:"))) 2366 (tbeg (match-beginning 1))
2330 (put-text-property (match-beginning 2) (match-end 2) 2367 (tag (buffer-substring tbeg (match-end 1))))
2331 'face 'info-node) 2368 (if (string-equal tag "Node")
2332 (put-text-property (match-beginning 2) (match-end 2) 2369 (put-text-property nbeg nend 'face 'info-header-node)
2333 'face 'info-xref) 2370 (put-text-property nbeg nend 'face 'info-header-xref)
2334 (put-text-property (match-beginning 2) (match-end 2) 2371 (put-text-property nbeg nend 'mouse-face 'highlight)
2335 'mouse-face 'highlight)))) 2372 (put-text-property tbeg nend
2373 'help-echo
2374 (concat "Goto node "
2375 (buffer-substring nbeg nend)))
2376 (let ((fun (cdr (assoc tag '(("Prev" . Info-prev)
2377 ("Next" . Info-next)
2378 ("Up" . Info-up))))))
2379 (when fun
2380 (let ((keymap (make-sparse-keymap)))
2381 (define-key keymap [header-line mouse-1] fun)
2382 (define-key keymap [header-line mouse-2] fun)
2383 (put-text-property tbeg nend 'local-map keymap))))
2384 ))))
2336 (goto-char (point-min)) 2385 (goto-char (point-min))
2337 (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\)$" 2386 (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\)$"
2338 nil t) 2387 nil t)