Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: make puni support org blocks #14

Open
QiangF opened this issue Dec 30, 2021 · 3 comments
Open

Feature request: make puni support org blocks #14

QiangF opened this issue Dec 30, 2021 · 3 comments

Comments

@QiangF
Copy link

QiangF commented Dec 30, 2021

To be specific, make puni-beginning-of-sexp and puni-end-of-sexp jump to cursor position designated with "|" in the following examples.

1. Greater Blocks

  #+BEGIN_NAME PARAMETERS
  |CONTENTS1
  CONTENTS2|
  #+END_NAME

2. Dynamic Blocks

  #+BEGIN: NAME PARAMETERS
  |CONTENTS1
  CONTENTS2|
  #+END:

3. Latex Environment

  \begin{equation*}
  |CONTENTS1
  CONTENTS2|
  \end{equation*}
@QiangF
Copy link
Author

QiangF commented Dec 30, 2021

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)))))))

@AmaiKinono
Copy link
Owner

It is handy but it contradicts with Puni's design:

  • I'd like to avoid mode-specific logic in Puni.
  • All the user commands should be built on the 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?

@QiangF
Copy link
Author

QiangF commented Dec 31, 2021

I find evil-matchit has support for different kind of matching pairs. Sadly it requires evil mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants