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.

Full log


View this message in rfc822 format

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




This bug report was last modified 4 years and 145 days ago.

Previous Next


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