From 85aa3c1850c4e234c42b6f9d3f3abf4d0de74dca Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sat, 1 Jul 2023 13:18:38 +0300 Subject: [PATCH] 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 --- lisp/org.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index fdb920864..832443c13 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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)