emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* collect info from org files in agenda when open?
@ 2013-07-12 22:16 Gregor Zattler
  2013-07-13  8:10 ` Noorul Islam K M
  0 siblings, 1 reply; 7+ messages in thread
From: Gregor Zattler @ 2013-07-12 22:16 UTC (permalink / raw)
  To: emacs-orgmode

Dear org-mod users and developers,

I customized my org-agenda-files variable to contain 4 files.
But I wished I could automatically add org files to the agenda
simply by opening them.  Is it possible to automagically add
some files to the agenda iff they are visited or add the contents
of org-mode buffers?

Ciao, Gregor
-- 
 -... --- .-. . -.. ..--.. ...-.-

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

* Re: collect info from org files in agenda when open?
  2013-07-12 22:16 collect info from org files in agenda when open? Gregor Zattler
@ 2013-07-13  8:10 ` Noorul Islam K M
  2013-07-13  8:33   ` Gregor Zattler
  0 siblings, 1 reply; 7+ messages in thread
From: Noorul Islam K M @ 2013-07-13  8:10 UTC (permalink / raw)
  To: emacs-orgmode

Gregor Zattler <telegraph@gmx.net> writes:

> Dear org-mod users and developers,
>
> I customized my org-agenda-files variable to contain 4 files.
> But I wished I could automatically add org files to the agenda
> simply by opening them.  Is it possible to automagically add
> some files to the agenda iff they are visited or add the contents
> of org-mode buffers?
>

I am not sure whether you already went through contents of this link.

http://orgmode.org/manual/Agenda-files.html

Thanks and Regards
Noorul

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

* Re: collect info from org files in agenda when open?
  2013-07-13  8:10 ` Noorul Islam K M
@ 2013-07-13  8:33   ` Gregor Zattler
  2013-07-13 15:09     ` Eric Abrahamsen
  0 siblings, 1 reply; 7+ messages in thread
From: Gregor Zattler @ 2013-07-13  8:33 UTC (permalink / raw)
  To: emacs-orgmode

Hi Noorul, org-mod users and developers,
* Noorul Islam K M <noorul@noorul.com> [13. Jul. 2013]:
> Gregor Zattler <telegraph@gmx.net> writes:
>> I customized my org-agenda-files variable to contain 4 files.
>> But I wished I could automatically add org files to the agenda
>> simply by opening them.  Is it possible to automagically add
>> some files to the agenda iff they are visited or add the contents
>> of org-mode buffers?
> 
> I am not sure whether you already went through contents of this link.
> 
> http://orgmode.org/manual/Agenda-files.html

Yes I read this part of the manual before posting my question.  

As I understand the manual, I have the possibility to customize a
static list of agenda files in org-agenda-files or to manually
add and remove org files from the agenda or restrict the agenda
manually.
I do not see how to *automatically* add open org-files to the
agenda?  Perhaps I could do this with some hooks?

Actually I think a static list of files which contribute to the
agenda is fine.  
But I wished there was also the ability to define a list of files
which do only contribute to the agenda if already open
(preferably with some pattern matching, so one could customize
org to add any open org file to the agenda).

Ciao, Gregor
-- 
 -... --- .-. . -.. ..--.. ...-.-

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

* Re: collect info from org files in agenda when open?
  2013-07-13  8:33   ` Gregor Zattler
@ 2013-07-13 15:09     ` Eric Abrahamsen
  2013-07-14 14:11       ` automagically add/remove org mode buffers to agenda files list (was: Re: collect info from org files in agenda when open?) Gregor Zattler
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Abrahamsen @ 2013-07-13 15:09 UTC (permalink / raw)
  To: emacs-orgmode

Gregor Zattler <telegraph@gmx.net> writes:

> Hi Noorul, org-mod users and developers,
> * Noorul Islam K M <noorul@noorul.com> [13. Jul. 2013]:
>> Gregor Zattler <telegraph@gmx.net> writes:
>>> I customized my org-agenda-files variable to contain 4 files.
>>> But I wished I could automatically add org files to the agenda
>>> simply by opening them.  Is it possible to automagically add
>>> some files to the agenda iff they are visited or add the contents
>>> of org-mode buffers?
>> 
>> I am not sure whether you already went through contents of this link.
>> 
>> http://orgmode.org/manual/Agenda-files.html
>
> Yes I read this part of the manual before posting my question.  
>
> As I understand the manual, I have the possibility to customize a
> static list of agenda files in org-agenda-files or to manually
> add and remove org files from the agenda or restrict the agenda
> manually.
> I do not see how to *automatically* add open org-files to the
> agenda?  Perhaps I could do this with some hooks?
>
> Actually I think a static list of files which contribute to the
> agenda is fine.  
> But I wished there was also the ability to define a list of files
> which do only contribute to the agenda if already open
> (preferably with some pattern matching, so one could customize
> org to add any open org file to the agenda).
>
> Ciao, Gregor

You could certainly do this with a function attached to
`find-file-hook'. In the function, check if (buffer-file-name) ends in
".org": if it does, then `org-agenda-file-to-front' and you're good to
go.

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

* automagically add/remove org mode buffers to agenda files list (was: Re: collect info from org files in agenda when open?)
  2013-07-13 15:09     ` Eric Abrahamsen
