comparison lisp/help.el @ 21385:a14e82c3a69e

(help-make-xrefs): Grok commands in keymap table expansions. (help-xref-button): Simplify. (help-make-xrefs): Set overriding keymap properly.
author Dave Love <fx@gnu.org>
date Mon, 06 Apr 1998 09:56:55 +0000
parents 22a3be0ae9dc
children 4718a738947a
comparison
equal deleted inserted replaced
21384:f245110aa619 21385:a14e82c3a69e
935 (save-excursion 935 (save-excursion
936 (while (re-search-forward 936 (while (re-search-forward
937 "\\<M-x\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)" nil t) 937 "\\<M-x\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)" nil t)
938 (let ((sym (intern-soft (match-string 1)))) 938 (let ((sym (intern-soft (match-string 1))))
939 (if (fboundp sym) 939 (if (fboundp sym)
940 (help-xref-button 1 #'describe-function sym)))))) 940 (help-xref-button 1 #'describe-function sym)))))
941 ;; Look for commands in whole keymap substitutions:
942 (save-excursion
943 ;; Find a header and the column at which the command
944 ;; name will be found.
945 (while (re-search-forward "^key +binding\n\\(-+ +\\)-+\n\n"
946 nil t)
947 (let ((col (- (match-end 1) (match-beginning 1))))
948 (while
949 ;; Ignore single blank lines in table, but not
950 ;; double ones, which should terminate it.
951 (and (looking-at "^\n?[^\n]")
952 (progn
953 (if (and (> (move-to-column col) 0)
954 (looking-at "\\(\\sw\\|\\s_\\)+$"))
955 ;;
956 (let ((sym (intern-soft (match-string 0))))
957 (if (fboundp sym)
958 (help-xref-button
959 0 #'describe-function sym))))
960 t)
961 (zerop (forward-line))
962 (move-to-column 0)))))))
941 (set-syntax-table stab)) 963 (set-syntax-table stab))
942 ;; Make a back-reference in this buffer if appropriate. 964 ;; Make a back-reference in this buffer if appropriate.
943 (when help-xref-stack 965 (when help-xref-stack
944 (goto-char (point-max)) 966 (goto-char (point-max))
945 (save-excursion 967 (save-excursion
949 (help-xref-button 1 #'help-xref-go-back nil))) 971 (help-xref-button 1 #'help-xref-go-back nil)))
950 ;; View mode steals RET from us. 972 ;; View mode steals RET from us.
951 (set (make-local-variable 'minor-mode-overriding-map-alist) 973 (set (make-local-variable 'minor-mode-overriding-map-alist)
952 (list (cons 'view-mode 974 (list (cons 'view-mode
953 (let ((map (make-sparse-keymap))) 975 (let ((map (make-sparse-keymap)))
976 (set-keymap-parent map view-mode-map)
954 (define-key map "\r" 'help-follow) 977 (define-key map "\r" 'help-follow)
955 map)))) 978 map))))
956 (set-buffer-modified-p old-modified)))) 979 (set-buffer-modified-p old-modified))))
957 980
958 (defun help-xref-button (match-number function data) 981 (defun help-xref-button (match-number function data)
960 983
961 MATCH-NUMBER is the subexpression of interest in the last matched 984 MATCH-NUMBER is the subexpression of interest in the last matched
962 regexp. FUNCTION is a function to invoke when the button is 985 regexp. FUNCTION is a function to invoke when the button is
963 activated, applied to DATA. DATA may be a single value or a list. 986 activated, applied to DATA. DATA may be a single value or a list.
964 See `help-make-xrefs'." 987 See `help-make-xrefs'."
965 (put-text-property (match-beginning match-number) 988 (add-text-properties (match-beginning match-number)
966 (match-end match-number) 989 (match-end match-number)
967 'mouse-face 'highlight) 990 (list 'mouse-face 'highlight
968 (if help-highlight-p
969 (put-text-property (match-beginning match-number)
970 (match-end match-number)
971 'face help-highlight-face))
972 (put-text-property (match-beginning match-number)
973 (match-end match-number)
974 'help-xref (cons function 991 'help-xref (cons function
975 (if (listp data) 992 (if (listp data)
976 data 993 data
977 (list data))))) 994 (list data)))))
995 (if help-highlight-p
996 (put-text-property (match-beginning match-number)
997 (match-end match-number)
998 'face help-highlight-face)))
978 999
979 1000
980 ;; Additional functions for (re-)creating types of help buffers. 1001 ;; Additional functions for (re-)creating types of help buffers.
981 (defun help-xref-interned (symbol) 1002 (defun help-xref-interned (symbol)
982 "Follow a hyperlink which appeared to be an arbitrary interned SYMBOL. 1003 "Follow a hyperlink which appeared to be an arbitrary interned SYMBOL.
1046 "Find the next help cross-reference in the buffer." 1067 "Find the next help cross-reference in the buffer."
1047 (interactive) 1068 (interactive)
1048 (let (pos) 1069 (let (pos)
1049 (while (not pos) 1070 (while (not pos)
1050 (if (get-text-property (point) 'help-xref) ; move off reference 1071 (if (get-text-property (point) 'help-xref) ; move off reference
1051 (or (goto-char (next-single-property-change (point) 'help-xref)) 1072 (goto-char (or (next-single-property-change (point) 'help-xref)
1052 (point))) 1073 (point))))
1053 (cond ((setq pos (next-single-property-change (point) 'help-xref)) 1074 (cond ((setq pos (next-single-property-change (point) 'help-xref))
1054 (if pos (goto-char pos))) 1075 (if pos (goto-char pos)))
1055 ((bobp) 1076 ((bobp)
1056 (message "No cross references in the buffer.") 1077 (message "No cross references in the buffer.")
1057 (setq pos t)) 1078 (setq pos t))