Skip to content

Commit 69f0368

Browse files
Fritz Mehnervim-scripts
Fritz Mehner
authored andcommitted
Version 5.18
- Hotkeys \lcs, \ucs removed. - Bugfix: delayed template initialization missing correct style. - Wrong cursor position when inserting some templates at the end of a line.
1 parent f9c152c commit 69f0368

File tree

6 files changed

+73
-63
lines changed

6 files changed

+73
-63
lines changed

README.csupport

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
README for c.vim (Version 5.17) / December 27 2011
1+
README for c.vim (Version 5.18) / March 03 2012
22

33
* DESCRIPTION
44
* INSTALLATION
@@ -147,17 +147,13 @@ Any problems ? See the TROUBLESHOOTING section at the end of the help file
147147
'doc/csupport.txt'.
148148

149149
================================================================================
150-
RELEASE NOTES FOR VERSION 5.17
150+
RELEASE NOTES
151151
================================================================================
152-
- Two new plugin tags: LICENSE,ORGANIZATION
153-
- System-wide installation: minimal Template file for a user will automatically
154-
be added.
155-
- New menu item and hotkey: choose a makefile.
156-
- New idiom: realloc.
157-
- New preprocessor item: #if #endif.
158-
- New hotkeys: \ire, \ifs, \ifp, \pif.
152+
- Hotkeys \lcs, \ucs removed.
153+
- Bugfix: delayed template initialization missing correct style.
154+
- Wrong cursor position when inserting some templates at the end of a line.
159155

160-
OLDER RELEASE NOTES : see file 'ChangeLog'
156+
Please see file ./c-support/doc/ChangeLog .
161157

162158
================================================================================
163159
FILES
@@ -218,7 +214,7 @@ rc/customization.vimrc Additional settings I use in .vimrc : incremental
218214

219215
Some ideas are taken from the following documents:
220216
1. Recommended C Style and Coding Standards (Indian Hill Style Guide)
221-
www.doc.ic.ac.uk/lab/secondyear/cstyle/cstyle.html
217+
http://ieng9.ucsd.edu/~cs30x/indhill-cstyle.html
222218
2. Programming in C++, Ellemtel Telecommunication Systems Laboratories
223219
www.it.bton.ac.uk/burks/burks/language/cpp/cppstyle/ellhome.htm
224220
3. C++ Coding Standard, Todd Hoff

doc/ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
================================================================================
2+
RELEASE NOTES FOR VERSION 5.18
3+
================================================================================
4+
5+
6+
================================================================================
7+
RELEASE NOTES FOR VERSION 5.17
8+
================================================================================
9+
- Two new plugin tags: LICENSE,ORGANIZATION
10+
- System-wide installation: minimal Template file for a user will automatically
11+
be added.
12+
- New menu item and hotkey: choose a makefile.
13+
- New idiom: realloc.
14+
- New preprocessor item: #if #endif.
15+
- New hotkeys: \ire, \ifs, \ifp, \pif.
16+
117
================================================================================
218
RELEASE NOTES FOR VERSION 5.16.1
319
================================================================================

doc/c-hotkeys.pdf

14 Bytes
Binary file not shown.

doc/c-hotkeys.tex

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
%% Copyright: Copyright (C) 2006-2010 Dr.-Ing. Fritz Mehner (mehner@fh-swf.de)
1111
%% Version: 1.0
1212
%% Created: 10.11.2006
13-
%% Revision: $Id: c-hotkeys.tex,v 1.48 2011/12/27 21:09:44 mehner Exp $
13+
%% Revision: $Id: c-hotkeys.tex,v 1.50 2012/03/03 19:17:56 mehner Exp $
1414
%%
1515
%% Notes:
1616
%%
@@ -28,8 +28,8 @@
2828

2929
\setlength\parindent{0pt}
3030

31-
\newcommand{\Pluginversion}{5.17}
32-
\newcommand{\ReleaseDate}{ December 2011}
31+
\newcommand{\Pluginversion}{5.18}
32+
\newcommand{\ReleaseDate}{\today}
3333
\newcommand{\Rep}{{\tiny{[n]}}}
3434

