diff options
| author | Eli Zaretskii | 2000-05-24 11:35:22 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2000-05-24 11:35:22 +0000 |
| commit | f471ea57fdae351230ef6a4ff7fed34552543ac8 (patch) | |
| tree | aa3904eaf9834826cedd9a5f71142dcb455a0569 | |
| parent | e0d77f0da27e079942d74c152f58ab4931ac3407 (diff) | |
| download | emacs-f471ea57fdae351230ef6a4ff7fed34552543ac8.tar.gz emacs-f471ea57fdae351230ef6a4ff7fed34552543ac8.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/woman.el | 118 |
2 files changed, 67 insertions, 61 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 83ccca1b2df..e00a6e2a23f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2000-05-24 Eli Zaretskii <eliz@is.elta.co.il> | ||
| 2 | |||
| 3 | * woman.el: New version from Francis J. Wright | ||
| 4 | <F.J.Wright@Maths.QMW.ac.uk>. | ||
| 5 | (woman-parse-colon-path): Support Cygwin-style //d/foo/bar file | ||
| 6 | names in environment variables regardless of the path separator. | ||
| 7 | (woman-topic-all-completions-1): Don't call file-name-directory-p | ||
| 8 | on all files, since woman-file-regexp already filters out any | ||
| 9 | directories. | ||
| 10 | |||
| 1 | 2000-05-24 Kenichi Handa <handa@etl.go.jp> | 11 | 2000-05-24 Kenichi Handa <handa@etl.go.jp> |
| 2 | 12 | ||
| 3 | * international/quail.el (quail-start-translation): Don't change | 13 | * international/quail.el (quail-start-translation): Don't change |
diff --git a/lisp/woman.el b/lisp/woman.el index 1fa337e8527..dd1a37d296e 100644 --- a/lisp/woman.el +++ b/lisp/woman.el | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | ;; Keywords: help, man, UN*X, manual | 7 | ;; Keywords: help, man, UN*X, manual |
| 8 | ;; Adapted-By: Eli Zaretskii <eliz@is.elta.co.il> | 8 | ;; Adapted-By: Eli Zaretskii <eliz@is.elta.co.il> |
| 9 | ;; Version: see `woman-version' | 9 | ;; Version: see `woman-version' |
| 10 | ;; URL: http://centaur.maths.qmw.ac.uk/Emacs/ | 10 | ;; URL: http://centaur.maths.qmw.ac.uk/Emacs/WoMan/ |
| 11 | 11 | ||
| 12 | ;; This file is part of GNU Emacs. | 12 | ;; This file is part of GNU Emacs. |
| 13 | 13 | ||
| @@ -417,6 +417,7 @@ | |||
| 417 | ;; Paul A. Thompson <pat@po.cwru.edu> | 417 | ;; Paul A. Thompson <pat@po.cwru.edu> |
| 418 | ;; Arrigo Triulzi <arrigo@maths.qmw.ac.uk> | 418 | ;; Arrigo Triulzi <arrigo@maths.qmw.ac.uk> |
| 419 | ;; Geoff Voelker <voelker@cs.washington.edu> | 419 | ;; Geoff Voelker <voelker@cs.washington.edu> |
| 420 | ;; Eli Zaretskii <eliz@is.elta.co.il> | ||
| 420 | 421 | ||
| 421 | (defvar woman-version "0.54 (beta)" "WoMan version information.") | 422 | (defvar woman-version "0.54 (beta)" "WoMan version information.") |
| 422 | 423 | ||
| @@ -432,37 +433,35 @@ | |||
| 432 | (require 'apropos)) | 433 | (require 'apropos)) |
| 433 | 434 | ||
| 434 | (defun woman-mapcan (fn x) | 435 | (defun woman-mapcan (fn x) |
| 435 | "Return concatenated list of FN applied to successive CAR elements of X. | 436 | "Return concatenated list of FN applied to successive `car' elements of X. |
| 436 | FN must return a list, cons or nil. Useful for splicing into a list." | 437 | FN must return a list, cons or nil. Useful for splicing into a list." |
| 437 | ;; Based on the Standard Lisp function MAPCAN but with args swapped! | 438 | ;; Based on the Standard Lisp function MAPCAN but with args swapped! |
| 438 | (and x (nconc (funcall fn (car x)) (woman-mapcan fn (cdr x))))) | 439 | (and x (nconc (funcall fn (car x)) (woman-mapcan fn (cdr x))))) |
| 439 | 440 | ||
| 440 | (defun woman-parse-colon-path (cd-path) | 441 | (defun woman-parse-colon-path (cd-path) |
| 441 | "Explode a search path CD-PATH into a list of directory names. | 442 | "Explode a search path CD-PATH into a list of directory names. |
| 442 | If the platform is Microsoft Windows and no path contains `\\' then | 443 | Replace null components by calling `woman-parse-man.conf'. |
| 443 | assume a Cygwin-style colon-separated search path and convert any | 444 | Allow UN*X-style search paths on Microsoft platforms, i.e. allow path |
| 444 | leading drive specifier `//X/' to `X:', otherwise assume paths | 445 | elements to be separated by colons and convert Cygwin-style drive |
| 445 | separated by `path-separator'." | 446 | specifiers `//x/' to `x:'." |
| 446 | ;; Based on a suggestion by Jari Aalto. | 447 | ;; Based on suggestions by Jari Aalto and Eli Zaretskii. |
| 447 | (woman-mapcan ; splice into list... | 448 | (mapcar |
| 448 | (lambda (path) | 449 | (lambda (path) ; //a/b -> a:/b |
| 449 | ;; parse-colon-path returns nil for a null path component and | 450 | (when (and path (string-match "\\`//./" path)) |
| 450 | ;; an empty substring of MANPATH denotes the default list... | 451 | (setq path (substring path 1)) ; //a/b -> /a/b |
| 451 | (if path (cons path nil) (woman-parse-man.conf))) | 452 | (aset path 0 (aref path 1)) ; /a/b -> aa/b |
| 452 | (if (and (memq system-type '(windows-nt ms-dos)) | 453 | (aset path 1 ?:)) ; aa/b -> a:/b |
| 453 | (not (or (string-match ";" cd-path) | 454 | path) |
| 454 | (string-match "\\\\" cd-path)))) | 455 | (woman-mapcan ; splice into list... |
| 455 | (let ((path-separator ":")) | 456 | (lambda (path) |
| 456 | (mapcar | 457 | ;; parse-colon-path returns nil for a null path component and |
| 457 | (lambda (path) ; //a/b -> a:/b | 458 | ;; an empty substring of MANPATH denotes the default list... |
| 458 | (cond ((and path (string-match "\\`//./" path)) | 459 | (if path (list path) (woman-parse-man.conf))) |
| 459 | (setq path (substring path 1)) ; //a/b -> /a/b | 460 | (if (and (memq system-type '(windows-nt ms-dos)) |
| 460 | (aset path 0 (aref path 1)) ; /a/b -> aa/b | 461 | (not (string-match ";" cd-path))) |
| 461 | (aset path 1 ?:) ; aa/b -> a:/b | 462 | (let ((path-separator ":")) |
| 462 | )) | 463 | (parse-colon-path cd-path)) |
| 463 | path) | 464 | (parse-colon-path cd-path))))) |
| 464 | (parse-colon-path cd-path))) | ||
| 465 | (parse-colon-path cd-path)))) | ||
| 466 | 465 | ||
| 467 | 466 | ||
| 468 | ;;; User options: | 467 | ;;; User options: |
| @@ -513,9 +512,11 @@ instead to provide a default value for `woman-manpath'." | |||
| 513 | :group 'woman-interface) | 512 | :group 'woman-interface) |
| 514 | 513 | ||
| 515 | (defun woman-parse-man.conf () | 514 | (defun woman-parse-man.conf () |
| 516 | "Parse man config file if found. (Used only if MANPATH is not set.) | 515 | "Parse if possible Linux-style configuration file for man command. |
| 516 | Used only if MANPATH is not set or contains null components. | ||
| 517 | Look in `woman-man.conf-path' and return a value for `woman-manpath'. | 517 | Look in `woman-man.conf-path' and return a value for `woman-manpath'. |
| 518 | Concatenate data from all lines in the config file of the form | 518 | Concatenate data from all lines in the config file of the form |
| 519 | |||
| 519 | MANPATH /usr/man" | 520 | MANPATH /usr/man" |
| 520 | ;; Functionality suggested by Charles Curley. | 521 | ;; Functionality suggested by Charles Curley. |
| 521 | (let ((path woman-man.conf-path) | 522 | (let ((path woman-man.conf-path) |
| @@ -752,9 +753,9 @@ Should begin with \\. and end with \\' and MUST NOT be optional." | |||
| 752 | :set 'set-woman-file-regexp | 753 | :set 'set-woman-file-regexp |
| 753 | :group 'woman-interface) | 754 | :group 'woman-interface) |
| 754 | 755 | ||
| 755 | (defcustom woman-use-own-frame | 756 | (defcustom woman-use-own-frame ; window-system |
| 756 | (or (and (fboundp 'display-graphic-p) (display-graphic-p)) | 757 | (or (and (fboundp 'display-graphic-p) (display-graphic-p)) ; Emacs 21 |
| 757 | (memq window-system '(x w32))) | 758 | (memq window-system '(x w32))) ; Emacs 20 |
| 758 | "*If non-nil then use a dedicated frame for displaying WoMan windows. | 759 | "*If non-nil then use a dedicated frame for displaying WoMan windows. |
| 759 | Only useful when run on a graphic display such as X or MS-Windows." | 760 | Only useful when run on a graphic display such as X or MS-Windows." |
| 760 | :type 'boolean | 761 | :type 'boolean |
| @@ -876,7 +877,7 @@ Default: foreground orange." | |||
| 876 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 877 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 877 | ;; Experimental font support, initially only for MS-Windows. | 878 | ;; Experimental font support, initially only for MS-Windows. |
| 878 | (defconst woman-font-support | 879 | (defconst woman-font-support |
| 879 | (eq window-system 'w32) ; Support X later! | 880 | (eq window-system 'w32) ; Support X later! |
| 880 | "If non-nil then non-ASCII characters and symbol font supported.") | 881 | "If non-nil then non-ASCII characters and symbol font supported.") |
| 881 | 882 | ||
| 882 | (defun woman-select-symbol-fonts (fonts) | 883 | (defun woman-select-symbol-fonts (fonts) |
| @@ -1337,36 +1338,30 @@ The cdr of each alist element is the path-index / filename." | |||
| 1337 | ;; Uniquefy topics: | 1338 | ;; Uniquefy topics: |
| 1338 | (woman-topic-all-completions-merge files))) | 1339 | (woman-topic-all-completions-merge files))) |
| 1339 | 1340 | ||
| 1340 | (defsubst woman-list-n (n &rest args) | ||
| 1341 | "Return a list of at most the first N of the arguments ARGS. | ||
| 1342 | Treats N < 1 as if N = 1." | ||
| 1343 | (if (< n (length args)) | ||
| 1344 | (setcdr (nthcdr (1- n) args) nil)) | ||
| 1345 | args) | ||
| 1346 | |||
| 1347 | (defun woman-topic-all-completions-1 (dir path-index) | 1341 | (defun woman-topic-all-completions-1 (dir path-index) |
| 1348 | "Return an alist of the man files in directory DIR with index PATH-INDEX. | 1342 | "Return an alist of the man topics in directory DIR with index PATH-INDEX. |
| 1349 | The `cdr' of each alist element is the path-index / filename." | 1343 | A topic is a filename sans type-related extensions. |
| 1350 | ;; *** NEED case-fold-search t HERE ??? | 1344 | Support 3 levels of caching: each element of the alist will be a list |
| 1351 | (let ((old (directory-files dir nil woman-file-regexp)) | 1345 | of the first `woman-cache-level' elements from the following list: |
| 1352 | new file) | 1346 | \(topic path-index filename)." |
| 1353 | ;; Convert list to alist of non-directory files: | 1347 | ;; This function used to check that each file in the directory was |
| 1354 | (while old | 1348 | ;; not itself a directory, but this is very slow and should be |
| 1355 | (setq file (car old) | 1349 | ;; unnecessary. So let us assume that `woman-file-regexp' will |
| 1356 | old (cdr old)) | 1350 | ;; filter out any directories, which probably should not be there |
| 1357 | (if (file-directory-p file) | 1351 | ;; anyway, i.e. it is a user error! |
| 1358 | () | 1352 | (mapcar |
| 1359 | (setq new (cons | 1353 | (lambda (file) |
| 1360 | (woman-list-n | 1354 | (cons |
| 1361 | woman-cache-level | 1355 | (file-name-sans-extension |
| 1362 | (file-name-sans-extension | 1356 | (if (string-match woman-file-compression-regexp file) |
| 1363 | (if (string-match woman-file-compression-regexp file) | 1357 | (file-name-sans-extension file) |
| 1364 | (file-name-sans-extension file) | 1358 | file)) |
| 1365 | file)) | 1359 | (if (> woman-cache-level 1) |
| 1366 | path-index | 1360 | (cons |
| 1367 | file) | 1361 | path-index |
| 1368 | new)))) | 1362 | (if (> woman-cache-level 2) |
| 1369 | new)) | 1363 | (cons file nil)))))) |
| 1364 | (directory-files dir nil woman-file-regexp))) | ||
| 1370 | 1365 | ||
| 1371 | (defun woman-topic-all-completions-merge (alist) | 1366 | (defun woman-topic-all-completions-merge (alist) |
| 1372 | "Merge the alist ALIST so that the keys are unique. | 1367 | "Merge the alist ALIST so that the keys are unique. |
| @@ -1446,7 +1441,7 @@ Also make each path-info component into a list. | |||
| 1446 | (mapcar 'list files) | 1441 | (mapcar 'list files) |
| 1447 | )) | 1442 | )) |
| 1448 | 1443 | ||
| 1449 | 1444 | ||
| 1450 | ;;; dired support | 1445 | ;;; dired support |
| 1451 | 1446 | ||
| 1452 | (defun woman-dired-define-key (key) | 1447 | (defun woman-dired-define-key (key) |
| @@ -4477,5 +4472,6 @@ logging the message." | |||
| 4477 | ;; Comment order and doc strings changed substantially. | 4472 | ;; Comment order and doc strings changed substantially. |
| 4478 | ;; MS-DOS support added (by Eli Zaretskii). | 4473 | ;; MS-DOS support added (by Eli Zaretskii). |
| 4479 | ;; checkdoc run: no real errors. | 4474 | ;; checkdoc run: no real errors. |
| 4475 | ;; woman topic interface speeded up. | ||
| 4480 | 4476 | ||
| 4481 | ;;; woman.el ends here | 4477 | ;;; woman.el ends here |