emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Templates for cloning
@ 2012-08-02 17:12 Nathan Neff
  2012-08-03  7:25 ` Bastien
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Neff @ 2012-08-02 17:12 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

Is there a way to create a template structure for cloning?

The main purpose would be to create a shell or structure that is easy
to replicate,
such as a workflow, etc.  This shell, etc would not need any
hard-coded dates, but could
simply have offsets for sub-items whose due-dates or start dates are
relative to a single start date.

For example,

I'd like to have this:

* Some Project
** Plan Project
<start-date-placeholder>
** Step 1
<start-date-placeholder +1d>
** Step 2

<start-date-placeholder +1w>
** Project Due
<DEADLINE:start-date-placeholder +1m>

This would be cool, because

1)  You wouldn't see this template in the agenda, because the dates
aren't hard-coded
2)  You could be prompted for the start date when you clone this
template, and all the dates
would then be created from that start date
3)  When cloning this template, you wouldn't have to calculate the
delta between the
template's date and the initial start date that you plan for the clone
of this template

Does anyone know of a way to do this?
  - I could keep this template in another directory or re-name it as
.TXT so that the agenda wouldn't pick up
the template's fake start dates, but this seems hacky.

Thanks
--Nate

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

* Re: Templates for cloning
  2012-08-02 17:12 Templates for cloning Nathan Neff
@ 2012-08-03  7:25 ` Bastien
  2012-08-04  2:40   ` Sebastian Fischmeister
  0 siblings, 1 reply; 5+ messages in thread
From: Bastien @ 2012-08-03  7:25 UTC (permalink / raw)
  To: Nathan Neff; +Cc: emacs-orgmode

Hi Nathan,

Nathan Neff <nathan.neff@gmail.com> writes:

> Is there a way to create a template structure for cloning?

This is something I've wanted for long, and I hope I'll find the time 
to implement it after 7.9.

More precisely, I want something that captures the structure of the
subtree at point (with all elements), then let's you convert this
structure into a template for later interactive insertion.

> Does anyone know of a way to do this?

I guess yasnippet can help to produce something close to what you want
for now.

Best,

-- 
 Bastien

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

* Re: Templates for cloning
  2012-08-03  7:25 ` Bastien
@ 2012-08-04  2:40   ` Sebastian Fischmeister
  2012-08-06  1:35     ` Nathan Neff
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Fischmeister @ 2012-08-04  2:40 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

As an idea, this is how I use templates:

%+begin_src
(defun org-p (key)
  (let ((val (read-from-minibuffer (concat "Define " key ": "))))
    (plist-put org-store-link-plist 
	       (intern (concat ":" key)) val))
  ""
  )

(defmacro org-g (key)  
  (or (plist-get org-store-link-plist (intern (concat ":" key)))
  (concat "MISSING-KEY-" key)))

(setq org-capture-templates
       (quote (("p4" "Template: Bla" plain (file+headline
       "~/.org/todo.org" "Projects") (file "~/.org/templates/bla.tmpl")))))
%+end_src

%+begin_src yasnippet 
%(org-p "var1")
%(org-p "var2")
** Now copy here %(org-g "var1")
** And here %(org-g "var1")
   SCHEDULED: %^t
%+end_src

If you just swap the sequence of the buffer evaluation in
org-capture-fill-template, then you would even have a nicer version of
this. See this previous post for details:

http://comments.gmane.org/gmane.emacs.orgmode/57248

  Sebastian

On 08/03/12 09:25am, Bastien wrote:
> Hi Nathan,
> 
> Nathan Neff <nathan.neff@gmail.com> writes:
> 
> > Is there a way to create a template structure for cloning?
> 
> This is something I've wanted for long, and I hope I'll find the time 
> to implement it after 7.9.
> 
> More precisely, I want something that captures the structure of the
> subtree at point (with all elements), then let's you convert this
> structure into a template for later interactive insertion.
> 
> > Does anyone know of a way to do this?
> 
> I guess yasnippet can help to produce something close to what you want
> for now.
> 
> Best,

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

