Org supports dynamic blocks in Org documents. They are inserted with begin and end markers like any other code block, but the contents are updated automatically by a user function.
You can insert a dynamic block with
which is bound to C-c C-x x by default. For example,
C-c C-x x c l o c k t a b l e RET inserts a table that
updates the work time (see Clocking Work Time).
Dynamic blocks can have names and function parameters. The syntax is similar to source code block specifications:
#+BEGIN: myblock :parameter1 value1 :parameter2 value2 ... ... #+END:
These commands update dynamic blocks:
Update dynamic block at point.
Update all dynamic blocks in the current file.
Before updating a dynamic block, Org removes content between the
‘BEGIN’ and ‘END’ markers. Org then reads the parameters on the
‘BEGIN’ line for passing to the writer function as a plist. The
previous content of the dynamic block becomes erased from the buffer
and appended to the plist under
The syntax for naming a writer function with a dynamic block labeled
The following is an example of a dynamic block and a block writer function that updates the time when the function was last run:
#+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M" ... #+END:
The dynamic block’s writer function:
(defun org-dblock-write:block-update-time (params) (let ((fmt (or (plist-get params :format) "%d. %m. %Y"))) (insert "Last block update at: " (format-time-string fmt))))
To keep dynamic blocks up-to-date in an Org file, use the function,
org-update-all-dblocks in hook, such as
org-update-all-dblocks function does not run if the file is not in
Dynamic blocks, like any other block, can be narrowed with