Open QiangF opened 2 years ago
Someone have a function for this:
(defun my-org-babel-goto-block-corner (p)
"Go to the beginning of the current block.
If called with a prefix, go to the end of the block"
(interactive "P")
(let* ((element (org-element-at-point)))
(when (or (eq (org-element-type element) 'example-block)
(eq (org-element-type element) 'src-block))
(let ((begin (org-element-property :begin element))
(end (org-element-property :end element)))
;; Ensure point is not on a blank line after the block.
(beginning-of-line)
(skip-chars-forward " \r\t\n" end)
(when (< (point) end)
(goto-char (if p end begin))
(when p
(skip-chars-backward " \r\t\n")
(beginning-of-line)))))))
It is handy but it contradicts with Puni's design:
puni-strict-forward/backward-sexp
functions and avoid ad-hoc logic.An alternative way is to advise puni-beginning/end-of-sexp
to do things differently in org-mode. If you could find a way to do this, could you write it in the wiki?
I find evil-matchit has support for different kind of matching pairs. Sadly it requires evil mode.
To be specific, make puni-beginning-of-sexp and puni-end-of-sexp jump to cursor position designated with "|" in the following examples.