emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org Babel, Ruby and Outlook
@ 2009-10-15 22:47 Miguel Fernando Cabrera
  2009-10-16  0:26 ` Eric Schulte
  0 siblings, 1 reply; 2+ messages in thread
From: Miguel Fernando Cabrera @ 2009-10-15 22:47 UTC (permalink / raw)
  To: Org Mode


[-- Attachment #1.1: Type: text/plain, Size: 1982 bytes --]

Hi All,

In a similar way to  [1],  I want to import my Outlook appointments into
Org. I thought of a less sophisticated way to archive this using Org Babel.
I coded a Ruby script to "print out"  the Appointments in Org Format so I
can see them in the agenda view.  I execute the code using the ":results
output" header option to get the output from the ruby script (check the
script below).

Now, the only problem is that the output of the script is always surrounded
by  #+begin_example and #+end_example. I was wondering if there is a way to
prevent this. What I want is  the text lines to be put on the Org buffer so
Org can interpret them as headlines.

Also, I tried to get the output using a vector (value mode), but for some
reason I was getting "End of File During Parsing" message when executing the
script. I think it has to be with some characters in the Subject properties
of the Outlook appointments.

Any help will be really appreciated.

[1] http://osdir.com/ml/emacs-orgmode-gnu/2009-04/msg00264.html

-----------------------------------------------------------------------------------------------------------------

#+begin_src ruby :results output
  require 'win32ole'

  def to_org_date(otStr)
    "<%s>" % otStr.gsub("/","-")
  end

  def to_org_interval(start,endd)
    to_org_date(start)+"--"+to_org_date(endd)
  end

  outlook = WIN32OLE.new('Outlook.Application')

  mapi = outlook.GetNameSpace('MAPI')
  calendar = mapi.GetDefaultFolder(9)
  puts "* OUTLOOK APPOINTMENTS"
  calendar.Items.each do |appt|
    puts "** #{appt.Subject}\n #{to_org_interval(appt.Start,appt.End)} "
  end
#+end_src

------------------------------------------------------------------------------------------------------------


-- 
Miguel Fernando Cabrera Granados
http://mfcabrera.com
"A los hombres fuertes les pasa lo que a los barriletes; se elevan cuando es
mayor el viento que se opone a su ascenso." - José Ingenieros

[-- Attachment #1.2: Type: text/html, Size: 2342 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Org Babel, Ruby and Outlook
  2009-10-15 22:47 Org Babel, Ruby and Outlook Miguel Fernando Cabrera
@ 2009-10-16  0:26 ` Eric Schulte
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Schulte @ 2009-10-16  0:26 UTC (permalink / raw)
  To: Miguel Fernando Cabrera; +Cc: Org Mode

Hi Miguel,

That is a very cool application.  To insert your script's results
directly into the Org-mode buffer try changing your header line from

#+begin_src ruby :results output

to

#+begin_src ruby :results output raw

as this seems like the sort of thing which would be generally useful,
would you mind if it is added to the "Library of Babel"?

Best -- Eric

Miguel Fernando Cabrera <mfcabrera@gmail.com> writes:

> Hi All,
>
> In a similar way to  [1],  I want to import my Outlook appointments into Org. I thought of a less
> sophisticated way to archive this using Org Babel.
> I coded a Ruby script to "print out"  the Appointments in Org Format so I can see them in the agenda
> view.  I execute the code using the ":results output" header option to get the output from the ruby script
> (check the script below).
>
> Now, the only problem is that the output of the script is always surrounded by  #+begin_example and #
> +end_example. I was wondering if there is a way to prevent this. What I want is  the text lines to be put
> on the Org buffer so Org can interpret them as headlines.
>
> Also, I tried to get the output using a vector (value mode), but for some reason I was getting "End of
> File During Parsing" message when executing the script. I think it has to be with some characters in the
> Subject properties of the Outlook appointments.
>
> Any help will be really appreciated.
>
> [1] http://osdir.com/ml/emacs-orgmode-gnu/2009-04/msg00264.html
>
> -----------------------------------------------------------------------------------------------------------------
>
> #+begin_src ruby :results output
>   require 'win32ole'
>  
>   def to_org_date(otStr)
>     "<%s>" % otStr.gsub("/","-")
>   end
>  
>   def to_org_interval(start,endd)
>     to_org_date(start)+"--"+to_org_date(endd)
>   end
>  
>   outlook = WIN32OLE.new('Outlook.Application')
>  
>   mapi = outlook.GetNameSpace('MAPI')
>   calendar = mapi.GetDefaultFolder(9)
>   puts "* OUTLOOK APPOINTMENTS"
>   calendar.Items.each do |appt|
>     puts "** #{appt.Subject}\n #{to_org_interval(appt.Start,appt.End)} "
>   end
> #+end_src
>
> ------------------------------------------------------------------------------------------------------------
>
> --
> Miguel Fernando Cabrera Granados
> http://mfcabrera.com
> "A los hombres fuertes les pasa lo que a los barriletes; se elevan cuando es
> mayor el viento que se opone a su ascenso." - José Ingenieros
>
> _______________________________________________
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-16  0:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-15 22:47 Org Babel, Ruby and Outlook Miguel Fernando Cabrera
2009-10-16  0:26 ` Eric Schulte

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