GNU bug report logs - #14481
24.3.50; Highlighting escape sequences

Previous Next

Package: emacs;

Reported by: Dmitry Gutov <dgutov <at> yandex.ru>

Date: Mon, 27 May 2013 05:57:02 UTC

Severity: wishlist

Found in version 24.3.50

Done: Dmitry Gutov <raaahh <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Dmitry Gutov <dgutov <at> yandex.ru>
Subject: bug#14481: closed (Re: bug#14481: 24.3.50; Highlighting escape
 sequences)
Date: Sat, 29 Oct 2016 09:12:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#14481: 24.3.50; Highlighting escape sequences

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 14481 <at> debbugs.gnu.org.

-- 
14481: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14481
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Dmitry Gutov <raaahh <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>, 14481-done <at> debbugs.gnu.org
Subject: Re: bug#14481: 24.3.50; Highlighting escape sequences
Date: Sat, 29 Oct 2016 12:11:49 +0300
On 29.05.2013 00:45, Dmitry Gutov wrote:

> I can release it as a third-party minor mode, no problem.

Now published in GNU ELPA: 
http://elpa.gnu.org/packages/highlight-escape-sequences.html

[Message part 3 (message/rfc822, inline)]
From: Dmitry Gutov <dgutov <at> yandex.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; Highlighting escape sequences
Date: Mon, 27 May 2013 09:55:00 +0400
Most of the other text editors highlight stuff like \\, \t, \123 inside
string and regexp literals. For example, Vim and Sublime Text do.

In Emacs, we only have that in emacs-lisp-mode for grouping expressions,
I'm guessing because of their uncommon syntax.

Do we want it in other language modes? Here's some initial
implementation for ruby-mode and js-mode, using the face
font-lock-regexp-grouping-backslash, because it's the closest we have.

(defconst escape-sequence-re
  "\\(\\\\\\(\\(?:[0-9]\\|x\\)\\(?:[0-9]\\(?:[0-9]\\)?\\)?\\|.\\)\\)"
  "Regexp to match an escape sequence.
Currently handles octals (\\123), hexadecimals (\\x12) and
backslash followed by anything else.")

(font-lock-add-keywords
 'ruby-mode
 `((,escape-sequence-re
    (1 (let ((term (nth 3 (syntax-ppss))))
         (when (or (and (eq term ?')
                        (member (match-string 2) '("\\" "'")))
                   (memq term '(?\" ?/ ?\n t)))
           'font-lock-regexp-grouping-backslash))
       prepend)))
 'append)

(font-lock-add-keywords
 'js-mode
 `((,escape-sequence-re
    (1 (when (nth 3 (syntax-ppss))
         'font-lock-regexp-grouping-backslash)
       prepend)))
 'append)

If yes, where should this code live? The regexp itself should be either
the same or quite similar for many modern languages, so I would prefer
to have it in one place.



This bug report was last modified 8 years and 209 days ago.

Previous Next


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