From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: regexp font-lock highlighting Date: Mon, 06 Jun 2005 16:05:25 +0300 Organization: JURTA Message-ID: <87ll5npre2.fsf@jurta.org> References: <429AD1B5.1020408@gmx.at> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1118063290 12786 80.91.229.2 (6 Jun 2005 13:08:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 6 Jun 2005 13:08:10 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 06 15:08:08 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DfHIp-00081G-2w for ged-emacs-devel@m.gmane.org; Mon, 06 Jun 2005 15:06:04 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DfHP8-0004wf-AY for ged-emacs-devel@m.gmane.org; Mon, 06 Jun 2005 09:12:34 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DfHOA-0004r0-KW for emacs-devel@gnu.org; Mon, 06 Jun 2005 09:11:34 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DfHO7-0004oP-4y for emacs-devel@gnu.org; Mon, 06 Jun 2005 09:11:31 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DfHO6-0004nk-IH for emacs-devel@gnu.org; Mon, 06 Jun 2005 09:11:30 -0400 Original-Received: from [194.126.101.111] (helo=mail.neti.ee) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DfHO5-0004lK-Uf for emacs-devel@gnu.org; Mon, 06 Jun 2005 09:11:30 -0400 Original-Received: from mail.neti.ee (80-235-41-238-dsl.mus.estpak.ee [80.235.41.238]) by Relayhost1.neti.ee (Postfix) with ESMTP id 8BA56409B; Mon, 6 Jun 2005 16:08:15 +0300 (EEST) Original-To: martin rudalics In-Reply-To: <429AD1B5.1020408@gmx.at> (martin rudalics's message of "Mon, 30 May 2005 10:41:25 +0200") User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) X-Virus-Scanned: by amavisd-new-2.2.1 (20041222) (Debian) at neti.ee X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:38172 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:38172 > Note that I removed the "\\(\\?:\\)?" since I find it distracting to > put yet another face here. If you believe that you _really_ need it > you will have to reinsert it, but in that case you have to modify > match-data cropping as well. (I do have to modify match-data since > redisplay wants some valid buffer positions for highlighting.) I fixed shy group handling in this regexp by allowing ?: to be only before `(' instead of before any of `(', `|' or `)'. You may need to adjust your code before submitting your final patch. Also I tried to extend this regexp to highlight other special backslash constructs like `\<', `\_<', `\w', `\sC', but soon discovered that sometimes there are similar constructs in non-regexp strings that become inappropriately highlighted. Unless it's possible to detect whether a given string is a regexp or not, I think the regexp highlighting code should be split into multi-level font-lock variables font-lock-regexp-keywords-1 and font-lock-regexp-keywords-2. The first variable would highlight only `\\(?:', `\\|' and `\\)' constructs, but the second - all other regexp constructs. Everyone agreed to see regexp constructs sometimes highlighted in wrong places could use the second level variable. > Finally, I would use three distinct font-lock faces for regexps: > > - One face for highlighting the "\\"s which by default should inherit > from `font-lock-string-face' with a dimmed foreground - I'm using > Green4 for strings and PaleGreen3 for the "\\"s. Anyone who doesn't ===== ===== I see everyone tends to change the default color of `font-lock-string-face' (which is barely visible on light backgrounds) to a green color. Currently on tty strings are fontified in green, so maybe this is one of the reasons why people prefer green strings. This indicates that we should change the current "RosyBrown" default to one of the shades of green. > like the highlighting could revert to `font-lock-string-face'. > > - One face for highlighting the "(", "|" and ")" in these expressions. > I find `bold' good here but again would leave it to the user whether > she wants to turn off highlighting this. Moreover, such a face could > allow paren-highlighting to _never_ match a paren with that face with > a paren with another face. Consequently, paren-matching could finally > provide more trustable information within regular expressions. I added two new faces: for a backslash and regexp constructs after a backslash. The former inherits from escape-glyph to be highlighted like a backslash in escape sequences, the latter is bold by default. I think there is no need for a face for shy groups. It is fontified now in the same face as other regexp constructs (bold). > - One face for highlighting the innermost grouping. Basically, > `underline' is not bad here but appears a bit noisy in multiline > expressions or things like > > (concat "\\(" > some-string > "\\)") You could add this face after implementing correct highlighting of nested groups. -- Juri Linkov http://www.jurta.org/emacs/