* [PATCH]add a custom function to get date string in agenda
@ 2007-09-12 3:08 Levin
2007-09-12 21:17 ` Carsten Dominik
0 siblings, 1 reply; 3+ messages in thread
From: Levin @ 2007-09-12 3:08 UTC (permalink / raw)
To: emacs-orgmode
I have a special need of customizing date string in agenda (the date format
string is even not enough because I'd like other date format than Gregorian).
So I add a custom variable org-agenda-date-string-function,
bind it to org-agenda-date-string to preserve current org behaviour.
Then in my org conf file, I add:
(defun my-org-agenda-date-string (date)
(...))
(setq org-agenda-date-string-function 'my-org-agenda-date-string)
Hope it helps.
--
Levin
diff --git a/lisp/org/org.el b/lisp/org/org.el
index 97bde49..3f6c9b5 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -2322,6 +2322,15 @@ FIXME: Not used currently, because of timezone
problem."
:group 'org-agenda-daily/weekly
:type 'string)
+(defcustom org-agenda-date-string-function
+ 'org-agenda-date-string
+ "Function that obtains a string for displaying date in the agenda.
+Used by the daily/weekly agenda and by the timeline.
+
+This function is passed a date and should return a string."
+ :group 'org-agenda-daily/weekly
+ :type 'function)
+
(defcustom org-agenda-include-diary nil
"If non-nil, include in the agenda entries from the Emacs Calendar's
diary."
:group 'org-agenda-daily/weekly
@@ -17565,6 +17574,12 @@ When a buffer is unmodified, it is just killed. When
modified, it is saved
(or (cdar tbl) (cdr (nth (1- (length org-category-table))
org-category-table))))))
;;; Agenda timeline
+(defun org-agenda-date-string (date)
+ (format "%-9s %2d %s %4d\n"
+ (calendar-day-name date)
+ (extract-calendar-day date)
+ (calendar-month-name (extract-calendar-month date))
+ (extract-calendar-year date)))
(defun org-timeline (&optional include-all)
"Show a time-sorted view of the entries in the current org file.
@@ -17626,10 +17641,8 @@ dates."
entry date args)))
(if (or rtn (equal d today) org-timeline-show-empty-dates)
(progn
- (insert (calendar-day-name date) " "
- (number-to-string (extract-calendar-day date)) " "
- (calendar-month-name (extract-calendar-month date)) " "
- (number-to-string (extract-calendar-year date)) "\n")
+ (insert (funcall org-agenda-date-string-function date)
+ "\n")
; FIXME: this gives a timezone problem
; (insert (format-time-string org-agenda-date-format
; (calendar-time-from-absolute d 0))
@@ -17806,11 +17819,8 @@ NDAYS defaults to `org-agenda-ndays'."
(setq rtnall (append rtnall rtn))))
(if (or rtnall org-agenda-show-all-dates)
(progn
- (insert (format "%-9s %2d %s %4d\n"
- (calendar-day-name date)
- (extract-calendar-day date)
- (calendar-month-name (extract-calendar-month date))
- (extract-calendar-year date)))
+ (insert (funcall org-agenda-date-string-function date)
+ "\n")
; FIXME: this gives a timezone problem
; (insert (format-time-string org-agenda-date-format
; (calendar-time-from-absolute d 0)) "\n")
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH]add a custom function to get date string in agenda
2007-09-12 3:08 [PATCH]add a custom function to get date string in agenda Levin
@ 2007-09-12 21:17 ` Carsten Dominik
2007-09-13 0:45 ` Levin
0 siblings, 1 reply; 3+ messages in thread
From: Carsten Dominik @ 2007-09-12 21:17 UTC (permalink / raw)
To: Levin; +Cc: emacs-orgmode
Hi Levin,
I always wanted this to be configurable, but used to have a strange
time zone problem with this. Your patch made me look again, and I
think I now understand what the problem was, and it is fixed now.
So I am implementing a slightly different version of you patch.
The new variable org-agenda-format-date can be a format string for
format-time-string, or it can be a function just like you describe it.
This will be in 5.09.
Thanks!
- Carsten
On Sep 12, 2007, at 5:08, Levin wrote:
> I have a special need of customizing date string in agenda (the date
> format
> string is even not enough because I'd like other date format than
> Gregorian).
> So I add a custom variable org-agenda-date-string-function,
> bind it to org-agenda-date-string to preserve current org behaviour.
>
> Then in my org conf file, I add:
> (defun my-org-agenda-date-string (date)
> (...))
>
> (setq org-agenda-date-string-function 'my-org-agenda-date-string)
>
> Hope it helps.
> --
> Levin
>
> diff --git a/lisp/org/org.el b/lisp/org/org.el
> index 97bde49..3f6c9b5 100644
> --- a/lisp/org/org.el
> +++ b/lisp/org/org.el
> @@ -2322,6 +2322,15 @@ FIXME: Not used currently, because of timezone
> problem."
> :group 'org-agenda-daily/weekly
> :type 'string)
>
> +(defcustom org-agenda-date-string-function
> + 'org-agenda-date-string
> + "Function that obtains a string for displaying date in the agenda.
> +Used by the daily/weekly agenda and by the timeline.
> +
> +This function is passed a date and should return a string."
> + :group 'org-agenda-daily/weekly
> + :type 'function)
> +
> (defcustom org-agenda-include-diary nil
> "If non-nil, include in the agenda entries from the Emacs Calendar's
> diary."
> :group 'org-agenda-daily/weekly
> @@ -17565,6 +17574,12 @@ When a buffer is unmodified, it is just
> killed. When
> modified, it is saved
> (or (cdar tbl) (cdr (nth (1- (length org-category-table))
> org-category-table))))))
> ;;; Agenda timeline
> +(defun org-agenda-date-string (date)
> + (format "%-9s %2d %s %4d\n"
> + (calendar-day-name date)
> + (extract-calendar-day date)
> + (calendar-month-name (extract-calendar-month date))
> + (extract-calendar-year date)))
>
> (defun org-timeline (&optional include-all)
> "Show a time-sorted view of the entries in the current org file.
> @@ -17626,10 +17641,8 @@ dates."
> entry date args)))
> (if (or rtn (equal d today) org-timeline-show-empty-dates)
> (progn
> - (insert (calendar-day-name date) " "
> - (number-to-string (extract-calendar-day date)) " "
> - (calendar-month-name (extract-calendar-month date)) " "
> - (number-to-string (extract-calendar-year date)) "\n")
> + (insert (funcall org-agenda-date-string-function date)
> + "\n")
> ; FIXME: this gives a timezone problem
> ; (insert (format-time-string org-agenda-date-format
> ; (calendar-time-from-absolute d 0))
> @@ -17806,11 +17819,8 @@ NDAYS defaults to `org-agenda-ndays'."
> (setq rtnall (append rtnall rtn))))
> (if (or rtnall org-agenda-show-all-dates)
> (progn
> - (insert (format "%-9s %2d %s %4d\n"
> - (calendar-day-name date)
> - (extract-calendar-day date)
> - (calendar-month-name (extract-calendar-month date))
> - (extract-calendar-year date)))
> + (insert (funcall org-agenda-date-string-function date)
> + "\n")
> ; FIXME: this gives a timezone problem
> ; (insert (format-time-string org-agenda-date-format
> ; (calendar-time-from-absolute d 0)) "\n")
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>
--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH]add a custom function to get date string in agenda
2007-09-12 21:17 ` Carsten Dominik
@ 2007-09-13 0:45 ` Levin
0 siblings, 0 replies; 3+ messages in thread
From: Levin @ 2007-09-13 0:45 UTC (permalink / raw)
To: Carsten Dominik; +Cc: emacs-orgmode
Carsten Dominik wrote:
> Hi Levin,
>
> I always wanted this to be configurable, but used to have a strange
> time zone problem with this. Your patch made me look again, and I
> think I now understand what the problem was, and it is fixed now.
>
> So I am implementing a slightly different version of you patch.
> The new variable org-agenda-format-date can be a format string for
> format-time-string, or it can be a function just like you describe it.
> This will be in 5.09.
>
> Thanks!
>
> - Carsten
That's great!
- Levin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-09-13 0:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-12 3:08 [PATCH]add a custom function to get date string in agenda Levin
2007-09-12 21:17 ` Carsten Dominik
2007-09-13 0:45 ` Levin
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.