Computer Science Canada

Xemacs, lisp help

Author:  MrUmunhum [ Sun Apr 27, 2008 4:28 pm ]
Post subject:  Xemacs, lisp help

Hi group,
I need some help with my init.el. I am trying to call a mod for Rexx when I load a rexx file.
I don't want to use the file type option (prog.rex). I want to define a rexx file as:
    First line of file will start with "/* ".
    File name does not end with .c, .cpp, .h or .hpp
I have tried these test without success:
    (if (looking-at "\/\* ") 'display-warning :warning "Rexx")
    (if (looking-at "\[/* ]") 'display-warning :warning "Rexx")
    (if (looking-at "^\/\* ") 'display-warning :warning "hello")
Does anyone have any URLs that could help me with my problem? BooHoo

I forgot, I am using FC8.

Author:  btiffin [ Sun Apr 27, 2008 10:16 pm ]
Post subject:  Re: Xemacs, lisp help

I'm not a regex guru, but try

[/][*][ ] as your pattern. regex square brackets are ANY ONE OF tests, so [/* ] (aside from the escaping looking-at may need) would match / or * or space, not the three chars as a sequence. If I remember correctly, the only thing that needs to be escaped in square brackets is caret, and then whatever may be the regex delimiters. For example in perl
code:
$str = "/* ";
if ($str =~ m%[/][*][ ]%) {print "$str is comment";}
would work, but
code:
$str = "/* ";
if ($str =~ m/[\/][*][ ]/) {print "$str is comment";}
would be required if you were using the usual slash delim.

There are other re expressions that would work, but I like simple, quick grok, than brain backtracking over escapes when possible.

Cheers


: