From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#10786: 24.0.93; ruby-mode improperly handles symbols with keyword names in JS-style hashes Date: Sat, 11 Feb 2012 04:27:33 +0400 Message-ID: <4F35B5F5.6040403@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050300050404020901030802" X-Trace: dough.gmane.org 1328920313 12509 80.91.229.3 (11 Feb 2012 00:31:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 11 Feb 2012 00:31:53 +0000 (UTC) To: 10786@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 11 01:31:52 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rw0sa-00008J-Ff for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Feb 2012 01:31:52 +0100 Original-Received: from localhost ([::1]:47656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rw0sZ-0003UB-Jv for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 Feb 2012 19:31:51 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:56166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rw0sW-0003Tu-Tn for bug-gnu-emacs@gnu.org; Fri, 10 Feb 2012 19:31:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rw0sV-0005YG-Pi for bug-gnu-emacs@gnu.org; Fri, 10 Feb 2012 19:31:48 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60048) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rw0sV-0005YC-Mm for bug-gnu-emacs@gnu.org; Fri, 10 Feb 2012 19:31:47 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Rw0ti-0003Ks-Dt for bug-gnu-emacs@gnu.org; Fri, 10 Feb 2012 19:33:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Feb 2012 00:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 10786 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.132892037412805 (code B ref -1); Sat, 11 Feb 2012 00:33:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Feb 2012 00:32:54 +0000 Original-Received: from localhost ([127.0.0.1]:35438 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rw0tZ-0003KT-9j for submit@debbugs.gnu.org; Fri, 10 Feb 2012 19:32:53 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:60355) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rw0tV-0003KD-D5 for submit@debbugs.gnu.org; Fri, 10 Feb 2012 19:32:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rw0sB-0005Xk-86 for submit@debbugs.gnu.org; Fri, 10 Feb 2012 19:31:28 -0500 Original-Received: from lists.gnu.org ([140.186.70.17]:41782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rw0sB-0005Xg-6d for submit@debbugs.gnu.org; Fri, 10 Feb 2012 19:31:27 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:56142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rw0sA-0003Hv-30 for bug-gnu-emacs@gnu.org; Fri, 10 Feb 2012 19:31:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rw0s8-0005XT-Tw for bug-gnu-emacs@gnu.org; Fri, 10 Feb 2012 19:31:26 -0500 Original-Received: from forward3.mail.yandex.net ([77.88.46.8]:55054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rw0s8-0005XN-Ac for bug-gnu-emacs@gnu.org; Fri, 10 Feb 2012 19:31:24 -0500 Original-Received: from smtp3.mail.yandex.net (smtp3.mail.yandex.net [77.88.46.103]) by forward3.mail.yandex.net (Yandex) with ESMTP id E807AB40CA4 for ; Sat, 11 Feb 2012 04:27:29 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1328920049; bh=D0MTJ0w1EqcukAW+ImLb8P+kptIqdv1f4c9+CfbjsL0=; h=Message-ID:Date:From:MIME-Version:To:Subject:Content-Type; b=CMOj8kKfskj0mWGlP4W5wXt/eK9V8KdXFuiRoCp7UH6u3sRteigs3BPg5Esjk0lmB THqWDyeU9am4EjOSwmEZFW4Q7o0pN+wMMaX4WkxlDXfohzoqWxjoheD6nlcN99ra1O WuNuZ+J8mNBnqI16RA/j2NcmDHOeUncTRUr9rTZU= Original-Received: from smtp3.mail.yandex.net (localhost [127.0.0.1]) by smtp3.mail.yandex.net (Yandex) with ESMTP id CEDA31BA0343 for ; Sat, 11 Feb 2012 04:27:29 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1328920049; bh=D0MTJ0w1EqcukAW+ImLb8P+kptIqdv1f4c9+CfbjsL0=; h=Message-ID:Date:From:MIME-Version:To:Subject:Content-Type; b=CMOj8kKfskj0mWGlP4W5wXt/eK9V8KdXFuiRoCp7UH6u3sRteigs3BPg5Esjk0lmB THqWDyeU9am4EjOSwmEZFW4Q7o0pN+wMMaX4WkxlDXfohzoqWxjoheD6nlcN99ra1O WuNuZ+J8mNBnqI16RA/j2NcmDHOeUncTRUr9rTZU= Original-Received: from 98-87.nwlink.spb.ru (98-87.nwlink.spb.ru [178.252.98.87]) by smtp3.mail.yandex.net (nwsmtp/Yandex) with ESMTP id RTpelFmM-RTpS96Ka; Sat, 11 Feb 2012 04:27:29 +0400 X-Yandex-Spam: 1 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:56782 Archived-At: This is a multi-part message in MIME format. --------------050300050404020901030802 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Ruby 1.9 introduced the new syntax for hashes: {key1: value1, key2: value2} which is synonymous to {:key1 => value1, :key2 => value2} The latest ruby-mode highlights the keywords in the new-style hashes properly, but fails to account for the case when the symbol's name is an otherwise reserved keyword. Examples: link_to("root", root_path, class: "pink") before_filter :do_stuff, if: :not_busy? announce("The end is near!", end: "2012-12-31") In all examples, the symbol (class, if, end) is being highlighted as a reserved keyword, and the indentation becomes broken on all lines below it. There's a similar bug on the Ruby bug tracker: http://bugs.ruby-lang.org/issues/5140 See attachment for the patch. --------------050300050404020901030802 Content-Type: text/plain; name="ruby-keyword-symbols-patch.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ruby-keyword-symbols-patch.diff" diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index a0a6509..8818911 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -96,7 +96,7 @@ (regexp-opt (append ruby-modifier-beg-keywords ruby-block-op-keywords)) "Regexp to match hanging block modifiers.") -(defconst ruby-block-end-re "\\") +(defconst ruby-block-end-re "\\_") (eval-and-compile (defconst ruby-here-doc-beg-re @@ -115,9 +115,9 @@ This should only be called after matching against `ruby-here-doc-beg-re'." (match-string 6))))) (defconst ruby-delimiter - (concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\(" + (concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\_<\\(" ruby-block-beg-re - "\\)\\>\\|" ruby-block-end-re + "\\)\\_>\\|" ruby-block-end-re "\\|^=begin\\|" ruby-here-doc-beg-re)) (defconst ruby-negative @@ -166,6 +166,7 @@ This should only be called after matching against `ruby-here-doc-beg-re'." (modify-syntax-entry ?$ "." table) (modify-syntax-entry ?? "_" table) (modify-syntax-entry ?_ "_" table) + (modify-syntax-entry ?: "_" table) (modify-syntax-entry ?< "." table) (modify-syntax-entry ?> "." table) (modify-syntax-entry ?& "." table) @@ -565,7 +566,7 @@ and `\\' when preceded by `?'." (setq nest (cons (cons nil pnt) nest)) (setq depth (1+ depth)))) (goto-char (match-end 0))) - ((looking-at (concat "\\<\\(" ruby-block-beg-re "\\)\\>")) + ((looking-at (concat "\\_<\\(" ruby-block-beg-re "\\)\\_>")) (and (save-match-data (or (not (looking-at (concat "do" ruby-keyword-end-re))) @@ -864,7 +865,7 @@ move backward." ;; It seems like it should move to the line where indentation should deepen, ;; but ruby-indent-beg-re only accounts for whitespace before class, module and def, ;; so this will only match other block beginners at the beginning of the line. - (and (re-search-backward (concat "^\\(" ruby-indent-beg-re "\\)\\b") nil 'move) + (and (re-search-backward (concat "^\\(" ruby-indent-beg-re "\\)\\_>") nil 'move) (beginning-of-line))) (defun ruby-move-to-block (n) --------------050300050404020901030802--