From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lawrence Mitchell Newsgroups: gmane.emacs.devel Subject: Re: calendar problem: week number Date: Thu, 07 Aug 2008 12:40:40 +0100 Organization: funfunfun Message-ID: References: <20080807.111511.144819219.wl@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1218109275 19533 80.91.229.12 (7 Aug 2008 11:41:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Aug 2008 11:41:15 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 07 13:42:01 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 1KR3sW-0007Qj-JK for ged-emacs-devel@m.gmane.org; Thu, 07 Aug 2008 13:42:00 +0200 Original-Received: from localhost ([127.0.0.1]:43210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KR3rb-0004eB-7J for ged-emacs-devel@m.gmane.org; Thu, 07 Aug 2008 07:41:03 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KR3rW-0004Zw-5s for emacs-devel@gnu.org; Thu, 07 Aug 2008 07:40:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KR3rU-0004WD-LK for emacs-devel@gnu.org; Thu, 07 Aug 2008 07:40:57 -0400 Original-Received: from [199.232.76.173] (port=37321 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KR3rU-0004Vq-DR for emacs-devel@gnu.org; Thu, 07 Aug 2008 07:40:56 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:34911 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KR3rT-0002qW-UN for emacs-devel@gnu.org; Thu, 07 Aug 2008 07:40:56 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KR3rO-000823-TN for emacs-devel@gnu.org; Thu, 07 Aug 2008 11:40:50 +0000 Original-Received: from lamacq.ph.ed.ac.uk ([129.215.72.156]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 07 Aug 2008 11:40:50 +0000 Original-Received: from wence by lamacq.ph.ed.ac.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 07 Aug 2008 11:40:50 +0000 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 59 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: lamacq.ph.ed.ac.uk Mail-Copies-To: nobody User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:4MiwOc8D3Xd1vXvjsOWnbKDr5Ec= 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:102155 Archived-At: Werner LEMBERG wrote: > Companies in German are used to refer to the `Kalenderwoche' (the > current number of the week counted from the beginning of the year). > For example, this week is the 32nd week. Can I configure `calendar' > to make it display, eg., like in the attached image? I haven't found > a hint in the info file. The following patch seems to do the right thing, although it only works correctly if calendar-week-start-day is 1 (monday). I don't think it breaks any of the movement commands. Cheers, Lawrence diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el index dc2f8ce..9989b22 100644 --- a/lisp/calendar/calendar.el +++ b/lisp/calendar/calendar.el @@ -1409,7 +1409,13 @@ line." (substring string 0 calendar-day-header-width))) (make-string (- calendar-column-width calendar-day-header-width) ?\s))) (calendar-ensure-newline) - (calendar-insert-at-column indent calendar-intermonth-text trunc) + (calendar-insert-at-column (- indent 3) calendar-intermonth-text trunc) + (insert (propertize (format "%2d " (car (calendar-iso-from-absolute + (calendar-dayname-on-or-before + 1 (calendar-absolute-from-gregorian + (list month 1 + year)))))) + 'font-lock-face 'font-lock-comment-face)) ;; Add blank days before the first of the month. (insert (make-string (* blank-days calendar-column-width) ?\s)) ;; Put in the days of the month. @@ -1429,7 +1435,18 @@ line." (/= day last)) (calendar-ensure-newline) (setq day (1+ day)) ; first day of next week - (calendar-insert-at-column indent calendar-intermonth-text trunc))))) + (calendar-insert-at-column (- indent 3) calendar-intermonth-text trunc) + (insert (propertize + (format "%2d " (car (calendar-iso-from-absolute + (calendar-dayname-on-or-before + 1 + (calendar-absolute-from-gregorian + (list month + (+ i + (- 7 + calendar-week-start-day)) + year)))))) + 'font-lock-face 'font-lock-comment-face)))))) (defun calendar-redraw () "Redraw the calendar display, if `calendar-buffer' is live." -- Lawrence Mitchell