emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* `org-capture' loads all the files in `org-directory'
@ 2022-07-16 22:53 Noel Errenil
  2022-07-17  8:16 ` Bruno Barbier
  2022-07-18  3:25 ` Ihor Radchenko
  0 siblings, 2 replies; 5+ messages in thread
From: Noel Errenil @ 2022-07-16 22:53 UTC (permalink / raw)
  To: emacs-orgmode

Hello, org community

I ran into the titled issue and haven't found any solution or explanation:

First, I start Emacs and there are just a few buffers such as *scratch* and
*Messages*.

Then, I fire `org-capture', captur a note and `C-c C-c' to save the captured
content.

Suddenly all the files under ~/projects/org will be loaded into the buffer
list, which confuses me so much. Those that have nothing to do with
capturing or capture-templates are loaded into Emacs, which makes
little sense to me.

I'm running Emacs 28.1 on (Gentoo) Linux. I can reproduce this on my
macOS too.

Currently I have `org-directory' set to `~/projects/org'. My
`org-capture' config is as follows:

;; vars
(with-eval-after-load 'org
  (setq-default fill-column 80)
  (setq
   org-deadline-warning-days 0
   org-startup-folded 'content
   org-hide-leading-stars t
   org-agenda-include-diary t
   org-src-fontify-natively t
   org-src-preserve-indentation t
   org-edit-source-content-indentation 0
   org-indent-indentation-per-level 1
   org-directory "~/projects/org"
   org-agenda-files (concat org-directory "/agenda.org")
   org-default-notes-file (concat org-directory "/notes.org")))

;; org-capture templates
(setq org-capture-templates
      '(("t" "Tasks")
        ("td" "With Dealines" entry     ; todos->deadline
               (file+headline "tasks.org" "Deadlines")
               "* TODO %? %^G\nDEADLINE: %T" :kill-buffer t :prepend t)
        ("ts" "Scheduled" entry         ; todos->scheduled
               (file+headline "tasks.org" "TODOS")
               "* TODO %? %^G\nSCHEDULED: %T" :kill-buffer t :prepend t)
        ;; memos
        ("m" "Memo" entry
         (file+headline "memo.org" "MEMO")
         "* %? %^G\n%U" :kill-buffer t :prepend t)
        ;; notes
        ("n" "Daily Notes" entry
         (file+headline "notes.org" "NOTES")
         "* %? %^G\n%U" :kill-buffer t :prepend t)
        ;; readings
        ("r" "Readings")
        ("ra" "Article" entry
         (file+headline "readings.org" "ARTICLE")
         "* TODO %^{Short title for heading} %^G \nTTL: %^{Long title}
\nSRC: %^{Link} \n%u \nSUM: %^{Quick note?}"
         :kill-buffer t)
        ("rb" "Book" entry
         (file+headline "readings.org" "BOOK")
         "* TODO %^{Short title for heading} %^G \nTTL: %^{Long title}
\nSRC: %^{Link} \n%u \nSUM: %^{Quick note?}"
         :kill-buffer t)))

I just expect that only the capture template will be loaded during capturing
and the template buffer should be killed (as config-ed) after capturing.

What am I doing wrong? Any advice? Thank you so much in advance.


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

* Re: `org-capture' loads all the files in `org-directory'
  2022-07-16 22:53 `org-capture' loads all the files in `org-directory' Noel Errenil
@ 2022-07-17  8:16 ` Bruno Barbier
  2022-07-18  3:25 ` Ihor Radchenko
  1 sibling, 0 replies; 5+ messages in thread
From: Bruno Barbier @ 2022-07-17  8:16 UTC (permalink / raw)
  To: errelinaaron, emacs-orgmode

Noel Errenil <errelinaaron@gmail.com> writes:

> Hello, org community
>
> I ran into the titled issue and haven't found any solution or explanation:
>
> First, I start Emacs and there are just a few buffers such as *scratch* and
> *Messages*.
>
> Then, I fire `org-capture', captur a note and `C-c C-c' to save the captured
> content.
>
> Suddenly all the files under ~/projects/org will be loaded into the buffer
> list, which confuses me so much. Those that have nothing to do with
> capturing or capture-templates are loaded into Emacs, which makes
> little sense to me.
>

