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).
This commit is contained in:
parent
7360c6b427
commit
d314882301
16
lisp/org.el
16
lisp/org.el
|
@ -7375,11 +7375,19 @@ With optional argument ELEMENT narrow to subtree around ELEMENT."
|
||||||
(org-element-lineage
|
(org-element-lineage
|
||||||
(or element (org-element-at-point))
|
(or element (org-element-at-point))
|
||||||
'headline 'with-self))
|
'headline 'with-self))
|
||||||
|
(begin (org-element-begin heading))
|
||||||
(end (org-element-end heading)))
|
(end (org-element-end heading)))
|
||||||
(if (and heading end)
|
(if (and heading end
|
||||||
(narrow-to-region (org-element-begin heading)
|
;; Preserve historical behavior throwing an error when
|
||||||
(if (= end (point-max))
|
;; current heading starts before active narrowing.
|
||||||
end (1- end)))
|
(<= (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))))
|
(signal 'outline-before-first-heading nil))))
|
||||||
|
|
||||||
(defun org-toggle-narrow-to-subtree ()
|
(defun org-toggle-narrow-to-subtree ()
|
||||||
|
|
Loading…
Reference in New Issue