Hi Carsten,

At Thu, 25 Aug 2011 07:40:52 +0200,
Carsten Dominik wrote:
>
>
> On 25.8.2011, at 06:25, David Maus wrote:
>
> > * org.el (org-map-entries): Extend scope 'region to include entire
> > body of last headline in active region.
> > ---
> > lisp/org.el |    8 ++++++--
> > 1 files changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/lisp/org.el b/lisp/org.el
> > index de8c72b..b69b77c 100644
> > --- a/lisp/org.el
> > +++ b/lisp/org.el
> > @@ -13633,8 +13633,12 @@ a *different* entry, you cannot use these 
> > techniques."
> >            (org-narrow-to-subtree)
> >            (setq scope nil))
> >           ((and (eq scope 'region) (org-region-active-p))
> > -          (narrow-to-region (region-beginning) (region-end))
> > -          (setq scope nil)))
> > +          (let ((end (save-excursion
> > +                       (goto-char (region-end))
> > +                       (outline-next-heading)
> > +                       (point))))
> > +            (narrow-to-region (region-beginning) end)
> > +            (setq scope nil))))
>
>
> Hi David,
>
> I think the better algorithm here would be this:
> If region-end is at the beginning of a line and that line is a headline,
> use region-end as it is.  If not, jump to the next headline.

Thanks, yes. This makes sense. Attached patch supersedes the previous.

Best,
  -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmj...@jabber.org
Email..... dm...@ictsoc.de
From 957dcbe6ae40fa332e48455a260782ba3e61e68d Mon Sep 17 00:00:00 2001
From: David Maus <dm...@ictsoc.de>
Date: Tue, 30 Aug 2011 06:22:12 +0200
Subject: [PATCH 1/4] Extend scope 'region to include entire body of last 
headline in active region

* org.el (org-map-entries): Extend scope 'region to include
entire body of last headline in active region.
---
 lisp/org.el |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index d63b854..b770fa6 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13629,7 +13629,12 @@ a *different* entry, you cannot use these techniques."
               (org-narrow-to-subtree)
               (setq scope nil))
              ((and (eq scope 'region) (org-region-active-p))
-              (narrow-to-region (region-beginning) (region-end))
+              (narrow-to-region (region-beginning)
+                                (save-excursion
+                                  (goto-char (region-end))
+                                  (unless (and (bolp) (org-at-heading-p))
+                                    (outline-next-heading))
+                                  (point)))
               (setq scope nil)))
 
        (if (not scope)
-- 
1.7.2.5

Attachment: pgpqnT8KK8oE5.pgp
Description: PGP signature

Reply via email to