FWIW, in my case, org seems to open org files that are necessary to
identify the capture target, like when refiling somewhere else. Using
`C-c C-c', org does not open other files though, just the targetted one.

Cleaning up your org agenda files, if possible, might reduce the number
of files org needs to load.

  (customize-option 'org-agenda-files)

Bruno

> I'm running Emacs 28.1 on (Gentoo) Linux. I can reproduce this on my
> macOS too.
>
> Currently I have `org-directory' set to `~/projects/org'. My
> `org-capture' config is as follows:
>
> ;; vars
> (with-eval-after-load 'org
>   (setq-default fill-column 80)
>   (setq
>    org-deadline-warning-days 0
>    org-startup-folded 'content
>    org-hide-leading-stars t
>    org-agenda-include-diary t
>    org-src-fontify-natively t
>    org-src-preserve-indentation t
>    org-edit-source-content-indentation 0
>    org-indent-indentation-per-level 1
>    org-directory "~/projects/org"
>    org-agenda-files (concat org-directory "/agenda.org")
>    org-default-notes-file (concat org-directory "/notes.org")))
>
> ;; org-capture templates
> (setq org-capture-templates
>       '(("t" "Tasks")
>         ("td" "With Dealines" entry     ; todos->deadline
>                (file+headline "tasks.org" "Deadlines")
>                "* TODO %? %^G\nDEADLINE: %T" :kill-buffer t :prepend t)
>         ("ts" "Scheduled" entry         ; todos->scheduled
>                (file+headline "tasks.org" "TODOS")
>                "* TODO %? %^G\nSCHEDULED: %T" :kill-buffer t :prepend t)
>         ;; memos
>         ("m" "Memo" entry
>          (file+headline "memo.org" "MEMO")
>          "* %? %^G\n%U" :kill-buffer t :prepend t)
>         ;; notes
>         ("n" "Daily Notes" entry
>          (file+headline "notes.org" "NOTES")
>          "* %? %^G\n%U" :kill-buffer t :prepend t)
>         ;; readings
>         ("r" "Readings")
>         ("ra" "Article" entry
>          (file+headline "readings.org" "ARTICLE")
>          "* TODO %^{Short title for heading} %^G \nTTL: %^{Long title}
> \nSRC: %^{Link} \n%u \nSUM: %^{Quick note?}"
>          :kill-buffer t)
>         ("rb" "Book" entry
>          (file+headline "readings.org" "BOOK")
>          "* TODO %^{Short title for heading} %^G \nTTL: %^{Long title}
> \nSRC: %^{Link} \n%u \nSUM: %^{Quick note?}"
>          :kill-buffer t)))
>
> I just expect that only the capture template will be loaded during capturing
> and the template buffer should be killed (as config-ed) after capturing.
>
> What am I doing wrong? Any advice? Thank you so much in advance.


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

* Re: `org-capture' loads all the files in `org-directory'
  2022-07-16 22:53 `org-capture' loads all the files in `org-directory' Noel Errenil
  2022-07-17  8:16 ` Bruno Barbier
@ 2022-07-18  3:25 ` Ihor Radchenko
  2022-07-19  4:48   ` Noel Errenil
  1 sibling, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2022-07-18  3:25 UTC (permalink / raw)
  To: errelinaaron; +Cc: emacs-orgmode

Noel Errenil <errelinaaron@gmail.com> writes:

> ...
> Then, I fire `org-capture', captur a note and `C-c C-c' to save the captured
> content.
>
> Suddenly all the files under ~/projects/org will be loaded into the buffer
> list, which confuses me so much. Those that have nothing to do with
> capturing or capture-templates are loaded into Emacs, which makes
> little sense to me.
> ...
> Currently I have `org-directory' set to `~/projects/org'. My
> `org-capture' config is as follows:
> ...
>    org-default-notes-file (concat org-directory "/notes.org")))
> ...
>         ("td" "With Dealines" entry     ; todos->deadline
>                (file+headline "tasks.org" "Deadlines")
>                "* TODO %? %^G\nDEADLINE: %T" :kill-buffer t :prepend t)

Note that you are using %^G, while implies (see org-capture-templates docstring):

  %^G         Prompt for tags, with completion on all tags in all agenda files.
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> I just expect that only the capture template will be loaded during capturing
> and the template buffer should be killed (as config-ed) after capturing.

Only the capture template is actually loaded. However, providing tag
completion for %^G requires Org to scan all the agenda files for
possible tags. Hence, agenda files must be opened and examined.

The reason why the capture target buffer and the agenda file buffers are
not closed is efficiency. Opening all the agenda files may take
considerable amount of time and hence it is generally better to keep
them open for future use. We might change it in future or provide an
option to close the opened files if there is enough interest. Feel free
to write a feature request - we will judge the number of user responses
to the request.

> What am I doing wrong? Any advice? Thank you so much in advance.

You may either not use global tag completion (use %^g instead %^G in
your templates) or advice org-capture to close the opened files.

Best,
Ihor


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

* Re: `org-capture' loads all the files in `org-directory'
  2022-07-18  3:25 ` Ihor Radchenko
@ 2022-07-19  4:48   ` Noel Errenil
  2022-07-20  7:19     ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Noel Errenil @ 2022-07-19  4:48 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Hi Ihor,

> ...
> Note that you are using %^G, while implies (see org-capture-templates docstring):
>
> %^G         Prompt for tags, with completion on all tags in all agenda files.
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Thank you so much for the help. You are absolutely right!

> Only the capture template is actually loaded. However, providing tag
> completion for %^G requires Org to scan all the agenda files for
> possible tags. Hence, agenda files must be opened and examined.

This is an oversight and misunderstanding by me. Really appreciate your
explanation.


