[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r111223: * lisp/progmodes/ruby-mode.e
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r111223: * lisp/progmodes/ruby-mode.el (ruby-syntax-propertize-function): |
Date: |
Fri, 14 Dec 2012 08:55:23 +0400 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111223
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Fri 2012-12-14 08:55:23 +0400
message:
* lisp/progmodes/ruby-mode.el (ruby-syntax-propertize-function):
Extract `ruby-syntax-propertize-expansions'.
(ruby-syntax-propertize-expansions): Only change syntax on
certain string delimiters, to punctuation. This way the common
functions like forward-word and thing-at-point still work.
* test/automated/ruby-mode-tests.el
Rename one interpolation test; add three more.
modified:
lisp/ChangeLog
lisp/progmodes/ruby-mode.el
test/ChangeLog
test/automated/ruby-mode-tests.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-12-13 18:15:42 +0000
+++ b/lisp/ChangeLog 2012-12-14 04:55:23 +0000
@@ -1,3 +1,12 @@
+2012-12-14 Dmitry Gutov <address@hidden>
+
+ * progmodes/ruby-mode.el (ruby-syntax-propertize-function):
+ Extract `ruby-syntax-propertize-expansions'.
+ (ruby-syntax-propertize-expansions): Only change syntax on
+ certain string delimiters, to punctuation. This way the common
+ functions like forward-word and thing-at-point still work.
+ (ruby-match-expression-expansion): Improve readability.
+
2012-12-13 Juanma Barranquero <address@hidden>
* emacs-lisp/edebug.el (edebug-unload-function): Make sure that
=== modified file 'lisp/progmodes/ruby-mode.el'
--- a/lisp/progmodes/ruby-mode.el 2012-11-14 12:17:21 +0000
+++ b/lisp/progmodes/ruby-mode.el 2012-12-14 04:55:23 +0000
@@ -1253,18 +1253,7 @@
((concat "\\(?:^\\|[[ \t\n<+(,=]\\)" ruby-percent-literal-beg-re)
(1 (prog1 "|" (ruby-syntax-propertize-percent-literal end)))))
(point) end)
- (remove-text-properties start end '(ruby-expansion-match-data))
- (goto-char start)
- ;; Find all expression expansions and
- ;; - set the syntax of all text inside to whitespace,
- ;; - save the match data to a text property, for font-locking later.
- (while (re-search-forward ruby-expression-expansion-re end 'move)
- (when (ruby-in-ppss-context-p 'string)
- (put-text-property (match-beginning 2) (match-end 2)
- 'syntax-table (string-to-syntax "-"))
- (put-text-property (match-beginning 2) (1+ (match-beginning 2))
- 'ruby-expansion-match-data
- (match-data)))))
+ (ruby-syntax-propertize-expansions start end))
(defun ruby-syntax-propertize-heredoc (limit)
(let ((ppss (syntax-ppss))
@@ -1331,6 +1320,23 @@
(string-to-syntax "|")))
;; Unclosed literal, leave the following text unpropertized.
((scan-error search-failed) (goto-char limit))))))
+
+ (defun ruby-syntax-propertize-expansions (start end)
+ (remove-text-properties start end '(ruby-expansion-match-data))
+ (goto-char start)
+ ;; Find all expression expansions and
+ ;; - save the match data to a text property, for font-locking later,
+ ;; - set the syntax of all double quotes and backticks to puctuation.
+ (while (re-search-forward ruby-expression-expansion-re end 'move)
+ (let ((beg (match-beginning 2))
+ (end (match-end 2)))
+ (when (and beg (save-excursion (nth 3 (syntax-ppss beg))))
+ (put-text-property beg (1+ beg) 'ruby-expansion-match-data
+ (match-data))
+ (goto-char beg)
+ (while (re-search-forward "[\"`]" end 'move)
+ (put-text-property (match-beginning 0) (match-end 0)
+ 'syntax-table (string-to-syntax ".")))))))
)
;; For Emacsen where syntax-propertize-rules is not (yet) available,
@@ -1605,10 +1611,10 @@
"Additional expressions to highlight in Ruby mode.")
(defun ruby-match-expression-expansion (limit)
- (let ((prop 'ruby-expansion-match-data) pos value)
- (when (and (setq pos (next-single-char-property-change (point) prop
- nil limit))
- (> pos (point)))
+ (let* ((prop 'ruby-expansion-match-data)
+ (pos (next-single-char-property-change (point) prop nil limit))
+ value)
+ (when (and pos (> pos (point)))
(goto-char pos)
(or (and (setq value (get-text-property pos prop))
(progn (set-match-data value) t))
=== modified file 'test/ChangeLog'
--- a/test/ChangeLog 2012-12-11 04:42:49 +0000
+++ b/test/ChangeLog 2012-12-14 04:55:23 +0000
@@ -1,3 +1,8 @@
+2012-12-14 Dmitry Gutov <address@hidden>
+
+ * automated/ruby-mode-tests.el
+ Rename one interpolation test; add three more.
+
2012-12-11 Glenn Morris <address@hidden>
* automated/f90.el (f90-test-bug13138): New test.
=== modified file 'test/automated/ruby-mode-tests.el'
--- a/test/automated/ruby-mode-tests.el 2012-12-02 06:06:32 +0000
+++ b/test/automated/ruby-mode-tests.el 2012-12-14 04:55:23 +0000
@@ -276,13 +276,33 @@
(ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16
font-lock-variable-name-face))
-(ert-deftest ruby-interpolation-suppresses-syntax-inside ()
+(ert-deftest ruby-interpolation-suppresses-quotes-inside ()
(let ((s "\"<ul><li>address@hidden(\"</li><li>\")}</li></ul>\""))
(ruby-assert-state s 8 nil)
(ruby-assert-face s 9 font-lock-string-face)
(ruby-assert-face s 10 font-lock-variable-name-face)
(ruby-assert-face s 41 font-lock-string-face)))
+(ert-deftest ruby-interpolation-suppresses-one-double-quote ()
+ (let ((s "\"foo#{'\"'}\""))
+ (ruby-assert-state s 8 nil)
+ (ruby-assert-face s 8 font-lock-variable-name-face)
+ (ruby-assert-face s 11 font-lock-string-face)))
+
+(ert-deftest ruby-interpolation-suppresses-one-backtick ()
+ (let ((s "`as#{'`'}das`"))
+ (ruby-assert-state s 8 nil)))
+
+(ert-deftest ruby-interpolation-keeps-non-quote-syntax ()
+ (let ((s "\"foo#{baz.tee}bar\""))
+ (with-temp-buffer
+ (save-excursion
+ (insert s))
+ (ruby-mode)
+ (font-lock-fontify-buffer)
+ (search-forward "tee")
+ (should (string= (thing-at-point 'symbol) "tee")))))
+
(ert-deftest ruby-interpolation-inside-percent-literal-with-paren ()
:expected-result :failed
(let ((s "%(^#{\")\"}^)"))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r111223: * lisp/progmodes/ruby-mode.el (ruby-syntax-propertize-function):,
Dmitry Gutov <=