3535
%%----------------------------------------------------------------------
@@ -261,11 +261,9 @@
261261
%% show plugin help
262262
%%----------------------------------------------------------------------
263263
\hline
264-
\multicolumn{2}{|r|}{\textsl{\textbf{H}elp and Menus}}\\
265-
\hline \verb'\hm' & show manual \hfill (n,i)\\
264+
\multicolumn{2}{|r|}{\textsl{\textbf{H}elp}}\\
265+
\hline \verb'\hm' & manual for word under cursor \hfill (n,i)\\
266266
\hline \verb'\hp' & help (c-support) \hfill (n,i)\\
267-
\hline \verb'\lcs' & load Menus\hfill \scriptsize{(n \& GUI only)}\\
268-
\hline \verb'\ucs' & unload Menus\hfill \scriptsize{(n \& GUI only)}\\
269267
\hline
270268
\end{tabular}
271269
\vspace{100mm}

doc/csupport.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
*csupport.txt* C/C++ Support December 28 2011
1+
*csupport.txt* C/C++ Support January 06 2012
22

33
C/C++ Support *c-support* *csupport*
4-
Plugin version 5.17
4+
Plugin version 5.18
55
for Vim version 7.0 and above
66
Fritz Mehner <mehner@fh-swf.de>
77

@@ -1245,11 +1245,6 @@ Legend: (i) insert mode, (n) normal mode, (v) visual mode
12451245
\rx set xterm size (n, only Linux/UNIX & GUI)
12461246
\ro change output destination (n,i)
12471247

1248-
-- Load / Unload C/C++ Support ----------------------------------------
1249-
1250-
\lcs Load C/C++ Support Menus (n, GUI only)
1251-
\ucs Unload C/C++ Support Menus (n, GUI only)
1252-
12531248
The hotkeys are defined in the file type plugin c.vim (part of this csupport
12541249
plugin package) and described in the document c-hot-keys.pdf
12551250

