emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Simon Guest <simon.guest@tesujimath.org>
Cc: emacs-orgmode@gnu.org
Subject: v4, now with properties and inclusion tags
Date: Wed, 08 Jun 2011 18:33:59 -0700	[thread overview]
Message-ID: <87d3inhjp4.fsf_-_@ericabrahamsen.net> (raw)
In-Reply-To: <8639l020r3.wl%simon.guest@tesujimath.org> (Simon Guest's message of "Sat, 30 Apr 2011 09:42:08 +1200")

[-- Attachment #1: Type: text/plain, Size: 2422 bytes --]

Simon Guest <simon.guest@tesujimath.org> writes:

> At Fri, 29 Apr 2011 10:56:51 -0400,
> Nick Dokos wrote:
>> Indeed: it would require a bit of refactoring of Simon's code to provide the
>> function(s) to apply to each entry, and changes to the top level functions to
>> use the mapping API instead of looping explicitly.
>
> That sounds like a good idea.  I may at some stage want to exclude
> counting certain trees, and then I may have another look at this if
> someone else hasn't already done it.
>
> But for now, time pressure dictates I stop hacking on my word count
> function.
>
> cheers,
> Simon

I'm afraid this is a bit of a two-steps-forward, one-step-back
situation, but I've rejiggered Simon's code so that it now:

1. Uses the mapping and property APIs
2. Allows selection of subtrees for count via a tag
3. Sets wordcount totals for each subtree as a property, instead of an
   overlay

First of all, this requires the fix to
=org-end-of-meta-data-and-drawers= that I sent (and then re-sent) to
this list earlier today. Otherwise it will "work funny".

I changed it to use properties instead of overlays because I wanted
something that was persistent, and available for programmatic
manipulation. Plus, you can get an overlay effect with column view.

So right now M-x org-word-count will do the following:

1. Add the subtree word count as a property (=org-wc-prop-name=) to each
   headline in the buffer
2. Respect the region, if it's active
3. Operate only on trees tagged with =org-wc-include-tag=, if that tag
   is present
4. Report a buffer/region word count total in the minibuffer
5. With a prefix arg, *only* give a minibuffer report, don't set
   properties

The two variables =org-wc-include-tag= and =org-wc-prop-name= are buffer
local, unless I've misunderstood how buffer local works and screwed it
up.

There's a helper function, =org-wc-remove-all-props= that can be used to
remove the =org-wc-prop-name= property from all headlines. Does anyone
else think that =org-entry-delete= should remove the whole drawer if
there are no other properties left?

This is very much a proposal, and I've got a bit of time to work on it,
so I'm willing to field requests, though my elisp is bad. Two immediate
possibilities would be: automatically excluding subtrees tagged
"noexport", and using =org-context= to be cleverer about what to avoid.

Further suggestions (and code fixes) welcome!

Eric


[-- Attachment #2: org-wc.el --]
[-- Type: application/emacs-lisp, Size: 3125 bytes --]

  reply	other threads:[~2011-06-09  1:34 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
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                       ` Eric Abrahamsen [this message]
2011-05-14 22:48             ` 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=87d3inhjp4.fsf_-_@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=simon.guest@tesujimath.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 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).