Reputation: 265
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.
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
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.
Upvotes: 2
Views: 140
Reputation: 1217
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
Upvotes: 1