org-narrow-to-block: Use element API and handle all the block types

* lisp/org.el (org-narrow-to-block): Narrow to any block type,
including dynamic blocks.  Use org-element API.

Reported-by: pva-outdoor@yandex.ru
Link: https://orgmode.org/list/87a5wij05o.fsf@yandex.ru
This commit is contained in:
Ihor Radchenko 2023-07-01 13:18:38 +03:00
parent dc70878fc0
commit 85aa3c1850
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 3 additions and 4 deletions

View File

@ -7303,10 +7303,9 @@ Use the command `\\[widen]' to see the whole buffer again."
Use the command `\\[widen]' to see the whole buffer again."
(interactive)
(let* ((case-fold-search t)
(blockp (org-between-regexps-p "^[ \t]*#\\+begin_.*"
"^[ \t]*#\\+end_.*")))
(if blockp
(narrow-to-region (car blockp) (cdr blockp))
(element (org-element-at-point)))
(if (string-match-p "block" (symbol-name (org-element-type element)))
(org-narrow-to-element)
(user-error "Not in a block"))))
(defun org-clone-subtree-with-time-shift (n &optional shift)