emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org
Subject: Re: v3, with support for narrowing
Date: Thu, 28 Apr 2011 23:35:41 -0400	[thread overview]
Message-ID: <17141.1304048141@alphaville.dokosmarshall.org> (raw)
In-Reply-To: Message from Eric Abrahamsen <eric@ericabrahamsen.net> of "Fri, 29 Apr 2011 10:41:38 +0800." <871v0leq3h.fsf@ericabrahamsen.net>

Eric Abrahamsen <eric@ericabrahamsen.net> wrote:

> On Fri, Apr 29 2011, Simon Guest wrote:
> 
> > At Thu, 28 Apr 2011 15:47:07 -0700,
> > Samuel Wales wrote:
> >> Is it possible to make it so that you can show the overlays for just a
> >> subtree or region instead of the entire buffer?
> >
> > Hi Samuel,
> >
> > Good idea!  So I just fixed it to handle narrowing properly, so narrow
> > to your region or subtree of interest first, and then count as usual.
> >
> > Attached v3 which does this.  I'm not normally this responsive, you
> > just caught me at a good time.  ;-)
> 
> Is this still a good time? Because what I'd really like is
> inclusion/exclusion tags, so that I can mark some subtrees to count, and
> others to ignore. I tried doing this last night, based on other parts of
> the export code, and my elisp failed. Perhaps just exclusion tags?
> Here's hoping you still have a bit of time/interest for improvements!
> 
> (I'm translating a novel, not writing one, and want to keep the original
> text out of the count. Plus I've got a bunch of research/notes sections
> that should be excluded.)
> 
> If you're out of time, I'll have another whack at it, and maybe bring my
> broken efforts to the list.
> 

The mapping API allows you to walk through the entries, filter the ones
you want and apply a function on each remaining entry. So cribbing heavily
from Simon's code, the following should count all the entries with tag "foo":

--8<---------------cut here---------------start------------->8---
(defun show-count ()
  (let ((p (point))
        wc)
    (when (setq wc (get-text-property p :org-wc))
      (org-wc-put-overlay wc (funcall outline-level)))
    (when org-remove-highlights-with-change
      (org-add-hook 'before-change-functions 'org-wc-remove-overlays
                    nil 'local))))

(defun count-foo ()
  (interactive)
  (let (bmp (buffer-modified-p))
    (org-wc-count-subtrees)
    (org-map-entries 'show-count "+foo" 'file)
    (set-buffer-modified-p bmp)))
--8<---------------cut here---------------end--------------->8---

Nick

  reply	other threads:[~2011-04-29  3:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-23  8:57 Implemented word count for subtrees Simon Guest
2011-04-27 17:51 ` Eric S Fraga
2011-04-27 22:41   ` Simon Guest
2011-04-28  8:34     ` Eric S Fraga
2011-04-28 22:05       ` Sub-tree word count v2 Simon Guest
2011-04-28 22:47         ` Samuel Wales
2011-04-29  1:57           ` v3, with support for narrowing Simon Guest
2011-04-29  2:41             ` Eric Abrahamsen
2011-04-29  3:35               ` Nick Dokos [this message]
2011-04-29  4:31                 ` Eric Abrahamsen
2011-04-29 14:56                   ` Nick Dokos
2011-04-29 21:42                     ` Simon Guest
2011-06-09  1:33                       ` v4, now with properties and inclusion tags Eric Abrahamsen
2011-05-14 22:48             ` v3, with support for narrowing Samuel Wales
2011-05-15  4:25               ` Simon Guest
2011-04-28 23:16         ` Sub-tree word count v2 Eric S Fraga
2011-04-28  7:53 ` Implemented word count for subtrees Sébastien Vauban
2011-04-28  8:35   ` Eric S Fraga
2011-05-02 12:19   ` Daniel Clemente

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=17141.1304048141@alphaville.dokosmarshall.org \
    --to=nicholas.dokos@hp.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=eric@ericabrahamsen.net \
    /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 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).