GNU logs - #32204, boring messages


Message sent to bug-cc-mode@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#32204: CC Mode 5.33.1 (Dart//l); cc-mode without fontification
Resent-From: Brady Trainor <mail@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-cc-mode@HIDDEN
Resent-Date: Wed, 18 Jul 2018 19:56:02 +0000
Resent-Message-ID: <handler.32204.B.153194373021948 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 32204
X-GNU-PR-Package: cc-mode
X-GNU-PR-Keywords: 
To: 32204 <at> debbugs.gnu.org
X-Debbugs-Original-To: submit <at> debbugs.gnu.org
Received: via spool by submit <at> debbugs.gnu.org id=B.153194373021948
          (code B ref -1); Wed, 18 Jul 2018 19:56:02 +0000
Received: (at submit) by debbugs.gnu.org; 18 Jul 2018 19:55:30 +0000
Received: from localhost ([127.0.0.1]:47212 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ffsXp-0005hw-Ic
	for submit <at> debbugs.gnu.org; Wed, 18 Jul 2018 15:55:29 -0400
Received: from out1-smtp.messagingengine.com ([66.111.4.25]:43385)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1ffsXn-0005ho-ON
 for submit <at> debbugs.gnu.org; Wed, 18 Jul 2018 15:55:28 -0400
Received: from compute4.internal (compute4.nyi.internal [10.202.2.44])
 by mailout.nyi.internal (Postfix) with ESMTP id 4A5DE21CF0;
 Wed, 18 Jul 2018 15:55:27 -0400 (EDT)
Received: from mailfrontend1 ([10.202.2.162])
 by compute4.internal (MEProxy); Wed, 18 Jul 2018 15:55:27 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=content-transfer-encoding:content-type
 :date:from:message-id:mime-version:subject:to:x-me-sender
 :x-me-sender:x-sasl-enc; s=fm3; bh=P5DprKVFUDQV23LfpUJRbnI5TNkkq
 gzDm3HH+oLSSMI=; b=gOTwIhqVPm3rgVfVhqJDqhsczdDfozWlLlmVarl4C2C/C
 bdn2B20s+D8Q3eEDZrDVFOMfz+lupoBa1q9awUgNp/68+8gTxqy0wOt1gSC5DxJu
 LLC9Nehci53AXIvrvL5aSGtJKsQzqzNOOSLPezsw1yVZhEarwc7duTMzEOBgr/3g
 FcRoAvOg6+T9JRgRXYSFblKW4APjyQRKML80G+nTAnLe4AnkdX5rhZA3IaA5gB5L
 reD1RMvITXdmH7RtKpvM/zXKiXN8Vdn5ezzYFYW4sCFXezcHpSPB0lELPbjBfi8d
 cWk/ojqR8nnCfICwID7UTQWxur7NsMgMzJJAoN/Yw==
X-ME-Proxy: <xmx:L5tPW6TzbGTLL6ov9LBgMlZOh6WX0ONUYmPUSH7O2c63NQoIqz1ORQ>
 <xmx:L5tPW_X-M12qBG8KBrLH9SFB64vXk7-XCYmYllEPbHAJlYcH4efr3A>
 <xmx:L5tPWxMwW2Kimtss_hJ63V1rmSFabMWLMaKMUFLFoABxaXFLx5sXJw>
 <xmx:L5tPW-3x7cU37kKtDXeeLxvyIXugYHE9oKjZIxEJRxEF-TC0f_5ryA>
 <xmx:L5tPWxPQLgjOx6BF8bliJESDFX4jD17NDc5GXq1WXGkIE9xRLPwW3w>
 <xmx:L5tPWzZrbiPFvnVE6F_z3nsF03p9rBV6HnSQqAXBpX45pvnKtTXQXg>
X-ME-Sender: <xms:LptPW2jrTlNjKQkSapcBEWIc1fxT3VnAr1m9OiDipQni1TpKnur_Pw>
From: Brady Trainor <mail@HIDDEN>
Date: Wed, 18 Jul 2018 12:55:25 -0700
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Message-Id: <20180718195526.83790E40A1@HIDDEN>
X-Spam-Score: -0.7 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Should it be possible for a language mode author to use only the
indentation functions from cc-mode, and write the font-lock-defaults
independently of cc-mode?

I attempted to do this with by using c-basic-common-init, instead of
c-common-init.

Here is the contents of my dart-mode.el

--8<---------------cut here---------------start------------->8---
;;; dart-mode.el --- Major mode for editing Dart files -*- lexical-binding:=
 t; -*-

;;; Code:

(require 'cc-mode)
(eval-when-compile
  (require 'cc-langs)
  (require 'cc-fonts))

(eval-and-compile (c-add-language 'dart-mode 'java-mode))

(c-lang-defconst c-multiline-string-start-char
  dart ?@)

(defconst dart-c-style
  '("java")
  "The default Dart styles.")

(c-add-style "dart" dart-c-style)

(defvar dart-mode-map (c-make-inherited-keymap)
  "Keymap used in dart-mode buffers.")

;;;###autoload
(add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))

;;;###autoload
(define-derived-mode dart-mode prog-mode "Dart"
  "Major mode for editing Dart files.

The hook `c-mode-common-hook' is run with no args at mode
initialization, then `dart-mode-hook'.

Key bindings:
\\{dart-mode-map}"
  (c-initialize-cc-mode t)
  (c-init-language-vars dart-mode)
  (c-basic-common-init 'dart-mode '((dart-mode . "dart")))
  (setq font-lock-defaults '(nil)))

(provide 'dart-mode)

;;; dart-mode.el ends here
--8<---------------cut here---------------end--------------->8---

I then open emacs with:

emacs -Q tmp.dart -l dart-mode.el --eval "(progn (toggle-debug-on-error) (d=
art-mode))"

However, I get errors when for example tmp.dart has the contents:

class SpaceCraft {

I put point after opening curly, hit RET, and type the closing curly, I
get the following stack trace:

--8<---------------cut here---------------end--------------->8---
Debugger entered--Lisp error: (args-out-of-range 20 40)
  put-text-property(20 40 fontified nil)
  c-extend-after-change-region(20 20 4)
  font-lock-extend-jit-lock-region-after-change(20 20 4)
  run-hook-with-args(font-lock-extend-jit-lock-region-after-change 20 20 4)
  jit-lock-after-change(20 20 4)
  c-shift-line-indentation(-4)
  c-indent-line(((class-close 1)))
  c-electric-brace(nil)
  funcall-interactively(c-electric-brace nil)
  call-interactively(c-electric-brace nil nil)
  command-execute(c-electric-brace)
--8<---------------cut here---------------end--------------->8---

If I remove the following expression, then the issue is resolved.

(c-lang-defconst c-multiline-string-start-char
  dart ?@)

But there are many c-lang-defconst expressions in current dart-mode
master, and I have not understood cc-mode enough to understand why each
should be there, and which should not. If I remove the above line, I can
continue to find such errors, so it seems more about having removed the
cc-mode fontification from the major mode.

(Why would I want to remove only the cc fontification? dart-mode may
become easier to maintain and deal with edge cases once we remove
cc-mode framework from its implementation. I would like to do this
piecemeal. It may take some time to create an indentation function from
scratch that is strictly as good as the one implemented via cc-mode
framework. But there are several issues on issue tracker related to
fontification, which are quite tractable to solve simply using the
font-lock framework standing alone. So I would like to add my
fontification improvements to the master branch, leaving cc-mode
indentation intact, so that I am not creating regressions on master
branch. In fact, inspired by haskell-mode, I'd like to offer multiple
choices in indentation functions, so that potentially, contributors can
improve their choice of either the cc-mode indentation or the "from
scratch" indentation function. I have more ideas for choices in
indentation, like being able to call `dartfmt` on regions, or have it
only look at region between point and point-min (to avoid dartfmt's
predilection to choke and spew errors).)

Thank you for reading!

--
Brady


Emacs  : GNU Emacs 27.0.50 (build 1, x86_64-apple-darwin17.4.0, NS appkit-1=
561.20 Version 10.13.3 (Build 17D102))
 of 2018-07-03
Package: CC Mode 5.33.1 (Dart//l)
Buffer Style: dart
c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-st=
ring-delim gen-comment-delim syntax-properties 1-bit)

current state:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
(setq
 c-basic-offset 4
 c-comment-only-line-offset '(0 . 0)
 c-indent-comment-alist '((anchored-comment column . 0) (end-block space . =
1)
			  (cpp-end-block space . 2))
 c-indent-comments-syntactically-p nil
 c-block-comment-prefix "* "
 c-comment-prefix-regexp '((pike-mode . "//+!?\\|\\**") (awk-mode . "#+")
			   (other . "//+\\|\\**"))
 c-doc-comment-style '((java-mode . javadoc) (pike-mode . autodoc)
		       (c-mode . gtkdoc))
 c-cleanup-list '(scope-operator)
 c-hanging-braces-alist '((brace-list-open) (brace-entry-open) (statement-c=
ont)
			  (substatement-open after)
			  (block-close . c-snug-do-while)
			  (extern-lang-open after) (namespace-open after)
			  (module-open after) (composition-open after)
			  (inexpr-class-open after) (inexpr-class-close before)
			  (arglist-cont-nonempty))
 c-hanging-colons-alist nil
 c-hanging-semi&comma-criteria '(c-semi&comma-inside-parenlist)
 c-backslash-column 48
 c-backslash-max-column 72
 c-special-indent-hook nil
 c-label-minimum-indentation 1
 c-offsets-alist '((inexpr-class . +)
		   (inexpr-statement . +)
		   (lambda-intro-cont . +)
		   (inlambda . c-lineup-inexpr-block)
		   (template-args-cont c-lineup-template-args +)
		   (incomposition . +)
		   (inmodule . +)
		   (innamespace . +)
		   (inextern-lang . +)
		   (composition-close . 0)
		   (module-close . 0)
		   (namespace-close . 0)
		   (extern-lang-close . 0)
		   (composition-open . 0)
		   (module-open . 0)
		   (namespace-open . 0)
		   (extern-lang-open . 0)
		   (objc-method-call-cont
		    c-lineup-ObjC-method-call-colons
		    c-lineup-ObjC-method-call
		    +
		    )
		   (objc-method-args-cont . c-lineup-ObjC-method-args)
		   (objc-method-intro . [0])
		   (friend . 0)
		   (cpp-define-intro c-lineup-cpp-define +)
		   (cpp-macro-cont . +)
		   (cpp-macro . [0])
		   (inclass . +)
		   (stream-op . c-lineup-streamop)
		   (arglist-cont-nonempty
		    c-lineup-gcc-asm-reg
		    c-lineup-arglist
		    )
		   (arglist-cont c-lineup-gcc-asm-reg 0)
		   (comment-intro c-lineup-knr-region-comment c-lineup-comment)
		   (catch-clause . 0)
		   (else-clause . 0)
		   (do-while-closure . 0)
		   (case-label . 0)
		   (substatement . +)
		   (statement-case-intro . +)
		   (statement . 0)
		   (brace-entry-open . 0)
		   (brace-list-entry . c-lineup-under-anchor)
		   (brace-list-intro . +)
		   (brace-list-close . 0)
		   (brace-list-open . 0)
		   (block-close . 0)
		   (block-open . 0)
		   (inher-intro . +)
		   (member-init-cont . c-lineup-multi-inher)
		   (member-init-intro . +)
		   (annotation-var-cont . +)
		   (annotation-top-cont . 0)
		   (topmost-intro . 0)
		   (knr-argdecl . 0)
		   (inline-close . 0)
		   (class-close . 0)
		   (class-open . 0)
		   (defun-block-intro . +)
		   (defun-close . 0)
		   (defun-open . 0)
		   (c . c-lineup-C-comments)
		   (string . c-lineup-dont-change)
		   (func-decl-cont . c-lineup-java-throws)
		   (inher-cont . c-lineup-java-inher)
		   (access-label . 0)
		   (arglist-close . c-lineup-arglist)
		   (arglist-intro . c-lineup-arglist-intro-after-paren)
		   (statement-cont . +)
		   (statement-case-open . +)
		   (label . +)
		   (substatement-label . +)
		   (substatement-open . +)
		   (knr-argdecl-intro . 5)
		   (statement-block-intro . +)
		   (topmost-intro-cont . +)
		   (inline-open . 0)
		   )
 c-buffer-is-cc-mode 'dart-mode
 c-tab-always-indent t
 c-syntactic-indentation t
 c-syntactic-indentation-in-macros t
 c-ignore-auto-fill '(string cpp code)
 c-auto-align-backslashes t
 c-backspace-function 'backward-delete-char-untabify
 c-delete-function 'delete-char
 c-electric-pound-behavior nil
 c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "gnu"))
 c-enable-xemacs-performance-kludge-p nil
 c-old-style-variable-behavior nil
 defun-prompt-regexp nil
 tab-width 8
 comment-column 32
 parse-sexp-ignore-comments t
 parse-sexp-lookup-properties t
 auto-fill-function nil
 comment-multi-line t
 comment-start-skip "\\(//+\\|/\\*+\\)\\s *"
 fill-prefix nil
 fill-column 70
 paragraph-start "[ 	]*\\(//+\\|\\**\\)[ 	]*\\(@[a-zA-Z]+\\>\\|$\\)\\|^\f"
 adaptive-fill-mode t
 adaptive-fill-regexp "[ 	]*\\(//+\\|\\**\\)[ 	]*\\([ 	]*\\([-=E2=80=93!|#%=