* Re: Templates for cloning
  2012-08-04  2:40   ` Sebastian Fischmeister
@ 2012-08-06  1:35     ` Nathan Neff
  2012-08-09  0:42       ` Sebastian Fischmeister
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Neff @ 2012-08-06  1:35 UTC (permalink / raw)
  To: Sebastian Fischmeister; +Cc: Bastien, emacs-orgmode

On Fri, Aug 3, 2012 at 9:40 PM, Sebastian Fischmeister
<sfischme@uwaterloo.ca> wrote:
> As an idea, this is how I use templates:
>
> %+begin_src
> (defun org-p (key)
>   (let ((val (read-from-minibuffer (concat "Define " key ": "))))
>     (plist-put org-store-link-plist
>                (intern (concat ":" key)) val))
>   ""
>   )
>
> (defmacro org-g (key)
>   (or (plist-get org-store-link-plist (intern (concat ":" key)))
>   (concat "MISSING-KEY-" key)))
>
> (setq org-capture-templates
>        (quote (("p4" "Template: Bla" plain (file+headline
>        "~/.org/todo.org" "Projects") (file "~/.org/templates/bla.tmpl")))))
> %+end_src
>
> %+begin_src yasnippet
> %(org-p "var1")
> %(org-p "var2")
> ** Now copy here %(org-g "var1")
> ** And here %(org-g "var1")
>    SCHEDULED: %^t
> %+end_src
>
> If you just swap the sequence of the buffer evaluation in
> org-capture-fill-template, then you would even have a nicer version of
> this. See this previous post for details:
>
> http://comments.gmane.org/gmane.emacs.orgmode/57248
>
>   Sebastian
>

Sebastian, thanks for your suggestion, but I'm having trouble understanding
how your solution works, and I don't know what you mean by "If you just swap
the sequence of the buffer evaluation".  I only glanced at your suggestion and
will review it later (hopefully).

If you can point me to more documentation about what's going on in
your solution,
or perhaps enlighten me a bit more, I would appreciate it!

Thanks,
--Nate

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

* Re: Templates for cloning
  2012-08-06  1:35     ` Nathan Neff
@ 2012-08-09  0:42       ` Sebastian Fischmeister
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastian Fischmeister @ 2012-08-09  0:42 UTC (permalink / raw)
  To: Nathan Neff; +Cc: Bastien, emacs-orgmode

The comment about swapping lines and getting a nicer version was
intended for the orgmode devs, just in case they want an easy way to
support templates with minimal changes to the source code.

My solution also works. Just copy the elisp definitions for org-p and
org-g into your .emacs file. Then define a new template and you're
set.

In the template:

- %(org-p "varname") will prompt you for a value that is then stored as
 'varname'.

- %(org-g "varname") will then insert the text you entered at the
 prompt.


  Sebastian


On 08/05/12 08:35pm, Nathan Neff wrote:
> On Fri, Aug 3, 2012 at 9:40 PM, Sebastian Fischmeister
> <sfischme@uwaterloo.ca> wrote:
> > As an idea, this is how I use templates:
> >
> > %+begin_src
> > (defun org-p (key)
> >   (let ((val (read-from-minibuffer (concat "Define " key ": "))))
> >     (plist-put org-store-link-plist
> >                (intern (concat ":" key)) val))
> >   ""
> >   )
> >
> > (defmacro org-g (key)
> >   (or (plist-get org-store-link-plist (intern (concat ":" key)))
> >   (concat "MISSING-KEY-" key)))
> >
> > (setq org-capture-templates
> >        (quote (("p4" "Template: Bla" plain (file+headline
> >        "~/.org/todo.org" "Projects") (file "~/.org/templates/bla.tmpl")))))
> > %+end_src
> >
> > %+begin_src yasnippet
> > %(org-p "var1")
> > %(org-p "var2")
> > ** Now copy here %(org-g "var1")
> > ** And here %(org-g "var1")
> >    SCHEDULED: %^t
> > %+end_src
> >
> > If you just swap the sequence of the buffer evaluation in
> > org-capture-fill-template, then you would even have a nicer version of
> > this. See this previous post for details:
> >
> > http://comments.gmane.org/gmane.emacs.orgmode/57248
> >
> >   Sebastian
> >
> 
> Sebastian, thanks for your suggestion, but I'm having trouble understanding
> how your solution works, and I don't know what you mean by "If you just swap
> the sequence of the buffer evaluation".  I only glanced at your suggestion and
> will review it later (hopefully).
> 
> If you can point me to more documentation about what's going on in
> your solution,
> or perhaps enlighten me a bit more, I would appreciate it!
> 
> Thanks,
> --Nate

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

end of thread, other threads:[~2012-08-09  0:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-02 17:12 Templates for cloning Nathan Neff
2012-08-03  7:25 ` Bastien
2012-08-04  2:40   ` Sebastian Fischmeister
2012-08-06  1:35     ` Nathan Neff
2012-08-09  0:42       ` Sebastian Fischmeister

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