emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

get subtree contents as string


From: Matt Price
Subject: get subtree contents as string
Date: Wed, 26 Feb 2020 13:35:48 -0500

I have the following convenience function that scans contents of a subtree and then sets a property, adds an overlay, and changes the TODO status:
(defun org-lms-set-grade ()
  "set grade property for all headings on basis of \"- Grade :: \" line
  Use with caution."
  (interactive)
  (save-restriction
    (org-narrow-to-subtree)
      (save-excursion
      (org-back-to-heading)
      (while (re-search-forward ol-grade-regex nil t )
        (org-set-property "GRADE" (or (match-string 2) 0))
        (org-todo "READY"))))
  (org-lms-overlay-headings)  )

It works, but there's a short (<1sec) non-responsive period when it runs. I'm wondering if it has to do with ~org-narrow-to-subtree~, so I thought I'd just copy the contents of the subtree as a string and replace re-search-forward with string-match. However, I'm not finding a super-obvious way to copy the subtree as a string. Am I missing something? And am I likely to be right that that's the source of the delay (as I write this, I'mwondering if hte overlay drawing might be the real problem? The whole project this is part of (https://github.com/titaniumbones/org-lms) suffers from delays while the buffer redraws, so I'm keen to figure out Better Ways To Do Things.

Thanks as always,
Matt


reply via email to

[Prev in Thread] Current Thread [Next in Thread]