From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Price Subject: get subtree contents as string Date: Wed, 26 Feb 2020 13:35:48 -0500 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000036ba59059f7eda72" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:51472) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j71Vm-0003mQ-2m for emacs-orgmode@gnu.org; Wed, 26 Feb 2020 13:34:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j71Vk-0003Wm-SX for emacs-orgmode@gnu.org; Wed, 26 Feb 2020 13:34:21 -0500 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]:43997) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j71Vk-0003Vw-N7 for emacs-orgmode@gnu.org; Wed, 26 Feb 2020 13:34:20 -0500 Received: by mail-ot1-x335.google.com with SMTP id p8so350058oth.10 for ; Wed, 26 Feb 2020 10:34:20 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Sender: "Emacs-orgmode" To: Org Mode --00000000000036ba59059f7eda72 Content-Type: text/plain; charset="UTF-8" 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 --00000000000036ba59059f7eda72 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I have the following convenience function that scans = contents of a subtree and then sets a property, adds an overlay, and change= s the TODO status:
(defun org-lms-set-grade ()
=C2=A0 "se= t grade property for all headings on basis of \"- Grade :: \" lin= e
=C2=A0 Use with caution."
=C2=A0 (interactive)
=C2=A0 (save= -restriction
=C2=A0 =C2=A0 (org-narrow-to-subtree)
=C2=A0 =C2=A0=C2= =A0=C2=A0 (save-excursion
=C2=A0 =C2=A0=C2=A0=C2=A0 (org-back-to-heading= )
=C2=A0 =C2=A0=C2=A0=C2=A0 (while (re-search-forward ol-grade-regex nil= t )
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-set-property "GRADE" (or= (match-string 2) 0))
=C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 (org-todo "R= EADY"))))
=C2=A0 (org-lms-overlay-headings)=C2=A0 )

<= /div>
It works, but there's a short (<1sec) non-responsive perio= d when it runs. I'm wondering if it has to do with ~org-narrow-to-subtr= ee~, 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 find= ing a super-obvious way to copy the subtree as a string. Am I missing somet= hing? 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

--00000000000036ba59059f7eda72--