From 9f070cda555df5293914c068fb31464e3abcbb88 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Fri, 19 Jan 2018 12:20:36 +0100 Subject: [PATCH] Add sp-forward-hybrid-sexp and sp-backward-hybrid-sexp --- smartparens.el | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/smartparens.el b/smartparens.el index a60ff6d9..cfedf420 100644 --- a/smartparens.el +++ b/smartparens.el @@ -5900,6 +5900,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)))