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

Add sp-forward-hybrid-sexp and sp-backward-hybrid-sexp #843

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions smartparens.el
Original file line number Diff line number Diff line change
Expand Up @@ -5911,6 +5911,31 @@ is the last child of the enclosing sexp as defined by
(sp-backward-sexp)))))))
re)))

;; TODO: skip empty lines?
(defun sp-forward-hybrid-sexp (&optional arg)
"Move forward over one hybrid sexp.

See `sp-get-hybrid-sexp'."
(interactive "^p")
(-when-let (sexp (sp-get-hybrid-sexp))
(sp-get sexp
;; if we did not move forward at all, let's try one more time
(if (< (point) :end-suf)
(sp-get sexp (goto-char :end-suf))
(when (= (forward-line 1) 0)
(-when-let (sexp2 (sp-get-hybrid-sexp))
(sp-get sexp2 (goto-char :end-suf))))))))

(defun sp-backward-hybrid-sexp (&optional arg)
"Move backward over one hybrid sexp.

See `sp-get-hybrid-sexp'."
(interactive "^p")
(-when-let (sexp (save-excursion
(when (sp-backward-sexp)
(sp-get-hybrid-sexp))))
(sp-get sexp (goto-char :beg-prf))))

(defun sp--raw-argument-p (arg)
"Return t if ARG represents raw argument, that is a non-empty list."
(and (listp arg) (car arg)))
Expand Down