all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric James Michael Ritz <lobbyjones@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Selective Case-Insensitive With font-lock
Date: Sat, 09 Mar 2013 14:27:37 -0500	[thread overview]
Message-ID: <513B8D29.1020409@gmail.com> (raw)

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	other threads:[~2013-03-09 19:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=513B8D29.1020409@gmail.com \
    --to=lobbyjones@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.