> The reason why the capture target buffer and the agenda file buffers are
> not closed is efficiency. Opening all the agenda files may take
> considerable amount of time and hence it is generally better to keep
> them open for future use. We might change it in future or provide an
> option to close the opened files if there is enough interest. Feel free
> to write a feature request - we will judge the number of user responses
> to the request.

Currently, I'm happy with this behavior. I'll learn how to submit a
feature request
anyway in case in the future I feel a need to.

After your first reply earlier, I came to realize that the pop-up
buffer in which I am
able to select a template is indeed some kind of agenda view/mode. This can be
confirmed by looking up the source code. So my original problem indeed had sth
to do with agenda, not `org-capture'.

Then I found my setting of `org-agenda-files' was indeed wrong:

Sth like:
(setq org-agenda-files ("~/projects/org/agenda.org"))
                                     ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^
empty file at the moment
will actually make the whole ~/projects/org directory as the agenda source,
hence all the files under it will be loaded once agenda function is activated.

I did that, again, because I misunderstood the manual. I should use a
list for agenda files
or a plain text file in which I specify agenda files, one per line.

Hope all the information in this thread will help whoever runs into
the same issue as I did.

Best,
Noel


On Mon, Jul 18, 2022 at 11:24 AM Ihor Radchenko <yantar92@gmail.com> wrote:
>
> Noel Errenil <errelinaaron@gmail.com> writes:
>
> > ...
> > Then, I fire `org-capture', captur a note and `C-c C-c' to save the captured
> > content.
> >
> > Suddenly all the files under ~/projects/org will be loaded into the buffer
> > list, which confuses me so much. Those that have nothing to do with
> > capturing or capture-templates are loaded into Emacs, which makes
> > little sense to me.
> > ...
> > Currently I have `org-directory' set to `~/projects/org'. My
> > `org-capture' config is as follows:
> > ...
> >    org-default-notes-file (concat org-directory "/notes.org")))
> > ...
> >         ("td" "With Dealines" entry     ; todos->deadline
> >                (file+headline "tasks.org" "Deadlines")
> >                "* TODO %? %^G\nDEADLINE: %T" :kill-buffer t :prepend t)
>
> Note that you are using %^G, while implies (see org-capture-templates docstring):
>
>   %^G         Prompt for tags, with completion on all tags in all agenda files.
>                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> > I just expect that only the capture template will be loaded during capturing
> > and the template buffer should be killed (as config-ed) after capturing.
>
> Only the capture template is actually loaded. However, providing tag
> completion for %^G requires Org to scan all the agenda files for
> possible tags. Hence, agenda files must be opened and examined.
>
> The reason why the capture target buffer and the agenda file buffers are
> not closed is efficiency. Opening all the agenda files may take
> considerable amount of time and hence it is generally better to keep
> them open for future use. We might change it in future or provide an
> option to close the opened files if there is enough interest. Feel free
> to write a feature request - we will judge the number of user responses
> to the request.
>
> > What am I doing wrong? Any advice? Thank you so much in advance.
>
> You may either not use global tag completion (use %^g instead %^G in
> your templates) or advice org-capture to close the opened files.
>
> Best,
> Ihor


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

* Re: `org-capture' loads all the files in `org-directory'
  2022-07-19  4:48   ` Noel Errenil
@ 2022-07-20  7:19     ` Ihor Radchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Ihor Radchenko @ 2022-07-20  7:19 UTC (permalink / raw)
  To: errelinaaron; +Cc: emacs-orgmode

Noel Errenil <errelinaaron@gmail.com> writes:

> Currently, I'm happy with this behavior. I'll learn how to submit a
> feature request
> anyway in case in the future I feel a need to.

Feature request is nothing but an email with justification why some new
feature will be useful for many users.

> After your first reply earlier, I came to realize that the pop-up
> buffer in which I am
> able to select a template is indeed some kind of agenda view/mode. This can be
> confirmed by looking up the source code. So my original problem indeed had sth
> to do with agenda, not `org-capture'.

Nope. It's just that agenda and capture template selection use similar
menus. The reason why Org opened agenda files was solely related to
collection of all the tags and offering them in the completion dialogue
during capture.

> Then I found my setting of `org-agenda-files' was indeed wrong:
>
> Sth like:
> (setq org-agenda-files ("~/projects/org/agenda.org"))
>                                      ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^
> empty file at the moment
> will actually make the whole ~/projects/org directory as the agenda source,
> hence all the files under it will be loaded once agenda function is activated.
>
> I did that, again, because I misunderstood the manual. I should use a
> list for agenda files
> or a plain text file in which I specify agenda files, one per line.

That's one option. Generally, you can check out about the possible
settings for a variable by examining the variable documentation:
<F1> v variable-name <RET>
In your case:
<F1> v org-agenda-files <RET>

Best,
Ihor



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

end of thread, other threads:[~2022-07-20  7:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-16 22:53 `org-capture' loads all the files in `org-directory' Noel Errenil
2022-07-17  8:16 ` Bruno Barbier
2022-07-18  3:25 ` Ihor Radchenko
2022-07-19  4:48   ` Noel Errenil
2022-07-20  7:19     ` Ihor Radchenko

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