[#17566] rubychecker - runs checks on a Ruby interpreter — Igal Koshevoy <igal@...>

I've put together a shell script that runs checks on a Ruby interpreter.

14 messages 2008/07/03

[#17615] [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes — Nathan Weizenbaum <nex342@...>

At the moment, ruby-mode.el uses font-lock-keywords as opposed to

22 messages 2008/07/05
[#17657] Re: [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes — Yukihiro Matsumoto <matz@...> 2008/07/08

[#17678] Re: [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes — Nathan Weizenbaum <nex342@...> 2008/07/09

It was designed to fix the following case:

[#17755] Re: [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes — Nathan Weizenbaum <nex342@...> 2008/07/13

Here's a third patch that fixes a bug in the second and uses a quicker

[#17772] Re: [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes — Nathan Weizenbaum <nex342@...> 2008/07/15

One more patch which fixes a few bugs in the the last one.

[#17773] Re: [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes — Nobuyoshi Nakada <nobu@...> 2008/07/15

Hi,

[#17776] Re: [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes — Nathan Weizenbaum <nex342@...> 2008/07/15

Looks like version 22 doesn't support explicitly numbered regexp groups.

[#17779] Re: [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes — Nobuyoshi Nakada <nobu@...> 2008/07/15

Hi,

[#17783] Re: [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes — Nobuyoshi Nakada <nobu@...> 2008/07/15

Hi,

[#17788] Re: [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes — Nathan Weizenbaum <nex342@...> 2008/07/15

Alright, here's a version that fixes both the highlighting bug and the

[#17793] Re: [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes — Nobuyoshi Nakada <nobu@...> 2008/07/16

Hi,

[#17644] Features to be included in Ruby 1.9.1 — "Yugui (Yuki Sonoda)" <yugui@...>

Hi, all

27 messages 2008/07/08

[#17674] [Ruby 1.8 - Bug #238] (Open) Ruby doesn't respect the Windows read-only flag — Jim Deville <redmine@...>

Issue #238 has been reported by Jim Deville.

10 messages 2008/07/08

[#17708] [Ruby 1.8 - Bug #252] (Open) Array#sort doesn't respect overridden <=> — Ryan Davis <redmine@...>

Issue #252 has been reported by Ryan Davis.

13 messages 2008/07/09

[#17871] duping the NilClass — "Nasir Khan" <rubylearner@...>

While nil is an object, calling dup on it causes TypeError. This doesnt seem

33 messages 2008/07/20
[#17872] Re: duping the NilClass — Urabe Shyouhei <shyouhei@...> 2008/07/20

Nasir Khan wrote:

[#17873] Re: duping the NilClass — "Meinrad Recheis" <meinrad.recheis@...> 2008/07/20

On Sun, Jul 20, 2008 at 7:55 PM, Urabe Shyouhei <shyouhei@ruby-lang.org>

[#17877] Re: duping the NilClass — Urabe Shyouhei <shyouhei@...> 2008/07/20

Meinrad Recheis wrote:

[#17879] Re: duping the NilClass — Kurt Stephens <ks@...> 2008/07/20

Urabe Shyouhei wrote:

[#17880] Re: duping the NilClass — "Nasir Khan" <rubylearner@...> 2008/07/21

I write a lot of hand crafted dup or clone because I want control as well as

[#17881] Re: duping the NilClass — "David A. Black" <dblack@...> 2008/07/21

Hi --

[#17882] Re: duping the NilClass — Urabe Shyouhei <shyouhei@...> 2008/07/21

+1 to David. A convenient way to do Marshal idiom should be a new

[#17885] Re: duping the NilClass — "Robert Dober" <robert.dober@...> 2008/07/21

On Mon, Jul 21, 2008 at 8:21 AM, Urabe Shyouhei <shyouhei@ruby-lang.org> wrote:

[#17887] Re: duping the NilClass — "David A. Black" <dblack@...> 2008/07/21

Hi --

[#17889] Re: duping the NilClass — "Robert Dober" <robert.dober@...> 2008/07/21

On Mon, Jul 21, 2008 at 1:02 PM, David A. Black <dblack@rubypal.com> wrote:

[#17883] [Ruby 1.9 - Bug #340] (Open) 1.9/trunk does not work when compiled with llvm-gcc4 2.3 (gcc 4.2.1) — Ollivier Robert <redmine@...>

Issue #340 has been reported by Ollivier Robert.

14 messages 2008/07/21

[#17943] RUBY_ENGINE? — "Vladimir Sizikov" <vsizikov@...>

Hi,

56 messages 2008/07/24
[#17950] Re: RUBY_ENGINE? — Tanaka Akira <akr@...> 2008/07/25

In article <3454c9680807241200xf7cc766qb987905a3987bb78@mail.gmail.com>,

[#17958] Re: RUBY_ENGINE? — "Vladimir Sizikov" <vsizikov@...> 2008/07/25

Hi,

[#17981] Re: RUBY_ENGINE? — Tanaka Akira <akr@...> 2008/07/26

In article <3454c9680807250054i70db563duf44b42d92ba41bfb@mail.gmail.com>,

[ruby-core:17788] Re: [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes

From: Nathan Weizenbaum <nex342@...>
Date: 2008-07-15 13:36:14 UTC
List: ruby-core #17788
Alright, here's a version that fixes both the highlighting bug and the 
Emacs 22 incompatibility (hopefully all of it this time). Thanks for 
helping me debug this.

Nobuyoshi Nakada wrote:
> Hi,
>
> At Tue, 15 Jul 2008 13:09:26 +0900,
> Nobuyoshi Nakada wrote in [ruby-core:17779]:
>   
>>> Looks like version 22 doesn't support explicitly numbered regexp groups. 
>>> Here's a patch that uses regexp-opt-depth instead, which is more robust 
>>> anyway.
>>>       
>> It worked fine.
>>     
>
> Not yet, try bootstraptest/runner.rb of 1.9.
>
>   

Attachments (1)

here-doc.6.patch (7.65 KB, text/x-diff)
Index: misc/ruby-mode.el
===================================================================
--- misc/ruby-mode.el	(revision 18050)
+++ misc/ruby-mode.el	(working copy)
@@ -48,16 +48,28 @@
 (defconst ruby-block-end-re "\\<end\\>")
 
 (defconst ruby-here-doc-beg-re
-  "<<\\(-\\)?\\(\\([a-zA-Z0-9_]+\\)\\|[\"]\\([^\"]+\\)[\"]\\|[']\\([^']+\\)[']\\)")
+  "\\(<\\)<\\(-\\)?\\(\\([a-zA-Z0-9_]+\\)\\|[\"]\\([^\"]+\\)[\"]\\|[']\\([^']+\\)[']\\)")
 
+(defconst ruby-here-doc-end-re
+  "^\\([ \t]+\\)?\\(.*\\)\\(.\\)$")
+
 (defun ruby-here-doc-end-match ()
   (concat "^"
-	  (if (match-string 1) "[ \t]*" nil)
+	  (if (match-string 2) "[ \t]*" nil)
 	  (regexp-quote
-	   (or (match-string 3)
-	       (match-string 4)
-	       (match-string 5)))))
+	   (or (match-string 4)
+	       (match-string 5)
+	       (match-string 6)))))
 
+(defun ruby-here-doc-beg-match ()
+  (let ((contents (regexp-quote (concat (match-string 2) (match-string 3)))))
+    (concat "<<"
+            (let ((match (match-string 1)))
+              (if (and match (> (length match) 0))
+                  (concat "\\(?:-\\([\"']\\)\\|\\([\"']\\)" (match-string 1) "\\)"
+                          contents "\\(\\1\\|\\2\\)")
+                (concat "-?\\([\"']\\|\\)" contents "\\1"))))))
+
 (defconst ruby-delimiter
   (concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\("
 	  ruby-block-beg-re
@@ -163,8 +175,8 @@
 
 (eval-when-compile (require 'cl))
 (defun ruby-imenu-create-index-in-block (prefix beg end)
-  (let ((index-alist '()) (case-fold-search nil)
-	name next pos decl sing)
+  (let ((index-alist '())
+        name next pos decl sing)
     (goto-char beg)
     (while (re-search-forward "^\\s *\\(\\(class\\>\\(\\s *<<\\)?\\|module\\>\\)\\s *\\([^\(<\n ]+\\)\\|\\(def\\|alias\\)\\>\\s *\\([^\(\n ]+\\)\\)" end t)
       (setq sing (match-beginning 3))
@@ -211,6 +223,7 @@
 (defun ruby-mode-variables ()
   (set-syntax-table ruby-mode-syntax-table)
   (setq local-abbrev-table ruby-mode-abbrev-table)
+  (setq case-fold-search nil)
   (make-local-variable 'indent-line-function)
   (setq indent-line-function 'ruby-indent-line)
   (make-local-variable 'require-final-newline)
@@ -226,6 +239,8 @@
   (setq indent-tabs-mode ruby-indent-tabs-mode)
   (make-local-variable 'parse-sexp-ignore-comments)
   (setq parse-sexp-ignore-comments t)
+  (make-local-variable 'parse-sexp-lookup-properties)
+  (setq parse-sexp-lookup-properties t)
   (make-local-variable 'paragraph-start)
   (setq paragraph-start (concat "$\\|" page-delimiter))
   (make-local-variable 'paragraph-separate)
@@ -591,7 +606,6 @@
   (save-excursion
     (beginning-of-line)
     (let ((indent-point (point))
-	  (case-fold-search nil)
 	  state bol eol begin op-end
 	  (paren (progn (skip-syntax-forward " ")
 			(and (char-after) (matching-paren (char-after)))))
@@ -1007,7 +1021,7 @@
       (setq font-lock-variable-name-face font-lock-type-face))
 
   (setq ruby-font-lock-syntactic-keywords
-	'(
+	`(
 	  ;; #{ }, #$hoge, #@foo are not comments
 	  ("\\(#\\)[{$@]" 1 (1 . nil))
 	  ;; the last $', $", $` in the respective string is not variable
@@ -1023,8 +1037,64 @@
 	   (4 (7 . ?/))
 	   (6 (7 . ?/)))
 	  ("^\\(=\\)begin\\(\\s \\|$\\)" 1 (7 . nil))
-	  ("^\\(=\\)end\\(\\s \\|$\\)" 1 (7 . nil))))
+	  ("^\\(=\\)end\\(\\s \\|$\\)" 1 (7 . nil))
+	  (,(concat ruby-here-doc-beg-re ".*\\(\n\\)")
+	   ,(+ 1 (regexp-opt-depth ruby-here-doc-beg-re))
+           (ruby-here-doc-beg-syntax))
+	  (,ruby-here-doc-end-re 3 (ruby-here-doc-end-syntax))))
 
+  (defun ruby-in-here-doc-p ()
+    (save-excursion
+      (let ((old-point (point)))
+        (beginning-of-line)
+        (and (re-search-backward ruby-here-doc-beg-re nil t)
+             (not (ruby-here-doc-find-end old-point))))))
+
+  (defun ruby-here-doc-find-end (&optional limit)
+    "Expects the point to be on a line with one or more heredoc
+opener. Returns the buffer position at which all heredocs on the
+line are terminated, or nil if they aren't terminated before the
+buffer position `limit' or the end of the buffer."
+    (save-excursion
+      (beginning-of-line)
+      (catch 'done
+        (let ((eol (save-excursion (end-of-line) (point)))
+              ;; Fake match data such that (match-end 0) is at eol
+              (end-match-data (progn (looking-at ".*$") (match-data)))
+              beg-match-data end-re)
+          (while (re-search-forward ruby-here-doc-beg-re eol t)
+            (setq beg-match-data (match-data))
+            (setq end-re (ruby-here-doc-end-match))
+
+            (set-match-data end-match-data)
+            (goto-char (match-end 0))
+            (unless (re-search-forward end-re limit t) (throw 'done nil))
+            (setq end-match-data (match-data))
+
+            (set-match-data beg-match-data)
+            (goto-char (match-end 0)))
+          (set-match-data end-match-data)
+          (goto-char (match-end 0))
+          (point)))))
+
+  (defun ruby-here-doc-beg-syntax ()
+    (save-excursion
+      (goto-char (match-beginning 0))
+      (unless (ruby-in-here-doc-p) (string-to-syntax "|"))))
+
+  (defun ruby-here-doc-end-syntax ()
+    (save-excursion
+      (goto-char (match-end 0))
+      (let ((old-point (point))
+            (beg-exists (re-search-backward (ruby-here-doc-beg-match) nil t))
+            (eol (save-excursion (end-of-line) (point))))
+        (if (and beg-exists ; If there is a heredoc that matches this line...
+                 (null (syntax-ppss-context (syntax-ppss))) ; And that's not inside a heredoc/string/comment...
+                 (progn (goto-char (match-end 0)) ; And it's the last heredoc on its line...
+                        (not (re-search-forward ruby-here-doc-beg-re eol t)))
+                 (eq old-point (ruby-here-doc-find-end old-point))) ; And it ends at this point...
+            (string-to-syntax "|")))))
+
   (if (featurep 'xemacs)
       (put 'ruby-mode 'font-lock-defaults
 	   '((ruby-font-lock-keywords)
@@ -1064,35 +1134,7 @@
       (modify-syntax-entry ?_ "w" tbl)
       tbl))
 
-  (defun ruby-font-lock-here-docs (limit)
-    (if (re-search-forward ruby-here-doc-beg-re limit t)
-	(let (beg)
-	  (beginning-of-line)
-          (forward-line)
-	  (setq beg (point))
-	  (if (re-search-forward (ruby-here-doc-end-match) nil t)
-	      (progn
-		(set-match-data (list beg (point)))
-		t)))))
-
-  (defun ruby-font-lock-maybe-here-docs (limit)
-    (let (beg)
-      (save-excursion
-	(if (re-search-backward ruby-here-doc-beg-re nil t)
-	    (progn
-	      (beginning-of-line)
-              (forward-line)
-	      (setq beg (point)))))
-      (if (and beg
-	       (let ((end-match (ruby-here-doc-end-match)))
-                 (and (not (re-search-backward end-match beg t))
-		      (re-search-forward end-match nil t))))
-	  (progn
-	    (set-match-data (list beg (point)))
-	    t)
-          nil)))
-
-  (defvar ruby-font-lock-keywords
+  (defconst ruby-font-lock-keywords
     (list
      ;; functions
      '("^\\s *def\\s +\\([^( \t\n]+\\)"
@@ -1141,6 +1183,8 @@
 	     "\\|")
 	    "\\)\\>\\)")
 	   2)
+     ;; here-doc beginnings
+     (list ruby-here-doc-beg-re 0 'font-lock-string-face)
      ;; variables
      '("\\(^\\|[^_:.@$]\\|\\.\\.\\)\\b\\(nil\\|self\\|true\\|false\\)\\>"
        2 font-lock-variable-name-face)
@@ -1154,13 +1198,6 @@
        0 font-lock-comment-face t)
      '(ruby-font-lock-maybe-docs
        0 font-lock-comment-face t)
-     ;; "here" document
-     '(ruby-font-lock-here-docs
-       0 font-lock-string-face t)
-     '(ruby-font-lock-maybe-here-docs
-       0 font-lock-string-face t)
-     `(,ruby-here-doc-beg-re
-       0 font-lock-string-face t)
      ;; general delimited string
      '("\\(^\\|[[ \t\n<+(,=]\\)\\(%[xrqQwW]?\\([^<[{(a-zA-Z0-9 \n]\\)[^\n\\\\]*\\(\\\\.[^\n\\\\]*\\)*\\(\\3\\)\\)"
        (2 font-lock-string-face))

In This Thread