emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: word counts and org-mode drawers


From: Juan Manuel Macías
Subject: Re: word counts and org-mode drawers
Date: Tue, 02 Feb 2021 00:29:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Hi,

Sharon Kimble <boudiccas@skimble.plus.com> writes:

> How can I exempt an org-mode drawer, and its contents, from word counts
> please. I am using 'wc-mode' but I can't see how to do it.

It is not a solution with wc-mode, but maybe this simple function, based on
`count-words', can serve you. It counts the words in the buffer
excluding all drawers and their contents:

#+begin_src emacs-lisp
(defun my-count-words-in-org-buffer ()
  (interactive)
  (let ((words 0))
    (save-excursion
      (save-restriction
        (narrow-to-region (point-min) (point-max))
        (goto-char (point-min))
        (while (forward-word-strictly 1)
          (if (org-at-drawer-p)
              (re-search-forward ":END:")
            (setq words (1+ words))))))
    (message "Org buffer has %d word%s."
             words (if (= words 1) "" "s"))))
#+end_src

Best regards,

Juan Manuel 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]