GNU bug report logs - #32766
Wrong syntax colors with backslash in a string (F90 mode)

Previous Next

Package: emacs;

Reported by: Angelo Graziosi <angelo.g0 <at> libero.it>

Date: Tue, 18 Sep 2018 22:53:02 UTC

Severity: minor

Tags: fixed, moreinfo

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32766 in the body.
You can then email your comments to 32766 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#32766; Package emacs. (Tue, 18 Sep 2018 22:53:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Angelo Graziosi <angelo.g0 <at> libero.it>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 18 Sep 2018 22:53:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Angelo Graziosi <angelo.g0 <at> libero.it>
To: bug-gnu-emacs <at> gnu.org
Subject: Wrong syntax colors with backslash in a string (F90 mode)
Date: Wed, 19 Sep 2018 00:51:55 +0200 (CEST)
This code

  program foo
    integer, parameter :: FOO = ichar('\')
    integer, parameter :: BAR = 10
  end program foo

produces wrong color syntax from the comma in the second statement. After the first statement the indentation is lost and so the electric-pair-mode etc. Other programming modes could be affected.

Maybe we must live with this "issue", so I flag this just for the record...




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32766; Package emacs. (Mon, 08 Jul 2019 15:24:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Angelo Graziosi <angelo.g0 <at> libero.it>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: Wrong syntax colors with backslash in a string (F90 mode)
Date: Mon, 8 Jul 2019 17:23:07 +0200 (CEST)
> Il 19 settembre 2018 alle 0.51 Angelo Graziosi <angelo.g0 <at> libero.it> ha scritto:
> 
> 
> This code
> 
>   program foo
>     integer, parameter :: FOO = ichar('\')
>     integer, parameter :: BAR = 10
>   end program foo
> 
> produces wrong color syntax from the comma in the second statement. After the first statement the indentation is lost and so the electric-pair-mode etc. Other programming modes could be affected.
> 
> Maybe we must live with this "issue", so I flag this just for the record...

This issue seems more serious than it appears. Many important features of Emacs are broken (automatic indentation) and the buffer have to be edited manually, more or less in a _Fundamental_ mode..

Notepad++ (Windows) and XED (GNU/Linux Mint) don't have this issue.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32766; Package emacs. (Tue, 02 Feb 2021 15:26:01 GMT) Full text and rfc822 format available.

Message #11 received at 32766 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Angelo Graziosi <angelo.g0 <at> libero.it>
Cc: Glenn Morris <rgm <at> gnu.org>, 32766 <at> debbugs.gnu.org
Subject: Re: bug#32766: Wrong syntax colors with backslash in a string (F90
 mode)
Date: Tue, 02 Feb 2021 16:25:27 +0100
Angelo Graziosi <angelo.g0 <at> libero.it> writes:

>   program foo
>     integer, parameter :: FOO = ichar('\')
>     integer, parameter :: BAR = 10
>   end program foo

This behaviour is still present in Emacs 28.

f90-mode.el has the following:

    ;; I think that the f95 standard leaves the behavior of \
    ;; unspecified, but that f2k will require it to be non-special.
    ;; Use `f90-backslash-not-special' to change.

and indeed:

(defun f90-backslash-not-special (&optional all)
  "Make the backslash character (\\) be non-special in the current buffer.
With optional argument ALL, change the default for all present
and future F90 buffers.  F90 mode normally treats backslash as an
escape character."
  (or (derived-mode-p 'f90-mode)
      (user-error "This function should only be used in F90 buffers"))
  (when (equal (char-syntax ?\\ ) ?\\ )
    (or all (set-syntax-table (copy-syntax-table (syntax-table))))
    (modify-syntax-entry ?\\ ".")))

Executing this will make the snippet be fontified as the bug reporter
expects.

But I don't really know F90 any more -- would it make sense to flip the
defaults now and make \ non-special?  If that happened 21 years ago i
F2K, then perhaps it's time?

Adding Glenn to the CCs, since this was the commit that introduced the
-not-special functions:

commit 784d007b5033cb555482c9a50fbdaf5a10fa8ffa
Author:     Glenn Morris <rgm <at> gnu.org>
AuthorDate: Thu Nov 25 00:46:42 2004 +0000

    (f90-smart-end, f90-previous-statement, f90-beginning-of-block): Doc fix.
    (f90-calculate-indent): Handle un-named PROGRAM blocks.
    (f90-end-of-block): Doc fix.  Make check of outermost block
    conditional on value of `f90-smart-end'.
    (f90-block-match): Hack to deal with un-named PROGRAM blocks.
    Handle case where END-BLOCK is nil.
    (f90-match-end): Handle un-named PROGRAM blocks.
    (f90-backslash-not-special): New function.


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 02 Feb 2021 15:26:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32766; Package emacs. (Tue, 02 Feb 2021 16:35:02 GMT) Full text and rfc822 format available.

Message #16 received at 32766 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 32766 <at> debbugs.gnu.org, Angelo Graziosi <angelo.g0 <at> libero.it>
Subject: Re: bug#32766: Wrong syntax colors with backslash in a string (F90
 mode)
Date: Tue, 02 Feb 2021 11:34:10 -0500
> But I don't really know F90 any more -- would it make sense to flip the
> defaults now and make \ non-special?  If that happened 21 years ago i
> F2K, then perhaps it's time?

I haven't kept up with this stuff, but probably you are right.
Not quite as long ago as 21 years, but ref eg
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34203

(At one time I hoped to have separate modes for the various Fortran
standards, but it never went anywhere, so "f90-mode" should default to
whatever is appropriate for recent gfortran, I think.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32766; Package emacs. (Wed, 03 Feb 2021 13:38:01 GMT) Full text and rfc822 format available.

Message #19 received at 32766 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 32766 <at> debbugs.gnu.org, Angelo Graziosi <angelo.g0 <at> libero.it>
Subject: Re: bug#32766: Wrong syntax colors with backslash in a string (F90
 mode)
Date: Wed, 03 Feb 2021 14:36:53 +0100
Glenn Morris <rgm <at> gnu.org> writes:

> I haven't kept up with this stuff, but probably you are right.
> Not quite as long ago as 21 years, but ref eg
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34203
>
> (At one time I hoped to have separate modes for the various Fortran
> standards, but it never went anywhere, so "f90-mode" should default to
> whatever is appropriate for recent gfortran, I think.)

Yup.  So I've now made this change in Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 03 Feb 2021 13:38:01 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 32766 <at> debbugs.gnu.org and Angelo Graziosi <angelo.g0 <at> libero.it> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 03 Feb 2021 13:38:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 04 Mar 2021 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 25 days ago.

Previous Next


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