0

In 'Emacs org-mode' i can create links to headings and other things where I want to jump quickly. How can I create a link in 'Emacs org-mode' which opens a certain search agenda?

At the moment I have to hit 'Ctrl-C a s' for the search agenda and then enter the search term, e. g. '+keyword1 +keyword2 -keyword3' ...

If I want to get the same search later again, I would like to create a link which directly opens this search agenda again...

-- Pratical use case: I started a new project and did research for information in my (thousands of) notes about earlier activities which are related to the new project. For this research, I have put together (after some trial and error) a certain search syntax with different keywords.

I wanted to save this search syntax for later to be able to get the same result again, if I will continue working on this project (maybe tomorrow, maybe in some weeks). Then, it would be difficult to find the search syntax in my command history (or even to remember, that there might exist a matching search syntax). Instead, I would like to have a way to "save" this search syntax to execute the same search again later. It does not necessarily have to be a link, it could also be a command which I can execute..

When I work again on this project

5
  • 1
    Why do you need a link? What will that accomplish? C-c a s is easy enough to type and you can navigate through minibuffer history (with C-n / C-p) to bring back an earlier search (which can also be edited to refine it). That's accessible everywhere, not just from a single file where your link would live. I just don't see what a link would buy you.
    – NickD
    Commented Mar 7 at 1:49
  • @NickD good question - I've added explanations for my motivation and use case in the question Commented Mar 7 at 7:52
  • 1
    Couln't you save C-C a s + '+keyword1 +keyword2 -keyword3' into a macro that you would store in your init as an interactive function?
    – crocefisso
    Commented Mar 7 at 11:45
  • @crocefisso : maybe... is there a way to create such a macro from an already existing agenda buffer? Otherwise, I would have to do the whole process a second time for recording after I fond the right search term. But storing the macros in init and then somehow linking them to a certain projects seems quite complicated to me - much "bueraucracy", if you understand what I mean... It should be as easy and straightforward as possible... I defined a helpful search in a certain situation and want to store it directly for later.. Commented Mar 7 at 11:54
  • 1
    So IIUC, what you want is documentation: to store enough information about the search, so you can perform it again later. A link is one way to do that (storing the search string directly is another way); the main question then is how do you find that documentation/link/whatever when you need it again. I presume you have a project-planning specific file where you are going to store such things? In any case, see if my answer satisfies you.
    – NickD
    Commented Mar 7 at 14:19

2 Answers 2

1

You can use a link to document the search of course, although that's only one way of doing it. You can use an elisp link to execute arbitrary expressions (which can be dangerous so Org mode will ask for confirmation). Here is a link to search for items tagged apache:

[[elisp:(org-search-view nil "+apache" nil)][link]]

This is the function that C-c a s calls, so all that the link is doing is giving it the search argument. In order to use the C-c a S method (i.e. limit the search to TODO items), you just need to change the nil first argument to t.

3
  • thank you very much - this is great - already very helpful! I did not knew that this kind of link is possible. Then it would be great to have a command to create this link for an existing agenda search buffer.... :-/ Commented Mar 7 at 16:16
  • 1
    It's just text: you can cut and paste.
    – NickD
    Commented Mar 7 at 16:25
  • You can create this link from a command using skeleton-mode. See www.emacswiki.org/emacs/SkeletonMode.
    – crocefisso
    Commented Mar 7 at 22:18
0

The standard way to trigger had hoc agenda views is to use the org-agenda-custom-commands variable. See Custom Agenda View.

1
  • Thank you. I'm working already with custom agenda commands, but I do not want to create and save such a command in this case... I've added explanations about my use case in the question, maybe this helps understanding what I'm up to... Commented Mar 7 at 7:52

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.