From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.devel Subject: Re: Woman path : adding l10n man pages Date: Mon, 04 Feb 2008 14:58:34 -0500 Message-ID: References: <20071231144731.6993df8e@girafe.maisel.enst-bretagne.fr> <20080108151446.7bcd3769@girafe.maisel.enst-bretagne.fr> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1202155165 10141 80.91.229.12 (4 Feb 2008 19:59:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Feb 2008 19:59:25 +0000 (UTC) Cc: Andreas Schwab , emacs-devel@gnu.org To: frederic.perrin@resel.fr Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 04 20:59:47 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JM7TP-0002Jr-DV for ged-emacs-devel@m.gmane.org; Mon, 04 Feb 2008 20:59:23 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JM7Sx-0004MO-4e for ged-emacs-devel@m.gmane.org; Mon, 04 Feb 2008 14:58:55 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JM7Si-0004Hu-HC for emacs-devel@gnu.org; Mon, 04 Feb 2008 14:58:41 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JM7Sf-0004GN-P3 for emacs-devel@gnu.org; Mon, 04 Feb 2008 14:58:38 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JM7Sf-0004GC-Hi for emacs-devel@gnu.org; Mon, 04 Feb 2008 14:58:37 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JM7Sf-0005h9-2s for emacs-devel@gnu.org; Mon, 04 Feb 2008 14:58:37 -0500 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.67) (envelope-from ) id 1JM7Sc-0005Qh-EG; Mon, 04 Feb 2008 14:58:34 -0500 X-Spook: Steve Case IDEA ASDIC AMW terrorist blackjack e-bomb X-Ran: x\n(xtO*4&/}ip=F=cO`>1Z=zVrN>kKo6s?.,JXU+]`YMYX`}S*z!{.-]6w>6>B\S_rr#L X-Hue: green X-Attribution: GM In-Reply-To: (Andreas Schwab's message of "Tue, 08 Jan 2008 16:38:04 +0100") User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:88178 Archived-At: Andreas Schwab wrote: > LANG can also contain a language alias. There is no requirement that > the first two character have anything to do with the language code. > Moreover, the language should actually be derived from LC_MESSAGES. Please try this patch. I have no idea if `woman-expand-locale' is returning a sensible list of alternatives. Index: mule-cmds.el =================================================================== RCS file: /sources/emacs/emacs/lisp/international/mule-cmds.el,v retrieving revision 1.320 diff -c -c -w -r1.320 mule-cmds.el *** mule-cmds.el 1 Feb 2008 16:01:17 -0000 1.320 --- mule-cmds.el 4 Feb 2008 19:51:39 -0000 *************** *** 2422,2427 **** --- 2422,2440 ---- ;; too, for setting things such as calendar holidays, ps-print paper ;; size, spelling dictionary. + (defun locale-translate (locale) + "Expand LOCALE according to `locale-translation-file-name', if possible. + For example, translate \"swedish\" into \"sv_SE.ISO8859-1\"." + (if locale-translation-file-name + (with-temp-buffer + (set-buffer-multibyte nil) + (insert-file-contents locale-translation-file-name) + (if (re-search-forward + (concat "^" (regexp-quote locale) ":?[ \t]+") nil t) + (buffer-substring (point) (line-end-position)) + locale)) + locale)) + (defun set-locale-environment (&optional locale-name frame) "Set up multi-lingual environment for using LOCALE-NAME. This sets the language environment, the coding system priority, *************** *** 2491,2506 **** (setq locale mac-system-locale)) (when locale ! ! ;; Translate "swedish" into "sv_SE.ISO8859-1", and so on, ! ;; using the translation file that many systems have. ! (when locale-translation-file-name ! (with-temp-buffer ! (set-buffer-multibyte nil) ! (insert-file-contents locale-translation-file-name) ! (when (re-search-forward ! (concat "^" (regexp-quote locale) ":?[ \t]+") nil t) ! (setq locale (buffer-substring (point) (line-end-position)))))) ;; Leave the system locales alone if the caller did not specify ;; an explicit locale name, as their defaults are set from --- 2504,2510 ---- (setq locale mac-system-locale)) (when locale ! (setq locale (locale-translate locale)) ;; Leave the system locales alone if the caller did not specify ;; an explicit locale name, as their defaults are set from *************** *** 2508,2515 **** ;; want to set them to the same value as LC_CTYPE. (when locale-name (setq system-messages-locale locale) ! (setq system-time-locale locale)) (setq locale (downcase locale)) (let ((language-name --- 2512,2527 ---- ;; want to set them to the same value as LC_CTYPE. (when locale-name (setq system-messages-locale locale) ! (setq system-time-locale locale))) ! ! (setq woman-locale ! (or system-messages-locale ! (let ((msglocale (getenv "LC_MESSAGES"))) ! (if (zerop (length msglocale)) ! locale ! (locale-translate msglocale))))) + (when locale (setq locale (downcase locale)) (let ((language-name Index: woman.el =================================================================== RCS file: /sources/emacs/emacs/lisp/woman.el,v retrieving revision 1.67 diff -c -c -w -r1.67 woman.el *** woman.el 12 Jan 2008 23:21:13 -0000 1.67 --- woman.el 4 Feb 2008 19:56:37 -0000 *************** *** 603,610 **** (setq path (cdr path))) (nreverse manpath))) (defcustom woman-manpath ! (or (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 --- 603,661 ---- (setq path (cdr path))) (nreverse manpath))) + ;;;###autoload + (defcustom woman-locale nil + "String specifying a manual page locale, or nil. + If a manual page is available in the specified locale, 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") + + (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 ! ;; Locales could 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