]> code.delx.au - gnu-emacs/blobdiff - lisp/woman.el
(isearch-resume-enabled): New variable.
[gnu-emacs] / lisp / woman.el
index b6614992eb91550ae8696529f57aec84986867a9..e4440be46903498b0f5641643a7f1ea773c8742c 100644 (file)
@@ -2,12 +2,12 @@
 
 ;; 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.
 
@@ -500,7 +500,7 @@ Change only via `Customization' or the function `add-hook'."
   :group 'woman)
 
 (defcustom woman-man.conf-path
-  '("/etc" "/usr/local/lib")
+  '("/etc" "/etc/manpath.config" "/usr/local/lib")
   "*List of dirs to search and/or files to try for man config file.
 Default is '(\"/etc\" \"/usr/local/lib\") [for GNU/Linux, Cygwin resp.]
 A trailing separator (`/' for UNIX etc.) on directories is optional
@@ -517,7 +517,11 @@ Used only if MANPATH is not set or contains null components.
 Look in `woman-man.conf-path' and return a value for `woman-manpath'.
 Concatenate data from all lines in the config file of the form
 
-MANPATH        /usr/man"
+  MANPATH      /usr/man
+
+or
+
+  MANDATORY_MANPATH     /usr/man"
   ;; Functionality suggested by Charles Curley.
   (let ((path woman-man.conf-path)
        file manpath)
@@ -535,8 +539,8 @@ MANPATH     /usr/man"
                  (with-temp-buffer
                    (insert-file-contents file)
                    (while (re-search-forward
-                           "^[ \t]*MANPATH[ \t]+\\(\\S-+\\)" nil t)
-                     (setq manpath (cons (match-string 1) manpath)))
+                           "^[ \t]*\\(MANDATORY_\\)?MANPATH[ \t]+\\(\\S-+\\)" nil t)
+                     (setq manpath (cons (match-string 2) manpath)))
                    manpath))
                 ))
       (setq path (cdr path)))
@@ -547,7 +551,7 @@ MANPATH     /usr/man"
     (or
      (and manpath (woman-parse-colon-path manpath))
      (woman-parse-man.conf)
-     '("/usr/man" "/usr/local/man")
+     '("/usr/man" "/usr/share/man" "/usr/local/man")
      ))
   "*List of DIRECTORY TREES to search for UN*X manual files.
 Each element should be the name of a directory that contains
@@ -832,28 +836,28 @@ or different fonts."
   :type 'boolean
   :group 'woman-faces)
 
+;; This is overkill!  Troff uses just italic; Nroff uses just underline.
+;; You should probably select either italic or underline as you prefer, but
+;; not both, although italic and underline work together perfectly well!
 (defface woman-italic-face
-  `((t (:italic t :underline t :foreground "red")))
-  "Face for italic font in man pages.
-Default: italic, underlined, foreground red.
-This is overkill!  Troff uses just italic\; Nroff uses just underline.
-You should probably select either italic or underline as you prefer,
-but not both, although italic and underline work together perfectly well!"
+  `((((background light)) (:italic t :underline t :foreground "red"))
+    (((background dark)) (:italic t :underline t)))
+  "Face for italic font in man pages."
   :group 'woman-faces)
 
 (defface woman-bold-face
-  '((t (:bold t :foreground "blue")))
-  "Face for bold font in man pages.
-Default: bold, foreground blue."
+  '((((background light)) (:bold t :foreground "blue"))
+    (((background dark)) (:bold t :foreground "green2")))
+  "Face for bold font in man pages."
   :group 'woman-faces)
 
+;; Brown is a good compromise: it is distinguishable from the default
+;; but not enough so to make font errors look terrible.  (Files that use
+;; non-standard fonts seem to do so badly or in idiosyncratic ways!)
 (defface woman-unknown-face
-  '((t (:foreground "brown")))
-  "Face for all unknown fonts in man pages.
-Default: foreground brown.
-Brown is a good compromise: it is distinguishable from the default but
-not enough so to make font errors look terrible.  (Files that use
-non-standard fonts seem to do so badly or in idiosyncratic ways!)"
+  '((((background light)) (:foreground "brown"))
+    (((background dark)) (:foreground "cyan")))
+  "Face for all unknown fonts in man pages."
   :group 'woman-faces)
 
 (defface woman-addition-face
@@ -862,17 +866,19 @@ non-standard fonts seem to do so badly or in idiosyncratic ways!)"
 Default: foreground orange."
   :group 'woman-faces)
 
-(defun woman-colour-faces ()
-  "Set foreground colours of italic and bold faces to red and blue."
+(defun woman-default-faces ()
+  "Set foreground colours of italic and bold faces to their default values."
   (interactive)
-  (set-face-foreground 'woman-italic-face "Red")
-  (set-face-foreground 'woman-bold-face "Blue"))
+  (face-spec-set 'woman-italic-face
+                (face-user-default-spec 'woman-italic-face))
+  (face-spec-set 'woman-bold-face (face-user-default-spec 'woman-bold-face)))
 
-(defun woman-black-faces ()
-  "Set foreground colours of italic and bold faces both to black."
+(defun woman-monochrome-faces ()
+  "Set foreground colours of italic and bold faces to that of the default face.
+This is usually either black or white."
   (interactive)
-  (set-face-foreground 'woman-italic-face "Black")
-  (set-face-foreground 'woman-bold-face "Black"))
+  (set-face-foreground 'woman-italic-face 'unspecified)
+  (set-face-foreground 'woman-bold-face 'unspecified))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Experimental font support, initially only for MS-Windows.
@@ -1026,6 +1032,13 @@ The ordinal numbers start from 0.")
 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:
 
@@ -1694,8 +1707,10 @@ Leave point at end of new text.  Return length of inserted text."
 
 (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))
@@ -1703,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 "\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)
@@ -1740,8 +1750,8 @@ Argument EVENT is the invoking mouse event."
    ["Use Full Frame Width" woman-toggle-fill-frame
     :active t :style toggle :selected woman-fill-frame]
    ["Reformat Last Man Page" woman-reformat-last-file t]
-   ["Use Coloured Main Faces" woman-colour-faces t]
-   ["Use Black Main Faces" woman-black-faces t]
+   ["Use Monochrome Main Faces" woman-monochrome-faces t]
+   ["Use Default Main Faces" woman-default-faces t]
    ["Make Contents Menu" (woman-imenu t) (not woman-imenu-done)]
    "--"
    ["Describe (Wo)Man Mode" describe-mode t]
@@ -1938,10 +1948,8 @@ Otherwise use Man and record start of formatting time."
       (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:
@@ -4405,6 +4413,7 @@ If optional argument END is non-nil then make buffer read-only after
 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