Commit e664497b authored by Miles Bader's avatar Miles Bader
Browse files

(woman-mode-map): Copy button-buffer-map instead of

making a new keymap.  Don't bind mouse-2.  Bind M-mouse-2 to
`woman-follow-word' instead of `woman-mouse-2'.
(woman-follow-word): Renamed from `woman-mouse-2'.
Follow unconditionally, since this function is now only
bound to M-mouse-2.  Use accessor functions.
(WoMan-highlight-references): Use `make-text-button'.
(woman-xref): New button type.
parent d876f455
2001-10-07 Miles Bader <miles@gnu.org> 2001-10-07 Miles Bader <miles@gnu.org>
   
* woman.el (woman-mode-map): Copy button-buffer-map instead of
making a new keymap. Don't bind mouse-2. Bind M-mouse-2 to
`woman-follow-word' instead of `woman-mouse-2'.
(woman-follow-word): Renamed from `woman-mouse-2'.
Follow current unconditionally, since this function is now only
bound to M-mouse-2. Use accessor functions.
(WoMan-highlight-references): Use `make-text-button'.
(woman-xref): New button type.
* loadup.el ("faces"): Move load before loading "loaddefs.el". * loadup.el ("faces"): Move load before loading "loaddefs.el".
("button"): New load, just before "help" (which uses it). ("button"): New load, just before "help" (which uses it).
   
......
...@@ -1032,6 +1032,13 @@ The ordinal numbers start from 0.") ...@@ -1032,6 +1032,13 @@ The ordinal numbers start from 0.")
Should include ?e, ?o (page even/odd) and either ?n (nroff) or ?t (troff). Should include ?e, ?o (page even/odd) and either ?n (nroff) or ?t (troff).
Default is '(?n ?e ?o). Set via `woman-emulation'.") Default is '(?n ?e ?o). Set via `woman-emulation'.")
;;; Button types:
(define-button-type 'woman-xref
'action (lambda (button) (woman (button-label button)))
'help-echo "RET, mouse-2: display this man page")
;;; Specialized utility functions: ;;; Specialized utility functions:
...@@ -1700,8 +1707,10 @@ Leave point at end of new text. Return length of inserted text." ...@@ -1700,8 +1707,10 @@ Leave point at end of new text. Return length of inserted text."
(if woman-mode-map (if woman-mode-map
() ()
;; Set up the keymap, mostly inherited from Man-mode-map: ;; Set up the keymap, mostly inherited from Man-mode-map. Normally
(setq woman-mode-map (make-sparse-keymap)) ;; 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) (set-keymap-parent woman-mode-map Man-mode-map)
;; Above two lines were ;; Above two lines were
;; (setq woman-mode-map (cons 'keymap Man-mode-map)) ;; (setq woman-mode-map (cons 'keymap Man-mode-map))
...@@ -1709,19 +1718,14 @@ Leave point at end of new text. Return length of inserted text." ...@@ -1709,19 +1718,14 @@ Leave point at end of new text. Return length of inserted text."
(define-key woman-mode-map "w" 'woman) (define-key woman-mode-map "w" 'woman)
(define-key woman-mode-map "\en" 'WoMan-next-manpage) (define-key woman-mode-map "\en" 'WoMan-next-manpage)
(define-key woman-mode-map "\ep" 'WoMan-previous-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-follow-word))
(define-key woman-mode-map [M-mouse-2] 'woman-mouse-2))
(defun woman-mouse-2 (event) (defun woman-follow-word (event)
"Run WoMan with word under mouse as topic. "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." Argument EVENT is the invoking mouse event."
(interactive "e") ; mouse event (interactive "e") ; mouse event
(let ((pos (cadr (cadr event)))) ; extract buffer position (goto-char (posn-point (event-start event)))
(when (or (eq (car event) 'M-mouse-2) (woman (current-word t)))
(get-text-property pos 'mouse-face))
(goto-char pos)
(woman (current-word t)))))
;; WoMan menu bar and pop-up menu: ;; WoMan menu bar and pop-up menu:
(easy-menu-define ; (SYMBOL MAPS DOC MENU) (easy-menu-define ; (SYMBOL MAPS DOC MENU)
...@@ -1944,11 +1948,8 @@ Otherwise use Man and record start of formatting time." ...@@ -1944,11 +1948,8 @@ Otherwise use Man and record start of formatting time."
(while (re-search-forward Man-reference-regexp end t) (while (re-search-forward Man-reference-regexp end t)
;; Highlight reference when mouse is over it. ;; Highlight reference when mouse is over it.
;; (NB: WoMan does not hyphenate!) ;; (NB: WoMan does not hyphenate!)
;; [See (elisp)Clickable Text] (make-text-button (match-beginning 1) (match-end 1)
(add-text-properties (match-beginning 1) (match-end 1) 'type 'woman-xref)))))
'(mouse-face highlight
help-echo "mouse-2: display this man page"))
))))
;;; Buffer handling: ;;; Buffer handling:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment