unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Angelo Graziosi <angelo.g0@libero.it>
Cc: Glenn Morris <rgm@gnu.org>, 32766@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	[thread overview]
Message-ID: <87k0rqjxug.fsf@gnus.org> (raw)
In-Reply-To: <85507699.497150.1537311115648@mail.libero.it> (Angelo Graziosi's message of "Wed, 19 Sep 2018 00:51:55 +0200 (CEST)")

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





  parent reply	other threads:[~2021-02-02 15:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-02-02 16:34   ` Glenn Morris
2021-02-03 13:36     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k0rqjxug.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=32766@debbugs.gnu.org \
    --cc=angelo.g0@libero.it \
    --cc=rgm@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).