[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org d314882301 2/2: org-narrow-to-subtree: Fix when cur
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org d314882301 2/2: org-narrow-to-subtree: Fix when current narrowing intersects subtree |
Date: |
Sun, 18 Feb 2024 09:58:32 -0500 (EST) |
branch: externals/org
commit d3148823019353f98d2cb88273d451b3b0d08c13
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-narrow-to-subtree: Fix when current narrowing intersects subtree
* lisp/org.el (org-narrow-to-subtree): Fix error when current
narrowing intersects the current subtree. When intersection happens,
behave historically, like the previous version of the command (that
did not use org-element).
---
lisp/org.el | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 7da23310d2..9470375590 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7375,11 +7375,19 @@ With optional argument ELEMENT narrow to subtree around
ELEMENT."
(org-element-lineage
(or element (org-element-at-point))
'headline 'with-self))
+ (begin (org-element-begin heading))
(end (org-element-end heading)))
- (if (and heading end)
- (narrow-to-region (org-element-begin heading)
- (if (= end (point-max))
- end (1- end)))
+ (if (and heading end
+ ;; Preserve historical behavior throwing an error when
+ ;; current heading starts before active narrowing.
+ (<= (point-min) begin))
+ (narrow-to-region
+ begin
+ ;; Preserve historical behavior not extending the active
+ ;; narrowing when the subtree extends beyond it.
+ (min (point-max)
+ (if (= end (point-max))
+ end (1- end))))
(signal 'outline-before-first-heading nil))))
(defun org-toggle-narrow-to-subtree ()