aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCameron Desautels2013-12-09 05:43:34 +0200
committerDmitry Gutov2013-12-09 05:43:34 +0200
commit8f48d131819e34322f27d1202bfb8a723ce93983 (patch)
tree78219778d42d8d0a5a5f108112919c6018da15c4
parentff8c9764201440d24f928d864235d66263b6ed2f (diff)
downloademacs-8f48d131819e34322f27d1202bfb8a723ce93983.tar.gz
emacs-8f48d131819e34322f27d1202bfb8a723ce93983.zip
* lisp/progmodes/ruby-mode.el (ruby-forward-string): Document.
Handle caret-delimited strings. Fixes: debbugs:16079
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/progmodes/ruby-mode.el25
2 files changed, 26 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2e36fdbe4cd..6e2631887ad 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12013-12-09 Cameron Desautels <camdez@gmail.com> (tiny change)
2
3 * progmodes/ruby-mode.el (ruby-forward-string): Document. Handle
4 caret-delimited strings (Bug#16079).
5
12013-12-09 Dmitry Gutov <dgutov@yandex.ru> 62013-12-09 Dmitry Gutov <dgutov@yandex.ru>
2 7
3 * progmodes/ruby-mode.el (ruby-accurate-end-of-block): When 8 * progmodes/ruby-mode.el (ruby-accurate-end-of-block): When
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 0f5a2a5b2a0..fe36e725426 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -795,11 +795,28 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'."
795 (t nil))))))))) 795 (t nil)))))))))
796 796
797(defun ruby-forward-string (term &optional end no-error expand) 797(defun ruby-forward-string (term &optional end no-error expand)
798 "TODO: document." 798 "Move forward across one balanced pair of string delimiters.
799Skips escaped delimiters. If EXPAND is non-nil, also ignores
800delimiters in interpolated strings.
801
802TERM should be a string containing either a single, self-matching
803delimiter (e.g. \"/\"), or a pair of matching delimiters with the
804close delimiter first (e.g. \"][\").
805
806When non-nil, search is bounded by position END.
807
808Throws an error if a balanced match is not found, unless NO-ERROR
809is non-nil, in which case nil will be returned.
810
811This command assumes the character after point is an opening
812delimiter."
799 (let ((n 1) (c (string-to-char term)) 813 (let ((n 1) (c (string-to-char term))
800 (re (if expand 814 (re (concat "[^\\]\\(\\\\\\\\\\)*\\("
801 (concat "[^\\]\\(\\\\\\\\\\)*\\([" term "]\\|\\(#{\\)\\)") 815 (if (string= term "^") ;[^] is not a valid regexp
802 (concat "[^\\]\\(\\\\\\\\\\)*[" term "]")))) 816 "\\^"
817 (concat "[" term "]"))
818 (when expand "\\|\\(#{\\)")
819 "\\)")))
803 (while (and (re-search-forward re end no-error) 820 (while (and (re-search-forward re end no-error)
804 (if (match-beginning 3) 821 (if (match-beginning 3)
805 (ruby-forward-string "}{" end no-error nil) 822 (ruby-forward-string "}{" end no-error nil)