[#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:17755] Re: [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes

From: Nathan Weizenbaum <nex342@...>
Date: 2008-07-13 22:42:56 UTC
List: ruby-core #17755
Here's a third patch that fixes a bug in the second and uses a quicker 
method of determining if the point is in a here-doc. To do so, it 
enables parse-sexp-lookup-properties, which causes syntax-sensitive 
functions to respect font-lock-syntactic-keywords. I think this is a 
good thing to enable in general, because it means that forward-sexp and 
similar functions treat regexps the same way they treat strings and so 
forth.

Nathan Weizenbaum wrote:
> It was designed to fix the following case:
>
> <<FOO
> "
> FOO
> bar
>
> where "bar" is wrongly highlighted in font-lock-string-face. It also 
> fixes the following case:
>
> <<FOO
> <<BAR
> BAR
> FOO
>
> in which FOO is *not* highlighted in font-lock-string-face when it 
> should be.
>
> I've attached a modified version that works with the case you pointed 
> out.
>
> Yukihiro Matsumoto wrote:
>> In message "Re: [ruby-core:17615] [PATCH] ruby-mode.el: Fix here-doc 
>> strings with inner quotes"
>>     on Sat, 5 Jul 2008 17:57:32 +0900, Nathan Weizenbaum 
>> <nex342@gmail.com> writes:
>> |
>> |[1  <text/plain; ISO-8859-1 (7bit)>]
>> |At the moment, ruby-mode.el uses font-lock-keywords as opposed to 
>> |font-lock-syntactic-keywords to highlight here-doc strings. This 
>> means |that Emacs doesn't actually recognize them as strings, so 
>> unbalanced |quotes paint the whole buffer in font-lock-string-face. 
>> In addition, it |improperly highlights strings that look like nested 
>> heredocs, like the |following:
>> |
>> |<<FOO
>> |<<BAR
>> |BAR
>> |FOO
>> |
>> |The attached patch uses font-lock-syntactic-keywords instead, so 
>> that |heredocs actually register as strings, so stray quotation marks 
>> don't |wreak havoc.
>>
>> I am not sure what this patch fixes.  But at least, the patched
>> version does not work well for the following code:
>>
>> print <<FOO, <<BAR
>> <<BAR
>> foo
>> FOO
>> bar
>> BAR
>>
>> it should highlight here-doc up to the last BAR.
>>
>>                             matz.
>>
>>
>>   
>

Attachments (1)

here-doc.3.patch (5 KB, text/x-diff)
Index: ruby-mode.el
===================================================================
--- ruby-mode.el	(revision 18050)
+++ ruby-mode.el	(working copy)
@@ -48,16 +48,26 @@
 (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 "<<"
+            (if (match-string 1)
+                (concat "\\(?:-\\(?1:[\"']\\)\\|\\(?1:[\"']\\)" (match-string 1) "\\)" contents "\\1")
+              (concat "-?\\([\"']\\|\\)" contents "\\1")))))
+
 (defconst ruby-delimiter
   (concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\("
 	  ruby-block-beg-re
@@ -226,6 +236,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)
@@ -1007,7 +1019,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 +1035,28 @@
 	   (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 ".*\\(?100:\n\\)")
+	   100 (ruby-here-doc-beg-syntax))
+	  (,ruby-here-doc-end-re 3 (ruby-here-doc-end-syntax))))
 
+  (defun ruby-here-doc-beg-syntax ()
+    (save-excursion
+      (goto-char (match-beginning 0))
+      (if (null (syntax-ppss-context (syntax-ppss))) (string-to-syntax "|"))))
+
+  (defun ruby-here-doc-end-syntax ()
+    (save-excursion
+      (goto-char (match-beginning 0))
+      (let ((beg-exists (re-search-backward (ruby-here-doc-beg-match) nil t))
+            (beg-end (match-end 0))
+            (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 another heredoc/comment...
+                 (progn (goto-char beg-end) ; And it's the last heredoc on its line...
+                        (not (re-search-forward ruby-here-doc-beg-re eol t))))
+            (string-to-syntax "|")))))
+
   (if (featurep 'xemacs)
       (put 'ruby-mode 'font-lock-defaults
 	   '((ruby-font-lock-keywords)
@@ -1064,35 +1096,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 +1145,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 +1160,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