emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* using %(sexp) in capture templates
@ 2013-10-11  1:51 Manish
  2013-10-12  1:55 ` Mike McLean
  0 siblings, 1 reply; 6+ messages in thread
From: Manish @ 2013-10-11  1:51 UTC (permalink / raw)
  To: Org-Mode

[-- Attachment #1: Type: text/plain, Size: 450 bytes --]

i am trying to use %(org-mac-outlook-message-insert-selected) in a
capture template to create a todo entry from an email selected in
outlook on mac os x.  i was expecting that the function will get
executed when the template is called and enter a link to the email but
seems to return nothing.  the function works when used outside of
template.  any ideas how i can begin to debug this or if i should be
doing anything differently?

cheers!
--manish

[-- Attachment #2: Type: text/html, Size: 562 bytes --]

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

* Re: using %(sexp) in capture templates
  2013-10-11  1:51 using %(sexp) in capture templates Manish
@ 2013-10-12  1:55 ` Mike McLean
  2013-10-12  6:03   ` Manish
  0 siblings, 1 reply; 6+ messages in thread
From: Mike McLean @ 2013-10-12  1:55 UTC (permalink / raw)
  To: Manish; +Cc: Org-Mode

[-- Attachment #1: Type: text/plain, Size: 1177 bytes --]


On Oct 10, 2013, at 9:51 PM, Manish <mailtomanish.sharma@gmail.com> wrote:

> i am trying to use %(org-mac-outlook-message-insert-selected) in a
> capture template to create a todo entry from an email selected in
> outlook on mac os x.  i was expecting that the function will get
> executed when the template is called and enter a link to the email but
> seems to return nothing.  the function works when used outside of
> template.  any ideas how i can begin to debug this or if i should be
> doing anything differently?


When I added the support for Outlook I matched the style and design of the existing Org mac message (for Mail). In particular org-mac-outlook-message-insert-selected does not return a value, it is designed to be called interactively and inserts a link at the current point in the current buffer. As such it would not work as a %() capture template.

Now on the other hand all org-mac-outlook-message-insert-selected does is ~(insert (org-mac-outlook-message-get-links "s"))~. I presume (though I haven't tested) that you could use the inner form ~(org-mac-outlook-message-get-links "s")~ in a %() sexp in a capture template.

Mike



[-- Attachment #2: Type: text/html, Size: 1735 bytes --]

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

* Re: using %(sexp) in capture templates
  2013-10-12  1:55 ` Mike McLean
@ 2013-10-12  6:03   ` Manish
  2013-10-12 11:24     ` Mike McLean
  0 siblings, 1 reply; 6+ messages in thread
From: Manish @ 2013-10-12  6:03 UTC (permalink / raw)
  To: Mike McLean; +Cc: Org-Mode

