From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Swarnendu Biswas <biswas.38@buckeyemail.osu.edu>
Cc: biswass@cse.ohio-state.edu, 19898-done@debbugs.gnu.org
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 [thread overview]
Message-ID: <jwvwq3erls8.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <54E56033.1080303@buckeyemail.osu.edu> (Swarnendu Biswas's message of "Wed, 18 Feb 2015 23:01:55 -0500")
> 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 : <string>" 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 <monnier@iro.umontreal.ca>
-;; 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 ()
prev parent reply other threads:[~2015-02-19 14:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-18 23:49 bug#19898: 24.4; Syntax highlighting in jgraph-mode is wrong if title line is commented Swarnendu Biswas
2015-02-19 1:56 ` Stefan Monnier
2015-02-19 4:01 ` Swarnendu Biswas
2015-02-19 14:59 ` Stefan Monnier [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvwq3erls8.fsf-monnier+emacsbugs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=19898-done@debbugs.gnu.org \
--cc=biswas.38@buckeyemail.osu.edu \
--cc=biswass@cse.ohio-state.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).