all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* create new files from capture
@ 2011-04-01 17:43 Buck Brody
  2011-04-04 19:12 ` David Maus
  0 siblings, 1 reply; 6+ messages in thread
From: Buck Brody @ 2011-04-01 17:43 UTC (permalink / raw)
  To: emacs-orgmode

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

Is there a way to use capture to create new files? Can I fill out the name of the file, and add a date stamp, from within the capture template? 

I also considered creating a new headline and then exporting the subtree. The problem is that I need to have the title of the new file automatically created based upon the headline, and I can't figure out how to do this.

Thanks 

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

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

* Re: create new files from capture
  2011-04-01 17:43 create new files from capture Buck Brody
@ 2011-04-04 19:12 ` David Maus
  2011-04-04 19:49   ` Matthew Sauer
  2011-04-20 19:00   ` Bill Wishon
  0 siblings, 2 replies; 6+ messages in thread
From: David Maus @ 2011-04-04 19:12 UTC (permalink / raw)
  To: Buck Brody; +Cc: emacs-orgmode

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

At Fri, 1 Apr 2011 13:43:06 -0400,
Buck Brody wrote:
> Is there a way to use capture to create new files?  Can I fill out
> the name of the file, and add a date stamp, from within the capture
> template?

Prompting in the templates happens after the template is placed in the
target buffer.  So AFAIK there is no way to achive this without a
little bit hacking: You could specify a target function

