all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: Sharon Kimble <boudiccas@skimble.plus.com>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: word counts and org-mode drawers
Date: Tue, 02 Feb 2021 00:29:56 +0100	[thread overview]
Message-ID: <87tuqv1i4r.fsf@posteo.net> (raw)
In-Reply-To: <87v9bbq0k8.fsf@skimble.plus.com> (Sharon Kimble's message of "Mon, 01 Feb 2021 15:17:59 +0000")

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	other threads:[~2021-02-01 23:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 15:17 word counts and org-mode drawers Sharon Kimble
2021-02-01 23:29 ` Juan Manuel Macías [this message]
2021-02-04 13:50   ` Sharon Kimble
2021-02-02  0:43 ` Christopher Miles

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tuqv1i4r.fsf@posteo.net \
    --to=maciaschain@posteo.net \
    --cc=boudiccas@skimble.plus.com \
    --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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.