From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Roehler Newsgroups: gmane.emacs.devel Subject: Re: calendar m17n Date: Sat, 16 Sep 2006 09:21:20 +0200 Message-ID: <450BA5F0.4050804@easy-emacs.de> References: <45090552.3030606@easy-emacs.de> <4509A5DC.50607@easy-emacs.de> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1158391001 27807 80.91.229.2 (16 Sep 2006 07:16:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 16 Sep 2006 07:16:41 +0000 (UTC) Cc: Glenn Morris , emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 16 09:16:38 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GOUPm-000060-25 for ged-emacs-devel@m.gmane.org; Sat, 16 Sep 2006 09:16:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GOUPl-000291-9d for ged-emacs-devel@m.gmane.org; Sat, 16 Sep 2006 03:16:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GOUPW-00023n-Rg for emacs-devel@gnu.org; Sat, 16 Sep 2006 03:16:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GOUPV-00020f-5K for emacs-devel@gnu.org; Sat, 16 Sep 2006 03:16:21 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GOUPU-00020W-Vv for emacs-devel@gnu.org; Sat, 16 Sep 2006 03:16:21 -0400 Original-Received: from [212.227.126.187] (helo=moutng.kundenserver.de) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GOURo-0007un-UJ; Sat, 16 Sep 2006 03:18:45 -0400 Original-Received: from [84.190.148.247] (helo=[192.168.178.23]) by mrelayeu.kundenserver.de (node=mrelayeu4) with ESMTP (Nemesis), id 0ML21M-1GOUPP3mf7-0002oS; Sat, 16 Sep 2006 09:16:16 +0200 User-Agent: Thunderbird 1.5.0.4 (X11/20060516) Original-To: Kevin Rodgers In-Reply-To: X-Provags-ID: kundenserver.de abuse@kundenserver.de login:62d13292e0fce6aaed56aaadcb96352d 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:59902 Archived-At: Kevin Rodgers schrieb: > Andreas Roehler wrote: >> Thanks all for your useful hints. Here an already working draft: >> >> ;; (defcustom calendar-use-locales nil >> ;; "Use local names of day and month" >> >> ;; :type 'boolean >> ;; :group 'calendar) >> >> >> (setq calendar-use-locales t) >> >> (defun calendar-use-locales-function () >> " " >> (interactive) >> (when calendar-use-locales >> (progn >> (setq calendar-day-name-array (locale-info 'days)) >> (setq calendar-month-name-array (locale-info 'months))))) >> ;; with $LANG=de_DE.UTF-8 >> >> GNU Emacs 22.0.50.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) >> of 2006-09-11 >> >> Would be nice to hear from users with different languages. > > locale-info returns nil on: > > GNU Emacs 22.0.50.1 (i386-mingw-nt5.1.2600) of 2006-04-22 on YAMALOK > > so maybe the default value of calendar-use-locales should depend on > system-type, or you should just get rid of it: > > (let ((days (locale-info 'days)) > (months (locale-info 'months))) > (when days > (setq calendar-day-name-array days)) > (when months > (setq calendar-month-name-array months))) > > And since format-time-string's doc string claims that it takes the > locale into account, you could use it to provide the values when > locale-info can't: > > (let ((days (locale-info 'days)) > (months (locale-info 'months))) > (if days > (setq calendar-day-name-array days) > (let ((this-year > (string-to-number (format-time-string "%Y"))) > (this-month > (string-to-number (format-time-string "%m")))) > (setq calendar-day-name-array > (apply 'vector > (mapcar (lambda (time) > (format-time-string "%A" time)) > (sort (mapcar (lambda (day) > (encode-time 0 0 0 day > this-month this-year > 0)) > '(1 2 3 4 5 6 7)) > ;; by day of week: > (lambda (time-1 time-2) > (< (nth 6 (decode-time time-1)) > (nth 6 (decode-time time-2)))))))))) > (if months > (setq calendar-month-name-array months) > (let ((this-year > (string-to-number (format-time-string "%Y")))) > (setq calendar-month-name-array > (apply 'vector > (mapcar (lambda (month) > (let ((first (encode-time 0 0 0 1 month > this-year > 0))) > (format-time-string "%B" first t))) > '(1 2 3 4 5 6 7 8 9 10 11 12))))))) > > Is there any reason not to roll that directly into each variable's > defcustom in calendar.el, where the default values are defined? > And note that "%a" and "%b" can be used the same way to initialize > calendar-day-abbrev-array and calendar-month-abbrev-array, resp. > OK, thanks! Last question I would leave to the maintainer. Here the combined results so far: (defcustom calendar-use-locales nil "Use local names of day and month" :type 'boolean :group 'calendar) ;; Sometimes `defcustom' doesn't take effect immediatitly ;; (setq calendar-use-locales t) (defun calendar-use-locales-function () " " (interactive) (when calendar-use-locales (progn (let ((days (locale-info 'days)) (months (locale-info 'months))) (if days (setq calendar-day-name-array days) (let ((this-year (string-to-number (format-time-string "%Y"))) (this-month (string-to-number (format-time-string "%m")))) (setq calendar-day-name-array (apply 'vector (mapcar (lambda (time) (format-time-string "%A" time)) (sort (mapcar (lambda (day) (encode-time 0 0 0 day this-month this-year 0)) '(1 2 3 4 5 6 7)) ;; by day of week: (lambda (time-1 time-2) (< (nth 6 (decode-time time-1)) (nth 6 (decode-time time-2)))))))))) (if months (setq calendar-month-name-array months) (let ((this-year (string-to-number (format-time-string "%Y")))) (setq calendar-month-name-array (apply 'vector (mapcar (lambda (month) (let ((first (encode-time 0 0 0 1 month this-year 0))) (format-time-string "%B" first t))) '(1 2 3 4 5 6 7 8 9 10 11 12))))))))))