From unknown Sun Jun 15 08:49:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#10786: 24.0.93; ruby-mode improperly handles symbols with keyword names in JS-style hashes 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: To: 10786@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.132892037412805 (code B ref -1); Sat, 11 Feb 2012 00:33:02 +0000 Received: (at submit) by debbugs.gnu.org; 11 Feb 2012 00:32:54 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=unavailable version=3.3.2 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 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 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 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 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= 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= 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 Message-ID: <4F35B5F5.6040403@yandex.ru> Date: Sat, 11 Feb 2012 04:27:33 +0400 From: Dmitry Gutov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050300050404020901030802" 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-Received-From: 140.186.70.17 X-Spam-Score: -3.5 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) 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-- From unknown Sun Jun 15 08:49:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#10786: 24.0.93; ruby-mode improperly handles symbols with keyword names in JS-style hashes References: <4F35B5F5.6040403@yandex.ru> In-Reply-To: <4F35B5F5.6040403@yandex.ru> 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 01:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10786 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 10786@debbugs.gnu.org Received: via spool by 10786-submit@debbugs.gnu.org id=B10786.132892509419892 (code B ref 10786); Sat, 11 Feb 2012 01:52:01 +0000 Received: (at 10786) by debbugs.gnu.org; 11 Feb 2012 01:51:34 +0000 Received: from localhost ([127.0.0.1]:35472 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rw27i-0005Am-Bt for submit@debbugs.gnu.org; Fri, 10 Feb 2012 20:51:34 -0500 Received: from forward6.mail.yandex.net ([77.88.60.125]:50916) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rw27e-0005AR-Up for 10786@debbugs.gnu.org; Fri, 10 Feb 2012 20:51:33 -0500 Received: from smtp9.mail.yandex.net (smtp9.mail.yandex.net [77.88.61.35]) by forward6.mail.yandex.net (Yandex) with ESMTP id B512B11225B6 for <10786@debbugs.gnu.org>; Sat, 11 Feb 2012 05:50:05 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1328925005; bh=Uc37DP8mso1SeU+7tLGSWWBB5DQrCKJBb813sUUigE4=; h=Message-ID:Date:From:MIME-Version:To:Subject:Content-Type: Content-Transfer-Encoding; b=b8Rr151DwFyFxL9ODXa6QqJtFHrAAvPUbwHlpoeYxS1w6HXF50XL8C9Tsfn204R07 Kt6Ve+BNhzi61m8jDSmcyrzfkSUjJlUgjZCt+5dGHOTnPkPYsE1gcLMLmpxoZX+O2R yRTCWKzLdmyxbeLlQaTb5bBOcCWBKe2G1wSZ22bc= Received: from smtp9.mail.yandex.net (localhost [127.0.0.1]) by smtp9.mail.yandex.net (Yandex) with ESMTP id 9B66315201CC for <10786@debbugs.gnu.org>; Sat, 11 Feb 2012 05:50:05 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1328925005; bh=Uc37DP8mso1SeU+7tLGSWWBB5DQrCKJBb813sUUigE4=; h=Message-ID:Date:From:MIME-Version:To:Subject:Content-Type: Content-Transfer-Encoding; b=b8Rr151DwFyFxL9ODXa6QqJtFHrAAvPUbwHlpoeYxS1w6HXF50XL8C9Tsfn204R07 Kt6Ve+BNhzi61m8jDSmcyrzfkSUjJlUgjZCt+5dGHOTnPkPYsE1gcLMLmpxoZX+O2R yRTCWKzLdmyxbeLlQaTb5bBOcCWBKe2G1wSZ22bc= Received: from 98-87.nwlink.spb.ru (98-87.nwlink.spb.ru [178.252.98.87]) by smtp9.mail.yandex.net (nwsmtp/Yandex) with ESMTP id o5EWKnxq-o5E8YPbF; Sat, 11 Feb 2012 05:50:05 +0400 X-Yandex-Spam: 1 Message-ID: <4F35C952.1010401@yandex.ru> Date: Sat, 11 Feb 2012 05:50:10 +0400 From: Dmitry Gutov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Correction: >> The latest ruby-mode highlights the keywords in the new-style hashes properly Should be "highlights the symbols", not keywords. From unknown Sun Jun 15 08:49:32 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.428 (Entity 5.428) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Dmitry Gutov Subject: bug#10786: closed (Re: bug#10786: 24.0.93; ruby-mode improperly handles symbols with keyword names in JS-style hashes) Message-ID: References: <4F35B5F5.6040403@yandex.ru> X-Gnu-PR-Message: they-closed 10786 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 10786@debbugs.gnu.org Date: Wed, 21 Mar 2012 19:05:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1332356702-28456-1" This is a multi-part message in MIME format... ------------=_1332356702-28456-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #10786: 24.0.93; ruby-mode improperly handles symbols with keyword names in= JS-style hashes which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 10786@debbugs.gnu.org. --=20 10786: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D10786 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1332356702-28456-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 10786-done) by debbugs.gnu.org; 21 Mar 2012 19:04:14 +0000 Received: from localhost ([127.0.0.1]:60083 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SAQpR-0007O0-LM for submit@debbugs.gnu.org; Wed, 21 Mar 2012 15:04:14 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.183]:62312) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SAQpP-0007Nt-Ua for 10786-done@debbugs.gnu.org; Wed, 21 Mar 2012 15:04:12 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AicFAKU/KE9FxKFU/2dsb2JhbACBX5x7eYhpniCGGQSbGYQJ X-IronPort-AV: E=Sophos;i="4.73,1,1325480400"; d="scan'208";a="169222682" Received: from 69-196-161-84.dsl.teksavvy.com (HELO pastel.home) ([69.196.161.84]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 21 Mar 2012 14:33:28 -0400 Received: by pastel.home (Postfix, from userid 20848) id 4FD2658C3D; Wed, 21 Mar 2012 14:33:28 -0400 (EDT) From: Stefan Monnier To: Dmitry Gutov Subject: Re: bug#10786: 24.0.93; ruby-mode improperly handles symbols with keyword names in JS-style hashes Message-ID: References: <4F35B5F5.6040403@yandex.ru> Date: Wed, 21 Mar 2012 14:33:28 -0400 In-Reply-To: <4F35B5F5.6040403@yandex.ru> (Dmitry Gutov's message of "Sat, 11 Feb 2012 04:27:33 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10786-done Cc: 10786-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Thanks, installed, Stefan ------------=_1332356702-28456-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 11 Feb 2012 00:32:54 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=unavailable version=3.3.2 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 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 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 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 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= 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= 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 Message-ID: <4F35B5F5.6040403@yandex.ru> Date: Sat, 11 Feb 2012 04:27:33 +0400 From: Dmitry Gutov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Subject: 24.0.93; ruby-mode improperly handles symbols with keyword names in JS-style hashes Content-Type: multipart/mixed; boundary="------------050300050404020901030802" 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-Received-From: 140.186.70.17 X-Spam-Score: -3.5 (---) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) 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-- ------------=_1332356702-28456-1--