Commit f471ea57 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

New version from Francis J. Wright <F.J.Wright@Maths.QMW.ac.uk>:

(woman-parse-colon-path): Support Cygwin-style //d/foo/bar file
names in environment variables regardless of the path separator.
(woman-topic-all-completions-1): Don't call file-name-directory-p
on all files, since woman-file-regexp already filters out any
directories.
parent e0d77f0d
2000-05-24 Eli Zaretskii <eliz@is.elta.co.il>
* woman.el: New version from Francis J. Wright
<F.J.Wright@Maths.QMW.ac.uk>.
(woman-parse-colon-path): Support Cygwin-style //d/foo/bar file
names in environment variables regardless of the path separator.
(woman-topic-all-completions-1): Don't call file-name-directory-p
on all files, since woman-file-regexp already filters out any
directories.
2000-05-24 Kenichi Handa <handa@etl.go.jp> 2000-05-24 Kenichi Handa <handa@etl.go.jp>
* international/quail.el (quail-start-translation): Don't change * international/quail.el (quail-start-translation): Don't change
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
;; Keywords: help, man, UN*X, manual ;; Keywords: help, man, UN*X, manual
;; Adapted-By: Eli Zaretskii <eliz@is.elta.co.il> ;; Adapted-By: Eli Zaretskii <eliz@is.elta.co.il>
;; Version: see `woman-version' ;; Version: see `woman-version'
;; URL: http://centaur.maths.qmw.ac.uk/Emacs/ ;; URL: http://centaur.maths.qmw.ac.uk/Emacs/WoMan/
;; This file is part of GNU Emacs. ;; This file is part of GNU Emacs.
...@@ -417,6 +417,7 @@ ...@@ -417,6 +417,7 @@
;; Paul A. Thompson <pat@po.cwru.edu> ;; Paul A. Thompson <pat@po.cwru.edu>
;; Arrigo Triulzi <arrigo@maths.qmw.ac.uk> ;; Arrigo Triulzi <arrigo@maths.qmw.ac.uk>
;; Geoff Voelker <voelker@cs.washington.edu> ;; Geoff Voelker <voelker@cs.washington.edu>
;; Eli Zaretskii <eliz@is.elta.co.il>
(defvar woman-version "0.54 (beta)" "WoMan version information.") (defvar woman-version "0.54 (beta)" "WoMan version information.")
...@@ -432,37 +433,35 @@ ...@@ -432,37 +433,35 @@
(require 'apropos)) (require 'apropos))
(defun woman-mapcan (fn x) (defun woman-mapcan (fn x)
"Return concatenated list of FN applied to successive CAR elements of 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." 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! ;; Based on the Standard Lisp function MAPCAN but with args swapped!
(and x (nconc (funcall fn (car x)) (woman-mapcan fn (cdr x))))) (and x (nconc (funcall fn (car x)) (woman-mapcan fn (cdr x)))))
(defun woman-parse-colon-path (cd-path) (defun woman-parse-colon-path (cd-path)
"Explode a search path CD-PATH into a list of directory names. "Explode a search path CD-PATH into a list of directory names.
If the platform is Microsoft Windows and no path contains `\\' then Replace null components by calling `woman-parse-man.conf'.
assume a Cygwin-style colon-separated search path and convert any Allow UN*X-style search paths on Microsoft platforms, i.e. allow path
leading drive specifier `//X/' to `X:', otherwise assume paths elements to be separated by colons and convert Cygwin-style drive
separated by `path-separator'." specifiers `//x/' to `x:'."
;; Based on a suggestion by Jari Aalto. ;; Based on suggestions by Jari Aalto and Eli Zaretskii.
(woman-mapcan ; splice into list... (mapcar
(lambda (path) (lambda (path) ; //a/b -> a:/b
;; parse-colon-path returns nil for a null path component and (when (and path (string-match "\\`//./" path))
;; an empty substring of MANPATH denotes the default list... (setq path (substring path 1)) ; //a/b -> /a/b
(if path (cons path nil) (woman-parse-man.conf))) (aset path 0 (aref path 1)) ; /a/b -> aa/b
(if (and (memq system-type '(windows-nt ms-dos)) (aset path 1 ?:)) ; aa/b -> a:/b
(not (or (string-match ";" cd-path) path)
(string-match "\\\\" cd-path)))) (woman-mapcan ; splice into list...
(let ((path-separator ":")) (lambda (path)
(mapcar ;; parse-colon-path returns nil for a null path component and
(lambda (path) ; //a/b -> a:/b ;; an empty substring of MANPATH denotes the default list...
(cond ((and path (string-match "\\`//./" path)) (if path (list path) (woman-parse-man.conf)))
(setq path (substring path 1)) ; //a/b -> /a/b (if (and (memq system-type '(windows-nt ms-dos))
(aset path 0 (aref path 1)) ; /a/b -> aa/b (not (string-match ";" cd-path)))
(aset path 1 ?:) ; aa/b -> a:/b (let ((path-separator ":"))
)) (parse-colon-path cd-path))
path) (parse-colon-path cd-path)))))
(parse-colon-path cd-path)))
(parse-colon-path cd-path))))
;;; User options: ;;; User options:
...@@ -513,9 +512,11 @@ instead to provide a default value for `woman-manpath'." ...@@ -513,9 +512,11 @@ instead to provide a default value for `woman-manpath'."
:group 'woman-interface) :group 'woman-interface)
(defun woman-parse-man.conf () (defun woman-parse-man.conf ()
"Parse man config file if found. (Used only if MANPATH is not set.) "Parse if possible Linux-style configuration file for man command.
Used only if MANPATH is not set or contains null components.
Look in `woman-man.conf-path' and return a value for `woman-manpath'. 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 Concatenate data from all lines in the config file of the form
MANPATH /usr/man" MANPATH /usr/man"
;; Functionality suggested by Charles Curley. ;; Functionality suggested by Charles Curley.
(let ((path woman-man.conf-path) (let ((path woman-man.conf-path)
...@@ -752,9 +753,9 @@ Should begin with \\. and end with \\' and MUST NOT be optional." ...@@ -752,9 +753,9 @@ Should begin with \\. and end with \\' and MUST NOT be optional."
:set 'set-woman-file-regexp :set 'set-woman-file-regexp
:group 'woman-interface) :group 'woman-interface)
(defcustom woman-use-own-frame (defcustom woman-use-own-frame ; window-system
(or (and (fboundp 'display-graphic-p) (display-graphic-p)) (or (and (fboundp 'display-graphic-p) (display-graphic-p)) ; Emacs 21
(memq window-system '(x w32))) (memq window-system '(x w32))) ; Emacs 20
"*If non-nil then use a dedicated frame for displaying WoMan windows. "*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." Only useful when run on a graphic display such as X or MS-Windows."
:type 'boolean :type 'boolean
...@@ -876,7 +877,7 @@ Default: foreground orange." ...@@ -876,7 +877,7 @@ Default: foreground orange."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Experimental font support, initially only for MS-Windows. ;; Experimental font support, initially only for MS-Windows.
(defconst woman-font-support (defconst woman-font-support
(eq window-system 'w32) ; Support X later! (eq window-system 'w32) ; Support X later!
"If non-nil then non-ASCII characters and symbol font supported.") "If non-nil then non-ASCII characters and symbol font supported.")
(defun woman-select-symbol-fonts (fonts) (defun woman-select-symbol-fonts (fonts)
...@@ -1337,36 +1338,30 @@ The cdr of each alist element is the path-index / filename." ...@@ -1337,36 +1338,30 @@ The cdr of each alist element is the path-index / filename."
;; Uniquefy topics: ;; Uniquefy topics:
(woman-topic-all-completions-merge files))) (woman-topic-all-completions-merge files)))
(defsubst woman-list-n (n &rest args)
"Return a list of at most the first N of the arguments ARGS.
Treats N < 1 as if N = 1."
(if (< n (length args))
(setcdr (nthcdr (1- n) args) nil))
args)
(defun woman-topic-all-completions-1 (dir path-index) (defun woman-topic-all-completions-1 (dir path-index)
"Return an alist of the man files in directory DIR with index PATH-INDEX. "Return an alist of the man topics in directory DIR with index PATH-INDEX.
The `cdr' of each alist element is the path-index / filename." A topic is a filename sans type-related extensions.
;; *** NEED case-fold-search t HERE ??? Support 3 levels of caching: each element of the alist will be a list
(let ((old (directory-files dir nil woman-file-regexp)) of the first `woman-cache-level' elements from the following list:
new file) \(topic path-index filename)."
;; Convert list to alist of non-directory files: ;; This function used to check that each file in the directory was
(while old ;; not itself a directory, but this is very slow and should be
(setq file (car old) ;; unnecessary. So let us assume that `woman-file-regexp' will
old (cdr old)) ;; filter out any directories, which probably should not be there
(if (file-directory-p file) ;; anyway, i.e. it is a user error!
() (mapcar
(setq new (cons (lambda (file)
(woman-list-n (cons
woman-cache-level (file-name-sans-extension
(file-name-sans-extension (if (string-match woman-file-compression-regexp file)
(if (string-match woman-file-compression-regexp file) (file-name-sans-extension file)
(file-name-sans-extension file) file))
file)) (if (> woman-cache-level 1)
path-index (cons
file) path-index
new)))) (if (> woman-cache-level 2)
new)) (cons file nil))))))
(directory-files dir nil woman-file-regexp)))
(defun woman-topic-all-completions-merge (alist) (defun woman-topic-all-completions-merge (alist)
"Merge the alist ALIST so that the keys are unique. "Merge the alist ALIST so that the keys are unique.
...@@ -1446,7 +1441,7 @@ Also make each path-info component into a list. ...@@ -1446,7 +1441,7 @@ Also make each path-info component into a list.
(mapcar 'list files) (mapcar 'list files)
)) ))
;;; dired support ;;; dired support
(defun woman-dired-define-key (key) (defun woman-dired-define-key (key)
...@@ -4477,5 +4472,6 @@ logging the message." ...@@ -4477,5 +4472,6 @@ logging the message."
;; Comment order and doc strings changed substantially. ;; Comment order and doc strings changed substantially.
;; MS-DOS support added (by Eli Zaretskii). ;; MS-DOS support added (by Eli Zaretskii).
;; checkdoc run: no real errors. ;; checkdoc run: no real errors.
;; woman topic interface speeded up.
;;; woman.el ends here ;;; woman.el ends here
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