diff --git a/make-release.sh b/make-release.sh old mode 100755 new mode 100644 diff --git a/smartparens-ruby.el b/smartparens-ruby.el index 3ba86716..ed504842 100644 --- a/smartparens-ruby.el +++ b/smartparens-ruby.el @@ -127,7 +127,8 @@ ID, ACTION, CONTEXT." (when (equal action 'barf-forward) (sp-get enc - (let ((beg-line (line-number-at-pos :beg-in))) + (let ((beg-line (line-number-at-pos :beg-in)) + (end-line (line-number-at-pos :end-in))) (sp-forward-sexp arg) (sp-ruby-maybe-one-space) (when (not (= (line-number-at-pos) beg-line)) diff --git a/smartparens.el b/smartparens.el index 4c646cf3..ee4bbead 100644 --- a/smartparens.el +++ b/smartparens.el @@ -5338,15 +5338,12 @@ This function simply transforms BOUNDS, which is a cons (BEG . END) into format compatible with `sp-get-sexp'." (let* ((op (char-to-string (char-after (car bounds)))) (cl (char-to-string (char-before (cdr bounds))))) - ;; if the closing and opening isn't the same token, we should - ;; return nil - (when (equal op cl) - (list :beg (car bounds) - :end (cdr bounds) - :op cl - :cl cl - :prefix (sp--get-prefix (car bounds) op) - :suffix (sp--get-suffix (cdr bounds) cl))))) + (list :beg (car bounds) + :end (cdr bounds) + :op op + :cl cl + :prefix (sp--get-prefix (car bounds) op) + :suffix (sp--get-suffix (cdr bounds) cl)))) (defun sp-get-string (&optional back) "Find the nearest string after point, or before if BACK is non-nil. @@ -5666,7 +5663,9 @@ expressions are considered." (sp-get-sexp t)) ((sp--valid-initial-delimiter-p (sp--looking-back (sp--get-opening-regexp (sp--get-allowed-pair-list)) nil)) (sp-get-sexp t)) - ((and (eq (syntax-class (syntax-after (1- (point)))) 7) + ((and (memq (syntax-class + (syntax-after (1- (point)))) + '(7 15)) (not (sp-char-is-escaped-p (1- (point))))) (if (eq t (sp-point-in-string)) (save-excursion @@ -5717,7 +5716,8 @@ expressions are considered." (sp-get-sexp nil)) ;; TODO: merge the following two conditions and use ;; `sp-get-stringlike-or-textmode-expression' - ((and (eq (syntax-class (syntax-after (point))) 7) + ((and (memq (syntax-class (syntax-after (point))) + '(7 15)) (not (sp-char-is-escaped-p))) ;; It might happen that the string delimiter we are ;; looking at is nested inside another string diff --git a/test/smartparens-get-paired-expression-ruby-test.el b/test/smartparens-get-paired-expression-ruby-test.el index 698c8671..c14649ad 100644 --- a/test/smartparens-get-paired-expression-ruby-test.el +++ b/test/smartparens-get-paired-expression-ruby-test.el @@ -32,3 +32,21 @@ (ert-deftest sp-test-get-paired-expression-ruby-backward-fail () (sp-test--paired-expression-parse-in-ruby "de end|" nil t) ) + +(defun sp-test--thing-parse-in-ruby (initial result &optional back) + (let ((sp-pairs '((t . ((:open "def" :close "end" :actions (insert wrap autoskip navigate)) + (:open "if" :close "end" :actions (insert wrap autoskip navigate)) + (:open "do" :close "end" :actions (insert wrap autoskip navigate)) + (:open "begin" :close "end" :actions (insert wrap autoskip navigate)) + (:open "(" :close ")" :actions (insert wrap autoskip navigate))))))) + (sp-test-with-temp-buffer initial + (ruby-mode) + (should (equal (sp-get-thing back) result))))) + +(ert-deftest sp-test-get-thing-generic-string-ruby () + (sp-test--thing-parse-in-ruby "C = |%w(asd)#asdas" + '(:beg 5 :end 12 :op "%" :cl ")" :prefix "" :suffix "")) + ;; It's not exactly reversible, but this way is backward compatible + (sp-test--thing-parse-in-ruby "C = %w(asd)|#asdas" + '(:beg 7 :end 12 :op "(" :cl ")" :prefix "" :suffix "") t)) +