+2011-01-23 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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.
+
2011-01-22 Keitaro Miyazaki <keitaro.miyazaki@gmail.com>
* emacs-lisp/re-builder.el (reb-mode-map): Set case-fold-search in
"Return a regexp to find the beginning of a heredoc.
This should only be called after matching against `ruby-here-doc-end-re'."
- (let ((contents (regexp-quote (concat (match-string 2) (match-string 3)))))
+ (let ((contents (concat
+ (regexp-quote (concat (match-string 2) (match-string 3)))
+ (if (string= (match-string 3) "_") "\\B" "\\b"))))
(concat "<<"
(let ((match (match-string 1)))
(if (and match (> (length match) 0))
(concat "\\(?:-\\([\"']?\\)\\|\\([\"']\\)" (match-string 1) "\\)"
- contents "\\b\\(\\1\\|\\2\\)")
- (concat "-?\\([\"']\\|\\)" contents "\\b\\1"))))))
+ contents "\\(\\1\\|\\2\\)")
+ (concat "-?\\([\"']\\|\\)" contents "\\1"))))))
+
(defconst ruby-delimiter
(concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\("
(define-key map (kbd "C-M-h") 'backward-kill-word)
(define-key map (kbd "C-j") 'reindent-then-newline-and-indent)
(define-key map (kbd "C-m") 'newline)
+ (define-key map (kbd "C-c C-c") 'comment-region)
map)
"Keymap used in Ruby mode.")
(cdr (assq coding-system ruby-encoding-map)))
coding-system))
"ascii-8bit"))
- (if (looking-at "^#![^\n]*ruby") (beginning-of-line 2))
+ (if (looking-at "^#!") (beginning-of-line 2))
(cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)")
(unless (string= (match-string 2) coding-system)
(goto-char (match-beginning 2))
(condition-case nil
(while (> i 0)
(skip-syntax-forward " ")
+ (if (looking-at ",\\s *") (goto-char (match-end 0)))
(cond ((looking-at "\\?\\(\\\\[CM]-\\)*\\\\?\\S ")
(goto-char (match-end 0)))
((progn
;; ?' ?" ?` are ascii codes
("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" 3 (1 . nil))
;; regexps
- ("\\(^\\|[=(,~?:;<>]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)"
+ ("\\(^\\|[[=(,~?:;<>]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)"
(4 (7 . ?/))
(6 (7 . ?/)))
("^=en\\(d\\)\\_>" 1 "!")
;; symbols
'("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
2 font-lock-reference-face)
+ '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-reference-face)
;; expression expansion
'("#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)"
0 font-lock-variable-name-face t)