From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vasilij Schneidermann Newsgroups: gmane.emacs.devel Subject: Combining syntax comment sequences (yaml-mode) Date: Wed, 23 Dec 2015 11:47:41 +0100 Message-ID: <20151223104741.GA769@odonien.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="/04w6evG8XlLl3ft" X-Trace: ger.gmane.org 1450867688 12193 80.91.229.3 (23 Dec 2015 10:48:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 23 Dec 2015 10:48:08 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 23 11:47:57 2015 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 1aBgxZ-0007j5-5q for ged-emacs-devel@m.gmane.org; Wed, 23 Dec 2015 11:47:57 +0100 Original-Received: from localhost ([::1]:55337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBgxY-0006Ew-LK for ged-emacs-devel@m.gmane.org; Wed, 23 Dec 2015 05:47:56 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBgxT-0006Aw-C7 for emacs-devel@gnu.org; Wed, 23 Dec 2015 05:47:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aBgxP-0007Yb-Bw for emacs-devel@gnu.org; Wed, 23 Dec 2015 05:47:51 -0500 Original-Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:35645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBgxP-0007YI-5j for emacs-devel@gnu.org; Wed, 23 Dec 2015 05:47:47 -0500 Original-Received: by mail-wm0-x233.google.com with SMTP id l126so142868297wml.0 for ; Wed, 23 Dec 2015 02:47:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=x62wfMAN8Br1TTwb+NzTOF9WglWeUvFdHR2eGFvtiXA=; b=F7V8aMnsD8voHJZBKvnhIyZ+2G551JbtLUNIe1rfDxy6h+tovZY6B3UctsAPSXCb2d NUxj2H2d9+uyYJ7zjdkOU3SFLHrvb/t8IoqmcCcO+/UGtKRiHL8SIWCWlZQgCZEku6Zi JMuxnI8YnO7fLcKz1pMxBTE22JbLHqw1LSNAsI7HkAlJLt8Nk+eNmfVWwxIcQnOkoUQp 1I+pu0xdrZZPD202Q8Dy2F7q6ldhxM84CtgoGLKhcyKdDZQqFfEOTQxzQCmmS+tK/WSI err04hjoluFOeDzP7TyLkglI/UAhA0Uyk/L3teU/DgNSWOZPMLb+53QQA0EAdPref+L0 YLqw== X-Received: by 10.28.129.202 with SMTP id c193mr3686311wmd.35.1450867662988; Wed, 23 Dec 2015 02:47:42 -0800 (PST) Original-Received: from localhost (dslb-188-097-059-127.188.097.pools.vodafone-ip.de. [188.97.59.127]) by smtp.gmail.com with ESMTPSA id 193sm28897677wmp.16.2015.12.23.02.47.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Dec 2015 02:47:42 -0800 (PST) Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::233 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:196703 Archived-At: --/04w6evG8XlLl3ft Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Hello, I have reached out for maintainership of yaml-mode recently and am currently fixing a number of bugs that have been reported on its issue tracker. One of these bugs is rather subtle as it demonstrates that its syntax table isn't quite correct: YAML does use the "#" character to indicate a comment, like many other popular languages. You'd typically encode this in a syntax table as follows: (modify-syntax-entry ?# "<" yaml-mode-syntax-table) (modify-syntax-entry ?\n ">" yaml-mode-syntax-table) While this covers most cases one would run into, it doesn't conform to the YAML specification[1]: A comment is either a token separated by whitespace from other tokens or is on its own line. This rule allows you to use something like "foo#bar" as a token without "bar" getting interpreted as a comment. However with the code above "bar" will get fontified as if it were a comment. To highlight the former kind of comments correctly, the following works: (modify-syntax-entry ?\s ". 1" yaml-mode-syntax-table) (modify-syntax-entry ?# ". 2" yaml-mode-syntax-table) (modify-syntax-entry ?\n ">" yaml-mode-syntax-table) To do the same for the latter kind of comments: (modify-syntax-entry ?\n "> 1" yaml-mode-syntax-table) (modify-syntax-entry ?# ". 2" yaml-mode-syntax-table) I cannot find a way to combine both code snippets though. The obvious approach yields incorrect results: (modify-syntax-entry ?\s ". 1" yaml-mode-syntax-table) (modify-syntax-entry ?# ". 2" yaml-mode-syntax-table) (modify-syntax-entry ?\n "> 1" yaml-mode-syntax-table) Is there some other way to combine multiple comment syntaxes? I find the existing documentation rather confusing and couldn't find any tooling for debugging syntax table problems (other than staring hard at them and having an incomplete mental model of how they work). I've attached a test file for verifying the results. yaml-mode itself can be found on Github[2]. [1]: http://www.yaml.org/spec/1.2/spec.html#id2780069 [2]: https://github.com/yoshiki/yaml-mode --/04w6evG8XlLl3ft Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="test.yaml" foo: bar#baz # qux quux qux #bar --/04w6evG8XlLl3ft--