From 9c6b6153970360ff6dc9e35615563a3e6681abe0 Mon Sep 17 00:00:00 2001 From: Israel Chauca Fuentes Date: Thu, 1 Apr 2010 17:53:31 -0500 Subject: [PATCH] Doc update, fix backspace & global functions. Fixed a problem with MacVim and the Makefile. --- Makefile | 4 +- doc/delimitMate.txt | 96 ++++++++++++++++++++++++++++++++++++------ plugin/delimitMate.vim | 31 ++++++-------- 3 files changed, 99 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index 0df707c..90fc063 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ install: cp -f plugin/* ~/.vim/plugin/${PLUGIN}.vim doc_update: install - vim -u NONE -c 'helptags ~/.vim/doc' -c 'q' + /usr/bin/vim -u NONE -c ':helptags ~/.vim/doc' -c ':q' zip: zip -r ${PLUGIN}.zip doc plugin @@ -14,7 +14,7 @@ zip: vimball: install echo doc/${PLUGIN}.txt > vimball.txt echo plugin/${PLUGIN}.vim >> vimball.txt - vim -c 'e vimball.txt' -c '%MkVimball! ${PLUGIN}' -c 'q' + /usr/bin/vim -c 'e vimball.txt' -c '%MkVimball! ${PLUGIN}' -c 'q' gzip: vimball gzip -f ${PLUGIN}.vba diff --git a/doc/delimitMate.txt b/doc/delimitMate.txt index fec5de3..6de8b50 100644 --- a/doc/delimitMate.txt +++ b/doc/delimitMate.txt @@ -1,8 +1,18 @@ -*delimitMate.txt* Trying to keep those beasts at bay! v.2.0 +*delimitMate* Trying to keep those beasts at bay! v.2.0 *delimitMate.txt* + ========================================================================= ~ + ==== ========= ========================== ===== ===================== ~ + ==== ========= ========================== === ===================== ~ + ==== ========= ===================== === = = ========== ========= ~ + ==== === === == == = = === == == == == === === === == ~ + == == = == ====== ======= === ===== == = === === = = ~ + = = == == == == = = == === === ===== ===== === === = ~ + = = == ===== == == = = == === === ===== === === === ==== ~ + = = == = == == == = = == === === ===== == = === === = = ~ + == === === == == = = == === == ===== === === === == ~ + ========================================================================= ~ - REFERENCE MANUAL *delimitMate* - + REFERENCE MANUAL * ============================================================================== 0.- CONTENTS *delimitMate-contents* @@ -18,10 +28,11 @@ 3.1 Option summary_____________________|delimitMateOptionSummary| 3.2 Options details____________________|delimitMateOptionDetails| 4. Commands________________________________|delimitMateCommands| - 5. TODO list_______________________________|delimitMateTodo| - 6. Maintainer______________________________|delimitMateMaintainer| - 7. Credits_________________________________|delimitMateCredits| - 8. History_________________________________|delimitMateHistory| + 5. Functions_______________________________|delimitMateFunctions| + 6. TODO list_______________________________|delimitMateTodo| + 7. Maintainer______________________________|delimitMateMaintainer| + 8. Credits_________________________________|delimitMateCredits| + 9. History_________________________________|delimitMateHistory| ============================================================================== 1.- INTRODUCTION *delimitMateIntro* @@ -107,6 +118,10 @@ Expand to: > | ) < +Since and are used everywhere, I have made the functions involved +in expansions global, so they can be used to make custom mappings. Read +|delimitMateFunctions| for more details. + ------------------------------------------------------------------------------ 2.3 BACKSPACE *delimitMateBackspace* @@ -158,6 +173,9 @@ e.g. typing at the "|": > ============================================================================== 3. CUSTOMIZATION *delimitMateOptions* +You can create your own mappings for some features using the global functions. +Read |DelimitMateFunctions| for more info. + ------------------------------------------------------------------------------ 3.1 OPTIONS SUMMARY *delimitMateOptionSummary* @@ -385,14 +403,59 @@ represented by an "|": > < ============================================================================== - 5. TODO LIST *delimitMateTodo* + 5. FUNCTIONS *delimitMateFunctions* + +------------------------------------------------------------------------------ +delimitMate_WithinEmptyPair() *delimitMate_WithinEmptyPair* + +Returns 1 if the cursor is inside an empty pair, 0 otherwise. + +------------------------------------------------------------------------------ +DelimitMate_ExpandReturn() *DelimitMate_ExpandReturn()* + +Returns the expansion for . + +e.g.: This mapping could be used to select an item on a pop-up menu or expand + inside an empty pair: > + + inoremap pumvisible() ? "\" : + \ DelimitMate_WithinEmptyPair ? + \ DelimitMate_ExpandReturn() : "\" +< +------------------------------------------------------------------------------ +DelimitMate_ExpandSpace() *DelimitMate_ExpandSpace()* + +Returns the expansion for . +e.g.: > + + inoremap DelimitMate_WithinEmptyPair() ? + \ DelimitMate_ExpandSpace() : "\" +< +------------------------------------------------------------------------------ +DelimitMate_ShouldJump() *DelimitMate_ShouldJump()* + +Returns 1 if there is a closing delimiter or a quote to the right of the +cursor, 0 otherwise. + +------------------------------------------------------------------------------ +DelimitMate_JumpAny() *DelimitMate_JumpAny()* + +This function returns a mapping that will make the cursor jump to the right. +e.g.: You can use this to create your own mapping to jump over any delimiter. +> + inoremap DelimitMate_ShouldJump() ? + \ DelimitMate_JumpAny() : "\" +< + +============================================================================== + 6. TODO LIST *delimitMateTodo* - Automatic set-up by file type. - Make visual wrapping work on blockwise visual mode. - Limit behaviour by region. ============================================================================== - 6. MAINTAINER *delimitMateMaintainer* + 7. MAINTAINER *delimitMateMaintainer* Hi there! My name is Israel Chauca F. and I can be reached at: mailto:israelchauca@gmail.com @@ -401,7 +464,7 @@ Feel free to send me any suggestions and/or comments about this plugin, I'll be very pleased to read them. ============================================================================== - 7. CREDITS *delimitMateCredits* + 8. CREDITS *delimitMateCredits* Some of the code that make this script is modified or just shamelessly copied from the following sources: @@ -420,11 +483,11 @@ from the following sources: This script was inspired by the auto-completion of delimiters of TextMate. ============================================================================== - 8. HISTORY *delimitMateHistory* + 9. HISTORY *delimitMateHistory* Version Date Release notes ~ |---------|------------|-----------------------------------------------------| - 2.0 2010-04-01 New: + 2.0 2010-04-01 * New features: - All features are redo/undo-wise safe. - A single quote typed after an alphanumeric character is considered an apostrophe and one @@ -438,7 +501,8 @@ This script was inspired by the auto-completion of delimiters of TextMate. active if you have any of the expansion options set. - deletes the closing delimiter. - Fixed: + + * Fixed bug: - s:vars were being used to store buffer options. |---------|------------|-----------------------------------------------------| @@ -488,4 +552,10 @@ This script was inspired by the auto-completion of delimiters of TextMate. |---------|------------|-----------------------------------------------------| + + ... |"| _ _ . . ___ ~ + o,*,(o o) _|_|_ o' \,=./ `o . .:::. /_\ `* ~ + 8(o o)(_)Ooo (o o) (o o) :(o o): . (o o) ~ +---ooO-(_)---Ooo----ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo- ~ + vim:tw=78:ts=8:ft=help:norl:formatoptions+=tcroqn:autoindent: diff --git a/plugin/delimitMate.vim b/plugin/delimitMate.vim index 74c3aa3..de0067f 100644 --- a/plugin/delimitMate.vim +++ b/plugin/delimitMate.vim @@ -299,6 +299,11 @@ function! s:JumpOut(char) "{{{ return a:char endfunction " }}} +function! DelimitMate_JumpAny() " {{{ + let nchar = getline('.')[col('.')-1] + return nchar . "\" +endfunction " DelimitMate_JumpAny() }}} + function! s:SkipDelim(char) "{{{ let cur = strpart( getline('.'), col('.')-2, 3 ) if cur[0] == "\\" @@ -410,23 +415,13 @@ function! s:VisualMaps() " {{{ endfunction "}}} function! DelimitMate_ExpandReturn() "{{{ - if DelimitMate_WithinEmptyPair() - " Expand: - return "\a\x\\k$\"_xa" - else - " Don't - return "\" - endif + " Expand: + return "\a\x\\k$\"_xa" endfunction "}}} function! DelimitMate_ExpandSpace() "{{{ - if DelimitMate_WithinEmptyPair() - " Expand: - return s:WriteAfter(' ')."\" - else - " Don't - return "\" - endif + " Expand: + return s:WriteAfter(' ') . "\" endfunction "}}} function! s:ExtraMappings() "{{{ @@ -438,17 +433,19 @@ function! s:ExtraMappings() "{{{ " Expand return if inside an empty pair: if b:delimitMate_expand_cr != 0 - inoremap =DelimitMate_ExpandReturn() + inoremap DelimitMate_WithinEmptyPair() ? + \ DelimitMate_ExpandReturn() : "\" endif " Expand space if inside an empty pair: if b:delimitMate_expand_space != 0 - inoremap =DelimitMate_ExpandSpace() + inoremap DelimitMate_WithinEmptyPair() ? + \ DelimitMate_ExpandSpace() : "\" endif " Jump out ot any empty pair: if b:delimitMate_tab2exit - inoremap DelimitMate_ShouldJump() ? "\" : "\" + inoremap DelimitMate_ShouldJump() ? DelimitMate_JumpAny() : "\" endif endfunction "}}} "}}}