emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#14481: closed (24.3.50; Highlighting escape sequen


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#14481: closed (24.3.50; Highlighting escape sequences)
Date: Sat, 29 Oct 2016 09:12:02 +0000

Your message dated Sat, 29 Oct 2016 12:11:49 +0300
with message-id <address@hidden>
and subject line Re: bug#14481: 24.3.50; Highlighting escape sequences
has caused the debbugs.gnu.org bug report #14481,
regarding 24.3.50; Highlighting escape sequences
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
14481: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14481
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- 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.



--- End Message ---
--- Begin Message --- Subject: Re: bug#14481: 24.3.50; Highlighting escape sequences Date: Sat, 29 Oct 2016 12:11:49 +0300 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Thunderbird/50.0
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


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]