diff options
| author | Joakim Verona | 2012-12-14 06:02:06 +0100 |
|---|---|---|
| committer | Joakim Verona | 2012-12-14 06:02:06 +0100 |
| commit | cd184a052905b1be48208651d0b5bfc6d29a898f (patch) | |
| tree | ce2563b17c9fc0592bc3d84928126df90d01a549 | |
| parent | fa9b2fc34fc5d342e6a92c84aff1f4971d559d08 (diff) | |
| parent | dbb530d9887fd51de9f8e338b325537d9eac0a3a (diff) | |
| download | emacs-cd184a052905b1be48208651d0b5bfc6d29a898f.tar.gz emacs-cd184a052905b1be48208651d0b5bfc6d29a898f.zip | |
auto upstream
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 38 | ||||
| -rw-r--r-- | test/ChangeLog | 5 | ||||
| -rw-r--r-- | test/automated/ruby-mode-tests.el | 22 |
4 files changed, 57 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 66af3378b14..2d12a357cbf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2012-12-14 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * progmodes/ruby-mode.el (ruby-syntax-propertize-function): | ||
| 4 | Extract `ruby-syntax-propertize-expansions'. | ||
| 5 | (ruby-syntax-propertize-expansions): Only change syntax on | ||
| 6 | certain string delimiters, to punctuation. This way the common | ||
| 7 | functions like forward-word and thing-at-point still work. | ||
| 8 | (ruby-match-expression-expansion): Improve readability. | ||
| 9 | |||
| 1 | 2012-12-13 Juanma Barranquero <lekktu@gmail.com> | 10 | 2012-12-13 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 11 | ||
| 3 | * emacs-lisp/edebug.el (edebug-unload-function): Make sure that | 12 | * emacs-lisp/edebug.el (edebug-unload-function): Make sure that |
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 9d78b20ba4c..6b9e921be67 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el | |||
| @@ -1253,18 +1253,7 @@ It will be properly highlighted even when the call omits parens.")) | |||
| 1253 | ((concat "\\(?:^\\|[[ \t\n<+(,=]\\)" ruby-percent-literal-beg-re) | 1253 | ((concat "\\(?:^\\|[[ \t\n<+(,=]\\)" ruby-percent-literal-beg-re) |
| 1254 | (1 (prog1 "|" (ruby-syntax-propertize-percent-literal end))))) | 1254 | (1 (prog1 "|" (ruby-syntax-propertize-percent-literal end))))) |
| 1255 | (point) end) | 1255 | (point) end) |
| 1256 | (remove-text-properties start end '(ruby-expansion-match-data)) | 1256 | (ruby-syntax-propertize-expansions start end)) |
| 1257 | (goto-char start) | ||
| 1258 | ;; Find all expression expansions and | ||
| 1259 | ;; - set the syntax of all text inside to whitespace, | ||
| 1260 | ;; - save the match data to a text property, for font-locking later. | ||
| 1261 | (while (re-search-forward ruby-expression-expansion-re end 'move) | ||
| 1262 | (when (ruby-in-ppss-context-p 'string) | ||
| 1263 | (put-text-property (match-beginning 2) (match-end 2) | ||
| 1264 | 'syntax-table (string-to-syntax "-")) | ||
| 1265 | (put-text-property (match-beginning 2) (1+ (match-beginning 2)) | ||
| 1266 | 'ruby-expansion-match-data | ||
| 1267 | (match-data))))) | ||
| 1268 | 1257 | ||
| 1269 | (defun ruby-syntax-propertize-heredoc (limit) | 1258 | (defun ruby-syntax-propertize-heredoc (limit) |
| 1270 | (let ((ppss (syntax-ppss)) | 1259 | (let ((ppss (syntax-ppss)) |
| @@ -1331,6 +1320,23 @@ It will be properly highlighted even when the call omits parens.")) | |||
| 1331 | (string-to-syntax "|"))) | 1320 | (string-to-syntax "|"))) |
| 1332 | ;; Unclosed literal, leave the following text unpropertized. | 1321 | ;; Unclosed literal, leave the following text unpropertized. |
| 1333 | ((scan-error search-failed) (goto-char limit)))))) | 1322 | ((scan-error search-failed) (goto-char limit)))))) |
| 1323 | |||
| 1324 | (defun ruby-syntax-propertize-expansions (start end) | ||
| 1325 | (remove-text-properties start end '(ruby-expansion-match-data)) | ||
| 1326 | (goto-char start) | ||
| 1327 | ;; Find all expression expansions and | ||
| 1328 | ;; - save the match data to a text property, for font-locking later, | ||
| 1329 | ;; - set the syntax of all double quotes and backticks to puctuation. | ||
| 1330 | (while (re-search-forward ruby-expression-expansion-re end 'move) | ||
| 1331 | (let ((beg (match-beginning 2)) | ||
| 1332 | (end (match-end 2))) | ||
| 1333 | (when (and beg (save-excursion (nth 3 (syntax-ppss beg)))) | ||
| 1334 | (put-text-property beg (1+ beg) 'ruby-expansion-match-data | ||
| 1335 | (match-data)) | ||
| 1336 | (goto-char beg) | ||
| 1337 | (while (re-search-forward "[\"`]" end 'move) | ||
| 1338 | (put-text-property (match-beginning 0) (match-end 0) | ||
| 1339 | 'syntax-table (string-to-syntax "."))))))) | ||
| 1334 | ) | 1340 | ) |
| 1335 | 1341 | ||
| 1336 | ;; For Emacsen where syntax-propertize-rules is not (yet) available, | 1342 | ;; For Emacsen where syntax-propertize-rules is not (yet) available, |
| @@ -1605,10 +1611,10 @@ See `font-lock-syntax-table'.") | |||
| 1605 | "Additional expressions to highlight in Ruby mode.") | 1611 | "Additional expressions to highlight in Ruby mode.") |
| 1606 | 1612 | ||
| 1607 | (defun ruby-match-expression-expansion (limit) | 1613 | (defun ruby-match-expression-expansion (limit) |
| 1608 | (let ((prop 'ruby-expansion-match-data) pos value) | 1614 | (let* ((prop 'ruby-expansion-match-data) |
| 1609 | (when (and (setq pos (next-single-char-property-change (point) prop | 1615 | (pos (next-single-char-property-change (point) prop nil limit)) |
| 1610 | nil limit)) | 1616 | value) |
| 1611 | (> pos (point))) | 1617 | (when (and pos (> pos (point))) |
| 1612 | (goto-char pos) | 1618 | (goto-char pos) |
| 1613 | (or (and (setq value (get-text-property pos prop)) | 1619 | (or (and (setq value (get-text-property pos prop)) |
| 1614 | (progn (set-match-data value) t)) | 1620 | (progn (set-match-data value) t)) |
diff --git a/test/ChangeLog b/test/ChangeLog index 142dfcb42fd..ccebdda7411 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-12-14 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * automated/ruby-mode-tests.el | ||
| 4 | Rename one interpolation test; add three more. | ||
| 5 | |||
| 1 | 2012-12-11 Glenn Morris <rgm@gnu.org> | 6 | 2012-12-11 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * automated/f90.el (f90-test-bug13138): New test. | 8 | * automated/f90.el (f90-test-bug13138): New test. |
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index 620fe72fb69..6ae23f94f1a 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el | |||
| @@ -276,13 +276,33 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 276 | (ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16 | 276 | (ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16 |
| 277 | font-lock-variable-name-face)) | 277 | font-lock-variable-name-face)) |
| 278 | 278 | ||
| 279 | (ert-deftest ruby-interpolation-suppresses-syntax-inside () | 279 | (ert-deftest ruby-interpolation-suppresses-quotes-inside () |
| 280 | (let ((s "\"<ul><li>#{@files.join(\"</li><li>\")}</li></ul>\"")) | 280 | (let ((s "\"<ul><li>#{@files.join(\"</li><li>\")}</li></ul>\"")) |
| 281 | (ruby-assert-state s 8 nil) | 281 | (ruby-assert-state s 8 nil) |
| 282 | (ruby-assert-face s 9 font-lock-string-face) | 282 | (ruby-assert-face s 9 font-lock-string-face) |
| 283 | (ruby-assert-face s 10 font-lock-variable-name-face) | 283 | (ruby-assert-face s 10 font-lock-variable-name-face) |
| 284 | (ruby-assert-face s 41 font-lock-string-face))) | 284 | (ruby-assert-face s 41 font-lock-string-face))) |
| 285 | 285 | ||
| 286 | (ert-deftest ruby-interpolation-suppresses-one-double-quote () | ||
| 287 | (let ((s "\"foo#{'\"'}\"")) | ||
| 288 | (ruby-assert-state s 8 nil) | ||
| 289 | (ruby-assert-face s 8 font-lock-variable-name-face) | ||
| 290 | (ruby-assert-face s 11 font-lock-string-face))) | ||
| 291 | |||
| 292 | (ert-deftest ruby-interpolation-suppresses-one-backtick () | ||
| 293 | (let ((s "`as#{'`'}das`")) | ||
| 294 | (ruby-assert-state s 8 nil))) | ||
| 295 | |||
| 296 | (ert-deftest ruby-interpolation-keeps-non-quote-syntax () | ||
| 297 | (let ((s "\"foo#{baz.tee}bar\"")) | ||
| 298 | (with-temp-buffer | ||
| 299 | (save-excursion | ||
| 300 | (insert s)) | ||
| 301 | (ruby-mode) | ||
| 302 | (font-lock-fontify-buffer) | ||
| 303 | (search-forward "tee") | ||
| 304 | (should (string= (thing-at-point 'symbol) "tee"))))) | ||
| 305 | |||
| 286 | (ert-deftest ruby-interpolation-inside-percent-literal-with-paren () | 306 | (ert-deftest ruby-interpolation-inside-percent-literal-with-paren () |
| 287 | :expected-result :failed | 307 | :expected-result :failed |
| 288 | (let ((s "%(^#{\")\"}^)")) | 308 | (let ((s "%(^#{\")\"}^)")) |