diff options
| author | Cameron Desautels | 2013-12-09 05:43:34 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2013-12-09 05:43:34 +0200 |
| commit | 8f48d131819e34322f27d1202bfb8a723ce93983 (patch) | |
| tree | 78219778d42d8d0a5a5f108112919c6018da15c4 | |
| parent | ff8c9764201440d24f928d864235d66263b6ed2f (diff) | |
| download | emacs-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/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 25 |
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 @@ | |||
| 1 | 2013-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 | |||
| 1 | 2013-12-09 Dmitry Gutov <dgutov@yandex.ru> | 6 | 2013-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. |
| 799 | Skips escaped delimiters. If EXPAND is non-nil, also ignores | ||
| 800 | delimiters in interpolated strings. | ||
| 801 | |||
| 802 | TERM should be a string containing either a single, self-matching | ||
| 803 | delimiter (e.g. \"/\"), or a pair of matching delimiters with the | ||
| 804 | close delimiter first (e.g. \"][\"). | ||
| 805 | |||
| 806 | When non-nil, search is bounded by position END. | ||
| 807 | |||
| 808 | Throws an error if a balanced match is not found, unless NO-ERROR | ||
| 809 | is non-nil, in which case nil will be returned. | ||
| 810 | |||
| 811 | This command assumes the character after point is an opening | ||
| 812 | delimiter." | ||
| 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) |