plugin/c.vim

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
" warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
2828
" PURPOSE.
2929
" See the GNU General Public License version 2 for more details.
30-
" Revision: $Id: c.vim,v 1.156 2011/12/27 21:05:07 mehner Exp $
30+
" Revision: $Id: c.vim,v 1.162 2012/02/25 15:15:30 mehner Exp $
3131
"
3232
"------------------------------------------------------------------------------
3333
"
@@ -55,6 +55,8 @@ let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95")
5555
let s:UNIX = has("unix") || has("macunix") || has("win32unix")
5656
"
5757
let s:installation = '*undefined*'
58+
let s:plugin_dir = ''
59+
"
5860
let s:C_GlobalTemplateFile = ''
5961
let s:C_GlobalTemplateDir = ''
6062
let s:C_LocalTemplateFile = ''
@@ -85,20 +87,17 @@ if s:MSWIN
8587
endif
8688
"
8789
let s:C_FilenameEscChar = ''
88-
let s:C_Display = ''
8990
"
9091
else
9192
" ========== Linux/Unix ======================================================
9293
"
9394
if match( expand("<sfile>"), expand("$HOME") ) == 0
94-
"
9595
" USER INSTALLATION ASSUMED
9696
let s:installation = 'local'
9797
let s:plugin_dir = expand('<sfile>:p:h:h')
9898
let s:C_LocalTemplateFile = s:plugin_dir.'/c-support/templates/Templates'
9999
let s:C_LocalTemplateDir = fnamemodify( s:C_LocalTemplateFile, ":p:h" ).'/'
100100
else
101-
"
102101
" SYSTEM WIDE INSTALLATION
103102
let s:installation = 'system'
104103
let s:plugin_dir = $VIM.'/vimfiles'
@@ -109,7 +108,6 @@ else
109108
endif
110109
"
111110
let s:C_FilenameEscChar = ' \%#[]'
112-
let s:C_Display = $DISPLAY
113111
"
114112
endif
115113
"
@@ -187,6 +185,7 @@ call C_CheckGlobal('C_CodeCheckExeName ')
187185
call C_CheckGlobal('C_CodeCheckOptions ')
188186
call C_CheckGlobal('C_CodeSnippets ')
189187
call C_CheckGlobal('C_CplusCompiler ')
188+
call C_CheckGlobal('C_CreateMenusDelayed ')
190189
call C_CheckGlobal('C_Ctrl_j ')
191190
call C_CheckGlobal('C_ExeExtension ')
192191
call C_CheckGlobal('C_FormatDate ')
@@ -200,7 +199,6 @@ call C_CheckGlobal('C_LFlags ')
200199
call C_CheckGlobal('C_Libs ')
201200
call C_CheckGlobal('C_LineEndCommColDefault')
202201
call C_CheckGlobal('C_LoadMenus ')
203-
call C_CheckGlobal('C_CreateMenusDelayed ')
204202
call C_CheckGlobal('C_LocalTemplateFile ')
205203
call C_CheckGlobal('C_Man ')
206204
call C_CheckGlobal('C_MenuHeader ')
@@ -1739,14 +1737,14 @@ function! C_ProtoPick( type ) range
17391737
"
17401738
let prototyp = substitute( prototyp, '^template\s*<\s*class \w\+\s*>\s*', "", "" )
17411739
"
1742-
let idx = stridx( prototyp, '(' ) " start of the parameter list
1743-
let head = strpart( prototyp, 0, idx )
1740+
let idx = stridx( prototyp, '(' ) " start of the parameter list
1741+
let head = strpart( prototyp, 0, idx )
17441742
let parlist = strpart( prototyp, idx )
17451743
"
17461744
" remove the scope resolution operator
17471745
"
1748-
let template_id = '\h\w*\s*<[^>]\+>'
1749-
let rgx2 = '\('.template_id.'\s*::\s*\)*\([~A-Za-z]\w*\|operator.\+\)\s*$'
1746+
let template_id = '\h\w*\s*\(<[^>]\+>\)\?'
1747+
let rgx2 = '\('.template_id.'\s*::\s*\)*\([~]\?\h\w*\|operator.\+\)\s*$'
17501748
let idx = match( head, rgx2 ) " start of the function name
17511749
let returntype = strpart( head, 0, idx )
17521750
let fctname = strpart( head, idx )
@@ -2193,7 +2191,7 @@ function! C_Toggle_Gvim_Xterm ()
21932191
exe "amenu <silent> ".s:MenuRun.'.&output:\ VIM->buffer->xterm<Tab>\\ro :call C_Toggle_Gvim_Xterm()<CR><CR>'
21942192
exe "imenu <silent> ".s:MenuRun.'.&output:\ VIM->buffer->xterm<Tab>\\ro <C-C>:call C_Toggle_Gvim_Xterm()<CR><CR>'
21952193
endif
2196-
if (!s:MSWIN) && (!empty(s:C_Display))
2194+
if (!s:MSWIN) && (!empty($Display))
21972195
let s:C_OutputGvim = "xterm"
21982196
else
21992197
let s:C_OutputGvim = "vim"
@@ -2851,6 +2849,14 @@ endfunction " ---------- end of function C_BrowseTemplateFiles ----------
28512849
"
28522850
"------------------------------------------------------------------------------
28532851
let s:style = 'default'
2852+
2853+
function! C_CheckAndRereadTemplates ()
2854+
if s:C_TemplatesLoaded == 'no'
2855+
call C_RereadTemplates('no')
2856+
let s:C_TemplatesLoaded = 'yes'
2857+
endif
2858+
endfunction " ---------- end of function C_CheckAndRereadTemplates ----------
2859+
28542860
function! C_ReadTemplates ( templatefile )
28552861

