unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#32766: Wrong syntax colors with backslash in a string (F90 mode)
@ 2018-09-18 22:51 Angelo Graziosi
  2019-07-08 15:23 ` Angelo Graziosi
  2021-02-02 15:25 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Angelo Graziosi @ 2018-09-18 22:51 UTC (permalink / raw)
  To: 32766

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...





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#32766: Wrong syntax colors with backslash in a string (F90 mode)
  2018-09-18 22:51 bug#32766: Wrong syntax colors with backslash in a string (F90 mode) Angelo Graziosi
@ 2019-07-08 15:23 ` Angelo Graziosi
  2021-02-02 15:25 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Angelo Graziosi @ 2019-07-08 15:23 UTC (permalink / raw)
  To: 32766


> Il 19 settembre 2018 alle 0.51 Angelo Graziosi <angelo.g0@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#32766: Wrong syntax colors with backslash in a string (F90 mode)
  2018-09-18 22:51 bug#32766: Wrong syntax colors with backslash in a string (F90 mode) Angelo Graziosi
  2019-07-08 15:23 ` Angelo Graziosi
@ 2021-02-02 15:25 ` Lars Ingebrigtsen
  2021-02-02 16:34   ` Glenn Morris
  1 sibling, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-02-02 15:25 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: Glenn Morris, 32766

Angelo Graziosi <angelo.g0@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@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#32766: Wrong syntax colors with backslash in a string (F90 mode)
  2021-02-02 15:25 ` Lars Ingebrigtsen
@ 2021-02-02 16:34   ` Glenn Morris
  2021-02-03 13:36     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Glenn Morris @ 2021-02-02 16:34 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 32766, Angelo Graziosi


> 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.)





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#32766: Wrong syntax colors with backslash in a string (F90 mode)
  2021-02-02 16:34   ` Glenn Morris
@ 2021-02-03 13:36     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-02-03 13:36 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 32766, Angelo Graziosi

Glenn Morris <rgm@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-03 13:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-18 22:51 bug#32766: Wrong syntax colors with backslash in a string (F90 mode) Angelo Graziosi
2019-07-08 15:23 ` Angelo Graziosi
2021-02-02 15:25 ` Lars Ingebrigtsen
2021-02-02 16:34   ` Glenn Morris
2021-02-03 13:36     ` Lars Ingebrigtsen

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).