unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* case-insensitive regexp for fontlock specification
@ 2008-08-12 10:42 Joe Bloggs
  2008-08-13  1:51 ` Kevin Rodgers
  0 siblings, 1 reply; 2+ messages in thread
From: Joe Bloggs @ 2008-08-12 10:42 UTC (permalink / raw)
  To: help-gnu-emacs

Hi, I am writing a major mode for editing SPSS files.
I am following the tutorial on this webpage:
http://renormalist.net/cgi-bin/twiki/view/Renormalist/EmacsLanguageModeCreationTutorial

The keyword matching for font-lock should be case-insensitive. 
Is there an easy way to specify this?
At the moment I have the following (abbreviated):

(defconst spss-font-lock-keywords-1
  (list
   '("\\<\\(if\\|followed\\|by\\|some\\|other\\|keywords\\)\\>" . font-lock-keyword-face)
   "Minimal highlighting expressions for spss mode.")

which only matches lower case. I could change it like this for example:

(defconst spss-font-lock-keywords-1
  (list
   '("\\<\\([iI][fF]\\|followed\\|by\\|some\\|other\\|keywords\\)\\>" . font-lock-keyword-face)
   "Minimal highlighting expressions for spss mode.")

to make it match if, If, iF & IF, but to make that change for every keyword would take ages.

Is there a simpler way?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: case-insensitive regexp for fontlock specification
  2008-08-12 10:42 case-insensitive regexp for fontlock specification Joe Bloggs
@ 2008-08-13  1:51 ` Kevin Rodgers
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Rodgers @ 2008-08-13  1:51 UTC (permalink / raw)
  To: help-gnu-emacs

Joe Bloggs wrote:
> Hi, I am writing a major mode for editing SPSS files.
> I am following the tutorial on this webpage:
> http://renormalist.net/cgi-bin/twiki/view/Renormalist/EmacsLanguageModeCreationTutorial
> 
> The keyword matching for font-lock should be case-insensitive. 
> Is there an easy way to specify this?
> At the moment I have the following (abbreviated):
> 
> (defconst spss-font-lock-keywords-1
>   (list
>    '("\\<\\(if\\|followed\\|by\\|some\\|other\\|keywords\\)\\>" . font-lock-keyword-face)
>    "Minimal highlighting expressions for spss mode.")
> 
> which only matches lower case. I could change it like this for example:
> 
> (defconst spss-font-lock-keywords-1
>   (list
>    '("\\<\\([iI][fF]\\|followed\\|by\\|some\\|other\\|keywords\\)\\>" . font-lock-keyword-face)
>    "Minimal highlighting expressions for spss mode.")
> 
> to make it match if, If, iF & IF, but to make that change for every keyword would take ages.

`M-x apropos RET font SPC lock SPC case RET' shows:

font-lock-keywords-case-fold-search
   Variable: *Non-nil means the patterns in `font-lock-keywords' are 
case-insensitive.

Following the Variable link shows:

,----[ C-h v font-lock-keywords-case-fold-search RET ]
| font-lock-keywords-case-fold-search is a variable defined in 
`font-lock.el'.
| Its value is nil
|
| Automatically becomes buffer-local when set in any fashion.
|
|
| Documentation:
| *Non-nil means the patterns in `font-lock-keywords' are case-insensitive.
| This is normally set via `font-lock-defaults'.
|
| [back]
`----

Following the font-lock-defaults link shows:


,----[ C-h v font-lock-defaults RET ]
| font-lock-defaults is a variable defined in `font-core.el'.
| Its value is nil
|
| Automatically becomes buffer-local when set in any fashion.
|
|
| Documentation:
| Defaults for Font Lock mode specified by the major mode.
| Defaults should be of the form:
|
|  (KEYWORDS [KEYWORDS-ONLY [CASE-FOLD [SYNTAX-ALIST [SYNTAX-BEGIN ...]]]])
|
| KEYWORDS may be a symbol (a variable or function whose value is the 
keywords to
| use for fontification) or a list of symbols.  If KEYWORDS-ONLY is non-nil,
| syntactic fontification (strings and comments) is not performed.
| If CASE-FOLD is non-nil, the case of the keywords is ignored when 
fontifying.
| If SYNTAX-ALIST is non-nil, it should be a list of cons pairs of the form
| (CHAR-OR-STRING . STRING) used to set the local Font Lock syntax 
table, for
| keyword and syntactic fontification (see `modify-syntax-entry').
|
| If SYNTAX-BEGIN is non-nil, it should be a function with no args used 
to move
| backwards outside any enclosing syntactic block, for syntactic 
fontification.
| Typical values are `beginning-of-line' (i.e., the start of the line is 
known to
| be outside a syntactic block), or `beginning-of-defun' for programming 
modes or
| `backward-paragraph' for textual modes (i.e., the mode-dependent 
function is
| known to move outside a syntactic block).  If nil, the beginning of 
the buffer
| is used as a position outside of a syntactic block, in the worst case.
|
| These item elements are used by Font Lock mode to set the variables
| `font-lock-keywords', `font-lock-keywords-only',
| `font-lock-keywords-case-fold-search', `font-lock-syntax-table' and
| `font-lock-beginning-of-syntax-function', respectively.
|
| Further item elements are alists of the form (VARIABLE . VALUE) and 
are in no
| particular order.  Each VARIABLE is made buffer-local before set to VALUE.
|
| Currently, appropriate variables include `font-lock-mark-block-function'.
| If this is non-nil, it should be a function with no args used to mark any
| enclosing block of text, for fontification via M-o M-o.
| Typical values are `mark-defun' for programming modes or 
`mark-paragraph' for
| textual modes (i.e., the mode-dependent function is known to put point 
and mark
| around a text block relevant to that mode).
|
| Other variables include that for syntactic keyword fontification,
| `font-lock-syntactic-keywords' and those for buffer-specialized 
fontification
| functions, `font-lock-fontify-buffer-function',
| `font-lock-unfontify-buffer-function', 
`font-lock-fontify-region-function',
| `font-lock-unfontify-region-function', and `font-lock-inhibit-thing-lock'.
|
| [back]
`----

Emacs is the extensible, customizable, *self-documenting* real-time
display editor.

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-13  1:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-12 10:42 case-insensitive regexp for fontlock specification Joe Bloggs
2008-08-13  1:51 ` Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).