aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/ruby-mode.el
diff options
context:
space:
mode:
authorGlenn Morris2011-01-24 19:47:47 -0800
committerGlenn Morris2011-01-24 19:47:47 -0800
commit06d8ace51597cd41e110560a56a1abeb6cce23d6 (patch)
treee893bab169f27821637fc07e3cd2414b4b9b7b68 /lisp/progmodes/ruby-mode.el
parentc5ecc7690d4afafb42049634d64abd781ff76642 (diff)
parent0d19d4feaa653a315853716e64bbaddb210a26ca (diff)
downloademacs-06d8ace51597cd41e110560a56a1abeb6cce23d6.tar.gz
emacs-06d8ace51597cd41e110560a56a1abeb6cce23d6.zip
Merge from emacs-23.
Note setting of CANNOT_DUMP on ia64 hpux is still to be merged manually.
Diffstat (limited to 'lisp/progmodes/ruby-mode.el')
-rw-r--r--lisp/progmodes/ruby-mode.el92
1 files changed, 49 insertions, 43 deletions
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 733af999cdb..b3a640a2283 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -153,6 +153,7 @@ This should only be called after matching against `ruby-here-doc-beg-re'."
153 (define-key map (kbd "C-M-h") 'backward-kill-word) 153 (define-key map (kbd "C-M-h") 'backward-kill-word)
154 (define-key map (kbd "C-j") 'reindent-then-newline-and-indent) 154 (define-key map (kbd "C-j") 'reindent-then-newline-and-indent)
155 (define-key map (kbd "C-m") 'newline) 155 (define-key map (kbd "C-m") 'newline)
156 (define-key map (kbd "C-c C-c") 'comment-region)
156 map) 157 map)
157 "Keymap used in Ruby mode.") 158 "Keymap used in Ruby mode.")
158 159
@@ -319,7 +320,7 @@ Also ignores spaces after parenthesis when 'space."
319 (cdr (assq coding-system ruby-encoding-map))) 320 (cdr (assq coding-system ruby-encoding-map)))
320 coding-system)) 321 coding-system))
321 "ascii-8bit")) 322 "ascii-8bit"))
322 (if (looking-at "^#![^\n]*ruby") (beginning-of-line 2)) 323 (if (looking-at "^#!") (beginning-of-line 2))
323 (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)") 324 (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)")
324 (unless (string= (match-string 2) coding-system) 325 (unless (string= (match-string 2) coding-system)
325 (goto-char (match-beginning 2)) 326 (goto-char (match-beginning 2))
@@ -927,6 +928,7 @@ With ARG, do it many times. Negative ARG means move backward."
927 (condition-case nil 928 (condition-case nil
928 (while (> i 0) 929 (while (> i 0)
929 (skip-syntax-forward " ") 930 (skip-syntax-forward " ")
931 (if (looking-at ",\\s *") (goto-char (match-end 0)))
930 (cond ((looking-at "\\?\\(\\\\[CM]-\\)*\\\\?\\S ") 932 (cond ((looking-at "\\?\\(\\\\[CM]-\\)*\\\\?\\S ")
931 (goto-char (match-end 0))) 933 (goto-char (match-end 0)))
932 ((progn 934 ((progn
@@ -1179,56 +1181,59 @@ It's useful in that it divides up the match string so that
1179 "Return a regexp to find the beginning of a heredoc. 1181 "Return a regexp to find the beginning of a heredoc.
1180 1182
1181This should only be called after matching against `ruby-here-doc-end-re'." 1183This should only be called after matching against `ruby-here-doc-end-re'."
1182 (let ((contents (regexp-quote (match-string 2)))) 1184 (let ((contents (concat
1185 (regexp-quote (concat (match-string 2) (match-string 3)))
1186 (if (string= (match-string 3) "_") "\\B" "\\b"))))
1183 (concat "<<" 1187 (concat "<<"
1184 (let ((match (match-string 1))) 1188 (let ((match (match-string 1)))
1185 (if (and match (> (length match) 0)) 1189 (if (and match (> (length match) 0))
1186 (concat "\\(?:-\\([\"']?\\)\\|\\([\"']\\)" match "\\)" 1190 (concat "\\(?:-\\([\"']?\\)\\|\\([\"']\\)"
1187 contents "\\b\\(\\1\\|\\2\\)") 1191 (match-string 1) "\\)"
1188 (concat "-?\\([\"']\\|\\)" contents "\\b\\1")))))) 1192 contents "\\(\\1\\|\\2\\)")
1193 (concat "-?\\([\"']\\|\\)" contents "\\1"))))))
1189 1194
1190 (defconst ruby-font-lock-syntactic-keywords 1195 (defconst ruby-font-lock-syntactic-keywords
1191 `( ;; #{ }, #$hoge, #@foo are not comments 1196 `( ;; #{ }, #$hoge, #@foo are not comments
1192 ("\\(#\\)[{$@]" 1 (1 . nil)) 1197 ("\\(#\\)[{$@]" 1 (1 . nil))
1193 ;; the last $', $", $` in the respective string is not variable 1198 ;; the last $', $", $` in the respective string is not variable
1194 ;; the last ?', ?", ?` in the respective string is not ascii code 1199 ;; the last ?', ?", ?` in the respective string is not ascii code
1195 ("\\(^\\|[\[ \t\n<+\(,=]\\)\\(['\"`]\\)\\(\\\\.\\|\\2\\|[^'\"`\n\\\\]\\)*?\\\\?[?$]\\(\\2\\)" 1200 ("\\(^\\|[\[ \t\n<+\(,=]\\)\\(['\"`]\\)\\(\\\\.\\|\\2\\|[^'\"`\n\\\\]\\)*?\\\\?[?$]\\(\\2\\)"
1196 (2 (7 . nil)) 1201 (2 (7 . nil))
1197 (4 (7 . nil))) 1202 (4 (7 . nil)))
1198 ;; $' $" $` .... are variables 1203 ;; $' $" $` .... are variables
1199 ;; ?' ?" ?` are ascii codes 1204 ;; ?' ?" ?` are ascii codes
1200 ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" 3 (1 . nil)) 1205 ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" 3 (1 . nil))
1201 ;; regexps 1206 ;; regexps
1202 ("\\(^\\|[=(,~?:;<>]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)" 1207 ("\\(^\\|[[=(,~?:;<>]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)"
1203 (4 (7 . ?/)) 1208 (4 (7 . ?/))
1204 (6 (7 . ?/))) 1209 (6 (7 . ?/)))
1205 ("^=en\\(d\\)\\_>" 1 "!") 1210 ("^=en\\(d\\)\\_>" 1 "!")
1206 ("^\\(=\\)begin\\_>" 1 (ruby-comment-beg-syntax)) 1211 ("^\\(=\\)begin\\_>" 1 (ruby-comment-beg-syntax))
1207 ;; Currently, the following case is highlighted incorrectly: 1212 ;; Currently, the following case is highlighted incorrectly:
1208 ;; 1213 ;;
1209 ;; <<FOO 1214 ;; <<FOO
1210 ;; FOO 1215 ;; FOO
1211 ;; <<BAR 1216 ;; <<BAR
1212 ;; <<BAZ 1217 ;; <<BAZ
1213 ;; BAZ 1218 ;; BAZ
1214 ;; BAR 1219 ;; BAR
1215 ;; 1220 ;;
1216 ;; This is because all here-doc beginnings are highlighted before any endings, 1221 ;; This is because all here-doc beginnings are highlighted before any endings,
1217 ;; so although <<BAR is properly marked as a beginning, when we get to <<BAZ 1222 ;; so although <<BAR is properly marked as a beginning, when we get to <<BAZ
1218 ;; it thinks <<BAR is part of a string so it's marked as well. 1223 ;; it thinks <<BAR is part of a string so it's marked as well.
1219 ;; 1224 ;;
1220 ;; This may be fixable by modifying ruby-in-here-doc-p to use 1225 ;; This may be fixable by modifying ruby-in-here-doc-p to use
1221 ;; ruby-in-non-here-doc-string-p rather than syntax-ppss-context, 1226 ;; ruby-in-non-here-doc-string-p rather than syntax-ppss-context,
1222 ;; but I don't want to try that until we've got unit tests set up 1227 ;; but I don't want to try that until we've got unit tests set up
1223 ;; to make sure I don't break anything else. 1228 ;; to make sure I don't break anything else.
1224 (,(concat ruby-here-doc-beg-re ".*\\(\n\\)") 1229 (,(concat ruby-here-doc-beg-re ".*\\(\n\\)")
1225 ,(+ 1 (regexp-opt-depth ruby-here-doc-beg-re)) 1230 ,(+ 1 (regexp-opt-depth ruby-here-doc-beg-re))
1226 (ruby-here-doc-beg-syntax)) 1231 (ruby-here-doc-beg-syntax))
1227 (,ruby-here-doc-end-re 3 (ruby-here-doc-end-syntax))) 1232 (,ruby-here-doc-end-re 3 (ruby-here-doc-end-syntax)))
1228 "Syntactic keywords for Ruby mode. See `font-lock-syntactic-keywords'.") 1233 "Syntactic keywords for Ruby mode. See `font-lock-syntactic-keywords'.")
1229 1234
1230 (defun ruby-comment-beg-syntax () 1235 (defun ruby-comment-beg-syntax ()
1231 "Return the syntax cell for a the first character of a =begin. 1236 "Return the syntax cell for a the first character of a =begin.
1232See the definition of `ruby-font-lock-syntactic-keywords'. 1237See the definition of `ruby-font-lock-syntactic-keywords'.
1233 1238
1234This returns a comment-delimiter cell as long as the =begin 1239This returns a comment-delimiter cell as long as the =begin
@@ -1420,6 +1425,7 @@ See `font-lock-syntax-table'.")
1420 ;; symbols 1425 ;; symbols
1421 '("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)" 1426 '("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
1422 2 font-lock-reference-face) 1427 2 font-lock-reference-face)
1428 '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-reference-face)
1423 ;; expression expansion 1429 ;; expression expansion
1424 '("#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)" 1430 '("#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)"
1425 0 font-lock-variable-name-face t) 1431 0 font-lock-variable-name-face t)