* Re: Diary insert date formatting
[not found] <mailman.4212.1249760813.2239.help-gnu-emacs@gnu.org>
@ 2009-08-09 3:55 ` Xah Lee
2009-08-09 14:01 ` Diary insert date formatting-Help still needed please rpd
[not found] ` <mailman.4233.1249826480.2239.help-gnu-emacs@gnu.org>
2009-08-10 18:27 ` Diary insert date formatting Glenn Morris
1 sibling, 2 replies; 11+ messages in thread
From: Xah Lee @ 2009-08-09 3:55 UTC (permalink / raw)
To: help-gnu-emacs
On Aug 8, 12:46 pm, rpd <rich...@dickinson350.freeserve.co.uk> wrote:
> Hi
> Currently when I insert a diary date it is entered in this format:
> Jul 31, 2009
>
> Can I change this to include the abbreviated day as well e.g:
> Fri Jul 31, 2009 ?
use format-time-string.
call describe-function on the function.
here's some example how i use it.
(defun insert-date () "Insert current date." (interactive)
(insert (format-time-string "%Y-%m-%d"))
)
(put 'insert-date 'delete-selection t)
(defun insert-date-time ()
"Insert current date-time string."
(interactive)
(insert
(concat
(format-time-string "%Y-%m-%dT%T")
((lambda (x) (concat (substring x 0 3) ":" (substring x 3 5)))
(format-time-string "%z")))))
(defun fix-timestamp-string (timestr)
"Returns yyyy-mm-dd format of TIMESTR.
For example: “Nov. 28, 1994” ⇒ “1994-11-28”.
The result only contains year, month, date.
Any century, “day of week”, or time info are discarded."
(let (li year month date yyyy mm dd)
(setq timestr (replace-regexp-in-string "January " "Jan. "
timestr))
(setq timestr (replace-regexp-in-string "February " "Feb. "
timestr))
(setq timestr (replace-regexp-in-string "March " "Mar. " timestr))
(setq timestr (replace-regexp-in-string "April " "Apr. " timestr))
(setq timestr (replace-regexp-in-string "May " "May. " timestr))
(setq timestr (replace-regexp-in-string "June " "Jun. " timestr))
(setq timestr (replace-regexp-in-string "July " "Jul. " timestr))
(setq timestr (replace-regexp-in-string "August " "Aug. "
timestr))
(setq timestr (replace-regexp-in-string "September " "Sep. "
timestr))
(setq timestr (replace-regexp-in-string "October " "Oct. "
timestr))
(setq timestr (replace-regexp-in-string "November " "Nov. "
timestr))
(setq timestr (replace-regexp-in-string "December " "Dec. "
timestr))
(setq li (parse-time-string timestr))
(setq year (nth 5 li))
(setq month (nth 4 li))
(setq date (nth 3 li))
(setq yyyy (number-to-string year))
(setq mm
(if (< month 10)
(concat "0" (number-to-string month))
(number-to-string month)))
(setq dd
(if (< date 10)
(concat "0" (number-to-string date))
(number-to-string date)))
(concat yyyy "-" mm "-" dd)))
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Diary insert date formatting-Help still needed please
2009-08-09 3:55 ` Diary insert date formatting Xah Lee
@ 2009-08-09 14:01 ` rpd
[not found] ` <mailman.4233.1249826480.2239.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 11+ messages in thread
From: rpd @ 2009-08-09 14:01 UTC (permalink / raw)
To: Help-gnu-emacs
Thanks Xah Lee for your code.
However, I tried to get it to work to allow 'insert diary entry' to format
as I want but I could not get it to work.
Can anyone else please help me? I have looked at the Calendar group/diary
subset to customise this but I can find nothing to show 'insert diary entry'
to customise to the format I want (ie with dayname -either abbreviated or in
full : %a, %A).
I have searched .emacsfiles on the internet & looked in emacs manual (where
it seems to suggest this can be done but doesn't give an example!).
I look forward to some more help,thanks
--
View this message in context: http://www.nabble.com/Diary-insert-date-formatting-tp24881256p24887418.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.4233.1249826480.2239.help-gnu-emacs@gnu.org>]
* Re: Diary insert date formatting-Help still needed please
[not found] ` <mailman.4233.1249826480.2239.help-gnu-emacs@gnu.org>
@ 2009-08-09 22:09 ` B. T. Raven
2009-08-10 11:47 ` Diary insert date formatting-Help still needed please-Still needed! rpd
0 siblings, 1 reply; 11+ messages in thread
From: B. T. Raven @ 2009-08-09 22:09 UTC (permalink / raw)
To: help-gnu-emacs
rpd wrote:
>
> Thanks Xah Lee for your code.
>
> However, I tried to get it to work to allow 'insert diary entry' to format
> as I want but I could not get it to work.
>
> Can anyone else please help me? I have looked at the Calendar group/diary
> subset to customise this but I can find nothing to show 'insert diary entry'
> to customise to the format I want (ie with dayname -either abbreviated or in
> full : %a, %A).
> I have searched .emacsfiles on the internet & looked in emacs manual (where
> it seems to suggest this can be done but doesn't give an example!).
>
> I look forward to some more help,thanks
I have this in my emacs:
(global-set-key "\C-cid" (lambda() (interactive) (insert
(format-time-string "%a %Y-%m-%d - %l:%M %p"))))
which produces:
Sun 2009-08-09 - 4:26 PM
you want something like
(format-time-string "%a %b %d, %Y")
How to make that the format in insert diary entry I don't know. You
might have to modify diary-lib.el
This seems to do what you want, and more:
http://sachachua.com/notebook/emacs/cal-desk-calendar.el
Also look at diary-date-forms in Customize.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Diary insert date formatting
[not found] <mailman.4212.1249760813.2239.help-gnu-emacs@gnu.org>
2009-08-09 3:55 ` Diary insert date formatting Xah Lee
@ 2009-08-10 18:27 ` Glenn Morris
2009-08-10 20:00 ` rpd
[not found] ` <mailman.4324.1249934454.2239.help-gnu-emacs@gnu.org>
1 sibling, 2 replies; 11+ messages in thread
From: Glenn Morris @ 2009-08-10 18:27 UTC (permalink / raw)
To: help-gnu-emacs
rpd wrote:
> Currently when I insert a diary date it is entered in this format:
> Jul 31, 2009
>
> Can I change this to include the abbreviated day as well e.g:
> Fri Jul 31, 2009 ?
The problem with doing this is how to distinguish the latter from an
entry you want to apply every Friday, rather than one specific Friday.
The simplest method is to just remove support for such entries.
If you want to keep those as well, you will need to use a more complex
expression in the last element of diary-date-forms below.
The following assumes Emacs 23, and is only lightly tested.
(defun my-diary-insert-entry (arg &optional event)
"See `diary-insert-entry'."
(interactive
(list current-prefix-arg last-nonmenu-event))
(let ((calendar-date-display-form
'((if dayname
(concat dayname " "))
monthname " " day ", " year)))
(diary-make-entry (calendar-date-string (calendar-cursor-to-date t event) t)
arg)))
(add-hook 'calendar-load-hook
(lambda ()
(define-key calendar-mode-map "id" 'my-diary-insert-entry)))
(setq diary-date-forms
'(("\\sw+ *" monthname " *" day ", *" year "[^0-9]")
(month "/" day "[^/0-9]")
(month "/" day "/" year "[^0-9]")
(monthname " *" day "[^,0-9]")
(monthname " *" day ", *" year "[^0-9]")
;; (dayname "\\W")
))
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Diary insert date formatting
2009-08-10 18:27 ` Diary insert date formatting Glenn Morris
@ 2009-08-10 20:00 ` rpd
2009-08-11 16:25 ` Diary insert date formatting-continued! rpd
[not found] ` <mailman.4392.1250007957.2239.help-gnu-emacs@gnu.org>
[not found] ` <mailman.4324.1249934454.2239.help-gnu-emacs@gnu.org>
1 sibling, 2 replies; 11+ messages in thread
From: rpd @ 2009-08-10 20:00 UTC (permalink / raw)
To: Help-gnu-emacs
Hi Glenn Morris-5
Many thanks for your help. Your code is beyond me at the present as I am new
to Emacs but it throws an error when I use it (I have to learn more elisp! &
emacs!!):
>>>>>>
call-interactively: Invalid function: (lambda [f1] "Insert a diary entry for
the date indicated by point.
Prefix arg will make the entry nonmarking." (interactive "P")
(make-diary-entry (calendar-date-string (calendar-cursor-to-date t) t t)
arg))
<<<<<<
Also how do I remove support for entries as you suggest? (I would like to
use this date format for every time & day I insert a new diary date).
If you have any idea how to solve this error &/or more advice I am grateful.
Many thanks & best wishes
--
View this message in context: http://www.nabble.com/Diary-insert-date-formatting-tp24881256p24906500.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Diary insert date formatting-continued!
2009-08-10 20:00 ` rpd
@ 2009-08-11 16:25 ` rpd
[not found] ` <mailman.4392.1250007957.2239.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 11+ messages in thread
From: rpd @ 2009-08-11 16:25 UTC (permalink / raw)
To: Help-gnu-emacs
rpd wrote:
>
>
> Hi Glenn Morris-5
>
> Many thanks for your help. Your code is beyond me at the present as I am
> new to Emacs but it throws an error when I use it (I have to learn more
> elisp! & emacs!!):
>
>>>>>>>
> call-interactively: Invalid function: (lambda [f1] "Insert a diary entry
> for the date indicated by point.
> Prefix arg will make the entry nonmarking." (interactive "P")
> (make-diary-entry (calendar-date-string (calendar-cursor-to-date t) t t)
> arg))
> <<<<<<
>
> Also how do I remove support for entries as you suggest? (I would like to
> use this date format for every time & day I insert a new diary date).
> If you have any idea how to solve this error &/or more advice I am
> grateful. Many thanks & best wishes
>
Hi
My apologies to you Glenn Morris-5, as I have just seen the above error
message related to another piece of code relating to diary mode in my .emacs
file!
However your code still only gives me the default formatting when I use
'insert diary entry' (eg (for today)
Aug 11, 2009 - I want Tue Aug 11 2009).
If you can help further I am most grateful.
(Btw I have now added the facility to play mp3 in emacs with mpg123-but need
to explore how to do repeat play track & playlists etc-mplayer & Emms still
don't seem to work together & I have the other functions to fix especially
web browsing either with conkeror or other- the wondrous joys of emacs!).
Best wishes
--
View this message in context: http://www.nabble.com/Diary-insert-date-formatting-tp24881256p24920972.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.4392.1250007957.2239.help-gnu-emacs@gnu.org>]
* Re: Diary insert date formatting-continued!
[not found] ` <mailman.4392.1250007957.2239.help-gnu-emacs@gnu.org>
@ 2009-08-11 19:21 ` Glenn Morris
2009-08-11 20:06 ` rpd
0 siblings, 1 reply; 11+ messages in thread
From: Glenn Morris @ 2009-08-11 19:21 UTC (permalink / raw)
To: help-gnu-emacs
I sent this yesterday, but it doesn't seem to have appeared, so here it
is again. Beyond this, I'm afraid we are into "it works for me"
territory.
rpd wrote:
> it throws an error when I use it
I wrote:
> The following assumes Emacs 23...
Here is the version for Emacs 22, which you seem (?) to be using.
(defun my-diary-insert-entry (arg)
"See `insert-diary-entry'."
(interactive "P")
(let ((calendar-date-display-form
'((if dayname
(concat dayname " "))
monthname " " day ", " year)))
(make-diary-entry (calendar-date-string (calendar-cursor-to-date t) t)
arg)))
[The other pieces are unchanged from the Emacs 23 version originally
posted.]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Diary insert date formatting-continued!
2009-08-11 19:21 ` Glenn Morris
@ 2009-08-11 20:06 ` rpd
0 siblings, 0 replies; 11+ messages in thread
From: rpd @ 2009-08-11 20:06 UTC (permalink / raw)
To: Help-gnu-emacs
Hi again
I think our posts may have crossed.
Glenn Morris-5 wrote:
>
>
> I sent this yesterday, but it doesn't seem to have appeared, so here it
> is again. Beyond this, I'm afraid we are into "it works for me"
> territory.
>
>
Thanks for all your help Glenn. I am using Emacs 22.3 (primarily because v23
would not let me open a new file!!- My OS is Windows Vista-apologies if this
upset Linux or other OS users!).
Anyway your code only produces the same default diary date format for me and
does not add the extra dayname abbreviation I want. Strange it works for you
& not for me (bad luck really). I really appreciate your help & if you can
do anymore I am grateful, otherwise I am still very grateful! Many thanks
--
View this message in context: http://www.nabble.com/Diary-insert-date-formatting-tp24881256p24924553.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.4324.1249934454.2239.help-gnu-emacs@gnu.org>]
* Diary insert date formatting
@ 2009-08-08 19:46 rpd
0 siblings, 0 replies; 11+ messages in thread
From: rpd @ 2009-08-08 19:46 UTC (permalink / raw)
To: Help-gnu-emacs
Hi
Currently when I insert a diary date it is entered in this format:
Jul 31, 2009
Can I change this to include the abbreviated day as well e.g:
Fri Jul 31, 2009 ?
I am grateful for help,many thanks
--
View this message in context: http://www.nabble.com/Diary-insert-date-formatting-tp24881256p24881256.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2009-08-11 20:06 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.4212.1249760813.2239.help-gnu-emacs@gnu.org>
2009-08-09 3:55 ` Diary insert date formatting Xah Lee
2009-08-09 14:01 ` Diary insert date formatting-Help still needed please rpd
[not found] ` <mailman.4233.1249826480.2239.help-gnu-emacs@gnu.org>
2009-08-09 22:09 ` B. T. Raven
2009-08-10 11:47 ` Diary insert date formatting-Help still needed please-Still needed! rpd
2009-08-10 18:27 ` Diary insert date formatting Glenn Morris
2009-08-10 20:00 ` rpd
2009-08-11 16:25 ` Diary insert date formatting-continued! rpd
[not found] ` <mailman.4392.1250007957.2239.help-gnu-emacs@gnu.org>
2009-08-11 19:21 ` Glenn Morris
2009-08-11 20:06 ` rpd
[not found] ` <mailman.4324.1249934454.2239.help-gnu-emacs@gnu.org>
2009-08-10 21:45 ` Diary insert date formatting Glenn Morris
2009-08-08 19:46 rpd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).