From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-orgmode@gnu.org
Subject: Re: get subtree contents as string
Date: Wed, 26 Feb 2020 16:13:52 -0500 [thread overview]
Message-ID: <87zhd5vypb.fsf@ericabrahamsen.net> (raw)
In-Reply-To: CAN_Dec9xgBCjSPOrSw-qkmCPNiVcOdoHwvPb0tLyBBtODTHs2A@mail.gmail.com
Matt Price <moptop99@gmail.com> writes:
> 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.
If it's just a matter of getting the subtree text, you could use
buffer-substring with org-end-of-subtree to find the end of the string.
Does that do it?
prev parent reply other threads:[~2020-02-26 21:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-26 18:35 get subtree contents as string Matt Price
2020-02-26 21:13 ` Eric Abrahamsen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zhd5vypb.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).