[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emacs-wiki-discuss] Re: sachawiki: 2004.08.25
From: |
Daniel Barral |
Subject: |
[emacs-wiki-discuss] Re: sachawiki: 2004.08.25 |
Date: |
Fri, 27 Aug 2004 03:06:41 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040820 Debian/1.7.2-4 |
Hi, thanks for your reply:
You mean for the dates? That should still be pretty okay. To support
different date formats, I think you'd need to change planner-name-regexp,
planner-today, and planner-expand-name... Did I miss anything?
I redefine planner-name-regexp. I don't allow incomplete dates day and
I still haven't cared about completing
(defcustom planner-name-regexp
(when planner-use-day-pages
(if (eq european-calendar-style nil)
(concat "[0-9][0-9][0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9]#[A-Za-z0-9_%]+"
"\\|[0-9][0-9][0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9]")
"[0-9]\\{2\\}\\.[0-9]\\{2\\}\\.[0-9]\\{4\\}"))
"A regexp used to match planner references in a planning buffer."
:type 'regexp
:set 'planner-option-customized
:group 'planner-emacs-wiki)
Next I modify planner-date-to-filename, which is called by planner-today:
(defun planner-date-to-filename (date)
"Return the planner filename corresponding to DATE.
DATE is a list (month day year), or a list in european style (day
month year) or an internal date representation."
(if (eq european-calendar-style nil)
(progn (if (= (length date) 3)
(format "%04d.%02d.%02d" (elt date 2) (elt date 0) (elt date
1))
(if (= (length date) 2)
(setq date (decode-time date)))
(format "%04d.%02d.%02d" ; year.month.day
(elt date 5)
(elt date 4)
(elt date 3))))
(progn (if (= (length date) 3)
(format "%02d.%02d.%04d" (elt date 0) (elt date 1) (elt date 2))
(if (= (length date) 2)
(setq date (decode-time date)))
(format "%02d.%02d.%04d" ; day.month.year
(elt date 3)
(elt date 4)
(elt date 5))))))
This might become simpler, I still don't know if the list (day month
year) is of any use somewhere.
Test:
(planner-date-to-filename (decode-time (current-time))), ok
I modify planner-filename-to-calendar-date. I don't care about
(day month year).
(defun planner-filename-to-calendar-date (filename)
"Return the date of the planning file FILENAME.
Date is a list (month day year)."
(if (eq european-calendar-style nil)
(progn (list (string-to-number (substring filename 5 7)) ; month
(string-to-number (substring filename 8 10)) ; day
(string-to-number (substring filename 0 4)))) ; year
(progn (list (string-to-number (substring filename 3 5)) ; month
(string-to-number (substring filename 0 2)) ;day
(string-to-number (substring filename 6 10)))))) ; year
Evaluated (planner-filename-to-calendar-date "27.08.2004") as a test, ok
Finish whith the regular expression:
(if (eq european-calendar-style nil)
(progn (defvar planner-date-regexp
"\\`\\([1-9][0-9][0-9][0-9]\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\'"))
(progn (defvar planner-date-regexp
"\\`[0-9]\\{2\\}\\.[0-9]\\{2\\}\\.[0-9]\\{4\\}\\'")))
I'm not familiar with defvar//defcustom issues - ir order for all this
to work (setq european-calendar-style t) has to be placed in .emacs
BEFORE the custom. Maybe I've chosen a weird way of defining these two
regexps.
Q - why do you use defvar for one and defcustom for the other one?)
This is enough for basic usage being careful to introduce complete
day.month.year names, and with most of the gotos, except
planner-get-previous-existing-day and ...-next-..., working ok.
planner-read-date does not care and accepts european dates :-)
I still have to make it work with calendar. I'll let you know
Thanks
Dani