From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bob Proulx Newsgroups: gmane.emacs.help Subject: Re: ruby-mode interpolated quotes error Date: Fri, 2 May 2014 17:55:33 -0600 Message-ID: <20140502235533.GA29686@hysteria.proulx.com> References: <20140502231345.GA20703@hysteria.proulx.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1399074968 2243 80.91.229.3 (2 May 2014 23:56:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 2 May 2014 23:56:08 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat May 03 01:56:02 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WgNJA-0003So-UH for geh-help-gnu-emacs@m.gmane.org; Sat, 03 May 2014 01:56:01 +0200 Original-Received: from localhost ([::1]:46739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgNJA-0000xy-KO for geh-help-gnu-emacs@m.gmane.org; Fri, 02 May 2014 19:56:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgNIr-0000lz-7o for help-gnu-emacs@gnu.org; Fri, 02 May 2014 19:55:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WgNIk-0000cZ-7E for help-gnu-emacs@gnu.org; Fri, 02 May 2014 19:55:41 -0400 Original-Received: from joseki.proulx.com ([216.17.153.58]:40082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgNIj-0000cK-Sk for help-gnu-emacs@gnu.org; Fri, 02 May 2014 19:55:34 -0400 Original-Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 54C032183F for ; Fri, 2 May 2014 17:55:33 -0600 (MDT) Original-Received: by hysteria.proulx.com (Postfix, from userid 1000) id 4728A2DC1B; Fri, 2 May 2014 17:55:33 -0600 (MDT) Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <20140502231345.GA20703@hysteria.proulx.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 216.17.153.58 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:97546 Archived-At: Bob Proulx wrote: > Andrew Pennebaker wrote: > > Specifically, the initial double quote on line 46 should be colored yellow, > > like the end double quote, and the single quoted string above. > > > > Anyone else experience this? > > The #{...} construct causes the character immediately preceding the > '#' to be colored in the variable face color. This motivated me to poke into the problem a little. The problem appears to be ruby-match-expression-expansion which is looking for any character not a backslash before the #{...}. (defun ruby-match-expression-expansion (limit) (when (re-search-forward "[^\\]\\(\\\\\\\\\\)*\\(#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)\\)" limit 'move) (or (ruby-in-ppss-context-p 'string) (ruby-match-expression-expansion limit)))) It is trying to avoid matching a sub-expression in this case. Two test cases would be: "abc#{def}ghi" "abc\#{def}ghi" In the first #{def} is a subexpression. In the second the # is escaped and is not evaluated. So what is needed is a way to match a # that is not preceded by a backslash but not to include the non-backslash character in the expression. Or another method to accomplish the task. I am only an infrequent elisp hacker and am unfamiliar with the idioms needed to avoid this problem. Anyone else on the list know a good idiom to use? It needs to match but ignore the leading context. (This is the opposite of the "trailing context" match feature provided by lex.) As a quick hack to alleviate your particular symptom, while creating a more rare different one, you could remove the [^\\] part from the front of the expression. That would no longer match the non-backslash in front of the #{...} construct and your case would work correctly. It then would miscolor the new case "abc\#{def}ghi" which is not a sub-expression due to the escape but would still be colored as if it were. That might be a less annoying problem. Bob --- ruby-mode.el.orig 2014-05-02 17:29:15.312413975 -0600 +++ ruby-mode.el 2014-05-02 17:27:31.935234984 -0600 @@ -1578,7 +1578,7 @@ "Additional expressions to highlight in Ruby mode.") (defun ruby-match-expression-expansion (limit) - (when (re-search-forward "[^\\]\\(\\\\\\\\\\)*\\(#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)\\)" limit 'move) + (when (re-search-forward "\\(\\\\\\\\\\)*\\(#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)\\)" limit 'move) (or (ruby-in-ppss-context-p 'string) (ruby-match-expression-expansion limit))))