Re: [PATCH] Fix org-set-tags-command active region bug

2022-10-28 Thread Ihor Radchenko
Alex Giorev  writes:

> When `org-loop-over-headlines-in-active-region' is 'start-level, the
> command should loop only over the headings having the same level as the
> first one, but it loops over all headings in the region. This patch fixes
> the issue.

Thanks for reporting and providing the patch!
I have applied an equivalent patch that uses the code style more similar
to other places in Org where `org-loop-over-headlines-in-active-region'
is handled.

https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=78806952218e87f4a413a29c908161f97572f97d

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



[PATCH] Fix org-set-tags-command active region bug

2022-02-09 Thread Alex Giorev
When `org-loop-over-headlines-in-active-region' is 'start-level, the
command should loop only over the headings having the same level as the
first one, but it loops over all headings in the region. This patch fixes
the issue.
From 289d6bdcb8328554c6dd4136d38f1220d239940e Mon Sep 17 00:00:00 2001
From: alexgiorev 
Date: Wed, 9 Feb 2022 16:22:09 +0200
Subject: [PATCH] lisp/org.el: Fix org-set-tags-command active region bug

* lisp/org.el (org-set-tags-command): When called with an active
region and `org-loop-over-headlines-in-active-region` having a value
`start-level', it is supposed to loop only over the headings at the
same level as the first one, but without this fix it loops over all
headings in the region.
---
 lisp/org.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index ef8d460e1..b2091a4fe 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12183,11 +12183,12 @@ in Lisp code use `org-set-tags' instead."
 (cond
  ((equal '(4) arg) (org-align-tags t))
  ((and (org-region-active-p) org-loop-over-headlines-in-active-region)
-  (let (org-loop-over-headlines-in-active-region) ;  hint: infinite recursion.
+  (let ((original org-loop-over-headlines-in-active-region)
+(org-loop-over-headlines-in-active-region nil)) ;  hint: infinite recursion.
 	(org-map-entries
 	 #'org-set-tags-command
 	 nil
-	 (if (eq org-loop-over-headlines-in-active-region 'start-level)
+	 (if (eq original 'start-level)
 	 'region-start-level
 	   'region)
 	 (lambda () (when (org-invisible-p) (org-end-of-subtree nil t))
-- 
2.25.1