help-gnu-emacs
[Top][All Lists]
Advanced

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

Selective Case-Insensitive With font-lock


From: Eric James Michael Ritz
Subject: Selective Case-Insensitive With font-lock
Date: Sat, 09 Mar 2013 14:27:37 -0500
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130221 Thunderbird/17.0.3

Hello all!

I am attempting to fix a problem with php-mode but ran into a
situation that illuminates the gaps in my understanding of font-lock.
So I would greatly appreciate it if someone here could point me in the
right direction.  First, here is the full code in question:

https://raw.github.com/ejmr/php-mode/issue-75/php-mode.el

This is the problem I’m trying to address:

PHP treats most of its predefined constants in a case-sensitive way,
e.g. a programmer cannot substitute ‘e_error’ in place of ‘E_ERROR’
because PHP requires the all-caps version.  Since the majority of
PHP’s constants have this behavior I set font-lock to disable
case-folding (search for ‘setq font-lock-defaults …’).

However, there are a small group of constants which PHP accepts in any
case.  In the code these are the ‘php-magic-constants’ group.  So if a
user writes ‘__dir__’ instead of ‘__DIR__’ php-mode should treat those
as the same thing in terms of syntax highlighting.

But I do not know how to tell font-lock to selectively enable
case-insensitivity for a small group of regular expressions while
enforcing case-sensitivity for the rest.  I could rewrite the
expressions that need to be case-insensitive in a form like

    "__[dD][iI][rR]__"

but I wanted to first ask if there is a simplier, less tedious
solution that I’m unaware of.

Thanks in advanced for any pointers and help.

--
ejmr
南無妙法蓮華經



reply via email to

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