emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Calendar hack: take the default date from clipboard
@ 2006-09-28 22:32 Piotr Zielinski
  0 siblings, 0 replies; only message in thread
From: Piotr Zielinski @ 2006-09-28 22:32 UTC (permalink / raw)
  To: emacs-orgmode

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/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-09-28 22:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-28 22:32 Calendar hack: take the default date from clipboard Piotr Zielinski

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).