emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: "François Pinard" <pinard@iro.umontreal.ca>
Cc: emacs-orgmode@gnu.org
Subject: Re: Weight of headers
Date: Sun, 26 Feb 2012 13:30:36 +0100	[thread overview]
Message-ID: <874nudhj4j.fsf@gmail.com> (raw)
In-Reply-To: <8762euxqli.fsf@iro.umontreal.ca> ("François Pinard"'s message of "Sat, 25 Feb 2012 21:42:33 -0500")

Hello,

pinard@iro.umontreal.ca (François Pinard) writes:

> Here is a need I have once in a while, but for which I do not even have
> realistic suggestions to offer (at least, so I feel).  Maybe someone
> would offer more precise ideas. :-)
>
> When I have a big Org file which I want to re-organize, one of the
> criteria I use is to manage the overall plan, always keeping a logical
> organization of things of course, and move things around so top-level
> headers become of comparable weights.  By "weight", I mean the amount of
> contents, which is a fuzzy concept (it could be measured as the number
> of sub-headers or sub-items, the depth of structure, or even the raw
> number or lines or characters).
>
> It may look strange, but this is not so bizarre after all.  When reading
> a book, it is unusual to have a chapter having one page next to a
> chapter having hundreds of page; we expect that the effort of reading a
> chapter is not widely different from the effort of reading another.  In
> the same way, if I decide to tackle the topics under a header, I would
> expect that the energy needed somehow announces the energy that would be
> required to handle another level at the same level.  Of course, there
> could be quite a variance, but nevertheless, I would like to keep that
> variance within bounds.
>
> And recursively!  The same way I would like to work an weight
> equilibrium for top-level headers, I would like to do the same for the
> sub-headers of a given header.
>
> My need here is to get an estimate of the weight of displayed headers.
> I could of course expand the whole document and page through to get an
> idea, but at least in the document I'm currently handling, I'm just
> overwhelmed.  (This is not the only document triggering this in me, I
> remember having felt that need many times when I was using WorkFlowy).
>
> I once thought that colors could encode the weight, but it just would
> not fit Org mode so far that I understand it.  However, it seems that,
> here and there, Org uses some overly magic to display extra information
> -- for example, like with `C-c C-x C-d (`org-clock-display')'.  Maybe
> that some similar machinery could be use to display header weights?  Or
> maybe this would be overkill, because there are simpler ways which I
> just do not know?

The following function will give you the number of sub-headings and
paragraphs (or equivalent, i.e. tables verse-blocks....).

You'll need a recent Org to use it. 

#+begin_src emacs-lisp
(defun pinard-count-subtree-and-paragraphs ()
  "Return number of subtrees and paragraphs in the subtree at point."
  (interactive)
  (org-with-wide-buffer
   (org-narrow-to-subtree)
   (let ((tree (org-element-parse-buffer 'element)) (num-hl 0) (num-el 0))
     (org-element-map tree 'headline (lambda (hl) (incf num-hl)))
     (org-element-map
      tree '(paragraph table verse-block quote-block src-block example-block)
      (lambda (el) (incf num-el)))
     (message "Sub-headings: %d ; Parapraphs (or equivalent): %d"
              (1- num-hl) num-el))))
#+end_src

There's no colour, but it's a starter.


Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2012-02-26 12:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-26  2:42 Weight of headers François Pinard
2012-02-26 12:30 ` Nicolas Goaziou [this message]
2012-02-27  3:36   ` François Pinard
2012-02-27  3:56     ` François Pinard
2012-02-27  4:12       ` Nick Dokos
2012-02-27  4:52     ` Samuel Wales

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=874nudhj4j.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=pinard@iro.umontreal.ca \
    /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).