;; Copyright (C) 2000 Free Software Foundation, Inc.
-;; Author: Francis J. Wright <F.J.Wright@Maths.QMW.ac.uk>
-;; Maintainer: Francis J. Wright <F.J.Wright@Maths.QMW.ac.uk>
-;; Keywords: help, man, UN*X, manual
-;; Adapted-By: Eli Zaretskii <eliz@is.elta.co.il>
-;; Version: see `woman-version'
-;; URL: http://centaur.maths.qmw.ac.uk/Emacs/WoMan/
+;; Author: Francis J. Wright <F.J.Wright@Maths.QMW.ac.uk>
+;; Maintainer: Francis J. Wright <F.J.Wright@Maths.QMW.ac.uk>
+;; Keywords: help, man, UN*X, manual
+;; Adapted-By: Eli Zaretskii <eliz@is.elta.co.il>
+;; Version: see `woman-version'
+;; URL: http://centaur.maths.qmw.ac.uk/Emacs/WoMan/
;; This file is part of GNU Emacs.
Should include ?e, ?o (page even/odd) and either ?n (nroff) or ?t (troff).
Default is '(?n ?e ?o). Set via `woman-emulation'.")
+\f
+;;; Button types:
+
+(define-button-type 'woman-xref
+ 'action (lambda (button) (woman (button-label button)))
+ 'help-echo "RET, mouse-2: display this man page")
+
\f
;;; Specialized utility functions:
(if woman-mode-map
()
- ;; Set up the keymap, mostly inherited from Man-mode-map:
- (setq woman-mode-map (make-sparse-keymap))
+ ;; Set up the keymap, mostly inherited from Man-mode-map. Normally
+ ;; button-buffer-map is used as a parent keymap, but we can't have two
+ ;; parents, so we just copy it.
+ (setq woman-mode-map (copy-keymap button-buffer-map))
(set-keymap-parent woman-mode-map Man-mode-map)
;; Above two lines were
;; (setq woman-mode-map (cons 'keymap Man-mode-map))
(define-key woman-mode-map "w" 'woman)
(define-key woman-mode-map "\en" 'WoMan-next-manpage)
(define-key woman-mode-map "\ep" 'WoMan-previous-manpage)
- (define-key woman-mode-map [mouse-2] 'woman-mouse-2)
- (define-key woman-mode-map [M-mouse-2] 'woman-mouse-2))
+ (define-key woman-mode-map [M-mouse-2] 'woman-follow-word))
-(defun woman-mouse-2 (event)
+(defun woman-follow-word (event)
"Run WoMan with word under mouse as topic.
-Require it to be mouse-highlighted unless Meta key used.
Argument EVENT is the invoking mouse event."
(interactive "e") ; mouse event
- (let ((pos (cadr (cadr event)))) ; extract buffer position
- (when (or (eq (car event) 'M-mouse-2)
- (get-text-property pos 'mouse-face))
- (goto-char pos)
- (woman (current-word t)))))
+ (goto-char (posn-point (event-start event)))
+ (woman (current-word t)))
;; WoMan menu bar and pop-up menu:
(easy-menu-define ; (SYMBOL MAPS DOC MENU)
(while (re-search-forward Man-reference-regexp end t)
;; Highlight reference when mouse is over it.
;; (NB: WoMan does not hyphenate!)
- ;; [See (elisp)Clickable Text]
- (put-text-property (match-beginning 1) (match-end 1)
- 'mouse-face 'highlight)
- ))))
+ (make-text-button (match-beginning 1) (match-end 1)
+ 'type 'woman-xref)))))
\f
;;; Buffer handling:
logging the message."
(save-excursion
(set-buffer (get-buffer-create "*WoMan-Log*"))
+ (setq buffer-read-only nil)
(goto-char (point-max))
(or end (insert " ")) (insert string "\n")
(if end