Function: org-next-block
org-next-block is an interactive and byte-compiled function defined in
org.el.gz.
Signature
(org-next-block ARG &optional BACKWARD BLOCK-REGEXP)
Documentation
Jump to the next block.
With a prefix argument ARG, jump forward ARG many blocks.
When BACKWARD is non-nil, jump to the previous block.
When BLOCK-REGEXP is non-nil, use this regexp to find blocks. Match data is set according to this regexp when the function returns.
Return point at beginning of the opening line of found block. Throw an error if no block is found.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-next-block (arg &optional backward block-regexp)
"Jump to the next block.
With a prefix argument ARG, jump forward ARG many blocks.
When BACKWARD is non-nil, jump to the previous block.
When BLOCK-REGEXP is non-nil, use this regexp to find blocks.
Match data is set according to this regexp when the function
returns.
Return point at beginning of the opening line of found block.
Throw an error if no block is found."
(interactive "p")
(let ((re (or block-regexp "^[ \t]*#\\+BEGIN"))
(case-fold-search t)
(search-fn (if backward #'re-search-backward #'re-search-forward))
(count (or arg 1))
(origin (point))
last-element)
(if backward (forward-line 0)
(let ((inhibit-field-text-motion t)) (end-of-line)))
(while (and (> count 0) (funcall search-fn re nil t))
(let ((element (save-excursion
(goto-char (match-beginning 0))
(save-match-data (org-element-at-point)))))
(when (and (org-element-type-p
element
'(center-block comment-block dynamic-block
example-block export-block quote-block
special-block src-block verse-block))
(<= (match-beginning 0)
(org-element-post-affiliated element)))
(setq last-element element)
(cl-decf count))))
(if (= count 0)
(prog1 (goto-char (org-element-post-affiliated last-element))
(save-match-data (org-fold-show-context)))
(goto-char origin)
(user-error "No %s code blocks" (if backward "previous" "further")))))