From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Writing syntax-propertize-function for strings in code in strings, etc Date: Sat, 08 Sep 2012 07:23:37 +0400 Message-ID: <87a9x1jiyu.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1347074639 2132 80.91.229.3 (8 Sep 2012 03:23:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 8 Sep 2012 03:23:59 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 08 05:23:59 2012 Return-path: Envelope-to: ged-emacs-devel@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 1TABeG-00009m-Ma for ged-emacs-devel@m.gmane.org; Sat, 08 Sep 2012 05:23:56 +0200 Original-Received: from localhost ([::1]:35491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TABeD-0001zC-IG for ged-emacs-devel@m.gmane.org; Fri, 07 Sep 2012 23:23:53 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TABeA-0001yv-JS for emacs-devel@gnu.org; Fri, 07 Sep 2012 23:23:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TABe9-0005y2-41 for emacs-devel@gnu.org; Fri, 07 Sep 2012 23:23:50 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:54977) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TABe8-0005xn-Ts for emacs-devel@gnu.org; Fri, 07 Sep 2012 23:23:49 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TABe8-0008PQ-Gs for emacs-devel@gnu.org; Sat, 08 Sep 2012 05:23:48 +0200 Original-Received: from 5.166.243.132 ([5.166.243.132]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 08 Sep 2012 05:23:48 +0200 Original-Received: from dgutov by 5.166.243.132 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 08 Sep 2012 05:23:48 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 31 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 5.166.243.132 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (windows-nt) Cancel-Lock: sha1:+00QuQ3Adi3NKI2M8GW2a0cGauQ= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:153171 Archived-At: Hi all, I've been looking into this bug: http://bugs.ruby-lang.org/issues/6090 To elaborate, Ruby allows arbitrary code between string interpolation braces, and even unlimited nesting of those. Sublime Text handles these aspects rather excellently, and even highlights the code inside as code, not string contents: http://i.imgur.com/NH1Ye.png Is there a proper way to do so in Emacs? My first idea was, when propertizing interpolation, to see what kind of string we're inside, and apply the appropriate syntax to the enclosing braces, thus splitting the literal in two. But (a) string quotes class doesn't work that way (text characters on both ends of a literal must be the same), (b) if we're inside a percent literal (syntax class: generic string), and the literal spans several lines, we need to be able to jump to its real beginning position from its end, but with this approach (nth 8 (syntax-ppss)) will just return the beginning of the last piece. Saving buffer positions to text properties looks not very reliable, since the respective text may be deleted and re-inserted. Suggestions? A quick and dirty way is to limit the support to double-quoted strings, no change in highlighting, and no nesting, but that would be the last resort. --Dmitry