target       Specification of where the captured item should be placed.
             In Org-mode files, targets usually define a node.  Entries will
             become children of this node, other types will be added to the
             table or list in the body of this node.

             Most target specifications contain a file name.  If that file
             name is the empty string, it defaults to `org-default-notes-file'.
             A file can also be given as a variable, function, or Emacs Lisp
             form.

	     ...

             (function function-finding-location)
                Most general way, write your own function to find both
                file and location

That could read the target file name with a prompt.

> I also considered creating a new headline and then exporting the
> subtree.  The problem is that I need to have the title of the new
> file automatically created based upon the headline, and I can't
> figure out how to do this.

Same here. The function `org-heading-components' (C-h f
org-heading-components RET) will get you the title of the headline
which you would have to transform to a valid file name
(i.e. `replace-regexp-in-string').

Best,
  -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #2: Type: application/pgp-signature, Size: 230 bytes --]

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

* Re: create new files from capture
  2011-04-04 19:12 ` David Maus
@ 2011-04-04 19:49   ` Matthew Sauer
  2011-04-20 19:00   ` Bill Wishon
  1 sibling, 0 replies; 6+ messages in thread
From: Matthew Sauer @ 2011-04-04 19:49 UTC (permalink / raw)
  To: David Maus; +Cc: emacs-orgmode, Buck Brody

Could one not have it go into a temporary file and then have an exit
hook attatched to a particular template that if a particular property
had been filled in that it would create a new file with that name and
either refile to or cut to and then paste from the kill ring?

Matthew

obviously would require some modification/hacking

On Mon, Apr 4, 2011 at 2:12 PM, David Maus <dmaus@ictsoc.de> wrote:
> At Fri, 1 Apr 2011 13:43:06 -0400,
> Buck Brody wrote:
>> Is there a way to use capture to create new files?  Can I fill out
>> the name of the file, and add a date stamp, from within the capture
>> template?
>
> Prompting in the templates happens after the template is placed in the
> target buffer.  So AFAIK there is no way to achive this without a
> little bit hacking: You could specify a target function
>
> target       Specification of where the captured item should be placed.
>             In Org-mode files, targets usually define a node.  Entries will
>             become children of this node, other types will be added to the
>             table or list in the body of this node.
>
>             Most target specifications contain a file name.  If that file
>             name is the empty string, it defaults to `org-default-notes-file'.
>             A file can also be given as a variable, function, or Emacs Lisp
>             form.
>
>             ...
>
>             (function function-finding-location)
>                Most general way, write your own function to find both
>                file and location
>
> That could read the target file name with a prompt.
>
>> I also considered creating a new headline and then exporting the
>> subtree.  The problem is that I need to have the title of the new
>> file automatically created based upon the headline, and I can't
>> figure out how to do this.
>
> Same here. The function `org-heading-components' (C-h f
> org-heading-components RET) will get you the title of the headline
> which you would have to transform to a valid file name
> (i.e. `replace-regexp-in-string').
>
> Best,
>  -- David
> --
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de
>

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

* Re: create new files from capture
  2011-04-04 19:12 ` David Maus
  2011-04-04 19:49   ` Matthew Sauer
@ 2011-04-20 19:00   ` Bill Wishon
  2011-04-20 19:22     ` Bill Wishon
  1 sibling, 1 reply; 6+ messages in thread
From: Bill Wishon @ 2011-04-20 19:00 UTC (permalink / raw)
  To: emacs-orgmode

>              (function function-finding-location)
>                 Most general way, write your own function to find both
>                 file and location

I just started trying to do this today myself when I found this thread.

From what I can tell the expectation is that this function places the point 
in the buffer/file at the location where you want to insert the captured 
template item.

I created to following which works for me to open a new file and puts the 
test template there:

(defun prompt-for-new-orgfile ()
  "This function prompts for a file to save to"

  (call-interactively 'find-file)
  (end-of-buffer))

(setq org-capture-templates
	  '(("t" "Todo" entry (file+headline (concat org-directory "/gtd.org")
"Tasks")
		 "* TODO %?\n %i\n %a")
		("m" "Meeting Notes" entry (function prompt-for-new-orgfile) 
"* %^{meetingtitle}" :unnarrowed)))

What I'm trying to figure out now is how to read the template from a file.  
The documentation says that it can be done by using (file "path/to/file") 
in place of the template text argument, but I haven't gotten that working yet.

~>Bill

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

* Re: create new files from capture
  2011-04-20 19:00   ` Bill Wishon
@ 2011-04-20 19:22     ` Bill Wishon
  2011-04-20 19:44       ` Nick Dokos
  0 siblings, 1 reply; 6+ messages in thread
From: Bill Wishon @ 2011-04-20 19:22 UTC (permalink / raw)
  To: emacs-orgmode

Bill Wishon <bill <at> wishon.org> writes:

> What I'm trying to figure out now is how to read the template from a file.  
> The documentation says that it can be done by using (file "path/to/file") 
> in place of the template text argument, but I haven't gotten that working yet.

Nevermind, my elisp skills are rusty (file "path/to/template.org") works fine,
what I was trying to do required lisp code evaluation in that context and
therefore didn't work eg: (file (concat org-directory "/template.org")) to do
that I'd have to use (function function-returning-the-template), but it's not
really worth it for what I was trying to do.

~>Bill

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

* Re: create new files from capture
  2011-04-20 19:22     ` Bill Wishon
@ 2011-04-20 19:44       ` Nick Dokos
  0 siblings, 0 replies; 6+ messages in thread
From: Nick Dokos @ 2011-04-20 19:44 UTC (permalink / raw)
  To: Bill Wishon; +Cc: nicholas.dokos, emacs-orgmode

Bill Wishon <bill@wishon.org> wrote:

> Bill Wishon <bill <at> wishon.org> writes:
> 
> > What I'm trying to figure out now is how to read the template from a file.  
> > The documentation says that it can be done by using (file "path/to/file") 
> > in place of the template text argument, but I haven't gotten that working yet.
> 
> Nevermind, my elisp skills are rusty (file "path/to/template.org") works fine,
> what I was trying to do required lisp code evaluation in that context and
> therefore didn't work eg: (file (concat org-directory "/template.org")) to do
> that I'd have to use (function function-returning-the-template), but it's not
> really worth it for what I was trying to do.
> 

Alternatively, you can use the backquote mechanism - see e.g.

   http://thread.gmane.org/gmane.emacs.orgmode/17612/focus=17620

Nick

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

end of thread, other threads:[~2011-04-20 19:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-01 17:43 create new files from capture Buck Brody
2011-04-04 19:12 ` David Maus
2011-04-04 19:49   ` Matthew Sauer
2011-04-20 19:00   ` Bill Wishon
2011-04-20 19:22     ` Bill Wishon
2011-04-20 19:44       ` Nick Dokos

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.