Re: [O] Best way to implement project specific captures

2012-08-26 Thread Richard Riley
Bastien b...@altern.org writes:

 Hi Richard,

 Richard Riley rile...@gmail.com writes:

 ALso it would be really really nice if it would
 use the existing org file if that file is on the agenda list and I dont
 specify a path component on the destination file variable in the
 template.

 Mhh... can't parse this, sorry :/

 Can you re-explain again what you want?

If you see my initial reply about which file is used to add the
capture, its explained there - does this make sense?

,
|  I'm not sure if the error (?!) is mine or on your side - possibly error
|  is the wrong word. See this img here
| 
|  http://i.imgur.com/Tvdgx.png
| 
|  When I hit C-c c I then hit c for my customised j template  its
|  recreating shamrock/barwebs.org (see status line) as opposed to using
|  the existing barwebs.com which I have referenced via  org-agenda-files
|^^^ this should say barwebs.org of course, sorry for 
the confusion.  
|  '(~/.orgfiles ~/webs/.orgfiles).
| 
|  Can you advise further? (Looks great regardless btw!)
`

The reply is that I should hard code the path but I'm really averse to
this. 




Re: [O] Best way to implement project specific captures

2012-08-24 Thread Bastien
Richard Riley rile...@gmail.com writes:

 I see Bastien and Carsten are in on the thread too, I'll step back and
 see in what direction this now goes ;) Thanks again for the great
 feature!

This is how it works right now.

For each agenda custom command or capture template, you can define 
a context where it will be accessible.

E.g. you have these custom commands:

(setq org-agenda-custom-commands
  '((A  ...)
(B  ...)))

But you don't need B in .txt files:

(setq org-agenda-custom-commands-contexts
  '((B ((not-in-file . \.txt)

That's it.

Or maybe you want B to be accessible with the A key (and 
don't want the A key):

(setq org-agenda-custom-commands-contexts
  '((A B ((not-in-file . \.txt)

Or maybe you want B to be accessible only in your first two
hours of using Emacs...

(defun less-than-nhours-of-emacs-uptime (optional n)
 (interactive P)
 (let ((n (or n 2)))
   ( (time-to-seconds (time-subtract (current-time) before-init-time))
  (* n 3600

(setq org-agenda-custom-commands-contexts
  '((B (less-then-nhours-of-emacs-uptime

Enjoy,

-- 
 Bastien



Re: [O] Best way to implement project specific captures

2012-08-24 Thread Richard Riley
Bastien b...@altern.org writes:

 Richard Riley rile...@gmail.com writes:

 I see Bastien and Carsten are in on the thread too, I'll step back and
 see in what direction this now goes ;) Thanks again for the great
 feature!

 This is how it works right now.

 For each agenda custom command or capture template, you can define 
 a context where it will be accessible.

 E.g. you have these custom commands:

 (setq org-agenda-custom-commands
   '((A  ...)
   (B  ...)))

 But you don't need B in .txt files:

 (setq org-agenda-custom-commands-contexts
   '((B ((not-in-file . \.txt)

 That's it.

 Or maybe you want B to be accessible with the A key (and 
 don't want the A key):

Im not sure I follow that.


 (setq org-agenda-custom-commands-contexts
   '((A B ((not-in-file . \.txt)

 Or maybe you want B to be accessible only in your first two
 hours of using Emacs...

 (defun less-than-nhours-of-emacs-uptime (optional n)
  (interactive P)
  (let ((n (or n 2)))
( (time-to-seconds (time-subtract (current-time) before-init-time))
   (* n 3600

 (setq org-agenda-custom-commands-contexts
   '((B (less-then-nhours-of-emacs-uptime

 Enjoy,

Hi, my head isnt really in org mode (oops!) at the moment, how would I
then implement the template for files under this directory as
originally mentioned? ALso it would be really really nice if it would
use the existing org file if that file is on the agenda list and I dont
specify a path component on the destination file variable in the
template.

THanks!

r,





Re: [O] Best way to implement project specific captures

2012-08-24 Thread Bastien
Hi Richard,

Richard Riley rile...@gmail.com writes:

 Hi, my head isnt really in org mode (oops!) at the moment, how would I
 then implement the template for files under this directory as
 originally mentioned?

The in-file and not-in-file conditions use regexp and expanded file
names.  You can use your directory as the regexp, it will be okay.

-- 
 Bastien



Re: [O] Best way to implement project specific captures

2012-08-24 Thread Bastien
Hi Richard,

Richard Riley rile...@gmail.com writes:

 ALso it would be really really nice if it would
 use the existing org file if that file is on the agenda list and I dont
 specify a path component on the destination file variable in the
 template.

Mhh... can't parse this, sorry :/

Can you re-explain again what you want?

-- 
 Bastien



Re: [O] Best way to implement project specific captures

2012-08-23 Thread Sylvain Rousseau
It is an org-capture issue. You have to specify the full path of the org
file in the template even if this file is an agenda file. Otherwise
org-capture assumes that the file is located in `org-directory'.


 Can you advise further? (Looks great regardless btw!)

