* org-word-count exemptions
@ 2020-01-25 7:35 Sharon Kimble
2020-01-25 8:15 ` Adam Porter
0 siblings, 1 reply; 2+ messages in thread
From: Sharon Kimble @ 2020-01-25 7:35 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 356 bytes --]
If I have a drawer titled 'mydrawer', how can I exempt it and its
contents from word-count please? This is using wc-mode and also in
org-word-count too.
Thanks
Sharon.
--
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk
Debian 10.2, fluxbox 1.3.7, emacs 26.3, org 9.3.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: org-word-count exemptions
2020-01-25 7:35 org-word-count exemptions Sharon Kimble
@ 2020-01-25 8:15 ` Adam Porter
0 siblings, 0 replies; 2+ messages in thread
From: Adam Porter @ 2020-01-25 8:15 UTC (permalink / raw)
To: emacs-orgmode
There are various solutions floating around. Here's one way:
(defun ap/org-count-words ()
"If region is active, count words in it; otherwise count words in current subtree."
(interactive)
(if (use-region-p)
(funcall-interactively #'count-words-region (region-beginning) (region-end))
(org-with-wide-buffer
(cl-loop for (lines words characters)
in (org-map-entries
(lambda ()
(unpackaged/org-forward-to-entry-content 'unsafe)
(let ((end (org-entry-end-position)))
(list (count-lines (point) end)
(count-words (point) end)
(- end (point)))))
nil 'tree)
sum lines into total-lines
sum words into total-words
sum characters into total-characters
finally do (message "Subtree \"%s\" has %s lines, %s words, and %s characters."
(org-get-heading t t) total-lines total-words total-characters)))))
(defun unpackaged/org-forward-to-entry-content (&optional unsafe)
"Skip headline, planning line, and all drawers in current entry.
If UNSAFE is non-nil, assume point is on headline."
(unless unsafe
;; To improve performance in loops (e.g. with `org-map-entries')
(org-back-to-heading))
(cl-loop for element = (org-element-at-point)
for pos = (pcase element
(`(headline . ,_)
(org-element-property :contents-begin element))
(`(,(or 'planning 'property-drawer 'drawer) . ,_)
(org-element-property :end element)))
while pos
do (goto-char pos)))
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-25 8:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-25 7:35 org-word-count exemptions Sharon Kimble
2020-01-25 8:15 ` Adam Porter
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).