Does anyone know of a function that will return the last subheading of a tree? I have a capture template set up for journal entries, but the subheading I want them to be filed under is dynamic (changes for each work rotation where the most current is the last in the list). So my capture template target needs to be (file+function "path/to/file" function-finding-location) where the "function-finding-location" finds the last subheading of a given top level header.
* Log Book
** 2018-01-01 to 2018-01-29
** 2018-02-26 to 2018-03-26
*** New Journal Entry to go here
Related
I'm looking for a way to simplify the task of selecting from org-tree using hooking into the org-refile function.
It is known that through org-org refile it is possible to select certain subtrees and copy them under defined org-heading.
I don't need to copy all the content selected in the standard way from the subtree, but only take certain elements from the selected subtree such as:
todo-state from the parent heading. It ignores parent heading id/tags since it play as name of this group.
tags and id (from the properties) of each of the child headings. It is advisable to put it in a table.
Tags and todo are compiled into 1 column.
Take a look at this example. This is selection from large org-tree in the same file.
***** HEADER certain ways
****** some problem :Title:
:PROPERTIES:
:ID: 2022-06-07-09-24_some_problem
:END:
some content
***** SOLUTION where is solution living
****** read this topic :Topic:
:PROPERTIES:
:ID: 2022-04-23-topic
:END:
****** get the plan :One_way:
:PROPERTIES:
:CREATED: [2022-03-31 Thu 21:02]
:ID: 2022-06-06-15-12_get_the_plan
:END:
some content
the result will be not all selected subtrees but only their 'map' with IDs and tags which may be processed by requesting actual headings of large tree in the same file.
Result.
| Article part | ID |
-----------------------------------------------------------------
| Header Title | id:2022-06-07-09-24_some_problem |
| Solution Topic | id:2022-04-23-topic |
| Solution One_way | id:2022-06-06-15-12_get_the_plan |
For a while I've modified a snippet from this answer. But it requires additional step to copy all selected subtrees and then run this code under selection.
I'll be glad if it is possible to erase this step and compile such 'map' during org-refile process. Think it is possible through the org-refile hook.
In my case the sequence of headings/IDs one by one is important.
I'm trying to find a way to add a clickable link in org-mode that opens another local file and scrolls to a specific property id.
It's easier to explain with an example:
$ cat file1.org
* org links that I've tried and they don't work properly
[[file:path/to/another-file.org::#d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]]
[[file:path/to/another-file.org:id:d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]]
[[file:path/to/another-file.org::d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]]
[[file:path/to/another-file.org::id:d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]]
$ cat another-file.org
* Top category
** Category X
*** Question :drill:
:PROPERTIES:
:ID: d89ba6bd-7c9a-4559-9965-7a6541f1a7c5
:END:
Content of d89ba6bd-7c9a-4559-9965-7a6541f1a7c5 entry
*** Question :drill:
:PROPERTIES:
:ID: some-other-property-uuid
:END:
Content of some-other-property-uuid entry
Unfortunately, I can't change the structure of another-file.org. I can only reference using a property id.
Just renaming "Question :drill:" would have been much easier but it is duplicated many times and as I said it is not available for updates.
Update:
With "CUSTOM_ID" property it seems to be working
*** Question :drill:
:PROPERTIES:
:CUSTOM_ID: d89ba6bd-7c9a-4559-9965-7a6541f1a7c5
:END:
Content of d89ba6bd-7c9a-4559-9965-7a6541f1a7c5 entry
[[file:path/to/another-file.org::#d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]]
But is there any way to make it with with default :ID: property?
Try setting org-link-search-must-match-exact-headline to nil. That makes the third type of link above [[file:path/to/another-file.org::d89ba6bd-7c9a-4559-9965-7a6541f1a7c5][ref]] do a fuzzy text search, whereas the other values (t and the default query-to-create) are biased towards headlines when the target file is an Org mode file.
Here's the doc string of org-link-search-must-match-exact-headline:
org-link-search-must-match-exact-headline is a variable defined in ‘ol.el’.
Its value is nil
Original value was ‘query-to-create’
This variable is safe as a file local variable if its value
satisfies the predicate ‘symbolp’.
You can customize this variable.
This variable was introduced, or its default value was changed, in
version 24.1 of Emacs.
Documentation:
Non-nil means internal fuzzy links can only match headlines.
When nil, the a fuzzy link may point to a target or a named
construct in the document. When set to the special value
‘query-to-create’, offer to create a new headline when none
matched.
Spaces and statistics cookies are ignored during heading searches.
BTW, I found it by reading the External Links section of the manual: look for text search and the accompanying footnote.
Here is the use case that I want to have in org-mode
I have next org-mode structure
Work.org file
* heading one
- Note taken on [2018-12-20 Fri 16:07] \\
Some note here
- Note taken on [2018-12-21 Fri 12:37] \\
Some note here
Personal.org file
* headin two
- Note taken on [2018-12-21 Fri 16:07] \\
some note here
- Note taken on [2018-12-22 Fri 12:37] \\
some note here
I want to see the log statistics for 2018-12-21 and as result have
* heading one
- Note taken on [2018-12-21 Fri 12:37] \\
Some note here
* headin two
- Note taken on [2018-12-21 Fri 16:07] \\
some note here
Any idea how I can implement it or use some existing features?
PS: Look like I can't use agenda features as the heading items doesn't have TODO
It should be possible to see your desired result via the agenda and some special commands in it:
when you press "v" while in Agenda you can see which additional commands are possible:
"[" will include the inactive timestamps
"E" will include the first few lines of your entry (the number of lines can be configred via: "org-agenda-entry-text-maxlines").
It is not exactly what you want, but quite close.
I see this question was asked quite some time ago so perhaps this is newer functionality, using org-version 9.1.14... I would have added this as a comment to #sanenr9 answer, but I do not have that wizard level yet <:-(
Note, this does not work in tag-type agenda buffers, so not what I'm looking for.
From Agenda day or week view use v and select L - "Log-all" which does then display all entries with updates and their logs within the selected date range.
* Parent
Some text under this level
** Headline below parent
** Another Headline at the same level
I don't want this text to be a headline but be indented same as the text under the parent level without being a headline. Cannot do this.
I just cannot re-indent this text just below the parent level here
* Another top-level headline
Is there any way in org-mode to re-indent plain text back to the same indent level as the plain text just under the parent level but below several headlines under the parent?
I am trying to do something like this:
* A Section
Introductory text.....
** Subsection 1
** Subsection 2
Further Reading
Now, that "Further Reading" is not a headline, I don't want it to be one. However, I cannot "get out of" Subsection 2: Anything I type below it is a part of it. Perhaps I need to structure this some other way such as using lists instead of headlines.
There is no way to do this in org, currently - there is no syntax that ends a subheader to return you to the previous level. But you could add a subsection at the same level - e.g. in your example,
* A Section
Introductory text.....
** Subsection 1
Subsection 1 text
** Subsection 2
Subsection 2 text
** Further Reading
Some further reading
It might be nice if org had some syntax, like **-, that would end a subsection, but I'm not sure how involved a change that would be - probably pretty extensive.
I have a heading in my orgmode file. It is automatically updated periodically with new children. I want the heading line to show the number of children.
So if I have one child it would say something like (1)
* Heading (1)
** Subheading
After it gets updated with another subheading the number should automatically be changed to (2)
* Heading (2)
** Subheading
** A new added subheading
I want it to do this because the toplevel heading will normally be collapsed. I want to be able to see if any new children were added to it without having to expand it
What's most similar to what you're searching are called statistics cookies. They're described at the end of this page in the manual. At first meant for lists, but that can also count headlines. Just put [/] at the end of your header, like so :
* Main header [/]
** sub-header 1
** sub-header 2
** sub-header 3
And press C-c C-c on the cookie to update it (make it update its count). What you do need to add to what you describe to be your use-case is TODO keywords to your headers, because what the cookie will count is how many are done over how many are to do. Therefore I suggest you mark them all as DONE, like so :
* Main header [3/3]
** DONE sub-header 1
** DONE sub-header 2
** DONE sub-header 3
Then, the counter will show you what you want.
You could probably adapt these cookies' code to meet your precise needs.