[-- Attachment #1: Type: text/plain, Size: 1964 bytes --]

  >> On Fri, Oct 11, 2013 at 9:55 PM, Mike McLean wrote:
  >>
  >>   > On Oct 10, 2013, at 9:51 PM, Manish wrote:
  >>   >
  >>   > i am trying to use %(org-mac-outlook-message-insert-selected)
  >>   > in a capture template to create a todo entry from an email
  >>   > selected in outlook on mac os x.  i was expecting that the
  >>   > function will get executed when the template is called and
  >>   > enter a link to the email but seems to return nothing.  the
  >>   > function works when used outside of template.  any ideas how i
  >>   > can begin to debug this or if i should be doing anything
  >>   > differently?
  >>   >
  >>
  >> When I added the support for Outlook I matched the style and design
  >> of the existing Org mac message (for Mail). In particular
  >> org-mac-outlook-message-insert-selected does not return a value, it
  >> is designed to be called interactively and inserts a link at the
  >> current point in the current buffer. As such it would not work as a
  >> %() capture template.
  >>
  >> Now on the other hand all org-mac-outlook-message-insert-selected
  >> does is ~(insert (org-mac-outlook-message-get-links "s"))~. I
  >> presume (though I haven't tested) that you could use the inner form
  >> ~(org-mac-outlook-message-get-links "s")~ in a %() sexp in a
  >> capture template.
  >>

thanks!  it does work this way.

i am not sure if it's directly related but there's a weird issue.  once
i have a link to an email, i can open it by c-c c-o only once.  any
following attempt just fails with a message: "org-mac-link: error could
not find outlook message <msgid>" where msgid is the id of the
message. when i ran the mdfind command that i found in the source in the
terminal, it again worked once only.  any subsequent attempt opens a
finder window.  very very odd behavior since i am not even modifying the
email in anyway (other than just opening it) that might change its
message id or something.

cheers!
--manish

[-- Attachment #2: Type: text/html, Size: 2442 bytes --]

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

* Re: using %(sexp) in capture templates
  2013-10-12  6:03   ` Manish
@ 2013-10-12 11:24     ` Mike McLean
  2013-10-12 21:54       ` Manish
  0 siblings, 1 reply; 6+ messages in thread
From: Mike McLean @ 2013-10-12 11:24 UTC (permalink / raw)
  To: Manish; +Cc: Org-Mode

[-- Attachment #1: Type: text/plain, Size: 2501 bytes --]


On Oct 12, 2013, at 2:03 AM, Manish <mailtomanish.sharma@gmail.com> wrote:

>  >> On Fri, Oct 11, 2013 at 9:55 PM, Mike McLean wrote:
>   >> 
>   >>   > On Oct 10, 2013, at 9:51 PM, Manish wrote:
>   >>   > 
>   >>   > i am trying to use %(org-mac-outlook-message-insert-selected)
>   >>   > in a capture template to create a todo entry from an email
>   >>   > selected in outlook on mac os x.  i was expecting that the
>   >>   > function will get executed when the template is called and
>   >>   > enter a link to the email but seems to return nothing.  the
>   >>   > function works when used outside of template.  any ideas how i
>   >>   > can begin to debug this or if i should be doing anything
>   >>   > differently?
>   >>   > 
>   >> 
>   >> When I added the support for Outlook I matched the style and design
>   >> of the existing Org mac message (for Mail). In particular
>   >> org-mac-outlook-message-insert-selected does not return a value, it
>   >> is designed to be called interactively and inserts a link at the
>   >> current point in the current buffer. As such it would not work as a
>   >> %() capture template.
>   >> 
>   >> Now on the other hand all org-mac-outlook-message-insert-selected
>   >> does is ~(insert (org-mac-outlook-message-get-links "s"))~. I
>   >> presume (though I haven't tested) that you could use the inner form
>   >> ~(org-mac-outlook-message-get-links "s")~ in a %() sexp in a
>   >> capture template.
>   >> 
> 
> thanks!  it does work this way.
> 
> i am not sure if it's directly related but there's a weird issue.  once
> i have a link to an email, i can open it by c-c c-o only once.  any
> following attempt just fails with a message: "org-mac-link: error could
> not find outlook message <msgid>" where msgid is the id of the
> message. when i ran the mdfind command that i found in the source in the
> terminal, it again worked once only.  any subsequent attempt opens a
> finder window.  very very odd behavior since i am not even modifying the
> email in anyway (other than just opening it) that might change its
> message id or something.

It has definitely worked for the same message multiple times for me (even after changing a message by moving it, etc.). Since the Org mac Outlook interface uses Spotlight indexing, and Spotlight uses the loose messages in the Microsoft User Data folder, maybe rebuilding one or both of the Outlook profile or the Spotlight index would fix your issues?

[-- Attachment #2: Type: text/html, Size: 3387 bytes --]

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

* Re: using %(sexp) in capture templates
  2013-10-12 11:24     ` Mike McLean
@ 2013-10-12 21:54       ` Manish
  2013-10-13 14:16         ` Mike McLean
  0 siblings, 1 reply; 6+ messages in thread
From: Manish @ 2013-10-12 21:54 UTC (permalink / raw)
  To: Mike McLean; +Cc: Org-Mode

[-- Attachment #1: Type: text/plain, Size: 2862 bytes --]

> On Sat, Oct 12, 2013 at 7:24 AM, Mike McLean wrote:
>
> > On Oct 12, 2013, at 2:03 AM, Manish wrote:
> >
> > > On Fri, Oct 11, 2013 at 9:55 PM, Mike McLean wrote:
> > >
> > > > On Oct 10, 2013, at 9:51 PM, Manish wrote:
> > > >
> > > > i am trying to use %(org-mac-outlook-message-insert-selected) in
> > > > a capture template to create a todo entry from an email selected
> > > > in outlook on mac os x.  i was expecting that the function will
> > > > get executed when the template is called and enter a link to the
> > > > email but seems to return nothing.  the function works when used
> > > > outside of template.  any ideas how i can begin to debug this or
> > > > if i should be doing anything differently?
> > > >
> > >
> > > When I added the support for Outlook I matched the style and
> > > design of the existing Org mac message (for Mail). In particular
> > > org-mac-outlook-message-insert-selected does not return a value,
> > > it is designed to be called interactively and inserts a link at
> > > the current point in the current buffer. As such it would not work
> > > as a %() capture template.
> > >
> > > Now on the other hand all org-mac-outlook-message-insert-selected
> > > does is ~(insert (org-mac-outlook-message-get-links "s"))~. I
> > > presume (though I haven't tested) that you could use the inner
> > > form ~(org-mac-outlook-message-get-links "s")~ in a %() sexp in a
> > > capture template.
> > >
> >
> > thanks!  it does work this way.
> >
> > i am not sure if it's directly related but there's a weird issue.
> > once i have a link to an email, i can open it by c-c c-o only once.
> > any following attempt just fails with a message: "org-mac-link:
> > error could not find outlook message <msgid>" where msgid is the id
> > of the message. when i ran the mdfind command that i found in the
> > source in the terminal, it again worked once only.  any subsequent
> > attempt opens a finder window.  very very odd behavior since i am
> > not even modifying the email in anyway (other than just opening it)
> > that might change its message id or something.
>
> it has definitely worked for the same message multiple times for me
> (even after changing a message by moving it, etc.). since the org mac
> outlook interface uses spotlight indexing, and spotlight uses the
> loose messages in the microsoft user data folder, maybe rebuilding one
> or both of the outlook profile or the spotlight index would fix your
> issues?

i'll look into rebuilding outlook profiles and spotlight indexes.
meanwhile, following has worked consistently for me:

#+begin_src emacs-lisp
(defun org-mac-outlook-message-open (msgid)
  "open a message in outlook"
  (do-applescript
   (concat
    "tell application \"Microsoft Outlook\"\n"
     (format "open message id %s\n" msgid)
     "activate\n"
     "end tell")))
#+end_src

cheers!
--manish

[-- Attachment #2: Type: text/html, Size: 7019 bytes --]

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

* Re: using %(sexp) in capture templates
  2013-10-12 21:54       ` Manish
@ 2013-10-13 14:16         ` Mike McLean
  0 siblings, 0 replies; 6+ messages in thread
From: Mike McLean @ 2013-10-13 14:16 UTC (permalink / raw)
  To: Manish; +Cc: Org-Mode

[-- Attachment #1: Type: text/plain, Size: 646 bytes --]


On Oct 12, 2013, at 5:54 PM, Manish <mailtomanish.sharma@gmail.com> wrote:

> 
> 
> i'll look into rebuilding outlook profiles and spotlight indexes.
> meanwhile, following has worked consistently for me:
> 
> #+begin_src emacs-lisp
> (defun org-mac-outlook-message-open (msgid)
>   "open a message in outlook"
>   (do-applescript
>    (concat
>     "tell application \"Microsoft Outlook\"\n"
>      (format "open message id %s\n" msgid)
>      "activate\n"
>      "end tell")))
> #+end_src
> 
> cheers!
> --manish
> 

And I just submitted a patch that changes to Outlook message open to use Applescript as your code does.

[-- Attachment #2: Type: text/html, Size: 2020 bytes --]

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

end of thread, other threads:[~2013-10-13 14:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-11  1:51 using %(sexp) in capture templates Manish
2013-10-12  1:55 ` Mike McLean
2013-10-12  6:03   ` Manish
2013-10-12 11:24     ` Mike McLean
2013-10-12 21:54       ` Manish
2013-10-13 14:16         ` Mike McLean

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