;>*=C2=B7=E2=80=A2=E2=80=A3=E2=81=83=E2=97=A6]+[ 	]*\\)*\\)"
 )




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Brady Trainor <mail@HIDDEN>
Subject: bug#32204: Acknowledgement (CC Mode 5.33.1 (Dart//l); cc-mode
 without fontification)
Message-ID: <handler.32204.B.153194373021948.ack <at> debbugs.gnu.org>
References: <20180718195526.83790E40A1@HIDDEN>
X-Gnu-PR-Message: ack 32204
X-Gnu-PR-Package: cc-mode
Reply-To: 32204 <at> debbugs.gnu.org
Date: Wed, 18 Jul 2018 19:56:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-cc-mode@HIDDEN

If you wish to submit further information on this problem, please
send it to 32204 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
32204: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D32204
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-cc-mode@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#32204: CC Mode 5.33.1 (Dart//l); cc-mode without fontification
Resent-From: Alan Mackenzie <acm@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-cc-mode@HIDDEN
Resent-Date: Sat, 21 Jul 2018 21:23:01 +0000
Resent-Message-ID: <handler.32204.B32204.15322081226951 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 32204
X-GNU-PR-Package: cc-mode
X-GNU-PR-Keywords: 
To: Brady Trainor <mail@HIDDEN>
Cc: 32204 <at> debbugs.gnu.org
Received: via spool by 32204-submit <at> debbugs.gnu.org id=B32204.15322081226951
          (code B ref 32204); Sat, 21 Jul 2018 21:23:01 +0000
