emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] New feature: loop over siblings for some commands


From: David Maus
Subject: Re: [O] New feature: loop over siblings for some commands
Date: Wed, 20 Jul 2011 21:46:59 +0200
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.8 Emacs/23.2 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

After a first look at the macro and its usage I have the feeling that
the macro would be wrong and/or a bad design choice.

It conditionally implements a mapping of body to a headline's
siblings. Thus it is a specialized case of applying a function to zero
or more headlines based on a selection criteria: In other words it is
a special case of org-map-entries.

So first there is duplicate code. Second the usage of the macro in for
instance `org-schedule'. The macro is wrapped around the entire
function body (except the interactive expression) and its only use is
avoidance of creating a separate function with the scheduling
implementation.

I highly recommend to not use this macro but to build the intended
functionality with separate building blocks: Factor out the flesh of
the respective functions (e.g. org-schedule) and use org-map-entries
to map. As far as I can see, the latter provides all we need:

(org-map-entries FUNC &optional MATCH SCOPE &rest SKIP)

We have FUNC (schedule) and MATCH (siblings). Region is the SCOPE (we
have to extend map-entries here). We might even extend the syntax of
MATCH to accept symbols indicating concepts like "sibling" and the
like. Ideally:

#+begin_src emacs-lisp
  (if (or (not (org-region-active-p))
          (not org-loop-over-siblings-within-active-region-p))  ;; -p? its not 
a predicate function!
      (org-really-do-the-schedule)
    (org-map-entries 'org-really-do-the-schedule 'siblings 'region))
#+end_src

Another abstraction: Instead
'org-loop-over-siblings-with-active-region' something like:
'org-loop-over-headlines-with-active-region' that can be set to a
symbol or a list of symbols indicating which headings to loop over
(e.g. 'siblings, 'children, ...).

Best,
  -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... address@hidden
Email..... address@hidden

Attachment: pgpZIMYJPP3cp.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]