title: How to count characters of a subtree in emacs org mode?
body: <p>I would like to count characters in a subtree (heading) in org mode. Right now I have figured out how to count characters in a single paragraph, but not over multiple paragraphs. I first define a source block:</p>
  
  <pre><code>#+NAME: countChars
  #+BEGIN_SRC sh :var X="" :results output
  echo "$X" | wc --chars
  #+END_SRC
  </code></pre>
  
  <p>And then I use it on named paragraphs:</p>
  
  <pre><code>#+NAME: paragraph
  This is the paragraph
  
  #+CALL: countChars(paragraph)
  </code></pre>
  
  <p>This works well but the #+NAME: only covers one paragraph. I have tried to use a heading as argument but I could not make it work.</p>
  
  <p>EDIT: Based on comments, I came up with:</p>
  
  <pre><code>#+NAME: countChars
  #+BEGIN_SRC emacs-lisp :results output :eval no-export :exports results
  (interactive)
  (save-excursion
    (org-mark-subtree)
    (setq a (- (mark) (point)))
    (deactivate-mark)
    (prin1 'Count= )
    (prin1 a))
  #+END_SRC
  </code></pre>
  
  <p>which does almost what I want when invoked as </p>
  
  <pre><code>#+CALL: countChars()
  </code></pre>
  
  <p>but has the problem of counting source code blocks (including itself) as well as text. I would like to count text only (excluding the headline).</p>