From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#19898: 24.4; Syntax highlighting in jgraph-mode is wrong if title line is commented Date: Thu, 19 Feb 2015 09:59:06 -0500 Message-ID: References: <54E524F1.5000908@buckeyemail.osu.edu> <54E56033.1080303@buckeyemail.osu.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1424358032 32130 80.91.229.3 (19 Feb 2015 15:00:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 19 Feb 2015 15:00:32 +0000 (UTC) Cc: biswass@cse.ohio-state.edu, 19898-done@debbugs.gnu.org To: Swarnendu Biswas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Feb 19 16:00:19 2015 Return-path: Envelope-to: geb-bug-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 1YOSaL-0006KH-1B for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Feb 2015 16:00:13 +0100 Original-Received: from localhost ([::1]:56651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOSaK-0006GA-8E for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Feb 2015 10:00:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOSaG-0006ET-UE for bug-gnu-emacs@gnu.org; Thu, 19 Feb 2015 10:00:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOSaD-0007le-NM for bug-gnu-emacs@gnu.org; Thu, 19 Feb 2015 10:00:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57492) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOSaD-0007kd-JS for bug-gnu-emacs@gnu.org; Thu, 19 Feb 2015 10:00:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YOSaD-0001Vm-60 for bug-gnu-emacs@gnu.org; Thu, 19 Feb 2015 10:00:05 -0500 Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Feb 2015 15:00:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 19898 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 19898@debbugs.gnu.org, monnier@iro.umontreal.ca, biswass@cse.ohio-state.edu Original-Received: via spool by 19898-done@debbugs.gnu.org id=D19898.14243579745733 (code D ref 19898); Thu, 19 Feb 2015 15:00:03 +0000 Original-Received: (at 19898-done) by debbugs.gnu.org; 19 Feb 2015 14:59:34 +0000 Original-Received: from localhost ([127.0.0.1]:48730 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YOSZh-0001UM-Cl for submit@debbugs.gnu.org; Thu, 19 Feb 2015 09:59:33 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:4916) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YOSZd-0001UB-DG for 19898-done@debbugs.gnu.org; Thu, 19 Feb 2015 09:59:30 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApEUAPOG1lTO+LI//2dsb2JhbABbDoJ4gSyCM4VTwGUEAgKBDUQBAQEBAQF8hA0BBAFWIwULCzQSFBgNJBOIJQjOIwEBAQEBAQQBAQEBAR2PCxZXB4QqBYonhFOaeIFFIoIyf1sgMYEDgT8BAQE X-IPAS-Result: ApEUAPOG1lTO+LI//2dsb2JhbABbDoJ4gSyCM4VTwGUEAgKBDUQBAQEBAQF8hA0BBAFWIwULCzQSFBgNJBOIJQjOIwEBAQEBAQQBAQEBAR2PCxZXB4QqBYonhFOaeIFFIoIyf1sgMYEDgT8BAQE X-IronPort-AV: E=Sophos;i="5.09,536,1418101200"; d="scan'208";a="110916910" Original-Received: from 206-248-178-63.dsl.teksavvy.com (HELO pastel.home) ([206.248.178.63]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 19 Feb 2015 09:59:28 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 8EAD11760; Thu, 19 Feb 2015 09:59:06 -0500 (EST) In-Reply-To: <54E56033.1080303@buckeyemail.osu.edu> (Swarnendu Biswas's message of "Wed, 18 Feb 2015 23:01:55 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:99594 Archived-At: > I have attached a file, hopefully you will be able to reproduce the syntax > highlighting problem by commenting/uncommenting the "title" line. Indeed, there was a bug with "foo : " inside comments. I installed the patch below which should make those strings work more reliably, including in the multi-line case. Stefan diff --git a/packages/jgraph-mode/jgraph-mode.el b/packages/jgraph-mode/jgraph-mode.el index a56449e..ea2a0d2 100644 --- a/packages/jgraph-mode/jgraph-mode.el +++ b/packages/jgraph-mode/jgraph-mode.el @@ -1,9 +1,9 @@ ;;; jgraph-mode.el --- Major mode for Jgraph files -*- lexical-binding:t -*- -;; Copyright (C) 2006, 2011-2012, 2014 Free Software Foundation, Inc +;; Copyright (C) 2006, 2011-2012, 2014, 2015 Free Software Foundation, Inc ;; Author: Stefan Monnier -;; Version: 1.0 +;; Version: 1.1 ;; Package-Requires: ((cl-lib "0.5")) ;; Keywords: tex, wp @@ -138,7 +138,8 @@ (,(concat "\\_<" (regexp-opt (cons "include" (apply 'append (mapcar 'cdr jgraph-commands)))) - "\\_>") . font-lock-keyword-face) + "\\_>") + . font-lock-keyword-face) ) "Keyword highlighting specification for `jgraph-mode'.") @@ -172,6 +173,20 @@ ;;;###autoload (add-to-list 'auto-mode-alist '("\\.jgr\\'" . jgraph-mode)) +(defun jgraph--syntax-end-of-string (limit) + (when (eq t (nth 3 (syntax-ppss))) + (when (re-search-forward "\\(?:\\=\\|[^\\]\\)\\(\n\\)" limit t) + (put-text-property (match-beginning 1) (match-end 1) + 'syntax-table (string-to-syntax "|"))))) + +(defun jgraph--syntax-propertize (start end) + (goto-char start) + (jgraph--syntax-end-of-string end) + (funcall + (syntax-propertize-rules + ("\\s-:\\(\\s-\\)" (1 (prog1 "|" (jgraph--syntax-end-of-string end))))) + start end)) + ;;;###autoload (define-derived-mode jgraph-mode prog-mode "Jgraph" "A major mode for editing Jgraph files." @@ -182,9 +197,7 @@ (set (make-local-variable 'font-lock-defaults) '(jgraph-font-lock-keywords)) (set (make-local-variable 'syntax-propertize-function) - (syntax-propertize-rules - ;; FIXME: naive(broken) multiline pattern. - ("\\s-\\(:\\)\\s-\\(?:.*\\\\\n\\)*.*\\(\n\\)" (1 "|") (2 "|")))) + #'jgraph--syntax-propertize) (set (make-local-variable 'indent-line-function) 'jgraph-indent-line) ;; (set (make-local-variable 'imenu-generic-expression) ;; jgraph-imenu-generic-expression) @@ -195,7 +208,6 @@ (defcustom jgraph-indent-offset 4 "Basic indentation step size in `jgraph-mode'." - :group 'jgraph-mode :type 'integer) (defun jgraph-indent-line ()