1. Tamas Kovacs
  2. slimv

Commits

Tamas Kovacs  committed 57e33ec

In Vim 7.4 normal mode cursor movements and winrestview() cannot be used in an 'indentexpr'
Otherwise the screen is moved after auto-indenting so that the cursor line is in the center

  • Participants
  • Parent commits 0d79300
  • Branches default

Comments (0)

Files changed (1)

File ftplugin/slimv.vim

View file
  • Ignore whitespace
 " slimv.vim:    The Superior Lisp Interaction Mode for VIM
-" Version:      0.9.12
-" Last Change:  15 Dec 2013
+" Version:      0.9.13
+" Last Change:  30 Jan 2014
 " Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 " License:      This file is placed in the public domain.
 "               No warranty, express or implied.
     let li = lispindent( a:lnum )
     set nolisp
     let backline = max([a:lnum-g:slimv_indent_maxlines, 1])
-    let oldpos = winsaveview()
-    normal! 0
+    let oldpos = getpos( '.' )
+    call cursor( oldpos[1], 1 )
     " Find containing form
     let [lhead, chead] = searchpairpos( '(', '', ')', 'bW', s:skip_sc, backline )
     if lhead == 0
         " No containing form, lispindent() is OK
-        call winrestview( oldpos )
+        call cursor( oldpos[1], oldpos[2] )
         return li
     endif
     " Find outer form
     let [lparent, cparent] = searchpairpos( '(', '', ')', 'bW', s:skip_sc, backline )
-    call winrestview( oldpos )
+    call cursor( oldpos[1], oldpos[2] )
     if lparent == 0 || lhead != lparent
         " No outer form or starting above inner form, lispindent() is OK
         return li
         " Hit the start of the file, use zero indent.
         return 0
     endif
-    let oldpos = winsaveview()
+    let oldpos = getpos( '.' )
     let linenum = a:lnum
 
     " Handle multi-line string
             let [l, c] = searchpairpos( '"', '', '"', 'bnW', s:skip_q )
             if l > 0 && strpart(getline(l), 0, c-1) =~ '^\s*$'
                 " Nothing else before the string: indent to the opening "
-                call winrestview( oldpos )
                 return c - 1
             endif
             if l > 0
                 let linenum = l + 1
             endif
         endif
-        call winrestview( oldpos )
+        call cursor( oldpos[1], oldpos[2] )
     endif
 
     " Handle special indentation style for flet, labels, etc.
             endif
         endif
     endif
-    call winrestview( oldpos )
 
     " Find beginning of the innermost containing form
-    normal! 0
+    call cursor( oldpos[1], 1 )
     let [l, c] = searchpairpos( '(', '', ')', 'bW', s:skip_sc, backline )
     if l > 0
         if SlimvGetFiletype() =~ '.*\(clojure\|scheme\|racket\).*'
             " Is this a clojure form with [] binding list?
-            call winrestview( oldpos )
+            call cursor( oldpos[1], oldpos[2] )
             let [lb, cb] = searchpairpos( '\[', '', '\]', 'bW', s:skip_sc, backline )
             if lb >= l && (lb > l || cb > c)
-                call winrestview( oldpos )
                 return cb
             endif
         endif
         if match( line, '\c^(\s*\('.s:spec_indent.'\)\>' ) >= 0
             " Search for the binding list and jump to its end
             if search( '(' ) > 0
-                exe 'normal! %'
+                call searchpair( '(', '', ')', '', s:skip_sc )
                 if line('.') == pnum
                     " We are indenting the first line after the end of the binding list
-                    call winrestview( oldpos )
                     return c + 1
                 endif
             endif
                     if search( '(' ) > 0
                         if line('.') == l && col('.') == c
                             " This is the parameter list of a special form
-                            call winrestview( oldpos )
                             return c
                         endif
                     endif
                 if SlimvGetFiletype() !~ '.*clojure.*'
                     if l2 == l && match( line2, '\c^(\s*\('.s:binding_form.'\)\>' ) >= 0
                         " Is this a lisp form with binding list?
-                        call winrestview( oldpos )
                         return c
                     endif
                     if match( line2, '\c^(\s*cond\>' ) >= 0 && match( line, '\c^(\s*t\>' ) >= 0
                         " Is this the 't' case for a 'cond' form?
-                        call winrestview( oldpos )
                         return c
                     endif
                     if match( line2, '\c^(\s*defpackage\>' ) >= 0
                     let line3 = strpart( getline(l3), c3-1 )
                     if match( line3, '\c^(\s*\('.s:spec_indent.'\)\>' ) >= 0
                         " This is the first body-line of a binding
-                        call winrestview( oldpos )
                         return c + 1
                     endif
                     if match( line3, '\c^(\s*defsystem\>' ) >= 0
     endif
 
     " Restore all cursor movements
-    call winrestview( oldpos )
+    call cursor( oldpos[1], oldpos[2] )
 
     " Check if the current form started in the previous nonblank line
     if l == parent