*** kate/smart/katesmartcursor.cpp.old	2009-07-20 02:50:08.000000000 +0900
--- kate/smart/katesmartcursor.cpp	2009-07-03 18:35:50.000000000 +0900
***************
*** 274,283 ****
--- 274,295 ----
      } else {
        newPos = *this + edit.translate();
      }

+ #ifndef	ORIGINAL_CODE
+   if (newPos.line() > kateDocument()->lastLine()) {
+     kWarning() << "Attempted to set cursor position I" << newPos << " past end of document " << document()->documentRange();
+     return false;
+     }
+ #endif
    } else {
      // just need to adjust line number
      newPos.setPosition(line() + edit.translate().line(), column());
+ #ifndef	ORIGINAL_CODE
+   if (newPos.line() > kateDocument()->lastLine()) {
+     kWarning() << "Attempted to set cursor position III" << newPos << " past end of document " << document()->documentRange();
+     return false;
+     }
+ #endif
    }
  
    if (newPos != *this) {
*** kate/utils/kateconfig.cpp.old	2009-07-20 02:51:56.000000000 +0900
--- kate/utils/kateconfig.cpp	2009-06-05 16:08:52.000000000 +0900
***************
*** 990,994 ****
--- 990,999 ----
  
  bool KateViewConfig::persistentSelection () const
  {
+ #ifndef	ORIGINAL_CODE
+   /* In vi mode, selection sould be persistent for the safty */
+   if (viInputMode())
+ 	return true;
+ #endif
    if (m_persistentSelectionSet || isGlobal())
      return m_persistentSelection;
*** kate/utils/katesearchbar.cpp.old	2009-07-20 02:53:10.000000000 +0900
--- kate/utils/katesearchbar.cpp	2009-06-05 16:08:24.000000000 +0900
***************
*** 349,355 ****
--- 349,357 ----
      view->setCursorPositionInternal(range.start(), 1);
  
      // don't make a selection if the vi input mode is used
+ #ifdef	ORIGINAL_CODE
      if (!view->viInputMode())
+ #endif
          view->setSelection(range);
  }
  
***************
*** 771,781 ****
--- 773,787 ----
                  // if the vi input mode is used, the cursor will stay a the first character of the
                  // matched pattern (no selection will be made), so the next search should start from
                  // match column + 1
+ #ifdef	ORIGINAL_CODE
                  if (!view()->viInputMode()) {
                      inputRange.setRange(cursorPos, view()->doc()->documentEnd());
                  } else {
                      inputRange.setRange(Cursor(cursorPos.line(), cursorPos.column()+1), view()->doc()->documentEnd());
                  }
+ #else
+                     inputRange.setRange(cursorPos, view()->doc()->documentEnd());
+ #endif
              } else {
                  inputRange.setRange(Cursor(0, 0), cursorPos);
              }
*** kate/vimode/katevinormalmode.cpp.old	2009-07-20 02:58:07.000000000 +0900
--- kate/vimode/katevinormalmode.cpp	2009-06-13 02:11:29.000000000 +0900
***************
*** 867,874 ****
--- 867,880 ----
    bool r = false;
    QString yankedText;
  
+ #ifdef	ORIGINAL_CODE
    bool linewise = ( m_commandRange.startLine != m_commandRange.endLine
        && m_viInputModeManager->getCurrentViMode() != VisualMode );
+ #else
+   bool linewise = m_viInputModeManager->getCurrentViMode() == VisualLineMode
+        || ( m_commandRange.startLine != m_commandRange.endLine
+       && m_viInputModeManager->getCurrentViMode() != VisualMode );
+ #endif
  
    yankedText = getRange( m_commandRange, linewise );
  
***************
*** 1655,1661 ****
--- 1661,1671 ----
    QString item = l.mid( n1, n2-n1 );
  
    // use kate's built-in matching bracket finder for brackets
+ #ifdef	ORIGINAL_CODE
    if ( QString("{}()[]").indexOf( item ) != -1 ) {
+ #else
+   if ( QString("{}()[]").indexOf( item.left(1) ) != -1 ) {
+ #endif
  
      // move the cursor to the first bracket
      c.setColumn( n1+1 );
*** kate/vimode/kateviinsertmode.cpp.old	2009-09-03 01:36:44.000000000 +0900
--- kate/vimode/kateviinsertmode.cpp	2009-09-03 01:35:18.000000000 +0900
***************
*** 246,259 ****
--- 246,291 ----
        startNormalMode();
        return true;
        break;
+ #ifdef	ORIGINAL_CODE
      case Qt::Key_D:
        commandUnindent();
        return true;
+ #else
+     /* Emacs emulate */
+     case Qt::Key_D:
+       m_view->keyDelete();
+       return true;
+     case Qt::Key_H:
+       m_view->backspace();
+       return true;
+     case Qt::Key_F:
+       m_view->cursorRight();
+       return true;
+     case Qt::Key_B:
+       m_view->cursorLeft();
+       return true;
+     case Qt::Key_P:
+       m_view->up();
+       return true;
+     case Qt::Key_N:
+       m_view->down();
+       return true;
+ #endif
        break;
+ #ifdef	ORIGINAL_CODE
      case Qt::Key_E:
        commandInsertFromBelow();
        return true;
+ #else
+     case Qt::Key_E:
+       m_view->end();
+       return true;
+     case Qt::Key_A:
+       m_view->home();
+       return true;
        break;
+ #endif
+ #ifdef 	ORIGINAL_CODE
      case Qt::Key_N:
        commandCompleteNext();
        return true;
***************
*** 262,267 ****
--- 294,300 ----
        commandCompletePrevious();
        return true;
        break;
+ #endif
      case Qt::Key_T:
        commandIndent();
        return true;