Thank you, building on Bastien's suggestion I'm working on a stealing
feature, that steals templates from `org-capture-templates' and changes the
target.

Sylvain.


Re: [O] Best way to implement project specific captures

2012-08-23 Thread Bastien
Sylvain Rousseau this...@gmail.com writes:

 One possible enhancement: allow using only the capture/agenda
 template instead of the full template in
 `org-context-capture-alist'
 and `org-context-agenda-alist'.

 Good idea! Adding it to my todo list with org-context ;-)

Actually I love your idea so much I just implemented it in core.

See these new options:

  org-agenda-custom-commands-contexts
  org-capture-templates-contexts

The basic idea is the same than yours, except you only need to
define rules for the agenda/capture keys.  It's also extending
the notion of context by allowing to check against modes, not
only files.

Please let me know what do you think.  And thanks again for this
simple and beautiful idea.

-- 
 Bastien



Re: [O] Best way to implement project specific captures

2012-08-23 Thread Carsten Dominik
Hi Sylvain and Bastien,

this is an interesting idea!

I am wondering if the following feature would be useful as well:  Context 
sensitivity sounds most interesting to me if the same key would do different 
things in different contexts.  I am not sure if this is possible with the 
current implementation?  For example, I might want to have a bug recording key 
which creates an entry in a bug tracker file, but the file is different for 
different source files, and also the template and target type definitions might 
be different in different contexts.

That would require a setup which defines a selection letter, and then an a list 
of (sets of) conditions and the corresponding template definition.

Or am I going overboard here?

- Carsten

On 23 aug. 2012, at 11:13, Bastien b...@altern.org wrote:

 Sylvain Rousseau this...@gmail.com writes:
 
 One possible enhancement: allow using only the capture/agenda
 template instead of the full template in
 `org-context-capture-alist'
 and `org-context-agenda-alist'.
 
 Good idea! Adding it to my todo list with org-context ;-)
 
 Actually I love your idea so much I just implemented it in core.
 
 See these new options:
 
  org-agenda-custom-commands-contexts
  org-capture-templates-contexts
 
 The basic idea is the same than yours, except you only need to
 define rules for the agenda/capture keys.  It's also extending
 the notion of context by allowing to check against modes, not
 only files.
 
 Please let me know what do you think.  And thanks again for this
 simple and beautiful idea.
 
 -- 
 Bastien
 

- Carsten






Re: [O] Best way to implement project specific captures

2012-08-23 Thread Jambunathan K

May be dir local variables could be used?

Carsten Dominik carsten.domi...@gmail.com writes:

 Hi Sylvain and Bastien,

 this is an interesting idea!

 I am wondering if the following feature would be useful as well:
 Context sensitivity sounds most interesting to me if the same key
 would do different things in different contexts.  I am not sure if
 this is possible with the current implementation?  For example, I
 might want to have a bug recording key which creates an entry in a bug
 tracker file, but the file is different for different source files,
 and also the template and target type definitions might be different
 in different contexts.

 That would require a setup which defines a selection letter, and then
 an a list of (sets of) conditions and the corresponding template
 definition.

 Or am I going overboard here?

 - Carsten

 On 23 aug. 2012, at 11:13, Bastien b...@altern.org wrote:

 Sylvain Rousseau this...@gmail.com writes:
 
 One possible enhancement: allow using only the capture/agenda
 template instead of the full template in
 `org-context-capture-alist'
 and `org-context-agenda-alist'.
 
 Good idea! Adding it to my todo list with org-context ;-)
 
 Actually I love your idea so much I just implemented it in core.
 
 See these new options:
 
  org-agenda-custom-commands-contexts
  org-capture-templates-contexts
 
 The basic idea is the same than yours, except you only need to
 define rules for the agenda/capture keys.  It's also extending
 the notion of context by allowing to check against modes, not
 only files.
 
 Please let me know what do you think.  And thanks again for this
 simple and beautiful idea.
 
 -- 
 Bastien
 

 - Carsten






-- 



Re: [O] Best way to implement project specific captures

2012-08-23 Thread Bastien
Hi Carsten,

Carsten Dominik carsten.domi...@gmail.com writes:

 I am wondering if the following feature would be useful as well: Context
 sensitivity sounds most interesting to me if the same key would do
 different things in different contexts.  I am not sure if this is possible
 with the current implementation?  For example, I might want to have a bug
 recording key which creates an entry in a bug tracker file, but the file is
 different for different source files, and also the template and target type
 definitions might be different in different contexts.

 That would require a setup which defines a selection letter, and then an a
 list of (sets of) conditions and the corresponding template
 definition.

I implemented this, relying on the existing contexts options.

Please have a go with the attached patch.  I copy the comment
from the commit log:

In the setup below, X is not a real capture template, it is just
an alias to templates A and B in .txt and .el files.  A and B are
deactivated by default in all files.

(setq org-capture-templates
  '((X Nothing but an alias)
(A  entry (file+headline [...]))
(B  entry (file+headline [...]

(setq org-capture-templates-contexts
  '((A A ((not-in-file . .*)))
(B B ((not-in-file . .*)))
(X A ((in-file . \\.txt)))
(X B ((in-file . \\.el)

I find this quite handy...  let me know what you think!

From c191d48aa1f2eb6c28fe2503b6b039265fb1da1e Mon Sep 17 00:00:00 2001
From: Bastien Guerry b...@altern.org
Date: Thu, 23 Aug 2012 17:04:43 +0200
Subject: [PATCH] Implement key replacement depending on the contexts.

* org.el (org-contextualize-agenda-or-capture): Handle key
replacement depending on the contexts.

* org-capture.el (org-capture-templates-contexts): Allow to
use the context as a way to replace one capture template by
another one.

* org-agenda.el (org-agenda-custom-commands-contexts): Allow
to use the context as a way to replace one agenda custom
command by another one.

* org.texi (Templates in contexts): Document the new structure
of the variables `org-agenda-custom-commands-contexts' and
`org-capture-templates-contexts'.

In the setup below, X is not a real capture template, it is just
an alias to templates A and B in .txt and .el files.  A and B are
deactivated by default in all files.

(setq org-capture-templates
  '((X Nothing but an alias)
	(A  entry (file+headline [...]))
	(B  entry (file+headline [...]

(setq org-capture-templates-contexts
  '((A A ((not-in-file . .*)))
	(B B ((not-in-file . .*)))
	(X A ((in-file . \\.txt)))
	(X B ((in-file . \\.el)

Thanks to Carsten for suggesting this key-replacement idea!
---
 doc/org.texi|   16 +---
 lisp/org-agenda.el  |   20 +---
 lisp/org-capture.el |   22 ++
 lisp/org.el |   40 +++-
 4 files changed, 79 insertions(+), 19 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 897115c..3ec72b3 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -6863,10 +6863,14 @@ for example that you have a capture template @code{p} for storing Gnus
 emails containing patches.  Then you would configure this option like this:
 
 @example
-(setq org-capture-templates-contexts '((p (in-mode . message-mode
+(setq org-capture-templates-contexts
+  '((p p (in-mode . message-mode
 @end example
 
-See the docstring of the variable for more information.
+The second @code{p} tells what template to really call in the specified
+context.  You can set this to another capture template, so that @code{p} will
+transparently fall back on it.  See the docstring of the variable for more
+information.
 
 @node Attachments, RSS Feeds, Capture, Capture - Refile - Archive
 @section Attachments
@@ -8778,9 +8782,15 @@ that you only need when reading emails.  Then you would configure this option
 like this:
 
 @example
-(setq org-agenda-custom-commands-contexts '((o (in-mode . message-mode
+(setq org-agenda-custom-commands-contexts
+  '((o o (in-mode . message-mode
 @end example
 
+The second @code{o} tells what command to really call in the specified
+context.  You can set this to another agenda custom command, so that @code{o}
+will transparently fall back on it.  See the docstring of the variable for
+more information.
+
 See the docstring of the variable for more information.
 
 @node Exporting Agenda Views, Agenda column view, Custom agenda views, Agenda Views
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 9c7f29b..563ed3f 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2341,9 +2341,22 @@ For example, if you have a custom agenda command \p\ and you
 want this command to be accessible only from plain text files,
 use this:
 
-   '((\p\ (in-file . \\\.txt\)))
+   '((\p\ \p\ (in-file . \\\.txt\)))
 
-Here are the available checks:
+If you replace the second \p\ by another key (say \q\), then
+the \p\ key will be 

Re: [O] Best way to implement project specific captures

2012-08-23 Thread Sylvain Rousseau
2012/8/23 Carsten Dominik carsten.domi...@gmail.com:
 I am wondering if the following feature would be useful as well:  Context 
 sensitivity sounds most interesting to me if the same key would do different 
 things in different contexts.  I am not sure if this is possible with the 
 current implementation?  For example, I might want to have a bug recording 
 key which creates an entry in a bug tracker file, but the file is different 
 for different source files, and also the template and target type definitions 
 might be different in different contexts.

For what it's worth I have pushed changes to github implementing this
and offering the choice to override templates or put them in a submenu
as well as a stealing mechanism to modify existing templates'
target.

I do not have access to Bastien's changes yet but from what I
understood we might run out of letters to identify templates. For
example, if we have 10 projects with 3 different templates each, we
already have 30 items in `org-capture-templates'... Or did I miss
something?

