aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNobuyoshi Nakada2011-01-22 20:02:37 -0500
committerChong Yidong2011-01-22 20:02:37 -0500
commitcc9c9831b980fac44b9d0249d89bd66a902e61c2 (patch)
tree74c44b1258d29ce11278fbec6cda531325cf36f0
parent43f90d65a2d9752212af0269eeec48ac87839835 (diff)
downloademacs-cc9c9831b980fac44b9d0249d89bd66a902e61c2.tar.gz
emacs-cc9c9831b980fac44b9d0249d89bd66a902e61c2.zip
Merge several fixes from upsteam ruby-mode.
* lisp/progmodes/ruby-mode.el (ruby-here-doc-beg-match): Fix for here-doc which ends with an underscore. (ruby-mode-set-encoding): Skip shebang line always. (ruby-mode-map): Bind C-c C-c to comment-region. (ruby-expr-beg, ruby-font-lock-keywords): Highlight literal hash key labels as symbols. (ruby-forward-sexp): Stop after literal hash key labels. (ruby-font-lock-syntactic-keywords): Highlight regexp after open bracket.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/progmodes/ruby-mode.el16
2 files changed, 23 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index acf25f155db..84965440a16 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12011-01-23 Nobuyoshi Nakada <nobu@ruby-lang.org>
2
3 * progmodes/ruby-mode.el (ruby-here-doc-beg-match): Fix for
4 here-doc which ends with an underscore.
5 (ruby-mode-set-encoding): Skip shebang line always.
6 (ruby-mode-map): Bind C-c C-c to comment-region.
7 (ruby-expr-beg, ruby-font-lock-keywords): Highlight literal hash
8 key labels as symbols.
9 (ruby-forward-sexp): Stop after literal hash key labels.
10 (ruby-font-lock-syntactic-keywords): Highlight regexp after open
11 bracket.
12
12011-01-22 Keitaro Miyazaki <keitaro.miyazaki@gmail.com> 132011-01-22 Keitaro Miyazaki <keitaro.miyazaki@gmail.com>
2 14
3 * emacs-lisp/re-builder.el (reb-mode-map): Set case-fold-search in 15 * emacs-lisp/re-builder.el (reb-mode-map): Set case-fold-search in
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 6f96dcd38df..81860b7e603 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -122,13 +122,16 @@ This should only be called after matching against `ruby-here-doc-beg-re'."
122 "Return a regexp to find the beginning of a heredoc. 122 "Return a regexp to find the beginning of a heredoc.
123 123
124This should only be called after matching against `ruby-here-doc-end-re'." 124This should only be called after matching against `ruby-here-doc-end-re'."
125 (let ((contents (regexp-quote (concat (match-string 2) (match-string 3))))) 125 (let ((contents (concat
126 (regexp-quote (concat (match-string 2) (match-string 3)))
127 (if (string= (match-string 3) "_") "\\B" "\\b"))))
126 (concat "<<" 128 (concat "<<"
127 (let ((match (match-string 1))) 129 (let ((match (match-string 1)))
128 (if (and match (> (length match) 0)) 130 (if (and match (> (length match) 0))
129 (concat "\\(?:-\\([\"']?\\)\\|\\([\"']\\)" (match-string 1) "\\)" 131 (concat "\\(?:-\\([\"']?\\)\\|\\([\"']\\)" (match-string 1) "\\)"
130 contents "\\b\\(\\1\\|\\2\\)") 132 contents "\\(\\1\\|\\2\\)")
131 (concat "-?\\([\"']\\|\\)" contents "\\b\\1")))))) 133 (concat "-?\\([\"']\\|\\)" contents "\\1"))))))
134
132 135
133(defconst ruby-delimiter 136(defconst ruby-delimiter
134 (concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\(" 137 (concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\("
@@ -170,6 +173,7 @@ This should only be called after matching against `ruby-here-doc-end-re'."
170 (define-key map (kbd "C-M-h") 'backward-kill-word) 173 (define-key map (kbd "C-M-h") 'backward-kill-word)
171 (define-key map (kbd "C-j") 'reindent-then-newline-and-indent) 174 (define-key map (kbd "C-j") 'reindent-then-newline-and-indent)
172 (define-key map (kbd "C-m") 'newline) 175 (define-key map (kbd "C-m") 'newline)
176 (define-key map (kbd "C-c C-c") 'comment-region)
173 map) 177 map)
174 "Keymap used in Ruby mode.") 178 "Keymap used in Ruby mode.")
175 179
@@ -336,7 +340,7 @@ Also ignores spaces after parenthesis when 'space."
336 (cdr (assq coding-system ruby-encoding-map))) 340 (cdr (assq coding-system ruby-encoding-map)))
337 coding-system)) 341 coding-system))
338 "ascii-8bit")) 342 "ascii-8bit"))
339 (if (looking-at "^#![^\n]*ruby") (beginning-of-line 2)) 343 (if (looking-at "^#!") (beginning-of-line 2))
340 (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)") 344 (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)")
341 (unless (string= (match-string 2) coding-system) 345 (unless (string= (match-string 2) coding-system)
342 (goto-char (match-beginning 2)) 346 (goto-char (match-beginning 2))
@@ -946,6 +950,7 @@ With ARG, do it many times. Negative ARG means move backward."
946 (condition-case nil 950 (condition-case nil
947 (while (> i 0) 951 (while (> i 0)
948 (skip-syntax-forward " ") 952 (skip-syntax-forward " ")
953 (if (looking-at ",\\s *") (goto-char (match-end 0)))
949 (cond ((looking-at "\\?\\(\\\\[CM]-\\)*\\\\?\\S ") 954 (cond ((looking-at "\\?\\(\\\\[CM]-\\)*\\\\?\\S ")
950 (goto-char (match-end 0))) 955 (goto-char (match-end 0)))
951 ((progn 956 ((progn
@@ -1141,7 +1146,7 @@ See `add-log-current-defun-function'."
1141 ;; ?' ?" ?` are ascii codes 1146 ;; ?' ?" ?` are ascii codes
1142 ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" 3 (1 . nil)) 1147 ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" 3 (1 . nil))
1143 ;; regexps 1148 ;; regexps
1144 ("\\(^\\|[=(,~?:;<>]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)" 1149 ("\\(^\\|[[=(,~?:;<>]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)"
1145 (4 (7 . ?/)) 1150 (4 (7 . ?/))
1146 (6 (7 . ?/))) 1151 (6 (7 . ?/)))
1147 ("^=en\\(d\\)\\_>" 1 "!") 1152 ("^=en\\(d\\)\\_>" 1 "!")
@@ -1364,6 +1369,7 @@ See `font-lock-syntax-table'.")
1364 ;; symbols 1369 ;; symbols
1365 '("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)" 1370 '("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
1366 2 font-lock-reference-face) 1371 2 font-lock-reference-face)
1372 '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-reference-face)
1367 ;; expression expansion 1373 ;; expression expansion
1368 '("#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)" 1374 '("#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)"
1369 0 font-lock-variable-name-face t) 1375 0 font-lock-variable-name-face t)