Re-organizing in org-mode - emacs

In org-mode, I have a simple list of items, with multiple tags (C-c C-c). I like convert this in such a way that I can display each tag as different header and see the items under that tag. For example, if I have tags 'company' and 'fruit' applied to the item 'apple' , then I like to see 'company' and 'fruit' as header and see the 'apple' as item under both of them. I have many other items and I like to combine them. So I can have all fruits under 'fruit' header etc..

The best approach is to use agenda views.
To do this, add your current file(s) to org-agenda-files and then use the org-agenda command. The m option allows you to perform a tag matching search across all your agenda files. So, for example, if you wanted to list all the headlines tagged with "company" in a list, you could do so with C-c a m company <enter>

Org-mode isn't made in a way that encourages you to reorganize your .org documents this way. Instead, you should do agenda searches that give you a dynamic view of what you want to see. E.g., if you do an agenda search for the tags 'company' and 'fruit', the agenda buffer will show all headings that have both of those tags.
As far as having a document that consists of a list of tags, without actual headings, I don't think Org would work that way very well. For example, take the case where you say you have three tags: 'company', 'fruit', and 'apple'. In a normal Org document all three of those tags would apply to the heading. They would not apply to each other. So if you have a case where 'company' and 'fruit' apply to apple then 'apple would have to be the headline, like this:
* Apple :company:fruit:
It makes no sense to have a blank headline that has just tags, since as I said the tags are intended to apply to the headline text, not to each other. So this doesn't really make any sense:
:company:fruit:apple:
What you could do is have a document like this:
* apple :fruit:company:
* fruit :apple:company:
* company :fruit:apple:
And in that case the agenda searches would show what you want. But the document has some redundancy, since same term shows up in different cases as both heading and as a tag.

Related

View/autocomplete org-mode tags (with group tag) as a tree structure

I use org-mode tags with the "group tag" Tags Hierarchy and groups.
My preferences - use the #+TAGS: syntax for a specific file, without overriding org-tag-alist/org-tag-persistent-alist. I can see list of tags in the variable org-current-tag-alist.
So, tags is a tree structure. The standard mini buffer org-mode for setting tags (C-c) is too inconvenient. Using autocomplete (ivy+counsel) shows tags well, but doesn't show tags hierarchy.
Question:
Is there a tool that will show tags in the form of a tree in a separate buffer? Like some modules show the directory/file structure of a project?
Is it possible to configure the autocomplete tools: helm/ivy+counsel/selectrum/(any other) to display a tags tree and autocomplete?

Emacs untagged agenda items in org-agenda

How I can find the agenda items which are not tagged in org-agenda mode?
If I use the filtering option org-agenda-filter-by-tag (/ - or C=u /) I have to exclude one by one all tags to achieve this and that is not what I want exactly.
Use the special property TAGS:
TAGS=""
will match headlines with no tags.
See http://orgmode.org/org.html#Special-properties.

How can I control in org-mode the distance of tags from the text they apply to?

I really dislike the way org-mode places tags far from the text they refer to. It makes it hard to see which tag refers to which line. Is there some way to shorten that distance?
Tags are aligned to org-tags-column, which you can set in Customize:
M-x customize-apropos org-tags
[Hide] Org Tags Column: [-77]
State : [STANDARD].
The column to which tags should be indented in a headline. Hide
If this number is positive, it specifies the column. If it is negative,
it means that the tags should be flushright to that column. For example,
-80 works well for a normal 80 character screen.
When 0, place tags directly after headline text, with only one space in
between.
Groups: Org Tags

matching property in agenda view

I want collect and create a block containing headlines which only has "ID" property in the headlines.
i.e The headlines to be filtered looks like
* Headline
:PROPERTIES:
:ID: my-id
:END:
I am using the following code to configure the custom agenda command which does not work
(setq org-agenda-custom-commands
'(("c" "MY Agenda"
((tags "ID")))))
I have read the org manual http://orgmode.org/manual/Matching-tags-and-properties.html#Matching-tags-and-properties but still unable to figure out how to do it.
Your code as such is asking it to find all headlines that have a :ID: tag on the headline. To look for properties you have to use the property match feature which is listed a bit lower on the linked manual page.
Since I'm assuming you need it to match any ID and not just a specific ID you'll have to use the regexp matching by either matching (=) or not matching (<>) the regexp that follows in curly brackets.
To match your ID property you'll need the regexp to be ID={.+}. If you used .* as the match it would also match headlines without any ID property. If you have some a set of IDs you want to match that have something in common you can adjust the regexp to match them.
So your custom agenda command will have to be:
(setq org-agenda-custom-commands
'(("c" "MY Agenda"
((tags "ID={.+}")))))

How to display the full context of the entries in org-mode agenda tree view

In org-mode's daily/weekly agenda view, is there a way to display the full context of the entries?
My reading of the code is that it finds the first heading above the timestamp and displays that. However, in my case, that heading is often 3-4 levels deep and doesn't make sense without the bullets above it. It also doesn't seem like there are hooks to easily change that. Filtering is trivial, but not changing the fundamental presentation format.
There is no way to display all the context directly in the agenda view, but you can right click on the headline in agenda view and it will show you that headline in the main window in a sparse tree context.
You may have to collapse everything in the main window in order for the right-click-locating to show the sparse-tree view.
That seems pretty close to what you're looking for. To check, do this:
Create desired agenda view.
In main document window collapse everything to just first level headlines.
Right-click on the desired headline in the agenda view. It should show the headline in sparse tree context in the main document window.
There are several things you can do to get better information about context in agenda views, short of using the right-click function described above.
First, you can arrange your headlines themselves so that they give you more context information. It would be possible, e.g., to have numerous 4th level headlines labeled 'Tasks', each which includes tasks related to the headings above in each tree. That's not going to give good context info in agenda view, though, since each line's headline text would be the same (i.e., 'Task') and have no info in context. A simple solution would simply be to make the headlines more specific, e.g., 'Project xxxx Tasks' and 'Project yyy Tasks'.
A different way of getting more context in agenda view would be by using 'categories'. The first column in agenda view is the filename containing the headline by default, but if the headline has a category the category will be shown. To assign a category to a headline and all of its subtree you can add a category property to the main headline, like this:
:PROPERTIES:
:CATEGORY:Project xxx Stuff
:END:
Now agenda view will show 'Project xxx Stuff' in the first column for each of the agenda lines that are gathered from that headlines subtree.
Maybe an agenda is not really what you need. I would use this:
`M-x org-sparse-tree RET D'
then select the date range and navigate through the results.
HTH
Follow-mode (S-f) gets pretty close to what the OP is looking for. Credit to #armando.sano in a comment on another answer.