From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#14481: 24.3.50; Highlighting escape sequences Date: Mon, 27 May 2013 07:16:25 -0700 (PDT) Message-ID: <226f0791-6c9a-48ff-ae86-650147a1a622@default> References: <87li71ynkb.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1369664233 4205 80.91.229.3 (27 May 2013 14:17:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 May 2013 14:17:13 +0000 (UTC) To: Dmitry Gutov , 14481@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 27 16:17:12 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UgyEV-0005mW-3d for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 May 2013 16:17:07 +0200 Original-Received: from localhost ([::1]:38997 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UgyEU-00016K-Me for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 May 2013 10:17:06 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:54628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UgyEK-000120-1P for bug-gnu-emacs@gnu.org; Mon, 27 May 2013 10:17:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UgyEE-0007pN-1d for bug-gnu-emacs@gnu.org; Mon, 27 May 2013 10:16:55 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48212) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UgyED-0007pJ-U1 for bug-gnu-emacs@gnu.org; Mon, 27 May 2013 10:16:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UgyFO-0002zN-DI for bug-gnu-emacs@gnu.org; Mon, 27 May 2013 10:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 May 2013 14:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14481 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 14481-submit@debbugs.gnu.org id=B14481.136966426711465 (code B ref 14481); Mon, 27 May 2013 14:18:02 +0000 Original-Received: (at 14481) by debbugs.gnu.org; 27 May 2013 14:17:47 +0000 Original-Received: from localhost ([127.0.0.1]:36570 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UgyF8-0002yr-UM for submit@debbugs.gnu.org; Mon, 27 May 2013 10:17:47 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:48482) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UgyF3-0002yU-LK for 14481@debbugs.gnu.org; Mon, 27 May 2013 10:17:43 -0400 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r4REGKFs009701 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 27 May 2013 14:16:21 GMT Original-Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4REGLka005775 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 27 May 2013 14:16:22 GMT Original-Received: from abhmt110.oracle.com (abhmt110.oracle.com [141.146.116.62]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4REGL5V003504; Mon, 27 May 2013 14:16:21 GMT In-Reply-To: <87li71ynkb.fsf@yandex.ru> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.7 (607090) [OL 12.0.6668.5000 (x86)] X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:74596 Archived-At: > Most of the other text editors highlight stuff like \\, \t, \123 inside > string and regexp literals. For example, Vim and Sublime Text do. >=20 > In Emacs, we only have that in emacs-lisp-mode for grouping expressions, > I'm guessing because of their uncommon syntax.=20 > 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. >=20 > (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.") Something like this would be useful, IMO. But consider separating out the escape syntax for the various regexp parts - e.g., the parts that match more than a single escape char (for octal etc.). Using separate regexps (which can still be combined) for the various parts lets you choose whether to highlight each char group (e.g., highlight only hex escapes). --- FWIW, library highlight-chars.el lets you selectively highlight sets of=20 chars. This works together with font-lock: you can choose whether other font-lock highlighting overrides, is overridden by, or is merged with this highlighting (applied after or before it). You can specify chars to highlight in various ways: (1) individually (any in a given string), (2) using ranges, (3) using character classes=20 (e.g. [:digit:]), and (4) using character sets (e.g. `iso-8859-1' or=20 `lao'). You can also specify sets of chars to be excluded from such=20 highlighting - IOW, specify a set by subtraction as well as by=20 addition. You can thus, for example, highlight all characters in char set `greek-iso8859-7' except `GREEK SMALL LETTER LAMBDA'. Or all characters in class `[:space:]' (whitespace) except `tab'. Or all Unicode characters in the range ?\u2190 through ?\u21ff (mathematical arrows) except ?\u21b6, ?\u21b7, ?\u21ba, and ?\u21bb (curved arrows). You can use any faces for the highlighting. You can choose whether to add such highlighting automatically whenever font-lock mode is on in a buffer (via `font-lock-mode-hook'). You can use `(after-)change-major-mode-hook' to make the highlighting mode-specific. Or you can use the highlighting only in certain=20 buffers. http://www.emacswiki.org/emacs-en/download/highlight-chars.el http://www.emacswiki.org/emacs/ShowWhiteSpace#toc2