summaryrefslogtreecommitdiff
path: root/misc/ruby-mode.el
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-19 04:35:17 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-19 04:35:17 +0000
commit9d51cf8a6a5d651c1c4dd363dbf3f4905e3f307d (patch)
tree98247086ea05415f034f0b5a0e6cc97163f47be2 /misc/ruby-mode.el
parent6aa71d4c800d11d9735007cf3b063e5ea2fc5941 (diff)
* eval.c (rb_f_require): searches ".rb" and ".so" at the same
time. previous behavior (search ".rb", then ".so") has a security risk (ruby-bugs#PR140). * array.c (rb_ary_to_ary): new function to replace internal rb_Array(), which never calls to_a, but to_ary (rb_Array() might call both). [new] * regex.c (PUSH_FAILURE_POINT): push option status again. * regex.c (re_compile_pattern): avoid pushing unnecessary option_set. * eval.c (rb_load): tainted string is OK if wrapped *and* $SAFE >= 4. * eval.c (rb_thread_start_0): should not nail down higher blocks before preserving original context (i.e. should not alter original context). * eval.c (proc_yield): new method equivalent to Proc#call but no check for number of arguments. [new] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'misc/ruby-mode.el')
-rw-r--r--misc/ruby-mode.el50
1 files changed, 35 insertions, 15 deletions
diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
index 102de81..da31f98 100644
--- a/misc/ruby-mode.el
+++ b/misc/ruby-mode.el
@@ -660,21 +660,24 @@ An end of a defun is found by moving forward from the beginning of one."
(cond
((featurep 'font-lock)
-
- (setq ruby-font-lock-syntactic-keywords
- '(("\\$\\([#\"'`$\\]\\)" 1 (1 . nil))
- ("\\(#\\)[{$@]" 1 (1 . nil))
- ("\\(/\\)\\([^/\n]\\|\\/\\)*\\(/\\)"
- (1 (7 . ?'))
- (3 (7 . ?')))
- ("^\\(=\\)begin\\(\\s \\|$\\)" 1 (7 . nil))
- ("^\\(=\\)end\\(\\s \\|$\\)" 1 (7 . nil))))
- (put major-mode 'font-lock-defaults
- '((ruby-font-lock-keywords)
- nil nil nil
- beginning-of-line
- (font-lock-syntactic-keywords
- . ruby-font-lock-syntactic-keywords)))
+ (or (boundp 'font-lock-variable-name-face)
+ (setq font-lock-variable-name-face font-lock-type-face))
+
+
+ (add-hook 'ruby-mode-hook
+ '(lambda ()
+ (make-local-variable 'font-lock-syntactic-keywords)
+ (setq font-lock-syntactic-keywords
+ '(("\\$\\([#\"'`$\\]\\)" 1 (1 . nil))
+ ("\\(#\\)[{$@]" 1 (1 . nil))
+ ("\\(/\\)\\([^/\n]\\|\\/\\)*\\(/\\)"
+ (1 (7 . ?'))
+ (3 (7 . ?')))
+ ("^\\(=\\)begin\\(\\s \\|$\\)" 1 (7 . nil))
+ ("^\\(=\\)end\\(\\s \\|$\\)" 1 (7 . nil))))
+ (make-local-variable 'font-lock-defaults)
+ (setq font-lock-defaults '((ruby-font-lock-keywords) nil nil))
+ (setq font-lock-keywords ruby-font-lock-keywords)))
(defun ruby-font-lock-docs (limit)
(if (re-search-forward "^=begin\\(\\s \\|$\\)" limit t)
@@ -687,6 +690,21 @@ An end of a defun is found by moving forward from the beginning of one."
(set-match-data (list beg (point)))
t)))))
+ (defun ruby-font-lock-maybe-docs (limit)
+ (let (beg)
+ (save-excursion
+ (if (and (re-search-backward "^=\\(begin\\|end\\)\\(\\s \\|$\\)" nil t)
+ (string= (match-string-no-properties 1) "begin"))
+ (progn
+ (beginning-of-line)
+ (setq beg (point)))))
+ (if (and beg (and (re-search-forward "^=\\(begin\\|end\\)\\(\\s \\|$\\)" nil t)
+ (string= (match-string-no-properties 1) "end")))
+ (progn
+ (set-match-data (list beg (point)))
+ t)
+ nil)))
+
(defvar ruby-font-lock-keywords
(list
(cons (concat
@@ -741,6 +759,8 @@ An end of a defun is found by moving forward from the beginning of one."
;; embedded document
'(ruby-font-lock-docs
0 font-lock-comment-face t)
+ '(ruby-font-lock-maybe-docs
+ 0 font-lock-comment-face t)
;; constants
'("\\(^\\|[^_]\\)\\b\\([A-Z]+\\(\\w\\|_\\)*\\)"
2 font-lock-type-face)