Anyway, I'm glad to see that this feature will be in a future org release!

Sylvain.



Re: [O] Best way to implement project specific captures

2012-08-23 Thread Richard Riley
Sylvain Rousseau this...@gmail.com writes:

 It is an org-capture issue. You have to specify the full path of the org file 
 in the template even if this file is an agenda
 file. Otherwise org-capture assumes that the file is located in
 `org-directory'.

with no path to use the existing one would be a real boon and
certainly works for the original journal template capture. I dont know
about the implementation details but no path == loaded file would make
sense with the user wanting specific files then hard code it. 

I see Bastien and Carsten are in on the thread too, I'll step back and
see in what direction this now goes ;) Thanks again for the great
feature!



 Can you advise further? (Looks great regardless btw!)

 Thank you, building on Bastien's suggestion I'm working on a stealing 
 feature, that steals templates from
 `org-capture-templates' and changes the target.

 Sylvain.





Re: [O] Best way to implement project specific captures

2012-08-22 Thread Sylvain Rousseau
Have a look at https://github.com/thisirs/org-context : Context agenda and
capture for Org-mode

It dynamically adds templates depending on the buffer you are currently
editing. New templates are available with the key c or merged if there is
no conflict with existing ones.

Hope this helps,


Sylvain.


Re: [O] Best way to implement project specific captures

