Mercurial > emacs
comparison lisp/woman.el @ 39653:b36d97729582
(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.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 07 Oct 2001 12:39:00 +0000 |
parents | b174db545cfd |
children | 0cfd64a10789 |
comparison
equal
deleted
inserted
replaced
39652:cd4ae2af5d87 | 39653:b36d97729582 |
---|---|
1029 | 1029 |
1030 (defvar woman-if-conditions-true '(?n ?e ?o) | 1030 (defvar woman-if-conditions-true '(?n ?e ?o) |
1031 "List of one-character built-in condition names that are true. | 1031 "List of one-character built-in condition names that are true. |
1032 Should include ?e, ?o (page even/odd) and either ?n (nroff) or ?t (troff). | 1032 Should include ?e, ?o (page even/odd) and either ?n (nroff) or ?t (troff). |
1033 Default is '(?n ?e ?o). Set via `woman-emulation'.") | 1033 Default is '(?n ?e ?o). Set via `woman-emulation'.") |
1034 | |
1035 | |
1036 ;;; Button types: | |
1037 | |
1038 (define-button-type 'woman-xref | |
1039 'action (lambda (button) (woman (button-label button))) | |
1040 'help-echo "RET, mouse-2: display this man page") | |
1034 | 1041 |
1035 | 1042 |
1036 ;;; Specialized utility functions: | 1043 ;;; Specialized utility functions: |
1037 | 1044 |
1038 ;;; Fast deletion without saving on the kill ring (cf. simple.el): | 1045 ;;; Fast deletion without saving on the kill ring (cf. simple.el): |
1698 | 1705 |
1699 (defvar woman-mode-map nil "Keymap for woman mode.") | 1706 (defvar woman-mode-map nil "Keymap for woman mode.") |
1700 | 1707 |
1701 (if woman-mode-map | 1708 (if woman-mode-map |
1702 () | 1709 () |
1703 ;; Set up the keymap, mostly inherited from Man-mode-map: | 1710 ;; Set up the keymap, mostly inherited from Man-mode-map. Normally |
1704 (setq woman-mode-map (make-sparse-keymap)) | 1711 ;; button-buffer-map is used as a parent keymap, but we can't have two |
1712 ;; parents, so we just copy it. | |
1713 (setq woman-mode-map (copy-keymap button-buffer-map)) | |
1705 (set-keymap-parent woman-mode-map Man-mode-map) | 1714 (set-keymap-parent woman-mode-map Man-mode-map) |
1706 ;; Above two lines were | 1715 ;; Above two lines were |
1707 ;; (setq woman-mode-map (cons 'keymap Man-mode-map)) | 1716 ;; (setq woman-mode-map (cons 'keymap Man-mode-map)) |
1708 (define-key woman-mode-map "R" 'woman-reformat-last-file) | 1717 (define-key woman-mode-map "R" 'woman-reformat-last-file) |
1709 (define-key woman-mode-map "w" 'woman) | 1718 (define-key woman-mode-map "w" 'woman) |
1710 (define-key woman-mode-map "\en" 'WoMan-next-manpage) | 1719 (define-key woman-mode-map "\en" 'WoMan-next-manpage) |
1711 (define-key woman-mode-map "\ep" 'WoMan-previous-manpage) | 1720 (define-key woman-mode-map "\ep" 'WoMan-previous-manpage) |
1712 (define-key woman-mode-map [mouse-2] 'woman-mouse-2) | 1721 (define-key woman-mode-map [M-mouse-2] 'woman-follow-word)) |
1713 (define-key woman-mode-map [M-mouse-2] 'woman-mouse-2)) | 1722 |
1714 | 1723 (defun woman-follow-word (event) |
1715 (defun woman-mouse-2 (event) | |
1716 "Run WoMan with word under mouse as topic. | 1724 "Run WoMan with word under mouse as topic. |
1717 Require it to be mouse-highlighted unless Meta key used. | |
1718 Argument EVENT is the invoking mouse event." | 1725 Argument EVENT is the invoking mouse event." |
1719 (interactive "e") ; mouse event | 1726 (interactive "e") ; mouse event |
1720 (let ((pos (cadr (cadr event)))) ; extract buffer position | 1727 (goto-char (posn-point (event-start event))) |
1721 (when (or (eq (car event) 'M-mouse-2) | 1728 (woman (current-word t))) |
1722 (get-text-property pos 'mouse-face)) | |
1723 (goto-char pos) | |
1724 (woman (current-word t))))) | |
1725 | 1729 |
1726 ;; WoMan menu bar and pop-up menu: | 1730 ;; WoMan menu bar and pop-up menu: |
1727 (easy-menu-define ; (SYMBOL MAPS DOC MENU) | 1731 (easy-menu-define ; (SYMBOL MAPS DOC MENU) |
1728 woman-menu | 1732 woman-menu |
1729 woman-mode-map | 1733 woman-mode-map |
1942 (point)))) | 1946 (point)))) |
1943 (back-to-indentation) | 1947 (back-to-indentation) |
1944 (while (re-search-forward Man-reference-regexp end t) | 1948 (while (re-search-forward Man-reference-regexp end t) |
1945 ;; Highlight reference when mouse is over it. | 1949 ;; Highlight reference when mouse is over it. |
1946 ;; (NB: WoMan does not hyphenate!) | 1950 ;; (NB: WoMan does not hyphenate!) |
1947 ;; [See (elisp)Clickable Text] | 1951 (make-text-button (match-beginning 1) (match-end 1) |
1948 (add-text-properties (match-beginning 1) (match-end 1) | 1952 'type 'woman-xref))))) |
1949 '(mouse-face highlight | |
1950 help-echo "mouse-2: display this man page")) | |
1951 )))) | |
1952 | 1953 |
1953 | 1954 |
1954 ;;; Buffer handling: | 1955 ;;; Buffer handling: |
1955 | 1956 |
1956 (defun WoMan-previous-manpage () | 1957 (defun WoMan-previous-manpage () |