Commit 1edbbf8a authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

(From Francis J. Wright <F.J.Wright@Maths.QMW.ac.uk)

(woman-mapcan, woman-parse-man.conf)
(woman-toggle-use-extended-font, woman-toggle-use-symbol-font)
(woman-reset-emulation): New functions.
(woman-parse-colon-path): Call woman-mapcan.  Recognize Cygwin
path syntax better.
(woman-man.conf-path, woman-use-own-frame): New defcustoms.
(woman-manpath): Call woman-parse-man.conf.
(woman-emulation): New defcustom, defaults to nroff.
(woman-font-support): New defconst.
(woman-select-symbol-fonts): New function.
(woman-use-symbol-font): New defcustom.
(woman-menu): Add new menu items: "Colored/BW", "Advanced",
"Emulation".
Many functions: Doc fix.
parent 99da6af3
2000-05-22 Eli Zaretskii <eliz@is.elta.co.il>
* woman.el (From Francis J. Wright <F.J.Wright@Maths.QMW.ac.uk)
(woman-mapcan, woman-parse-man.conf)
(woman-toggle-use-extended-font, woman-toggle-use-symbol-font)
(woman-reset-emulation, woman-select-symbol-fonts): New functions.
(woman-parse-colon-path): Call woman-mapcan. Recognize Cygwin
path syntax better.
(woman-man.conf-path, woman-use-own-frame): New defcustoms.
(woman-manpath): Call woman-parse-man.conf.
(woman-emulation): New defcustom, defaults to nroff.
(woman-font-support): New defconst.
(woman-use-symbol-font): New defcustom.
(woman-menu): Add new menu items: "Colored/BW", "Advanced",
"Emulation".
Many functions: Doc fix.
2000-05-22 Kenichi Handa <handa@etl.go.jp>
* international/quail.el (quail-simple-translation-keymap): Map
......
......@@ -7,6 +7,7 @@
;; 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/
;; This file is part of GNU Emacs.
......@@ -67,11 +68,6 @@
;; work -- I am adding and improving functionality as testing shows
;; that it is necessary. See below for guidance on reporting bugs.
;; The latest versions of this (and related) files are available from
;; the URL
;; http://centaur.maths.qmw.ac.uk/Emacs/
;; Recommended use
;; ===============
......@@ -100,8 +96,8 @@
;; (autoload 'woman-dired-find-file "woman"
;; "In dired, run the WoMan man-page browser on this file." t)
;; (add-hook 'dired-mode-hook
;; #'(lambda ()
;; (define-key dired-mode-map "W" 'woman-dired-find-file)))
;; (lambda ()
;; (define-key dired-mode-map "W" 'woman-dired-find-file)))
;; and open the directory containing the man page file using dired,
;; put the cursor on the file, and press `W'.
......@@ -158,7 +154,7 @@
;; may be useful to provide special private key bindings, e.g.
;; (global-set-key "\C-cw"
;; #'(lambda ()
;; (lambda ()
;; (interactive)
;; (let ((woman-topic-at-point t))
;; (woman)))))
......@@ -274,9 +270,9 @@
;; (cons
;; '(man "UN*X man-page source format" "\\.\\(TH\\|ig\\) "
;; woman-decode-region nil nil
;; #'(lambda (arg)
;; (set-visited-file-name
;; (file-name-sans-extension buffer-file-name)))))
;; (lambda (arg)
;; set-visited-file-name
;; (file-name-sans-extension buffer-file-name)))))
;; format-alist))
......@@ -336,6 +332,7 @@
;; TO DO
;; =====
;; Reconsider case sensitivity of file names.
;; MUST PROCESS .if, .nr IN ORDER ENCOUNTERED IN FILE! (rcsfile, mf).
;; Allow general delimiter in `\v', cf. `\h'.
;; Improve major-mode documentation.
......@@ -356,6 +353,7 @@
;; Implement a bug reporter?
;; Support diversion and traps (to some extent) - for Tcl/tk pages?
;; Add a menu of WoMan buffers?
;; Fix .fc properly?
;; Implementation strategy [this description is now well out of date!]
......@@ -370,7 +368,9 @@
;; perform the required formatting. Based originally on enriched.el
;; and format.el.
;; See also /usr/local/share/groff/tmac/tmac.an
;; The background information that made this project possible is
;; freely available courtesy of Bell Labs from
;; http://cm.bell-labs.com/7thEdMan/
;; Acknowledgements
......@@ -415,56 +415,13 @@
;; Karel Sprenger <ks@ic.uva.nl>
;; Chris Szurgot <szurgot@itribe.net>
;; Paul A. Thompson <pat@po.cwru.edu>
;; Arrigo Triulzi <arrigo@maths.qmw.ac.uk>
;; Geoff Voelker <voelker@cs.washington.edu>
(defconst woman-version "0.52 (beta), Time-stamp: <09 January 2000>"
"WoMan version information.")
;; $Id: woman.el,v 1.26 2000-01-09 09:44:25+00 fjw Rel $
;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;; Changes in version 0.52 ([*] => user interface change)
;; Speeded up handling of underlined faces (mainly for "italics").
;; [*] WoMan formatting time display and log added. Emacs `man'
;; formatting time display advice added. (This suggests that
;; WoMan formatting is faster than Emacs `man' *formatting*,
;; i.e. when man is not using `catman' caching. E.g. `woman
;; bash' takes 27s whereas `man bash' takes 35s and for smaller
;; files `woman' can be relatively much faster than `man'.)
;; [*] Experimental support for non-ASCII characters from the
;; default and symbol fonts added, initially only for MS-Windows.
;; NOTE: It is off by default, mainly because it may increase the
;; line spacing; customize `woman-use-symbols' to `on' to use it.
;; Pad character handling for .fc fixed.
;; Tested: see `woman.status'.
;; Changes in version 0.51 ([*] => user interface change)
;; [*] Improved handling of underlined faces (mainly for "italics").
;; [*] Allow environment variables in directory path elements.
;; Display of pre-formatted files improved.
;; [*] Unintentional interaction with standard Man mode reduced.
;; [*] bzip2 decompression support added. All decompression now
;; works by turning on `auto-compression-mode' to decompress the
;; file if necessary, rather than decompressing explicitly.
;; Filename and compression regexps are now customizable user
;; options.
(defvar woman-version "0.54 (beta)" "WoMan version information.")
;; Changes in version 0.50 ([*] => user interface change)
;; [*] Requires GNU Emacs 20.3+.
;; [*] `defface' used to define faces.
;; [*] Follow `see also' references with mouse-2 click.
;; Number register increment support added (woman-registers).
;; .j must be a NUMBER acceptable by .ad request.
;; Very crude field support added.
;; Vertical unit specifier `v' added to register handling.
;; Improvement to local horizontal motion processing.
;; Minor fix to handle negative numeric arguments.
;; Handle horizontal motion escapes `\h' better.
;; Allow arbitrary delimiters in `.if', inc. special character escapes.
;; Allow `\n' within `.if' string comparisons.
;; Allow arbitrary delimiters in `\w', inc. special character escapes.
;; Processing of `\h' moved much later -- after indenting etc!
;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;;; History:
;; For recent change log see end of file.
;;; Code:
......@@ -474,29 +431,38 @@
(require 'dired)
(require 'apropos))
(defun woman-mapcan (fn x)
"Return concatenated list of FN applied to successive CAR elements of X.
FN must return a list, cons or nil. Useful for splicing into a list."
;; Based on the Standard Lisp function MAPCAN but with args swapped!
(and x (nconc (funcall fn (car x)) (woman-mapcan fn (cdr x)))))
(defun woman-parse-colon-path (cd-path)
"Explode a search path CD-PATH into a list of directory names.
If the platform is MS-DOS/MS-Windows and any path begins with `//',
If the platform is Microsoft Windows and no path contains `\\' then
assume a Cygwin-style colon-separated search path and convert any
leading drive specifier `//X/' to `X:', otherwise assume paths
separated by `path-separator'."
;; Based on a suggestion by Jari Aalto.
(if (and (memq system-type '(ms-dos windows-nt))
(or (string-match "://" cd-path)
(and (not (string-match ":" cd-path))
(string-match "\\`//" cd-path))))
(let ((path-separator ":"))
(mapcar
(function
(woman-mapcan ; splice into list...
(lambda (path)
;; parse-colon-path returns nil for a null path component and
;; an empty substring of MANPATH denotes the default list...
(if path (cons path nil) (woman-parse-man.conf)))
(if (and (memq system-type '(windows-nt ms-dos))
(not (or (string-match ";" cd-path)
(string-match "\\\\" cd-path))))
(let ((path-separator ":"))
(mapcar
(lambda (path) ; //a/b -> a:/b
(cond ((string-match "\\`//" path)
(cond ((and path (string-match "\\`//./" path))
(setq path (substring path 1)) ; //a/b -> /a/b
(aset path 0 (aref path 1)) ; /a/b -> aa/b
(aset path 0 (aref path 1)) ; /a/b -> aa/b
(aset path 1 ?:) ; aa/b -> a:/b
))
path))
(parse-colon-path cd-path)))
(parse-colon-path cd-path)))
path)
(parse-colon-path cd-path)))
(parse-colon-path cd-path))))
;;; User options:
......@@ -534,24 +500,71 @@ Change only via `Customization' or the function `add-hook'."
:tag "WoMan Interface"
:group 'woman)
(defcustom woman-man.conf-path
'("/etc" "/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
and the filename matched if a directory is specified is the first to
contain the string \"man.conf\".
If MANPATH is not set but a config file is found then it is parsed
instead to provide a default value for `woman-manpath'."
:type '(repeat string)
:group 'woman-interface)
(defun woman-parse-man.conf ()
"Parse man config file if found. (Used only if MANPATH is not set.)
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"
;; Functionality suggested by Charles Curley.
(let ((path woman-man.conf-path)
file manpath)
(while (and
path
(not (and
(file-readable-p (setq file (car path)))
;; If not a file then find the file:
(or (not (file-directory-p file))
(and
(setq file
(directory-files file t "man\\.conf" t))
(file-readable-p (setq file (car file)))))
;; Parse the file -- if no MANPATH data ignore it:
(with-temp-buffer
(insert-file-contents file)
(while (re-search-forward
"^[ \t]*MANPATH[ \t]+\\(\\S-+\\)" nil t)
(setq manpath (cons (match-string 1) manpath)))
manpath))
))
(setq path (cdr path)))
(nreverse manpath)))
(defcustom woman-manpath
(let ((manpath (getenv "MANPATH")))
(if manpath
(woman-parse-colon-path manpath)
;; NB: `parse-colon-path' creates null elements for redundant
;; (semi-)colons and trailing `/'s!
'("/usr/man" "/usr/local/man")
))
(or
(and manpath (woman-parse-colon-path manpath))
(woman-parse-man.conf)
'("/usr/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
subdirectories of the form `man?', or more precisely subdirectories
selected by the value of `woman-manpath-man-regexp'. Non-directory
and unreadable files are ignored. The default value of this variable
is based on the UN*X MANPATH environment variable if set, otherwise
and unreadable files are ignored.
If not set then the environment variable MANPATH is used. If no such
environment variable is found, the default list is determined by
consulting the man configuration file if found. By default this is
either `/etc/man.config' or `/usr/local/lib/man.conf', which is
determined by the user option `woman-man.conf-path'. An empty
substring of MANPATH denotes the default list. Otherwise, the default
value of this variable is
(\"/usr/man\" \"/usr/local/man\").
Any environment variables (which must have the UN*X-style form $NAME,
Any environment variables (names must have the UN*X-style form $NAME,
e.g. $HOME, $EMACSDATA, $EMACS_DIR) are evaluated first but each
element must evaluate to a SINGLE directory name. Trailing `/'s are
ignored. (Specific directories in `woman-path' are also searched.)
......@@ -654,9 +667,8 @@ see the documentation for `imenu-generic-expression'."
:group 'woman-interface)
(defcustom woman-imenu nil
"*If non-nil, WoMan adds a Contents menu to the menubar.
WoMan adds the Contents menu by calling `imenu-add-to-menubar'.
Default is nil."
"*If non-nil then WoMan adds a Contents menu to the menubar.
It does this by calling `imenu-add-to-menubar'. Default is nil."
:type 'boolean
:group 'woman-interface)
......@@ -699,7 +711,7 @@ Built automatically from the customizable user options
(defun set-woman-file-regexp (symbol value)
"Bind SYMBOL to VALUE and set `woman-file-regexp' as per user customizations.
Used as :set cookie by Customize when user customized the user options
Used as :set cookie by Customize when customizing the user options
`woman-uncompressed-file-regexp' and `woman-file-compression-regexp'."
(set-default symbol value)
(and (boundp 'woman-uncompressed-file-regexp)
......@@ -729,13 +741,25 @@ MUST NOT end with any kind of string terminator such as $ or \\'."
"\\.\\(g?z\\|bz2\\)\\'"
"*Do not change this unless you are sure you know what you are doing!
Regexp used to match compressed man file extensions for which
decompressors are available and handled by function `auto-compression-mode',
decompressors are available and handled by auto-compression mode,
e.g. \"\\\\.\\\\(g?z\\\\|bz2\\\\)\\\\'\" for `gzip' or `bzip2'.
Should begin with \\. and end with \\' and MUST NOT be optional."
;; Should be compatible with car of
;; `jka-compr-file-name-handler-entry', but that is unduly
;; complicated, includes an inappropriate extension (.tgz) and is
;; not loaded by default!
:type 'regexp
:set 'set-woman-file-regexp
:group 'woman-interface)
(defcustom woman-use-own-frame
(or (and (fboundp 'display-graphic-p) (display-graphic-p))
(memq window-system '(x w32)))
"*If non-nil then use a dedicated frame for displaying WoMan windows.
Only useful when run on a graphic display such as X or MS-Windows."
:type 'boolean
:group 'woman-interface)
;; Formatting options
......@@ -768,7 +792,7 @@ Heading emboldening is NOT standard `man' behaviour."
:group 'woman-formatting)
(defcustom woman-ignore t
"*If non-nil then unrecognised requests are ignored. Default is t.
"*If non-nil then unrecognised requests etc. are ignored. Default is t.
This gives the standard ?roff behaviour. If nil then they are left in
the buffer, which may aid debugging."
:type 'boolean
......@@ -781,6 +805,13 @@ This is irrelevant unless the buffer is to be saved to a file."
:type 'boolean
:group 'woman-formatting)
(defcustom woman-emulation 'nroff
"*WoMan emulation, currently either nroff or troff. Default is nroff.
Troff emulation is experimental and largely untested.
\(Add groff later?)"
:type '(choice (const nroff) (const troff))
:group 'woman-formatting)
;; Faces:
......@@ -843,41 +874,44 @@ Default: foreground orange."
(set-face-foreground 'woman-bold-face "Black"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Experimental symbol font support, initially only for MS-Windows.
(eval-when-compile
(defvar woman-symbol-font)
(defvar woman-use-symbols))
(when (and window-system (eq system-type 'windows-nt))
;; Experimental font support, initially only for MS-Windows.
(defconst woman-font-support
(eq window-system 'w32) ; Support X later!
"If non-nil then non-ASCII characters and symbol font supported.")
(defun woman-select-symbol-fonts (fonts)
"Select symbol fonts from a list FONTS of font name strings."
(let (symbol-fonts)
;; With NTEmacs 20.5, the PATTERN option to `x-list-fonts' does
;; not seem to work and fonts may be repeated, so ...
(while fonts
(and (string-match "-Symbol-" (car fonts))
(not (member (car fonts) symbol-fonts))
(setq symbol-fonts (cons (car fonts) symbol-fonts)))
(setq fonts (cdr fonts)))
symbol-fonts))
(when woman-font-support
(make-face 'woman-symbol-face)
;; Set up the symbol font only if `woman-use-symbols' is true, to
;; Set the symbol font only if `woman-use-symbol-font' is true, to
;; avoid unnecessarily upsetting the line spacing in NTEmacs 20.5!
(defcustom woman-use-symbols nil
"*If non-nil then may use symbol font and non-ASCII characters
from the default font for special characters. It is off by default,
mainly because it may increase the line spacing in NTEmacs 20.5."
(defcustom woman-use-extended-font t
"*If non-nil then may use non-ASCII characters from the default font."
:type 'boolean
:group 'woman-faces)
(defcustom woman-use-symbol-font nil
"*If non-nil then may use the symbol font. It is off by default,
mainly because it may change the line spacing (in NTEmacs 20.5)."
:type 'boolean
:set #'(lambda (symbol value)
(set-default symbol value)
(if (and (boundp 'woman-symbol-font)
(stringp woman-symbol-font))
(set-face-font 'woman-symbol-face woman-symbol-font)))
:group 'woman-faces)
(defconst woman-symbol-font-list
(let ((fonts (x-list-fonts "*" 'default))
symbol-fonts)
;; With NTEmacs 20.5, the PATTERN option to `x-list-fonts' does
;; not seem to work and fonts may be repeated, so ...
(while fonts
(and (string-match "-Symbol-" (car fonts))
(not (member (car fonts) symbol-fonts))
(setq symbol-fonts (cons (car fonts) symbol-fonts)))
(setq fonts (cdr fonts)))
symbol-fonts)
"Symbol fonts in the same size as the default font when WoMan was loaded.")
(or (woman-select-symbol-fonts (x-list-fonts "*" 'default))
(woman-select-symbol-fonts (x-list-fonts "*")))
"Symbol font(s), preferably same size as default when WoMan was loaded.")
(defcustom woman-symbol-font (car woman-symbol-font-list)
"*A string describing the symbol font to use for special characters.
......@@ -885,18 +919,17 @@ It should be compatible with, and the same size as, the default text font.
Under MS-Windows, the default is
\"-*-Symbol-normal-r-*-*-*-*-96-96-p-*-ms-symbol\"."
:type `(choice
,@(mapcar #'(lambda (x) (list 'const x))
,@(mapcar (lambda (x) (list 'const x))
woman-symbol-font-list)
string)
:set #'(lambda (symbol value)
(set-default symbol value)
(if woman-use-symbols
(set-face-font 'woman-symbol-face value)))
:group 'woman-faces)
)
(defvar woman-use-symbols nil) ; for non windows-nt
;; For non windows-nt ...
(defvar woman-use-extended-font nil)
(defvar woman-use-symbol-font nil)
(defvar woman-symbol-font nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
......@@ -946,7 +979,7 @@ Set by .PD; used by .SH, .SS, .TP, .LP, .PP, .P, .IP, .HP.")
Set by `.ns' request; reset by any output or `.rs' request")
(defsubst woman-reset-nospace ()
"Make woman-nospace be nil."
"Set `woman-nospace' to nil."
(setq woman-nospace nil))
(defconst woman-mode-line-format
......@@ -970,7 +1003,7 @@ Set by `.ns' request; reset by any output or `.rs' request")
"Regexp to match a ?roff request plus trailing white space.")
(defvar woman-imenu-done nil
"Buffer-local: set to true if `woman-imenu' has been called.")
"Buffer-local: set to true if function `woman-imenu' has been called.")
(make-variable-buffer-local 'woman-imenu-done)
;; From imenu.el -- needed when reformatting a file in its old buffer.
......@@ -980,20 +1013,25 @@ Set by `.ns' request; reset by any output or `.rs' request")
(make-variable-buffer-local 'imenu--last-menubar-index-alist)
(defvar woman-buffer-alist nil
"An alist of WoMan buffers that are already decoded.
Each element is of the form (FILE-NAME BUFFER-NAME).")
"An alist representing WoMan buffers that are already decoded.
Each element is of the form (FILE-NAME . BUFFER-NAME).")
(defvar woman-buffer-number 0
"Ordinal number of current buffer entry in `woman-buffer-alist'.
The ordinal numbers start from 0.")
(defvar woman-if-conditions-true '(?n ?e ?o)
"List of one-character built-in condition names that are true.
Should include ?e, ?o (page even/odd) and either ?n (nroff) or ?t (troff).
Default is '(?n ?e ?o). Set via `woman-emulation'.")
;;; Specialized utility functions:
;;; Fast deletion without saving on the kill ring (cf. simple.el):
(defun woman-delete-line (&optional arg)
"Delete the rest of the current line; if all-blank line, delete thru newline.
"Delete rest of current line; if all blank then delete thru newline.
With a numeric argument ARG, delete that many lines from point.
Negative arguments delete lines backward."
;; This is a non-interactive version of kill-line in simple.el that
......@@ -1040,7 +1078,7 @@ Negative arguments delete lines backward."
;;;###autoload
(defun woman (&optional topic re-cache)
"Browse a UN*X man page for TOPIC WithOut using a `man' program.
"Browse UN*X man page for TOPIC (Without using external Man program).
The major browsing mode used is essentially the standard Man mode.
Choose the filename for the man page using completion, based on the
topic selected from the directories specified in `woman-manpath' and
......@@ -1048,9 +1086,8 @@ topic selected from the directories specified in `woman-manpath' and
speed, but a non-nil interactive argument forces the caches to be
updated (e.g. to re-interpret the current directory).
Used non-interactively, arguments are optional: if they are given then
the argument TOPIC should be a topic string and the RE-CACHE may be
non-nil to force re-caching."
Used non-interactively, arguments are optional: if given then TOPIC
should be a topic string and non-nil RE-CACHE forces re-caching."
(interactive (list nil current-prefix-arg))
;; The following test is for non-interactive calls via gnudoit etc.
(if (or (interactive-p) (not (stringp topic)) (string-match "\\S " topic))
......@@ -1065,10 +1102,7 @@ non-nil to force re-caching."
(ding))
)
;; The following allows to call WoMan via the standard Help menu
;; without the need to call it first via the keyboard:
;; Repeated calls of `define-key-after' do not seem to matter!
;; Allow WoMan to be called via the standard Help menu:
(define-key-after menu-bar-manuals-menu [woman]
'(menu-item "Read Man Page (WoMan)..." woman
:help "Man-page documentation Without Man") t)
......@@ -1087,9 +1121,8 @@ Called both to generate and to check the cache!"
(defun woman-read-directory-cache ()
"Load the directory and topic cache.
The cache is loaded from the file named precisely as specified by the
variable `woman-cache-filename'.
Value is t if the file exists, nil otherwise."
It is loaded from the file named by the variable `woman-cache-filename'.
Return t if the file exists, nil otherwise."
(and
woman-cache-filename
(load woman-cache-filename t nil t) ; file exists
......@@ -1097,8 +1130,7 @@ Value is t if the file exists, nil otherwise."
(defun woman-write-directory-cache ()
"Save the directory and topic cache.
The directory and topic cache is written to the file named precisely as
specified by the variable `woman-cache-filename'."
It is saved to the file named by the variable `woman-cache-filename'."
(if woman-cache-filename
(save-excursion ; to restore current buffer
;; Make a temporary buffer; name starting with space "hides" it.
......@@ -1127,11 +1159,10 @@ specified by the variable `woman-cache-filename'."
(defun woman-file-name (topic &optional re-cache)
"Get the name of the UN*X man-page file describing a chosen TOPIC.
When called interactively, the word at point may be used as the topic
or initial topic suggestion, subject to the value of the user option
`woman-topic-at-point'.
Optional argument RE-CACHE, if non-nil, forces the cache to be re-read.
Value is nil if no file can be found."
When `woman' is called interactively, the word at point may be used as
the topic or initial topic suggestion, subject to the value of the
user option `woman-topic-at-point'. Return nil if no file can be found.
Optional argument RE-CACHE, if non-nil, forces the cache to be re-read."
;; Handle the caching of the directory and topic lists:
(if (and (not re-cache)
(or
......@@ -1218,7 +1249,7 @@ Value is nil if no file can be found."
(WoMan-warn "Ignoring unreadable `manpath' directory tree `%s'!" dir)))
(defun woman-directory-files (head dir)
"Return a sorted list of files in directory HEAD matching the regexp in DIR.
"Return a sorted list of files in directory HEAD matching regexp in DIR.
Value is a sorted list of the absolute pathnames of all the files in
directory HEAD, or the current directory if HEAD is nil, that match the
regexp that is the final component of DIR. Log a warning if list is empty."
......@@ -1234,9 +1265,9 @@ regexp that is the final component of DIR. Log a warning if list is empty."
(WoMan-warn "Ignoring inaccessible `man-page' directory `%s'!" dir)))
(defun woman-expand-directory-path (woman-manpath woman-path)
"Expand manual directories in WOMAN-MANPATH and WOMAN-PATH.
WOMAN-MANPATH should be the list of the general manual directories, while
WOMAN-PATH should be the list of specific manual directory regexps.
"Expand the manual directories in WOMAN-MANPATH and WOMAN-PATH.
WOMAN-MANPATH should be a list of general manual directories, while
WOMAN-PATH should be a list of specific manual directory regexps.
Ignore any paths that are unreadable or not directories."
;; Allow each path to be a single string or a list of strings:
(if (not (listp woman-manpath)) (setq woman-manpath (list woman-manpath)))
......@@ -1269,21 +1300,21 @@ Ignore any paths that are unreadable or not directories."
(woman-select 'woman-file-accessible-directory-p dirs)))
(defun woman-canonicalize-dir (dir)
"Canonicalize a directory name DIR.
"Canonicalize the directory name DIR.
Any UN*X-style environment variables are evaluated first."
(setq dir (expand-file-name (substitute-in-file-name dir)))
;; A path that ends with / matches all directories in it,
;; including `.' and `..', so remove any trailing / !!!
(if (string= (substring dir -1) "/")
(setq dir (substring dir 0 -1)))
(if (memq system-type '(windows-nt ms-dos)) ; what else?
(if (memq system-type '(windows-nt ms-dos)) ; what else?
;; Match capitalization used by `file-name-directory':
(setq dir (concat (file-name-directory dir)
(file-name-nondirectory dir))))
dir)
(defsubst woman-not-member (dir path)
"Return true if DIR is not a member of the list PATH.
"Return t if DIR is not a member of the list PATH, nil otherwise.
If DIR is `.' it is first replaced by the current directory."
(not (member dir path)))
......@@ -1315,7 +1346,8 @@ Treats N < 1 as if N = 1."
(defun woman-topic-all-completions-1 (dir path-index)
"Return an alist of the man files in directory DIR with index PATH-INDEX.
The cdr of each alist element is the path-index / filename."
The `cdr' of each alist element is the path-index / filename."
;; *** NEED case-fold-search t HERE ???
(let ((old (directory-files dir nil woman-file-regexp))
new file)
;; Convert list to alist of non-directory files:
......@@ -1338,7 +1370,7 @@ The cdr of each alist element is the path-index / filename."
(defun woman-topic-all-completions-merge (alist)
"Merge the alist ALIST so that the keys are unique.
Also, make each path-info component into a list.
Also make each path-info component into a list.
\(Note that this function changes the value of ALIST.)"
;; Intended to be fast by avoiding recursion and list copying.
(if (> woman-cache-level 1)
......@@ -1487,7 +1519,7 @@ Also, make each path-info component into a list.
"Find, decode and browse a specific UN*X man-page source file FILE-NAME.
Use existing buffer if possible; reformat only if prefix arg given.
When called interactively, optional argument REFORMAT forces reformatting
of existing WoMan buffers formatted earlier.
of an existing WoMan buffer formatted earlier.
No external programs are used, except that `gunzip' will be used to
decompress the file if appropriate. See the documentation for the
`woman' command for further details."
......@@ -1531,12 +1563,19 @@ decompress the file if appropriate. See the documentation for the
(generate-new-buffer-name ; ensure uniqueness
(concat "*WoMan " bufname "*"))))
(defvar woman-frame nil
"Dedicated frame used for displaying WoMan windows.")
(defun woman-really-find-file (filename compressed bufname)
"Find, decompress, and decode a UN*X man page FILENAME.
If COMPRESSED is non-nil, turn on `auto-compression-mode' to