GNU bug report logs -
#18378
wrong fontification of Java code
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18378 in the body.
You can then email your comments to 18378 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#18378
; Package
emacs
.
(Mon, 01 Sep 2014 09:49:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Paul Pogonyshev <pogonyshev <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 01 Sep 2014 09:49:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
class X
{
public void x ()
{
for (int this_is_not_a_function_name : getX ()) {
}
}
}
In current trunk (compiled five minutes ago) 'this_is_not_a_function_name'
above is fontified as a function name. This seems to depend on whether I
have '()' after 'getX' or not.
Paul
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#18378
; Package
emacs
.
(Mon, 01 Sep 2014 19:21:03 GMT)
Full text and
rfc822 format available.
Message #8 received at 18378 <at> debbugs.gnu.org (full text, mbox):
I have a potential solution for this bug, as it has impacted me as well.
Not sure what the best solution would be but I have included a patch that does solve the problem. From what I can tell there are no tests for java fortification but I have not seen any issues arising in my own java projects. The issue was that in java, a “:” can mark the end of a declaration in a foreach, not just a “;” or “,”.
=== modified file 'lisp/ChangeLog'
*** lisp/ChangeLog 2014-09-01 15:03:45 +0000
--- lisp/ChangeLog 2014-09-01 19:11:46 +0000
***************
*** 1,3 ****
--- 1,8 ----
+ 2014-09-01 Jordon Biondo <jordonbiondo <at> gmail.com>
+
+ * progmodes/cc-fonts.el (c-font-lock-declarators): Special
+ case for declarations inside Java foreach loops (Bug#18378)
+
2014-09-01 Eli Zaretskii <eliz <at> gnu.org>
* ls-lisp.el (ls-lisp-use-string-collate)
=== modified file 'lisp/progmodes/cc-fonts.el'
*** lisp/progmodes/cc-fonts.el 2014-08-24 20:50:11 +0000
--- lisp/progmodes/cc-fonts.el 2014-09-01 19:11:59 +0000
*************** casts and declarations are fontified. U
*** 1116,1123 ****
;; initializing brace lists.
(let (found)
(while
! (and (setq found (c-syntactic-re-search-forward
! "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
(eq (char-before) ?\[)
(c-go-up-list-forward))
(setq brackets-after-id t))
--- 1116,1128 ----
;; initializing brace lists.
(let (found)
(while
! (and (setq found (c-syntactic-re-search-forward
! (concat "[;,]\\|\\s)\\|\\'\\|\\(=\\|"
! (if (c-major-mode-is 'java-mode)
! ":\\|"
! "")
! "\\s(\\)")
! limit t t))
(eq (char-before) ?\[)
(c-go-up-list-forward))
(setq brackets-after-id t))
Added tag(s) patch.
Request was from
Stefan Kangas <stefan <at> marxist.se>
to
control <at> debbugs.gnu.org
.
(Mon, 30 Sep 2019 02:56:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#18378
; Package
emacs
.
(Mon, 20 Jan 2020 21:17:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 18378 <at> debbugs.gnu.org (full text, mbox):
Hi Alan,
Could you please help review the below patch for cc-fonts.el?
Thanks in advance.
Best regards,
Stefan Kangas
Paul Pogonyshev <pogonyshev <at> gmail.com> writes:
> class X
> {
> public void x ()
> {
> for (int this_is_not_a_function_name : getX ()) {
> }
> }
> }
>
> In current trunk (compiled five minutes ago)
> 'this_is_not_a_function_name' above is fontified as a function
> name. This seems to depend on whether I have '()' after 'getX' or
> not.
>
> Paul
Jordon Biondo <jordonbiondo <at> gmail.com> writes:
> I have a potential solution for this bug, as it has impacted me as well.
>
> Not sure what the best solution would be but I have included a patch that does
> solve the problem. From what I can tell there are no tests for java
> fortification but I have not seen any issues arising in my own java
> projects. The issue was that in java, a “:” can mark the end of a declaration in
> a foreach, not just a “;” or “,”.
>
> === modified file 'lisp/ChangeLog'
> *** lisp/ChangeLog 2014-09-01 15:03:45 +0000
> --- lisp/ChangeLog 2014-09-01 19:11:46 +0000
> ***************
> *** 1,3 ****
> --- 1,8 ----
> + 2014-09-01 Jordon Biondo <jordonbiondo <at> gmail.com>
> +
> + * progmodes/cc-fonts.el (c-font-lock-declarators): Special
> + case for declarations inside Java foreach loops (Bug#18378)
> +
> 2014-09-01 Eli Zaretskii <eliz <at> gnu.org>
>
> * ls-lisp.el (ls-lisp-use-string-collate)
>
> === modified file 'lisp/progmodes/cc-fonts.el'
> *** lisp/progmodes/cc-fonts.el 2014-08-24 20:50:11 +0000
> --- lisp/progmodes/cc-fonts.el 2014-09-01 19:11:59 +0000
> *************** casts and declarations are fontified. U
> *** 1116,1123 ****
> ;; initializing brace lists.
> (let (found)
> (while
> ! (and (setq found (c-syntactic-re-search-forward
> ! "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
> (eq (char-before) ?\[)
> (c-go-up-list-forward))
> (setq brackets-after-id t))
> --- 1116,1128 ----
> ;; initializing brace lists.
> (let (found)
> (while
> ! (and (setq found (c-syntactic-re-search-forward
> ! (concat "[;,]\\|\\s)\\|\\'\\|\\(=\\|"
> ! (if (c-major-mode-is 'java-mode)
> ! ":\\|"
> ! "")
> ! "\\s(\\)")
> ! limit t t))
> (eq (char-before) ?\[)
> (c-go-up-list-forward))
> (setq brackets-after-id t))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#18378
; Package
emacs
.
(Wed, 22 Jan 2020 21:00:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 18378 <at> debbugs.gnu.org (full text, mbox):
Hello, Stefan.
On Mon, Jan 20, 2020 at 22:16:46 +0100, Stefan Kangas wrote:
> Hi Alan,
> Could you please help review the below patch for cc-fonts.el?
I missed this bug report back in 2014. The code has moved around so
much since then that Jordon's patch no longer applies. But a simple
patch with the same idea appears to fix this bug:
diff -r 3d883b66c245 cc-engine.el
--- a/cc-engine.el Tue Jan 07 19:24:00 2020 +0000
+++ b/cc-engine.el Wed Jan 22 20:49:53 2020 +0000
@@ -9025,7 +9025,7 @@
(if (looking-at c-:-op-cont-regexp)
(progn (goto-char (match-end 0)) t)
(not
- (and (c-major-mode-is 'c++-mode)
+ (and (c-major-mode-is '(c++-mode java-mode))
(save-excursion
(and
(c-go-up-list-backward)
This patch should apply cleanly to the emacs-27 branch, and most
probably to master, too.
> Thanks in advance.
> Best regards,
> Stefan Kangas
--
Alan Mackenzie (Nuremberg, Germany).
> Paul Pogonyshev <pogonyshev <at> gmail.com> writes:
> > class X
> > {
> > public void x ()
> > {
> > for (int this_is_not_a_function_name : getX ()) {
> > }
> > }
> > }
> >
> > In current trunk (compiled five minutes ago)
> > 'this_is_not_a_function_name' above is fontified as a function
> > name. This seems to depend on whether I have '()' after 'getX' or
> > not.
> >
> > Paul
> Jordon Biondo <jordonbiondo <at> gmail.com> writes:
> > I have a potential solution for this bug, as it has impacted me as well.
> >
> > Not sure what the best solution would be but I have included a patch that does
> > solve the problem. From what I can tell there are no tests for java
> > fortification but I have not seen any issues arising in my own java
> > projects. The issue was that in java, a “:” can mark the end of a declaration in
> > a foreach, not just a “;” or “,”.
> >
> > === modified file 'lisp/ChangeLog'
> > *** lisp/ChangeLog 2014-09-01 15:03:45 +0000
> > --- lisp/ChangeLog 2014-09-01 19:11:46 +0000
> > ***************
> > *** 1,3 ****
> > --- 1,8 ----
> > + 2014-09-01 Jordon Biondo <jordonbiondo <at> gmail.com>
> > +
> > + * progmodes/cc-fonts.el (c-font-lock-declarators): Special
> > + case for declarations inside Java foreach loops (Bug#18378)
> > +
> > 2014-09-01 Eli Zaretskii <eliz <at> gnu.org>
> >
> > * ls-lisp.el (ls-lisp-use-string-collate)
> >
> > === modified file 'lisp/progmodes/cc-fonts.el'
> > *** lisp/progmodes/cc-fonts.el 2014-08-24 20:50:11 +0000
> > --- lisp/progmodes/cc-fonts.el 2014-09-01 19:11:59 +0000
> > *************** casts and declarations are fontified. U
> > *** 1116,1123 ****
> > ;; initializing brace lists.
> > (let (found)
> > (while
> > ! (and (setq found (c-syntactic-re-search-forward
> > ! "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
> > (eq (char-before) ?\[)
> > (c-go-up-list-forward))
> > (setq brackets-after-id t))
> > --- 1116,1128 ----
> > ;; initializing brace lists.
> > (let (found)
> > (while
> > ! (and (setq found (c-syntactic-re-search-forward
> > ! (concat "[;,]\\|\\s)\\|\\'\\|\\(=\\|"
> > ! (if (c-major-mode-is 'java-mode)
> > ! ":\\|"
> > ! "")
> > ! "\\s(\\)")
> > ! limit t t))
> > (eq (char-before) ?\[)
> > (c-go-up-list-forward))
> > (setq brackets-after-id t))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#18378
; Package
emacs
.
(Thu, 23 Jan 2020 14:14:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 18378 <at> debbugs.gnu.org (full text, mbox):
Hi Alan,
Alan Mackenzie <acm <at> muc.de> writes:
> I missed this bug report back in 2014. The code has moved around so
> much since then that Jordon's patch no longer applies. But a simple
> patch with the same idea appears to fix this bug:
Thanks for taking a look.
With your fix, applied on the master branch, in the example given:
class X
{
public void x ()
{
for (int this_is_not_a_function_name : getX ()) {
}
}
}
The "int" no longer has font-lock-type-face. Should it?
Best regards,
Stefan Kangas
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#18378
; Package
emacs
.
(Thu, 23 Jan 2020 18:10:01 GMT)
Full text and
rfc822 format available.
Message #22 received at 18378 <at> debbugs.gnu.org (full text, mbox):
Hello, Stefan.
On Thu, Jan 23, 2020 at 15:13:05 +0100, Stefan Kangas wrote:
> Hi Alan,
> Alan Mackenzie <acm <at> muc.de> writes:
> > I missed this bug report back in 2014. The code has moved around so
> > much since then that Jordon's patch no longer applies. But a simple
> > patch with the same idea appears to fix this bug:
> Thanks for taking a look.
> With your fix, applied on the master branch, in the example given:
> class X
> {
> public void x ()
> {
> for (int this_is_not_a_function_name : getX ()) {
> }
> }
> }
> The "int" no longer has font-lock-type-face. Should it?
That's funny. It has font-lock-type-face for me, in all of emacs-27,
master and standalone CC Mode (in master). font-lock-type-face is indeed
correct, here.
Are you sure you were .... (I don't think I need to fill in the dots for
you. ;-)
> Best regards,
> Stefan Kangas
--
Alan Mackenzie (Nuremberg, Germany).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#18378
; Package
emacs
.
(Tue, 11 Feb 2020 20:07:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 18378 <at> debbugs.gnu.org (full text, mbox):
Hello again, Stefan.
Ping?
--
Alan Mackenzie (Nuremberg, Germany).
On Thu, Jan 23, 2020 at 18:09:47 +0000, Alan Mackenzie wrote:
> Hello, Stefan.
> On Thu, Jan 23, 2020 at 15:13:05 +0100, Stefan Kangas wrote:
> > Hi Alan,
> > Alan Mackenzie <acm <at> muc.de> writes:
> > > I missed this bug report back in 2014. The code has moved around so
> > > much since then that Jordon's patch no longer applies. But a simple
> > > patch with the same idea appears to fix this bug:
> > Thanks for taking a look.
> > With your fix, applied on the master branch, in the example given:
> > class X
> > {
> > public void x ()
> > {
> > for (int this_is_not_a_function_name : getX ()) {
> > }
> > }
> > }
> > The "int" no longer has font-lock-type-face. Should it?
> That's funny. It has font-lock-type-face for me, in all of emacs-27,
> master and standalone CC Mode (in master). font-lock-type-face is indeed
> correct, here.
> Are you sure you were .... (I don't think I need to fill in the dots for
> you. ;-)
> > Best regards,
> > Stefan Kangas
> --
> Alan Mackenzie (Nuremberg, Germany).
Reply sent
to
Alan Mackenzie <acm <at> muc.de>
:
You have taken responsibility.
(Sun, 23 Feb 2020 12:51:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Paul Pogonyshev <pogonyshev <at> gmail.com>
:
bug acknowledged by developer.
(Sun, 23 Feb 2020 12:51:02 GMT)
Full text and
rfc822 format available.
Message #30 received at 18378-done <at> debbugs.gnu.org (full text, mbox):
Hello, all.
I've committed a fix to this bug to the emacs-27 branch at savannah.
I'm closing the bug with this post.
--
Alan Mackenzie (Nuremberg, Germany).
On Mon, Jan 20, 2020 at 22:16:46 +0100, Stefan Kangas wrote:
> Hi Alan,
> Could you please help review the below patch for cc-fonts.el?
> Thanks in advance.
> Best regards,
> Stefan Kangas
> Paul Pogonyshev <pogonyshev <at> gmail.com> writes:
> > class X
> > {
> > public void x ()
> > {
> > for (int this_is_not_a_function_name : getX ()) {
> > }
> > }
> > }
> > In current trunk (compiled five minutes ago)
> > 'this_is_not_a_function_name' above is fontified as a function
> > name. This seems to depend on whether I have '()' after 'getX' or
> > not.
> > Paul
> Jordon Biondo <jordonbiondo <at> gmail.com> writes:
> > I have a potential solution for this bug, as it has impacted me as well.
> > Not sure what the best solution would be but I have included a patch that does
> > solve the problem. From what I can tell there are no tests for java
> > fortification but I have not seen any issues arising in my own java
> > projects. The issue was that in java, a “:” can mark the end of a declaration in
> > a foreach, not just a “;” or “,”.
> > === modified file 'lisp/ChangeLog'
> > *** lisp/ChangeLog 2014-09-01 15:03:45 +0000
> > --- lisp/ChangeLog 2014-09-01 19:11:46 +0000
> > ***************
> > *** 1,3 ****
> > --- 1,8 ----
> > + 2014-09-01 Jordon Biondo <jordonbiondo <at> gmail.com>
> > +
> > + * progmodes/cc-fonts.el (c-font-lock-declarators): Special
> > + case for declarations inside Java foreach loops (Bug#18378)
> > +
> > 2014-09-01 Eli Zaretskii <eliz <at> gnu.org>
> > * ls-lisp.el (ls-lisp-use-string-collate)
> > === modified file 'lisp/progmodes/cc-fonts.el'
> > *** lisp/progmodes/cc-fonts.el 2014-08-24 20:50:11 +0000
> > --- lisp/progmodes/cc-fonts.el 2014-09-01 19:11:59 +0000
> > *************** casts and declarations are fontified. U
> > *** 1116,1123 ****
> > ;; initializing brace lists.
> > (let (found)
> > (while
> > ! (and (setq found (c-syntactic-re-search-forward
> > ! "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
> > (eq (char-before) ?\[)
> > (c-go-up-list-forward))
> > (setq brackets-after-id t))
> > --- 1116,1128 ----
> > ;; initializing brace lists.
> > (let (found)
> > (while
> > ! (and (setq found (c-syntactic-re-search-forward
> > ! (concat "[;,]\\|\\s)\\|\\'\\|\\(=\\|"
> > ! (if (c-major-mode-is 'java-mode)
> > ! ":\\|"
> > ! "")
> > ! "\\s(\\)")
> > ! limit t t))
> > (eq (char-before) ?\[)
> > (c-go-up-list-forward))
> > (setq brackets-after-id t))
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 23 Mar 2020 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 years and 35 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.