Received: (at 32204) by debbugs.gnu.org; 21 Jul 2018 21:22:02 +0000
Received: from localhost ([127.0.0.1]:51441 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1fgzKE-0001o3-3o
	for submit <at> debbugs.gnu.org; Sat, 21 Jul 2018 17:22:02 -0400
Received: from colin.muc.de ([193.149.48.1]:16863 helo=mail.muc.de)
 by debbugs.gnu.org with smtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1fgzKB-0001nY-DA
 for 32204 <at> debbugs.gnu.org; Sat, 21 Jul 2018 17:22:00 -0400
Received: (qmail 37931 invoked by uid 3782); 21 Jul 2018 21:21:58 -0000
Received: from acm.muc.de (p5B146747.dip0.t-ipconnect.de [91.20.103.71]) by
 colin.muc.de (tmda-ofmipd) with ESMTP;
 Sat, 21 Jul 2018 23:21:57 +0200
Received: (qmail 24691 invoked by uid 1000); 21 Jul 2018 21:08:48 -0000
Date: Sat, 21 Jul 2018 21:08:48 +0000
Message-ID: <20180721210848.GA24684@ACM>
References: <20180718195526.83790E40A1@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20180718195526.83790E40A1@HIDDEN>
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Delivery-Agent: TMDA/1.1.12 (Macallan)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Brady.

On Wed, Jul 18, 2018 at 12:55:25 -0700, Brady Trainor wrote:
> Should it be possible for a language mode author to use only the
> indentation functions from cc-mode, and write the font-lock-defaults
> independently of cc-mode?

There is currently no provision in CC Mode for this strategy.  "Should"
is a difficult, philosophical word.  ;-)

