emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/woman.el,v


From: Glenn Morris
Subject: [Emacs-diffs] Changes to emacs/lisp/woman.el,v
Date: Fri, 08 Feb 2008 20:43:51 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Glenn Morris <gm>       08/02/08 20:43:51

Index: woman.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/woman.el,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- woman.el    12 Jan 2008 23:21:13 -0000      1.67
+++ woman.el    8 Feb 2008 20:43:50 -0000       1.68
@@ -603,8 +603,61 @@
       (setq path (cdr path)))
     (nreverse manpath)))
 
+;; Autoload so set-locale-environment can operate on it.
+;;;###autoload
+(defcustom woman-locale nil
+  "String specifying a manual page locale, or nil.
+If a manual page is available in the specified locale
+\(e.g. \"sv_SE.ISO8859-1\"), it will be offered in preference to the
+default version.  Normally, `set-locale-environment' sets this at startup."
+  :type '(choice string (const nil))
+  :group 'woman-interface
+  :version "23.1")
+
+;; FIXME Is this a sensible list of alternatives?
+(defun woman-expand-locale (locale)
+  "Expand a locale into a list suitable for man page lookup.
+Expands a locale of the form LANGUAGE_TERRITORY.CHARSET into the list:
+LANGUAGE_TERRITORY.CHARSET LANGUAGE_TERRITORY LANGUAGE.CHARSET LANGUAGE.
+The TERRITORY and CHARSET portions may be absent."
+  (string-match "\\([^._]*\\)\\(_[^.]*\\)?\\(\\..*\\)?" locale)
+  (let ((lang (match-string 1 locale))
+        (terr (match-string 2 locale))
+        (charset (match-string 3 locale)))
+    (delq nil (list locale
+                    (and charset terr (concat lang terr))
+                    (and charset terr (concat lang charset))
+                    (if (or charset terr) lang)))))
+
+(defun woman-manpath-add-locales (manpath)
+  "Add locale-specific subdirectories to the elements of MANPATH.
+MANPATH is a list of the form of `woman-manpath'.  Returns a list
+with those locale-specific subdirectories specified by the action
+of `woman-expand-locale' on `woman-locale' added, where they exist."
+  (if (zerop (length woman-locale))
+      manpath
+    (let ((subdirs (woman-expand-locale woman-locale))
+          lst dir)
+      (dolist (elem manpath (nreverse lst))
+        (dolist (sub subdirs)
+          (when (file-directory-p
+                 (setq dir
+                       ;; Use f-n-a-d because parse-colon-path does.
+                       (file-name-as-directory
+                        (expand-file-name sub (substitute-in-file-name
+                                               (if (consp elem)
+                                                   (cdr elem)
+                                                 elem))))))
+            (add-to-list 'lst (if (consp elem)
+                                  (cons (car elem) dir)
+                                dir))))
+        ;; Non-locale-specific has lowest precedence.
+        (add-to-list 'lst elem)))))
+
 (defcustom woman-manpath
-  (or (woman-parse-colon-path (getenv "MANPATH"))
+  ;; Locales could also be added in woman-expand-directory-path.
+  (or (woman-manpath-add-locales
+       (woman-parse-colon-path (getenv "MANPATH")))
       '("/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
@@ -636,6 +689,7 @@
 The MANPATH environment variable may be set using DOS semi-colon-
 separated or UN*X/Cygwin colon-separated syntax (but not mixed)."
   :type '(repeat (choice string (cons string string)))
+  :version "23.1"                    ; added woman-manpath-add-locales
   :group 'woman-interface)
 
 (defcustom woman-manpath-man-regexp "[Mm][Aa][Nn]"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]