Is there a way to delete all instances of, i.e.,

CLOCK: [2018-01-24 Wed 16:55]--[2018-01-24 Wed 17:15] =>  0:20

under a header in org-mode? That is, to delete (under a header) all multi-line strings that begin with :LOGBOOK and end with :END:?

  • The (almost) general answer for all variants of that questions is my answer on how to parse and modify an orgmode buffer. In the first run you modify org-element-map such that it shows you the parsing tree in the second run you define your transformation rules. Maybe it is a bit more complicated than just automatically editing text but it is the wonder weapon in the sense that it gives correct and complete results. One exploits the strictly defined orgmode syntax and the high-quality parser built-in into orgmode. – Tobias Jan 26 '18 at 13:42
(defun mw-org-log-delete ()
  "Delete logbook drawer of subtree."
    (goto-char (org-log-beginning))
    (when (save-excursion
              (beginning-of-line 0)
              (search-forward-regexp org-drawer-regexp)
              (goto-char (match-beginning 1))
              (looking-at "LOGBOOK")))
      (delete-region (region-beginning) (region-end))
      (org-remove-empty-drawer-at (point)))))
| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.