emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alex Giorev <alex.giorev@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Fix org-set-tags-command active region bug
Date: Wed, 9 Feb 2022 16:35:34 +0200	[thread overview]
Message-ID: <CAMq3WZh1sGW+BNKW1hZA+wP=iFskzShF-D-wUqWYqb_EponZ8g@mail.gmail.com> (raw)


[-- 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


             reply	other threads:[~2022-02-09 15:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09 14:35 Alex Giorev [this message]
2022-10-29  5:30 ` [PATCH] Fix org-set-tags-command active region bug Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMq3WZh1sGW+BNKW1hZA+wP=iFskzShF-D-wUqWYqb_EponZ8g@mail.gmail.com' \
    --to=alex.giorev@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).