Original Question

I am trying to use org-mode to remind me of whom I will have to follow up with, and when in a conversation with someone which topics I need to discuss with them.

My current plan is to query for TODO items that also have a specific value of the property WITH. The WITH property keys will be populated with my colleagues and clients names that I am working with on these tasks. To make it quick to retrieve this information, I thought of setting up a custom agenda view with an interactive user-input to fill in the keys for the WITH property.

I found documentation on how to setup "hardcoded" agenda views. How do I fill some parts of these queries with values provided by the user?

Background: I decided to try emacs for its org-mode a week ago. So I am quite new to emacs. I am try to explore as much of its potential as quickly as I can so I gauge whether or not emacs has the potential to solve my issues. So this question is potentially a mix of an org-mode specific and a generic beginners emacs question.

Intended Workflow

(I am adding this as requested in the comments)


I am managing different projects and interface with various systems, clients and internal teams. Due to this there is no single system used by everyone that would make sure tickets can be filed and tracked. Often I get ad-hoc requests that I cannot complete in real-time for various reasons. If I cannot complete a request in real-time, I want to file it away and retrieve it on demand: when deadline approaches (easy), when looking for open internal or external requests, ideas (easy), or when I have a catchup with any involved party (the tricky bit)


My plan so far is to create TODOs with various stages. The exact TODO states are not important, but lets say they are: NEW_REQUEST, PROCESSING, BLOCKED | COMPLETED

These TODOs can be of various kinds. I was thinking of using tags for this, like: :inbound:outbound:internal:request:idea

Because essentially I am an (not very well defined) API between different parties and individuals, I want to log which individuals are involved in each request. This will allow me to follow up on any open task whenever I speak to any involved person. For this I was planning to use properties, specifically the WITH keyword as I was looking for a short signifier.

As an example, a task could look like:

* PROCESSING Alice: setup computer for Bob    :internal:request:
  DEADLINE: <2020-05-22>
  :WITH: Alice, Bob

I will configure org-capture to make it fast to create such a task. I can use / configure the agenda to show me tasks by completion based on deadline and tags.

However, I have regular catchups with most people I interface with on regular intervals (which might be weekly). For non-urgent tasks I want to batch up all my requests that involve a person when I meet them anyway. If I have to report to anyone, I want to be able to get all their tasks and report what the status of the tasks they gave me is.

Because this system needs to scale to 20+ people, multiple TODO states and tags, hardcoding all the combinations is impractical. In the same time retyping the match-strings all the time is not practical either. But something inbetween would potentially possible.

I can define a few template searches I regularly need. For instance open tickets that are inbound involving person XXX:


Since C-c a m asks the user for the match string, I thought I could do the same. The user would just need to navigate to the custom query, and type in Alice and an agenda view TODO="-CLOSED"+inbound+WITH="Alice" would get created.

This is is what this question was about. I have tried setting org-agenda-custom-commands and it does work for static queries. But I cannot find out how to add a user-prompt to it. (might not be possible, as one of the answerers pointed out)

  • Can you describe your proposed workflow in a little more detail? An example might help both you (to make your workflow more concrete) and us (to understand what exactly you are looking for). E.g. "I want to select TODO items that are associated with a particular colleague or client of mine. I also want to be able to easily add that information to a given TODO item that might have no (or some) such associations already." Try to add all the requirements that you might want, but avoid proposing a (probably premature at this time) implementation scheme.
    – NickD
    May 15, 2020 at 12:34
  • Hi @NickD , thanks for trying to help. I added more detail to the question.
    – P.R.
    May 15, 2020 at 13:41
  • 1
    Thanks! That's helpful. I thought I had added a second comment but I don't see it now, so here goes: it might be the case that this question is too open-ended for Emacs SE, so if you don't get satisfactory answers here, you might want to take it to the Org mode mailing list.
    – NickD
    May 15, 2020 at 14:04
  • If the WITH property has the value "Alice, Bob", I don't think your query TODO="-CLOSED"+inbound+WITH="Alice" would work. That's one possible problem with using a property for this.
    – NickD
    May 15, 2020 at 16:44
  • After lots of trial an error, I managed to get this working as well The trick was to remove the " around the search term and instead wrapping it with { and }.
    – P.R.
    May 15, 2020 at 19:42

3 Answers 3


Generally the values inside org-agenda-custom-commands are hard-coded so you have no chance to prompt for input. But one of the choices for an entry type in org-agenda-custom-commands is a user defined function, which will be called with a single argument. So first define a function that prompts for a value of the WITH property and runs org-tags-view on that:

(defun with-prop-search (who)
  "Search by WITH propery, which is made inheritable for
this function"
    (completing-read "With: " (org-property-values "WITH"))
  (let ((org-use-property-inheritance
         (append org-use-property-inheritance '("WITH")))
    (org-tags-view t (format "WITH=\"%s\"/TODO" who))

This also does completion on the values of WITH in the current file and forces the WITH property to be inherited.

Then you can either call it manually with M-x with-prop-search or add it to an agenda view:

(add-to-list 'org-agenda-custom-commands
             '("W" "With"
               (lambda (arg) (call-interactively #'with-prop-search nil))

The call-interactively is only necessary because of how with-prop-search gets the value of WITH

  • This is amazing! A lot more functionality and ergonomy than I thought possible. It did not work out of the box straight away. I needed to turn (format "WITH=\"%s\"/TODO" who) to (format "WITH=\{%s}\/TODO" who) to match all occurrences of each person (even when part of a list like in my example). One thing that could not solve myself is that org-property-values are only generated from the current buffer, not all files tracked by the agenda. But I can really live with this for now. Thanks for this!
    – P.R.
    May 15, 2020 at 19:39
  • 2
    TIL I should read to the bottom of the docstring :-).
    – rpluim
    May 17, 2020 at 16:09

You can do this either with tags or with properties. Assuming an org file that looks like this:

* headline 1               :tag1:
:WITH:     hello
* headline 2               :tag2:
:WITH:     goodbye
* headline 3

Then C-c a m WITH="hello" RET will get you an agenda containing 'headline 1' (assuming that you're using C-c a to invoke org-agenda. It might be easier to this with tags, in which case it would become:

C-c a m tag1

If you want these custom views to be available all the time, you'd use org-agenda-custom-commands. This defines H and G commands in the agenda dispatcher:

(setq org-agenda-custom-commands
      '(("H" "Hello" tags "WITH=\"hello\"")
        ("G" "Goodbye" tags "WITH=\"goodbye\"")))

PS Use C-c C-x P to set a property and its value.

  • Thank you. These are examples of what I meant with "hard-coded" agenda views. Do you think there is a way to query the user dynamically for the values to be used for the WITH property? i.e. instead of H searching for \"hello\" it would search for any string the user inputs?
    – P.R.
    May 15, 2020 at 12:12
  • Agenda view custom commands can't prompt, so that's not currently possible.
    – rpluim
    May 15, 2020 at 12:19

What you want to do is probably possible with Emacs, if you put enough time and energy into it. However, as you say are new to both Emacs and Org, that could be a frustrating experience and put you off both Emacs and Org. Therefore I would suggest that you try to use tags to achieve what you want. This should work pretty much out of the box. If you subsequently find that this approach does not fulfill your needs you can always then try out something different and will have the advantage of having gained a bit of experience in the meantime.

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.