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.... dmj...@jabber.org
Email..... dm...@ictsoc.de

Attachment: pgp1ROKL7JIb5.pgp
Description: PGP signature

Reply via email to