9

I'm using org-mode to keep track of the time I spend on various projects. I have one main org file and two more for two large projects I'm working on. All three are listed in org-agenda-files. I created a clock table in the main org file and set

:scope agenda-with-archives

in the clocktable header to summarise the time spent. This all works fine.

However, I also have a few smaller projects that also have time tracked in their own org file (located in the subdirectory that contains everything about those projects), and I'd like to track time in those as well.

Of course I could add those files to org-agenda-files, but that would mean updating my .emacs every time I start a new small project. Not the end of the world of course, but since I already have a link to the small-project-org-files in the main org file (see example below), I'd like to set the :scope to something like

:scope agenda-with-archives linked-org-files

Ideally (although I'm not using that yet) including archive files of those smaller projects would be great to (something like :scope linked-org-files-with-archives).

Here is an example of how my main org file is structured:

* Small project 1
  See file:~/Projects/Project 1/notes_project_1.org for more details.
* Small project 2
  See file:~/Projects/Project 2/notes_project_2.org.
** DONE Some small task I can do quickly
   CLOCK: [2014-12-05 vr 12:19]--[2014-12-05 vr 12:40] =>  0:21
   Some info on the small task.

Any idea on how to achieve this?

2 Answers 2

6

You can use

:scope some-function

where function some-function returns required list of files. For example:

(defun some-function () org-agenda-files)

or

(defun some-function ()
  (append org-agenda-files
          (file-expand-wildcards "your-path/*.org")))
4
  • (defun some-function () org-agenda-files) with :scope (some-function) doesn't work for me, and isn't mentioned in the docs. Is it still supported?
    – avv
    Commented Aug 22, 2017 at 2:31
  • Which version of org-mode do you use? Is any error generated?
    – artscan
    Commented Aug 22, 2017 at 4:01
  • 1
    Lisp error: (wrong-type-argument stringp some-function). Org mode version 9.0.7
    – avv
    Commented Sep 2, 2017 at 2:24
  • Edited to fix the scope line - that should fix the lisp errors.
    – NickD
    Commented Apr 21, 2019 at 5:03
3

I've been having trouble with this as well.

@artscan's answer pointed me in the right direction, but returns an argument type error. Dropping the parentheses solves the issue.

I'd comment on artscan's answer, but I don't have enough reputation.

To summarize, then, here is what I use:

In the table, provide :scope efls/org-files-productive. No parentheses. Define a simple function to return a string of files.

For example, I use something like this:

(defun efls/org-files-productive ()
 "Return productive org files."
 '("/Users/efls/org/file1.org" "/Users/efls/org/file2.org" "/Users/efls/org/file3.org"))

You could, of course, also simply type in a list of files after :scope, but then you do need parentheses enclosing the list: scope: ("Users/efls/org/file1.org" "…").

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.