Take only todo-state, tags and IDs from selected subtrees via org refile in Emacs - emacs

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.

Related

Org-mode [[file: ]] link to a file with specific :PROPERTIES: :ID:

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.

Code block result as property value for a table

I'm writing my thesis in Org→Latex. As well as the individual chapter files, I keep track of the overall structure and progress in a separate file. One thing I look at and have to report on is the number of pages written versus the intended length.
I can use pdfinfo to get the number of physical pages in the individual chapters and get this into the outline with a code block. And I can generate a "columnview" table that automatically updates from the chapter info in the outline. I'd like to find out how I could put the two together.
Example
Hopefully this shows what I'm trying to do. In the real thing, there are obviously more like a dozen chapters.
#+TITLE: Thesis Outline
#+COLUMNS: %2ID %35ITEM %Target_Pages{+}
#+NAME: count-pdf-pages
#+BEGIN_SRC elisp :exports none :var pdf-file=""
(let
((pdf-file-info (shell-command-to-string (concat "pdfinfo " pdf-file))))
(string-match "Pages:[[:blank:]]+\\([0-9]+\\)" pdf-file-info)
(match-string 1 pdf-file-info)
)
#+END_SRC
* Chapter outlines
:PROPERTIES:
:ID: outlines
:END:
** 1. Introduction
:PROPERTIES:
:Target_Pages: 5
:END:
This is the introduction of the thesis. It currently has this many pages:
#+NAME: intro-page-count
#+CALL: count-pdf-pages("latex/intro-chapter.pdf")
* Page Allocation and Completion
#+BEGIN: columnview :hlines 1 :id outlines
| ID | ITEM | Target_Pages |
|----------+--------------------+--------------|
| outlines | * Chapter outlines | 5 |
| | ** 1. Introduction | 5 |
#+END
Question
What I would like to do is be able to use the return value of the CALL block for each chapter within the outline table at the end. However, having read through the relevant section of the manual a few times, I can't see whether it's possible to set a heading's property (say Written_Pages) to be the result of a code block.
Obviously, I'm also open to other org ways of approaching the problem of generating a table from the results of multiple code calls.
Org-mode properties can be set via elisp using org-set-properties. For example, (org-set-properties "Written_Pages" "5") (note that the property value must be a string. So just add an extra source block:
#+BEGIN_SRC elisp :export none :results none :var p=intro-page-count
(org-set-property "Written_Pages" p)
#+END_SRC

How do I move text back to just under the parent level

* 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.

How can I repeat a beamer frame with Org-mode?

With Beamer frames can be repeated by labeling the frame that should be repeated such as
\begin{frame}[label=framelabel]
...
\end{frame}
and then using \againframe{framelabel} at the place where that frame is to be repeated.
How can this method be used with Org-mode's Beamer export? The label can obviously be added by putting it in BEAMER_envargs such as:
* Org-mode section
:PROPERTIES:
:BEAMER_envargs: [label=questions]
:END:
But there are two problems in using \againframe via Org-mode:
\againframe is placed badly both if it is placed under an Org-mode section and if it is put directly in an Org-mode section. The problem is that in the former case is that is is placed inside a frame when it should be placed between. The problem in the latter case is that it is placed inside \frametitle.
\againframe is either swallowed by Org-mode sections or it is marked as one. Both are poor logical representations of its function.
So is there some effective way of using \againframe with Beamer or is there some other way to repeat frames with Org-mode that I have overlooked?
I have already looked at http://lists.gnu.org/archive/html/emacs-orgmode/2011-05/msg00954.html in trying to work this out.
I am running Org-mode 7.6 in Emacs 23.3.1 and I use Beamer 3.13.
The current org-mode has support for againframe. Just create a frame and add the beamer option BEAMER_env = againframe to the corresponding section. Or use C-c C-b a to insert it if you initialized the beamer mode on org-startup.
More information can be found in the org-mode documentation.
An example is available in the original proposal of the syntax:
* section
** My frame title :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:
Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.
** section :B_againframe:
:PROPERTIES:
:BEAMER_env: againframe
:BEAMER_act: 2
:BEAMER_ref: *My frame title
:END:
This section will create "\againframe<2>{sec-1-2}".
** Following frame
etc.
I don't think this is currently possible. The limitation lies in the tree structure of an org document. As far as I understood from your question, the \againframe{...} command basically repeats a slide as is. In org terms, that means the original tree used to generate the slide is repeated. Since the org document format doesn't let you have any content which is not part of a tree (other than the frontmatter/header at the top of a file), I believe this is not possible. This has been discussed on the mailing list a few times, from what I understood there are no plans to implement something like this.

How do I use overlay specifications for lists in org-mode's beamer export feature?

It seems like itemize lists are automatically generated in the beamer export for org-mode. I can specify things like <only#2> for things like blocks, but it seems like I have to write out an itemize list by hand if I want to use it with an item. For example, I expect to type this and see one list item at a time, but I don't, I see them all in one slide:
*** Test
**** one
:PROPERTIES:
:BEAMER_envargs: <only#+>
:END:
**** two
:PROPERTIES:
:BEAMER_envargs: <only#+>
:END:
**** three
:PROPERTIES:
:BEAMER_envargs: <only#+>
:END:
Also, it seems like I should be able to do:
*** Test
:PROPERTIES:
:BEAMER_envargs: [<only#+>]
:END:
- one
- two
- three
for the same effect, but I see the whole list. This doesn't work either:
*** Test
:PROPERTIES:
:BEAMER_envargs: [<only#+>]
:END:
**** one
**** two
**** three
What am I missing here?
The org-mode Info node has some extensive examples (at least in the most up to date development version).
The following minimal example should work exactly as you wish
#+LATEX_CLASS: beamer
* Section
*** Slide
List
#+ATTR_BEAMER: :overlay +-
- item 1
- item 2
Let me know if I misunderstood your request.