[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Count words under subtrees
From: |
Adam Porter |
Subject: |
Re: [O] Count words under subtrees |
Date: |
Wed, 28 Sep 2016 17:54:57 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
I think this should do it:
#+BEGIN_SRC elisp
(defun count-words-in-subtree ()
"Count words in current node and child nodes, excluding heading
text."
(interactive)
(save-excursion
(save-restriction
(widen)
(message "%s words"
(-sum (org-map-entries (lambda ()
(outline-back-to-heading)
(forward-line 1)
(count-words (point)
(progn
(outline-end-of-subtree)
(point))))
nil 'tree))))))
#+END_SRC
I haven't tested it extensively, but it seems to work correctly,
counting the current node and any child nodes, but not going into
sibling nodes. I've been thinking about doing this for a while now, so
thanks for reminding me! :)
Oh, and it uses the dash.el library, which most Emacs users should
have...