emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Calendar hack: take the default date from clipboard


From: Piotr Zielinski
Subject: [Orgmode] Calendar hack: take the default date from clipboard
Date: Fri, 29 Sep 2006 00:32:00 +0200

Hi all,

When adding a timestamp, org-mode proposes the current date.  This
hack makes it look at the contents of the clipboard, and if it
contains a valid date, org-mode proposes that date instead.  This
comes useful, when you copy a deadline from another application, for
example, a web browser.

(setq parse-time-months '(("jan" . 1) ("feb" . 2) ("mar" . 3)
                          ("apr" . 4) ("may" . 5) ("jun" . 6)
                          ("jul" . 7) ("aug" . 8) ("sep" . 9)
                          ("oct" . 10) ("nov" . 11) ("dec" . 12)
                        
                          ("january" . 1) ("february" . 2) ("march" . 3)
                          ("april" . 4) ("may" . 5) ("june" . 6)
                          ("july" . 7) ("august" . 8) ("september" . 9)
                          ("october" . 10) ("november" . 11) ("december" . 12)))
                        
(defadvice org-read-date (around local-org-read-date activate)
               (let ((local-ct
                      (let ((clipboard-time
                             (parse-time-string (current-kill 0))))
                        (if (nth 3 clipboard-time) ; if day is not nil
                            (apply 'encode-time
                                   (mapcar (lambda(x) (or x 0)) clipboard-time))
                          (org-current-time)))))
                 (flet ((org-current-time () local-ct))
                   ad-do-it)))

Test and enjoy.
Piotr


--
Piotr Zielinski, Research Associate
Cavendish Laboratory, University of Cambridge, UK
http://www.cl.cam.ac.uk/~pz215/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]