Re: Using % in makefiles... << Patch included
- Hi (Bram)
This is my first time editing Vim code and putting up a patch, so please
bear with me :)
Ok, I've made the changes I think are required. I've tested them out myself
(dunno if there are test scripts?).
What I did was get the latest Vim code via CVS, then edited the search.c
file (I had to manually change it to writable then compile it - i'm assuming
we don't have access to edit/submit files...)
Bram, I did it based on the fact you said that an option is not required
since C/C++ code doen'st have !if etc in them.
PS: Please let me know if i'm doing something wrong/stupid, so that I can
get it right the next time :) Thanks!
Here's the patch:
diff -r1.6 search.c
< else if (initc != '#' && initc != NUL)
> else if (initc != '#' && initc != '!' && initc != NUL)1223,1224c1223,1224
< * Either initc is '#', or no initc was given and we need to look
< * cursor.
> * Either initc is '#' or '!', or no initc was given and we need to1228c1228
> * look under the cursor.
< if (initc == '#')
> if (initc == '#' || initc == '!' )1241c1241
< /* Are we before or at #if, #else etc.? */
> /* Are we before or at #if, #else, !if (makefiles) etc? */1243c1243,1244
< if (*ptr == '#' && pos.col <= (colnr_t)(ptr - linep))
> if ( ( *ptr == '#' || *ptr == '!' )1284,1285c1285,1286
> && pos.col <= (colnr_t)(ptr - linep))
< * If we are not on a comment or the # at the start of a line, then
< * look for brace anywhere on this line after the cursor.
> * If we are not on a comment or the # or the ! at the start of a1326,1327c1327,1329
> * line, then look for brace anywhere on this line after the cursor.
< /* no brace in the line, maybe use " #if" then */
< if (!cpo_match && *skipwhite(linep) == '#')
> /* no brace in the line, maybe use " #if" then or !if */1337a1340
> if (!cpo_match && (*skipwhite(linep) == '#' ||
> *skipwhite(linep) == '!' ) )
> * Or the makefile variants, !if, !else, !endif1341c1344
< if (initc != '#')
> if (initc != '#' && initc != '!' )1365c1368
< if (*ptr != '#')
> if (*ptr != '#' && *ptr != '!' )1393c1396,1397
< else if (initc == '#' && STRNCMP(ptr, "el", 2) == 0)
> else if ( ( initc == '#' || initc == '!' ) &&- Tim
> STRNCMP(ptr, "el", 2) == 0)
----- Original Message -----
From: "Bram Moolenaar" <Bram@...>
To: "Tim" <rocket96@...>
Cc: "Vim" <vim-dev@...>
Sent: Sunday, February 20, 2000 6:35 AM
Subject: Re: Using % in makefiles...
> Tim wrote:
> > I'm able to use the % key when on top of a C/C++ preprocessor command to
> > jump to corresponding commands (ie, when on top of a #if, it'll jump to
> > #else, if any, and #endif).
> > Is it possible to extend that to makefiles? Some make utilities use !
> > instead of # as the first character. I find that I often replace
> > commands (!if) with preprocessor ones (#if) just to find mismatched
> > commands.
> The use of '#' is hard-coded. To change this would require an option to
> define the character in front of the if/else/endif. You would set it to
> for makefiles then.
> Hmm, perhaps it's possible to allow "!if", "!endif" and "!else" in C code
> without breaking anything. I don't think these can appear in a valid C
> We would not need an option then.
> Q: What is a patch 22?
> A: A patch you need to include to make it possible to include patches.
> /-/-- Bram Moolenaar --- Bram@... ---
> \ \ Vim: http://www.vim.org ICCF Holland: http://www.vim.org/iccf