Skip to content

Commit 52d0fb3

Browse files
committed
Add sp-forward-hybrid-sexp and sp-backward-hybrid-sexp
1 parent 163a593 commit 52d0fb3

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

smartparens.el

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5896,6 +5896,31 @@ is the last child of the enclosing sexp as defined by
58965896
(sp-backward-sexp)))))))
58975897
re)))
58985898

5899+
;; TODO: skip empty lines?
5900+
(defun sp-forward-hybrid-sexp (&optional arg)
5901+
"Move forward over one hybrid sexp.
5902+
5903+
See `sp-get-hybrid-sexp'."
5904+
(interactive "^p")
5905+
(-when-let (sexp (sp-get-hybrid-sexp))
5906+
(sp-get sexp
5907+
;; if we did not move forward at all, let's try one more time
5908+
(if (< (point) :end-suf)
5909+
(sp-get sexp (goto-char :end-suf))
5910+
(when (= (forward-line 1) 0)
5911+
(-when-let (sexp2 (sp-get-hybrid-sexp))
5912+
(sp-get sexp2 (goto-char :end-suf))))))))
5913+
5914+
(defun sp-backward-hybrid-sexp (&optional arg)
5915+
"Move backward over one hybrid sexp.
5916+
5917+
See `sp-get-hybrid-sexp'."
5918+
(interactive "^p")
5919+
(-when-let (sexp (save-excursion
5920+
(when (sp-backward-sexp)
5921+
(sp-get-hybrid-sexp))))
5922+
(sp-get sexp (goto-char :beg-prf))))
5923+
58995924
(defun sp--raw-argument-p (arg)
59005925
"Return t if ARG represents raw argument, that is a non-empty list."
59015926
(and (listp arg) (car arg)))

0 commit comments

Comments
 (0)