From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Robin Neatherway Newsgroups: gmane.emacs.help Subject: syntax-propertize-function for multiline strings Date: Mon, 6 Jan 2014 21:48:19 +0000 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1389045042 8771 80.91.229.3 (6 Jan 2014 21:50:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 6 Jan 2014 21:50:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 06 22:50:50 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 1W0I4P-0002LG-UK for geh-help-gnu-emacs@m.gmane.org; Mon, 06 Jan 2014 22:50:50 +0100 Original-Received: from localhost ([::1]:37733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W0I4P-0005Ir-K5 for geh-help-gnu-emacs@m.gmane.org; Mon, 06 Jan 2014 16:50:49 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W0I2L-0004ZW-SB for help-gnu-emacs@gnu.org; Mon, 06 Jan 2014 16:48:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W0I2K-0004zH-OX for help-gnu-emacs@gnu.org; Mon, 06 Jan 2014 16:48:41 -0500 Original-Received: from mail-oa0-x22f.google.com ([2607:f8b0:4003:c02::22f]:54255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W0I2K-0004yY-Jj for help-gnu-emacs@gnu.org; Mon, 06 Jan 2014 16:48:40 -0500 Original-Received: by mail-oa0-f47.google.com with SMTP id i7so1380452oag.6 for ; Mon, 06 Jan 2014 13:48:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=NAx6a4LK+jB0Vp0iC72oNhkkZTPKviraxjVdGeeMSLY=; b=Q12/4d1mWtE2+H2AlfwKLwRciqTkHq+wA3RfnTU36gt5pTcZ1S7xqKr+iZImGiEUQ8 XxbTG9+Zschtx5uDVAVIBLwg3zcdbleh/mBShzIri+nPimZnl4j3DF4/+LMrN8BvVUfj /rLzKhBS5gFuTe61BaeVaeTLNN0uJw+jdP1Bd0mtKJGfAsOhNmMkSCHw7gzpmdN6vhtK Ivg6hQYIyuqmMUIqDnWRDKlLsuL69ljN1Dbr1n9Y8hBPoaNExJQxUy0dq+2tYGy0yMfb JNoIt3rjBQcO+d6cjlsYgJxuB/n436nPh8ljdjBOWpUyAGkJ3sjJy0rQlgP8R8k7/UCX o1oA== X-Received: by 10.182.230.135 with SMTP id sy7mr73969750obc.24.1389044919105; Mon, 06 Jan 2014 13:48:39 -0800 (PST) Original-Received: by 10.60.38.233 with HTTP; Mon, 6 Jan 2014 13:48:19 -0800 (PST) X-Google-Sender-Auth: xSjcjwwmvfQyMUztn0NYNBYKCU4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c02::22f X-Mailman-Approved-At: Mon, 06 Jan 2014 16:50:26 -0500 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:95285 Archived-At: Hi, I'm trying to improve the syntax highlighting for fsharp-mode [1]. F# allow strings to be specified over multiple lines [2]. I'm trying to define verbatim strings, which are preceded with '@' and in which backslash is should not be treated as an escape character (and "" is interpreted as "). The syntax highlighting hasn't been updated to use syntax-propertize-function, so I am trying to use that. I've defined a rule with a regexp, but with a string that ends with \" the highlighting breaks if I insert newlines inside the verbatim string. I think this is because the parsing is being restarted at the newline and so the string is treated normally, with the backslash escaping the double quote. I don't know what the recommended technique is to handle this though. A minimal working example follows. I define a major mode "test-mode" that highlights just "//.*" style comments and give an example file. To reproduce open the example file and switch to "test-mode". Then insert newlines after the first line. The comment highlighting will turn to string highlighting. Then insert a space at the end of the first line. The highlighting will again be correct. Thanks for any help, Robin (setq test-syntax-table (let ((synTable (make-syntax-table))) (modify-syntax-entry ?\/ ". 12" synTable) (modify-syntax-entry ?\n "> " synTable) synTable)) (defconst test-syntax-propertize-function (syntax-propertize-rules ("@\\(\"\\)\\(:?\"\"\\|[^\"]\\)*\\(\"\\)" (1 "\"") (2 "\"")))) (define-derived-mode test-mode prog-mode "test" :syntax-table test-syntax-table (setq font-lock-mode t) (setq syntax-propertize-function test-syntax-propertize-function) (setq mode-name "test") ) Example file: let mystring = @"hello \" // This is a comment [1] https://github.com/fsharp/fsharpbinding/tree/master/emacs [2] http://msdn.microsoft.com/en-us/library/dd323829.aspx