comparison lisp/help-mode.el @ 90375:e6bf73e43cf4

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-49 Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 164-184) - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: man/mh-e.texi (Folders): Various edits. - Update from erc--emacs--0 * gnus--rel--5.10 (patch 62-70) - Merge from emacs--devo--0 - Update from CVS
author Miles Bader <miles@gnu.org>
date Tue, 28 Mar 2006 23:08:20 +0000
parents c5406394f567 ddaea7e69d4f
children 72dea2ff0142
comparison
equal deleted inserted replaced
90374:cf65b3d033bb 90375:e6bf73e43cf4
38 38
39 (set-keymap-parent help-mode-map button-buffer-map) 39 (set-keymap-parent help-mode-map button-buffer-map)
40 40
41 (define-key help-mode-map [mouse-2] 'help-follow-mouse) 41 (define-key help-mode-map [mouse-2] 'help-follow-mouse)
42 (define-key help-mode-map "\C-c\C-b" 'help-go-back) 42 (define-key help-mode-map "\C-c\C-b" 'help-go-back)
43 (define-key help-mode-map "\C-c\C-c" 'help-follow) 43 (define-key help-mode-map "\C-c\C-c" 'help-follow-symbol)
44 ;; Documentation only, since we use minor-mode-overriding-map-alist. 44 ;; Documentation only, since we use minor-mode-overriding-map-alist.
45 (define-key help-mode-map "\r" 'help-follow) 45 (define-key help-mode-map "\r" 'help-follow)
46 46
47 (defvar help-xref-stack nil 47 (defvar help-xref-stack nil
48 "A stack of ways by which to return to help buffers after following xrefs. 48 "A stack of ways by which to return to help buffers after following xrefs.
231 231
232 (defvar help-back-label (purecopy "[back]") 232 (defvar help-back-label (purecopy "[back]")
233 "Label to use by `help-make-xrefs' for the go-back reference.") 233 "Label to use by `help-make-xrefs' for the go-back reference.")
234 234
235 (defconst help-xref-symbol-regexp 235 (defconst help-xref-symbol-regexp
236 (purecopy (concat "\\(\\<\\(\\(variable\\|option\\)\\|" 236 (purecopy (concat "\\(\\<\\(\\(variable\\|option\\)\\|" ; Link to var
237 "\\(function\\|command\\)\\|" 237 "\\(function\\|command\\)\\|" ; Link to function
238 "\\(face\\)\\|" 238 "\\(face\\)\\|" ; Link to face
239 "\\(symbol\\)\\|" 239 "\\(symbol\\|program\\)\\|" ; Don't link
240 "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)" 240 "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)"
241 "[ \t\n]+\\)?" 241 "[ \t\n]+\\)?"
242 ;; Note starting with word-syntax character: 242 ;; Note starting with word-syntax character:
243 "`\\(\\sw\\(\\sw\\|\\s_\\)+\\)'")) 243 "`\\(\\sw\\(\\sw\\|\\s_\\)+\\)'"))
244 "Regexp matching doc string references to symbols. 244 "Regexp matching doc string references to symbols.
582 (help-setup-xref (list #'help-xref-interned symbol) nil))))))) 582 (help-setup-xref (list #'help-xref-interned symbol) nil)))))))
583 583
584 584
585 ;; Navigation/hyperlinking with xrefs 585 ;; Navigation/hyperlinking with xrefs
586 586
587 (defun help-follow-mouse (click)
588 "Follow the cross-reference that you CLICK on."
589 (interactive "e")
590 (let* ((start (event-start click))
591 (window (car start))
592 (pos (car (cdr start))))
593 (with-current-buffer (window-buffer window)
594 (help-follow pos))))
595
596 (defun help-xref-go-back (buffer) 587 (defun help-xref-go-back (buffer)
597 "From BUFFER, go back to previous help buffer text using `help-xref-stack'." 588 "From BUFFER, go back to previous help buffer text using `help-xref-stack'."
598 (let (item position method args) 589 (let (item position method args)
599 (with-current-buffer buffer 590 (with-current-buffer buffer
600 (when help-xref-stack 591 (when help-xref-stack
625 a proper [back] button." 616 a proper [back] button."
626 ;; There is a reference at point. Follow it. 617 ;; There is a reference at point. Follow it.
627 (let ((help-xref-following t)) 618 (let ((help-xref-following t))
628 (apply function args))) 619 (apply function args)))
629 620
630 (defun help-follow (&optional pos) 621 ;; The doc string is meant to explain what buttons do.
631 "Follow cross-reference at POS, defaulting to point. 622 (defun help-follow-mouse ()
623 "Follow the cross-reference that you click on."
624 (interactive)
625 (error "No cross-reference here"))
626
627 ;; The doc string is meant to explain what buttons do.
628 (defun help-follow ()
629 "Follow cross-reference at point.
632 630
633 For the cross-reference format, see `help-make-xrefs'." 631 For the cross-reference format, see `help-make-xrefs'."
632 (interactive)
633 (error "No cross-reference here"))
634
635 (defun help-follow-symbol (&optional pos)
636 "In help buffer, show docs for symbol at POS, defaulting to point.
637 Show all docs for that symbol as either a variable, function or face."
634 (interactive "d") 638 (interactive "d")
635 (unless pos 639 (unless pos
636 (setq pos (point))) 640 (setq pos (point)))
637 (unless (push-button pos) 641 ;; check if the symbol under point is a function, variable or face
638 ;; check if the symbol under point is a function or variable 642 (let ((sym
639 (let ((sym 643 (intern
640 (intern 644 (save-excursion
641 (save-excursion 645 (goto-char pos) (skip-syntax-backward "w_")
642 (goto-char pos) (skip-syntax-backward "w_") 646 (buffer-substring (point)
643 (buffer-substring (point) 647 (progn (skip-syntax-forward "w_")
644 (progn (skip-syntax-forward "w_") 648 (point)))))))
645 (point))))))) 649 (when (or (boundp sym)
646 (when (or (boundp sym) 650 (get sym 'variable-documentation)
647 (get sym 'variable-documentation) 651 (fboundp sym) (facep sym))
648 (fboundp sym) (facep sym)) 652 (help-do-xref pos #'help-xref-interned (list sym)))))
649 (help-do-xref pos #'help-xref-interned (list sym))))))
650 653
651 (defun help-insert-string (string) 654 (defun help-insert-string (string)
652 "Insert STRING to the help buffer and install xref info for it. 655 "Insert STRING to the help buffer and install xref info for it.
653 This function can be used to restore the old contents of the help buffer 656 This function can be used to restore the old contents of the help buffer
654 when going back to the previous topic in the xref stack. It is needed 657 when going back to the previous topic in the xref stack. It is needed