all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lawrence Mitchell <wence@gmx.li>
To: emacs-devel@gnu.org
Subject: Re: calendar problem: week number
Date: Thu, 07 Aug 2008 12:40:40 +0100	[thread overview]
Message-ID: <?fnord?y3h6zlnp129z.fsf@ID-97657.user.individual.net> (raw)
In-Reply-To: 20080807.111511.144819219.wl@gnu.org

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 <wence@gmx.li>





  parent reply	other threads:[~2008-08-07 11:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-07  9:15 calendar problem: week number Werner LEMBERG
2008-08-07  9:38 ` Tassilo Horn
2008-08-07 14:49   ` Ed Reingold
2008-08-08 14:43   ` Werner LEMBERG
2008-08-08 14:54     ` Werner LEMBERG
2008-08-08 15:17     ` Lawrence Mitchell
2008-08-07 10:03 ` tomas
2008-08-07 10:34   ` Werner LEMBERG
2008-08-07 11:40 ` Lawrence Mitchell [this message]
2008-08-07 11:58   ` Ed Reingold
2008-08-07 12:59     ` Lawrence Mitchell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='?fnord?y3h6zlnp129z.fsf@ID-97657.user.individual.net' \
    --to=wence@gmx.li \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.