@ 2013-07-14 14:11       ` Gregor Zattler
  2013-07-14 14:22         ` Drew Adams
  0 siblings, 1 reply; 7+ messages in thread
From: Gregor Zattler @ 2013-07-14 14:11 UTC (permalink / raw)
  To: emacs-orgmode, help-gnu-emacs

Hi Eric, org-mod users and developers,
* Eric Abrahamsen <eric@ericabrahamsen.net> [13. Jul. 2013]:
> Gregor Zattler <telegraph@gmx.net> writes:
>> But I wished there was also the ability to define a list of files
>> which do only contribute to the agenda if already open
>> (preferably with some pattern matching, so one could customize
>> org to add any open org file to the agenda).
> 
> You could certainly do this with a function attached to
> `find-file-hook'. In the function, check if (buffer-file-name) ends in
> ".org": if it does, then `org-agenda-file-to-front' and you're good to
> go.

Your answer motivated me to play with org-mode-hook.  Now I have
the following as part of my init.el:

; start with diary in agenda
(setq org-agenda-files '("~/org/diary.org"))
; automatically add org files to agenda
(add-hook 'org-mode-hook 'org-agenda-file-to-front)
; automagically remove killed org buffers from agenda files list
(add-hook 'kill-buffer-hook 'org-remove-file)

But the last hook does not work as espected.  Instead it says
"Current buffer does not visit a file".  But according to the
documentation kill-buffer-hook is run before the buffer is
actually killed and the buffer is current when calling the hook.
Any ideas what I'm doing wrong?


Ciao, Gregor
-- 
 -... --- .-. . -.. ..--.. ...-.-

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

* RE: automagically add/remove org mode buffers to agenda files list (was: Re: collect info from org files in agenda when open?)
  2013-07-14 14:11       ` automagically add/remove org mode buffers to agenda files list (was: Re: collect info from org files in agenda when open?) Gregor Zattler
@ 2013-07-14 14:22         ` Drew Adams
  2013-07-23 11:06           ` Gregor Zattler
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2013-07-14 14:22 UTC (permalink / raw)
  To: Gregor Zattler, emacs-orgmode, help-gnu-emacs

> (add-hook 'kill-buffer-hook 'org-remove-file)
> 
> But the last hook does not work as espected.  Instead it says
> "Current buffer does not visit a file".  But according to the
> documentation kill-buffer-hook is run before the buffer is
> actually killed and the buffer is current when calling the hook.
> Any ideas what I'm doing wrong?

I have no idea what `org-remove-file' does, but if it expects
the current buffer to be visiting a file then that explains
your problem.  `kill-buffer-hook' is run whenever ANY buffer is
killed, not just a buffer visiting a file.  And Emacs uses lots
of buffers that are not visiting files.

What you can do is use a different function, `foo', that first
tests whether the current buffer is the kind of buffer you want
to apply `org-remove-file' to, and if so invoke that, and if not
do nothing.

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

* Re: automagically add/remove org mode buffers to agenda files list (was: Re: collect info from org files in agenda when open?)
  2013-07-14 14:22         ` Drew Adams
@ 2013-07-23 11:06           ` Gregor Zattler
  0 siblings, 0 replies; 7+ messages in thread
From: Gregor Zattler @ 2013-07-23 11:06 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-orgmode

Hi Drew, org-mode-community,
* Drew Adams <drew.adams@oracle.com> [14. Jul. 2013]:
>> (add-hook 'kill-buffer-hook 'org-remove-file)
>> 
>> But the last hook does not work as espected.  Instead it says
>> "Current buffer does not visit a file".  But according to the
>> documentation kill-buffer-hook is run before the buffer is
>> actually killed and the buffer is current when calling the hook.
>> Any ideas what I'm doing wrong?
> 
> I have no idea what `org-remove-file' does, but if it expects
> the current buffer to be visiting a file then that explains
> your problem.  `kill-buffer-hook' is run whenever ANY buffer is
> killed, not just a buffer visiting a file.  And Emacs uses lots
> of buffers that are not visiting files.
> 
> What you can do is use a different function, `foo', that first
> tests whether the current buffer is the kind of buffer you want
> to apply `org-remove-file' to, and if so invoke that, and if not
> do nothing.

Thanks, this helped.  

For the record: I wrote function which tests if the current
buffer is associated with a file and if it is in org-mode.  Iff
so I remove it from the list of agenda files.



Ciao, Gregor
-- 
 -... --- .-. . -.. ..--.. ...-.-

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

end of thread, other threads:[~2013-07-23 11:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-12 22:16 collect info from org files in agenda when open? Gregor Zattler
2013-07-13  8:10 ` Noorul Islam K M
2013-07-13  8:33   ` Gregor Zattler
2013-07-13 15:09     ` Eric Abrahamsen
2013-07-14 14:11       ` automagically add/remove org mode buffers to agenda files list (was: Re: collect info from org files in agenda when open?) Gregor Zattler
2013-07-14 14:22         ` Drew Adams
2013-07-23 11:06           ` Gregor Zattler

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