diff options
| author | Glenn Morris | 2008-02-08 20:43:50 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-02-08 20:43:50 +0000 |
| commit | a7e65ac436a0a86742330b0ca3fbe195018ba90f (patch) | |
| tree | 11d9eacf3dca4afd4ca93cec1709f31ccf790a18 | |
| parent | 44ee1bdfe448c47dbf06fe06081cbc0725e0c6af (diff) | |
| download | emacs-a7e65ac436a0a86742330b0ca3fbe195018ba90f.tar.gz emacs-a7e65ac436a0a86742330b0ca3fbe195018ba90f.zip | |
(woman-locale): New defcustom.
(woman-expand-locale, woman-manpath-add-locales): New functions.
(woman-manpath): Call woman-manpath-add-locales. Bump :version.
| -rw-r--r-- | lisp/woman.el | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/lisp/woman.el b/lisp/woman.el index 2ba414aef9c..e46240884f8 100644 --- a/lisp/woman.el +++ b/lisp/woman.el | |||
| @@ -603,8 +603,61 @@ MANPATH_MAP[ \t]+\\(\\S-+\\)[ \t]+\\(\\S-+\\)\\)" nil t) | |||
| 603 | (setq path (cdr path))) | 603 | (setq path (cdr path))) |
| 604 | (nreverse manpath))) | 604 | (nreverse manpath))) |
| 605 | 605 | ||
| 606 | ;; Autoload so set-locale-environment can operate on it. | ||
| 607 | ;;;###autoload | ||
| 608 | (defcustom woman-locale nil | ||
| 609 | "String specifying a manual page locale, or nil. | ||
| 610 | If a manual page is available in the specified locale | ||
| 611 | \(e.g. \"sv_SE.ISO8859-1\"), it will be offered in preference to the | ||
| 612 | default version. Normally, `set-locale-environment' sets this at startup." | ||
| 613 | :type '(choice string (const nil)) | ||
| 614 | :group 'woman-interface | ||
| 615 | :version "23.1") | ||
| 616 | |||
| 617 | ;; FIXME Is this a sensible list of alternatives? | ||
| 618 | (defun woman-expand-locale (locale) | ||
| 619 | "Expand a locale into a list suitable for man page lookup. | ||
| 620 | Expands a locale of the form LANGUAGE_TERRITORY.CHARSET into the list: | ||
| 621 | LANGUAGE_TERRITORY.CHARSET LANGUAGE_TERRITORY LANGUAGE.CHARSET LANGUAGE. | ||
| 622 | The TERRITORY and CHARSET portions may be absent." | ||
| 623 | (string-match "\\([^._]*\\)\\(_[^.]*\\)?\\(\\..*\\)?" locale) | ||
| 624 | (let ((lang (match-string 1 locale)) | ||
| 625 | (terr (match-string 2 locale)) | ||
| 626 | (charset (match-string 3 locale))) | ||
| 627 | (delq nil (list locale | ||
| 628 | (and charset terr (concat lang terr)) | ||
| 629 | (and charset terr (concat lang charset)) | ||
| 630 | (if (or charset terr) lang))))) | ||
| 631 | |||
| 632 | (defun woman-manpath-add-locales (manpath) | ||
| 633 | "Add locale-specific subdirectories to the elements of MANPATH. | ||
| 634 | MANPATH is a list of the form of `woman-manpath'. Returns a list | ||
| 635 | with those locale-specific subdirectories specified by the action | ||
| 636 | of `woman-expand-locale' on `woman-locale' added, where they exist." | ||
| 637 | (if (zerop (length woman-locale)) | ||
| 638 | manpath | ||
| 639 | (let ((subdirs (woman-expand-locale woman-locale)) | ||
| 640 | lst dir) | ||
| 641 | (dolist (elem manpath (nreverse lst)) | ||
| 642 | (dolist (sub subdirs) | ||
| 643 | (when (file-directory-p | ||
| 644 | (setq dir | ||
| 645 | ;; Use f-n-a-d because parse-colon-path does. | ||
| 646 | (file-name-as-directory | ||
| 647 | (expand-file-name sub (substitute-in-file-name | ||
| 648 | (if (consp elem) | ||
| 649 | (cdr elem) | ||
| 650 | elem)))))) | ||
| 651 | (add-to-list 'lst (if (consp elem) | ||
| 652 | (cons (car elem) dir) | ||
| 653 | dir)))) | ||
| 654 | ;; Non-locale-specific has lowest precedence. | ||
| 655 | (add-to-list 'lst elem))))) | ||
| 656 | |||
| 606 | (defcustom woman-manpath | 657 | (defcustom woman-manpath |
| 607 | (or (woman-parse-colon-path (getenv "MANPATH")) | 658 | ;; Locales could also be added in woman-expand-directory-path. |
| 659 | (or (woman-manpath-add-locales | ||
| 660 | (woman-parse-colon-path (getenv "MANPATH"))) | ||
| 608 | '("/usr/man" "/usr/share/man" "/usr/local/man")) | 661 | '("/usr/man" "/usr/share/man" "/usr/local/man")) |
| 609 | "List of DIRECTORY TREES to search for UN*X manual files. | 662 | "List of DIRECTORY TREES to search for UN*X manual files. |
| 610 | Each element should be the name of a directory that contains | 663 | Each element should be the name of a directory that contains |
| @@ -636,6 +689,7 @@ I recommend including drive letters explicitly, e.g. | |||
| 636 | The MANPATH environment variable may be set using DOS semi-colon- | 689 | The MANPATH environment variable may be set using DOS semi-colon- |
| 637 | separated or UN*X/Cygwin colon-separated syntax (but not mixed)." | 690 | separated or UN*X/Cygwin colon-separated syntax (but not mixed)." |
| 638 | :type '(repeat (choice string (cons string string))) | 691 | :type '(repeat (choice string (cons string string))) |
| 692 | :version "23.1" ; added woman-manpath-add-locales | ||
| 639 | :group 'woman-interface) | 693 | :group 'woman-interface) |
| 640 | 694 | ||
| 641 | (defcustom woman-manpath-man-regexp "[Mm][Aa][Nn]" | 695 | (defcustom woman-manpath-man-regexp "[Mm][Aa][Nn]" |