I'd normally ask at this point why you'd want to do this, but you
explain lower down.

> I attempted to do this with by using c-basic-common-init, instead of
> c-common-init.

> Here is the contents of my dart-mode.el

> --8<---------------cut here---------------start------------->8---
> ;;; dart-mode.el --- Major mode for editing Dart files -*- lexical-binding: t; -*-

> ;;; Code:

> (require 'cc-mode)
> (eval-when-compile
>   (require 'cc-langs)
>   (require 'cc-fonts))

> (eval-and-compile (c-add-language 'dart-mode 'java-mode))

> (c-lang-defconst c-multiline-string-start-char
>   dart ?@)

> (defconst dart-c-style
>   '("java")
>   "The default Dart styles.")

> (c-add-style "dart" dart-c-style)

> (defvar dart-mode-map (c-make-inherited-keymap)
>   "Keymap used in dart-mode buffers.")

> ;;;###autoload
> (add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))

> ;;;###autoload
> (define-derived-mode dart-mode prog-mode "Dart"
>   "Major mode for editing Dart files.

> The hook `c-mode-common-hook' is run with no args at mode
> initialization, then `dart-mode-hook'.

> Key bindings:
> \\{dart-mode-map}"
>   (c-initialize-cc-mode t)
>   (c-init-language-vars dart-mode)
>   (c-basic-common-init 'dart-mode '((dart-mode . "dart")))
>   (setq font-lock-defaults '(nil)))

> (provide 'dart-mode)

> ;;; dart-mode.el ends here
> --8<---------------cut here---------------end--------------->8---

> I then open emacs with:

> emacs -Q tmp.dart -l dart-mode.el --eval "(progn (toggle-debug-on-error) (dart-mode))"

> However, I get errors when for example tmp.dart has the contents:

> class SpaceCraft {

> I put point after opening curly, hit RET, and type the closing curly, I
> get the following stack trace:

> --8<---------------cut here---------------end--------------->8---
> Debugger entered--Lisp error: (args-out-of-range 20 40)
>   put-text-property(20 40 fontified nil)
>   c-extend-after-change-region(20 20 4)
>   font-lock-extend-jit-lock-region-after-change(20 20 4)
>   run-hook-with-args(font-lock-extend-jit-lock-region-after-change 20 20 4)
>   jit-lock-after-change(20 20 4)
>   c-shift-line-indentation(-4)
>   c-indent-line(((class-close 1)))
>   c-electric-brace(nil)
>   funcall-interactively(c-electric-brace nil)
>   call-interactively(c-electric-brace nil nil)
>   command-execute(c-electric-brace)
> --8<---------------cut here---------------end--------------->8---

I loaded dart-mode.el and tried it out.  Just before typing that closing
brace, after-change-functions looks like this:

    (jit-lock-after-change c-after-change t)

.  For CC Mode to work, it would need to look like this:

    (c-after-change jit-lock-after-change t)

, with CC Mode's after change hook executing before jit-lock's, so that
c-after-change can adjust certain position variables which later get
used by c-extend-after-change-region.

Normally this rearrangement of after-change-functions is done by the
function c-after-font-lock-init, which is placed on font-lock-mode-hook
by c-font-lock-init.

c-font-lock-init is called from c-common-init, which dart-mode isn't
calling.  It's worth emphasising that c-font-lock-init is initialising
CC Mode for font-lock, just as much as it is initialising font-lock for
CC Mode.

> If I remove the following expression, then the issue is resolved.

> (c-lang-defconst c-multiline-string-start-char
>   dart ?@)

I think it's just coincidence that that "works".  I also think that
you'll run into a whole sequence of bugs like this while attempting to
remove CC Mode's fontification routines.

> But there are many c-lang-defconst expressions in current dart-mode
> master, and I have not understood cc-mode enough to understand why each
> should be there, and which should not.

All the c-lang-defconsts are needed; if you don't specify a value, you
will inherit the value from the base language (here, Java Mode).  The
c-lang-defconts are compile time variables.  From them are built the
c-lang-defvars, which are normal runtime variables (constants, really)
which take on different values for different languages.  In a sense they
_define_ the different CC Mode languages.

> If I remove the above line, I can continue to find such errors, so it
> seems more about having removed the cc-mode fontification from the
> major mode.

Yes.  Bear in mind CC Mode is very old code indeed, it's development
extending back more that 30 years.  In that time it's become somewhat
twisted and inelegant (for which I'm partly to blame).

> (Why would I want to remove only the cc fontification? dart-mode may
> become easier to maintain and deal with edge cases once we remove
> cc-mode framework from its implementation. I would like to do this
> piecemeal. It may take some time to create an indentation function from
> scratch that is strictly as good as the one implemented via cc-mode
> framework.

This depends on whether you definitely want to build a better mode, or
whether you merely want to have a better mode.  Indentation functions
for C-like languages are difficult.  Correct fontification is not much
easier.  As a matter of interest, Stefan Monnier has done some work
creating a modern C Mode; I'm not entirely sure how far he's got, but
it's certainly at least basically working.  You can reach him on the
Emacs developers' mailing list, emacs-devel@HIDDEN

> But there are several issues on issue tracker related to
> fontification, which are quite tractable to solve simply using the
> font-lock framework standing alone.

Fontification (and indeed indentation) errors tend to be like bubbles of
paste underneath freshly hung wallpaper; you think you've managed to
eliminate an unsightly bubble, but it's just popped up somewhere else.

> So I would like to add my fontification improvements to the master
> branch, leaving cc-mode indentation intact, so that I am not creating
> regressions on master branch.

Do make sure they really are improvements.  You might well be interested
in the CC Mode unit tests which test indentation and fontification.
They're in directory "tests" in the standalone CC Mode repository at
SourceForge.

> In fact, inspired by haskell-mode, I'd like to offer multiple choices
> in indentation functions, so that potentially, contributors can
> improve their choice of either the cc-mode indentation or the "from
> scratch" indentation function.

CC Mode's indentation is already very configurable, see the CC Mode
manual.  There is no single "CC Mode indentation".

> I have more ideas for choices in indentation, like being able to call
> `dartfmt` on regions, or have it only look at region between point and
> point-min (to avoid dartfmt's predilection to choke and spew errors).)

> Thank you for reading!

Happy hacking!

> --
> Brady

[ CC Mode configuration appreciated, but snipped. ]

-- 
Alan Mackenzie (Nuremberg, Germany).





Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.