4

I've got a dynamic block in org-mode (e.g. a clocktable) and I want to update it on save. To do this, I have written the following function (which I'm calling in a before-save-buffer hook):

(defun my/org-update-and-realign ()
  (interactive)
  (org-map-dblocks 'org-update-dblock)
  (org-table-map-tables 'org-table-align))

(I need to do realignment because otherwise tables come up garbled.)

However, it doesn't wok. I get “Mapping tables: done” in the Messages buffer, but the table isn't realigned. Bafflingly, if I add (redisplay), it does work:

(defun my/org-update-and-realign ()
  (interactive)
  (org-map-dblocks 'org-update-dblock)
  (redisplay)
  (org-table-map-tables 'org-table-align))

So, I've got two questions:

  1. How come?
  2. Can I do it without (redisplay)? The (redisplay) forces a blink, which I don't want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.