From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Piotr Zielinski" Subject: Calendar hack: take the default date from clipboard Date: Fri, 29 Sep 2006 00:32:00 +0200 Message-ID: <3c12eb8d0609281532n63301603s5b90bde6dc3943c7@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GT4QG-0006N7-8a for emacs-orgmode@gnu.org; Thu, 28 Sep 2006 18:32:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GT4QD-0006MP-Qy for emacs-orgmode@gnu.org; Thu, 28 Sep 2006 18:32:02 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GT4QD-0006MM-MP for emacs-orgmode@gnu.org; Thu, 28 Sep 2006 18:32:01 -0400 Received: from [64.233.166.179] (helo=py-out-1112.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GT4VO-0004Me-Jg for emacs-orgmode@gnu.org; Thu, 28 Sep 2006 18:37:22 -0400 Received: by py-out-1112.google.com with SMTP id x66so904760pye for ; Thu, 28 Sep 2006 15:32:00 -0700 (PDT) Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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/