28562862
if !filereadable( a:templatefile )
@@ -2956,6 +2962,7 @@ endfunction " ---------- end of function C_ReadTemplates ----------
29562962
" ex-command CStyle : callback function
29572963
"------------------------------------------------------------------------------
29582964
function! C_Style ( style )
2965+
call C_CheckAndRereadTemplates()
29592966
let lstyle = substitute( a:style, '^\s\+', "", "" ) " remove leading whitespaces
29602967
let lstyle = substitute( lstyle, '\s\+$', "", "" ) " remove trailing whitespaces
29612968
if has_key( s:C_Template, lstyle )
@@ -3139,7 +3146,9 @@ function! C_InsertTemplate ( key, ... )
31393146
if mode == 'insert'
31403147
let pos1 = line(".")
31413148
let pos2 = pos1
3142-
let string= @*
3149+
" windows: recover area of the visual mode and yank, puts the selected area in the buffer
3150+
normal gvy
3151+
let string = eval('@"')
31433152
let replacement = part[0].string.part[1]
31443153
" remove trailing '\n'
31453154
let replacement = substitute( replacement, '\n$', '', '' )
@@ -3184,11 +3193,7 @@ function! C_InsertTemplate ( key, ... )
31843193
if a:0 != 0 && a:1 == 'v' && getline(".") =~ '^\s*$'
31853194
normal J
31863195
else
3187-
if getpos(".")[2] < len(getline(".")) || mode == 'insert'
3188-
:startinsert
3189-
else
3190-
:startinsert!
3191-
endif
3196+
:startinsert!
31923197
endif
31933198
else
31943199
call setline( mtch, substitute( line, '<CURSOR>\|{CURSOR}', '', '' ) )
@@ -3456,6 +3461,8 @@ endfunction " ---------- end of function C_DateAndTime ----------
34563461
"------------------------------------------------------------------------------
34573462
function! C_InsertTemplateWrapper ()
34583463
" prevent insertion for a file generated from a link error:
3464+
"
3465+
call C_CheckAndRereadTemplates()
34593466
if isdirectory(expand('%:p:h'))
34603467
if index( s:C_SourceCodeExtensionsList, expand('%:e') ) >= 0
34613468
call C_InsertTemplate("comment.file-description")
@@ -3687,9 +3694,6 @@ if s:C_LoadMenus == 'yes' && s:C_CreateMenusDelayed == 'no'
36873694
call C_CreateGuiMenus()
36883695
endif
36893696
"
3690-
nmap <unique> <silent> <Leader>lcs :call C_CreateGuiMenus()<CR>
3691-
nmap <unique> <silent> <Leader>ucs :call C_RemoveGuiMenus()<CR>
3692-
"
36933697
"------------------------------------------------------------------------------
36943698
" Automated header insertion
36953699
" Local settings for the quickfix window
@@ -3719,26 +3723,27 @@ if has("autocmd")
37193723
\ if (&filetype=='cpp' || &filetype=='c') |
37203724
\ call C_CreateMenusDelayed() |
37213725
\ endif
3722-
"
3723-
" Automated header insertion (suffixes from the gcc manual)
3724-
"
3725-
if !exists( 'g:C_Styles' )
3726-
"-------------------------------------------------------------------------------
3727-
" template styles are the default settings
3728-
"-------------------------------------------------------------------------------
3729-
autocmd BufNewFile * if &filetype =~ '^\(c\|cpp\)$' && expand("%:e") !~ 'ii\?' |
3730-
\ call C_InsertTemplateWrapper() | endif
3731-
"
3732-
else
3726+
37333727
"-------------------------------------------------------------------------------
3734-
" template styles are related to file extensions
3728+
" style switching :Automated header insertion (suffixes from the gcc manual)
37353729
"-------------------------------------------------------------------------------
3736-
for [ pattern, stl ] in items( g:C_Styles )
3737-
exe "autocmd BufNewFile,BufRead,BufEnter ".pattern." call C_Style( '".stl."' )"
3738-
exe "autocmd BufNewFile ".pattern." call C_InsertTemplateWrapper()"
3739-
endfor
3740-
"
3741-
endif
3730+
if !exists( 'g:C_Styles' )
3731+
"-------------------------------------------------------------------------------
3732+
" template styles are the default settings
3733+
"-------------------------------------------------------------------------------
3734+
autocmd BufNewFile * if &filetype =~ '^\(c\|cpp\)$' && expand("%:e") !~ 'ii\?' |
3735+
\ call C_InsertTemplateWrapper() | endif
3736+
"
3737+
else
3738+
"-------------------------------------------------------------------------------
3739+
" template styles are related to file extensions
3740+
"-------------------------------------------------------------------------------
3741+
for [ pattern, stl ] in items( g:C_Styles )
3742+
exe "autocmd BufNewFile,BufRead,BufEnter ".pattern." call C_Style( '".stl."' )"
3743+
exe "autocmd BufNewFile ".pattern." call C_InsertTemplateWrapper()"
3744+
endfor
3745+
"
3746+
endif
37423747
"
37433748
" Wrap error descriptions in the quickfix window.
37443749
"

0 commit comments

Comments
 (0)