2012-08-22 Thread Bastien
Hi Sylvain,

Sylvain Rousseau this...@gmail.com writes:

 Have a look at https://github.com/thisirs/org-context : Context
 agenda and capture for Org-mode

I *love* it!  This would be a great addition to contrib/lisp/ -- 
doors are open, just ring the bell.

One possible enhancement: allow using only the capture/agenda 
template instead of the full template in `org-context-capture-alist'
and `org-context-agenda-alist'.

For example, it would be easy to read/write

(setq org-context-capture-alist
  '((*el  . (a b))
(*org . (c d

`a' and `b' being templates (triggered in *el files) already 
defined in `org-capture-templates'.

I guess this would speed up adoption of org-context...  but again, 
thanks for this!

-- 
 Bastien



Re: [O] Best way to implement project specific captures

2012-08-22 Thread Bastien
Bastien b...@altern.org writes:

 allow using only the capture/agenda 
 template instead of the full template

Of course, this should read:

... template letter instead of the full template definition.

-- 
 Bastien



Re: [O] Best way to implement project specific captures

2012-08-22 Thread Sylvain Rousseau
 One possible enhancement: allow using only the capture/agenda
 template instead of the full template in `org-context-capture-alist'
 and `org-context-agenda-alist'.

Good idea! Adding it to my todo list with org-context ;-)

If you think this addon deserves to be added to the contrib directory, feel
free to add it!


Sylvain.


Re: [O] Best way to implement project specific captures

2012-08-22 Thread Richard Riley
Sylvain Rousseau this...@gmail.com writes:

 Have a look at https://github.com/thisirs/org-context : Context agenda and 
 capture for Org-mode

 It dynamically adds templates depending on the buffer you are currently 
 editing. New templates are available with the key
 c or merged if there is no conflict with existing ones.

 Hope this helps,

 Sylvain.


Org and its users/contributors never cease to impress me!

Thanks!




Re: [O] Best way to implement project specific captures

2012-08-22 Thread Richard Riley
Sylvain Rousseau this...@gmail.com writes:

 Have a look at https://github.com/thisirs/org-context : Context agenda and 
 capture for Org-mode

 It dynamically adds templates depending on the buffer you are currently 
 editing. New templates are available with the key
 c or merged if there is no conflict with existing ones.

 Hope this helps,

 Sylvain.


Hi,

I'm not sure if the error (?!) is mine or on your side - possibly error
is the wrong word. See this img here

http://i.imgur.com/Tvdgx.png

When I hit C-c c I then hit c for my customised j template  its
recreating shamrock/barwebs.org (see status line) as opposed to using
the existing barwebs.com which I have referenced via  org-agenda-files
'(~/.orgfiles ~/webs/.orgfiles).

Can you advise further? (Looks great regardless btw!)




-- 
Sent using Emacs/Gnus from home ...




Re: [O] Best way to implement project specific captures

2012-08-22 Thread Richard Riley
Richard Riley rile...@gmail.com writes:

 Sylvain Rousseau this...@gmail.com writes:

 Have a look at https://github.com/thisirs/org-context : Context agenda and 
 capture for Org-mode

 It dynamically adds templates depending on the buffer you are currently 
 editing. New templates are available with the key
 c or merged if there is no conflict with existing ones.

 Hope this helps,

 Sylvain.


 Hi,

 I'm not sure if the error (?!) is mine or on your side - possibly error
 is the wrong word. See this img here

 http://i.imgur.com/Tvdgx.png

 When I hit C-c c I then hit c for my customised j template  its
 recreating shamrock/barwebs.org (see status line) as opposed to using
 the existing barwebs.com which I have referenced via  org-agenda-files
   ^^^ this should say barwebs.org of course, sorry for the 
confusion.  
 '(~/.orgfiles ~/webs/.orgfiles).

 Can you advise further? (Looks great regardless btw!)




[O] Best way to implement project specific captures

2012-08-21 Thread Richard Riley

Currently I maintain a datetree journal capture using a template so

,
| (j journal entry (file+datetree journal.org)
|  * %?\n\t:PROPERTIES:\n\t:DateCreated: 
%T\n\t:Link: %a\n\t:END:\n)
`

I also use j rockways' eproject set up that allows a hook to be run when
a file is opened inside a project. e.g

,
| (add-hook 'web-project-file-visit-hook '(lambda ()
| (ignore-errors
|   (message Web Project : %s 
eproject-root)
|   )))
`

where web-project is created this:-

,
| (define-project-type web (generic)
|   (look-for plan.org)
|   :relevant-files (\\.php$ \\.js$ \\.org$ \\.sql$ \\.css$ 
authinfo vhost))
`

So whenever I open a file in a directory hierarchy which contains a
plan.org matching those types then my web-project-file-visit-hook is run.

What is the best emacs/elisp approach to setting a capture file
destination specific to a particular project? THe main point being that
the default capture template above should only be replaced if I am
actually in a project : any capture done in a file NOT contained
within a project should default to the capture template above. Is it
someting to do with buffer-locals perhaps or is there a
better/alternative way? e.g Perhaps journal.org becomes a variable and
this is overwritten (or whatever the elisp jargon is) in the project
hook as a buffer local?

Hope was clear!

regards

r.