emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix org-set-tags-command active region bug
@ 2022-02-09 14:35 Alex Giorev
  2022-10-29  5:30 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Giorev @ 2022-02-09 14:35 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 226 bytes --]

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.

[-- Attachment #1.2: Type: text/html, Size: 260 bytes --]

[-- Attachment #2: 0001-lisp-org.el-Fix-org-set-tags-command-active-region-b.patch --]
[-- Type: text/x-patch, Size: 1416 bytes --]

From 289d6bdcb8328554c6dd4136d38f1220d239940e Mon Sep 17 00:00:00 2001
From: alexgiorev <alex.giorev@gmail.com>
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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix org-set-tags-command active region bug
  2022-02-09 14:35 [PATCH] Fix org-set-tags-command active region bug Alex Giorev
@ 2022-10-29  5:30 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2022-10-29  5:30 UTC (permalink / raw)
  To: Alex Giorev; +Cc: emacs-orgmode

Alex Giorev <alex.giorev@gmail.com> 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 <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-29  5:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-09 14:35 [PATCH] Fix org-set-tags-command active region bug Alex Giorev
2022-10-29  5:30 ` Ihor Radchenko

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).