Commit fafba80d authored by Bozhidar Batsov's avatar Bozhidar Batsov

Simplify ruby--string-region

* progmodes/ruby-mode.el (ruby--string-region): Simplify code
by leveraging `syntax-ppss'.
parent 251463c6
2014-12-22 Bozhidar Batsov <>
* progmodes/ruby-mode.el (ruby--string-region): Simplify code
by leveraging `syntax-ppss'.
2014-12-22 Artur Malabarba <>
* let-alist.el (let-alist): Use `make-symbol' instead of `gensym'.
......@@ -1768,17 +1768,12 @@ If the result is do-end block, it will always be multiline."
(defun ruby--string-region ()
"Return region for string at point."
(let ((orig-point (point)) (regex "'\\(\\(\\\\'\\)\\|[^']\\)*'\\|\"\\(\\(\\\\\"\\)\\|[^\"]\\)*\"") beg end)
(goto-char (line-beginning-position))
(while (and (re-search-forward regex (line-end-position) t) (not (and beg end)))
(let ((match-beg (match-beginning 0)) (match-end (match-end 0)))
(when (and
(> orig-point match-beg)
(< orig-point match-end))
(setq beg match-beg)
(setq end match-end))))
(and beg end (list beg end)))))
(let ((state (syntax-ppss)))
(when (memq (nth 3 state) '(?' ?\"))
(goto-char (nth 8 state))
(list (nth 8 state) (point))))))
(defun ruby-string-at-point-p ()
"Check if cursor is at a string or not."
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment