Sharon Kimble <[email protected]> writes:
> And question 2 - how can I auto-count the number of words from the end
> of the drawer `:END:` to the beginning of the next `* Chapter` please,
> using some form of command? I need this to let me know how many words
> there are in each of my chapters.

Is that from the PROPERTIES drawer under a heading, or from an arbitrary
Org drawer, e.g. =:DETAILS: ... :END:= ?

I would normally suggest org-wc (https://github.com/tesujimath/org-wc),
which you can install with `M-x list-packages'. It's a word-count
package that is aware of Org syntax, so it ignores keywords and blocks
that shouldn't be counted as words. You do `M-x org-wc' or `M-x
org-wc-display' to get a word count for every heading, summing over
subheadings. With a prefix argument, you instead get a word count in the
minibuffer for the buffer or the active region. It skips property
drawers, so you don't need to worry about starting from the end of the
drawer.

However, at present there seems to be a bug: While org-wc handles
property drawers, for me it hangs if the buffer contains any other Org
drawer. From what you say, you use drawers to keep checklists in, so
that bug would make it less useful. It will still work on regions with
`C-u M-x org-wc-display' as long as the region doesn't contain a drawer,
so you could use it manually. And with a little more information on how
your chapters/drawers are organized, it should be possible to come up
with a simple function to do these manual checks from a drawer =:END:=
to the next heading as you asked, working around whatever currently
makes org-wc hang.

(Another way to count words in an active region manually is with the
=wc= shell command and `M-x shell-command-on-region' (bound to `M-|'),
but it's not org-aware and will count everything.)

Regards,
Christian

Reply via email to