/**
  * @see com.mulgasoft.emacsplus.commands.EmacsPlusCmdHandler#transform(ITextEditor, IDocument,
  *     ITextSelection, ExecutionEvent)
  */
 @Override
 protected int transform(
     ITextEditor editor, IDocument document, ITextSelection currentSelection, ExecutionEvent event)
     throws BadLocationException {
   int result = getCursorOffset(editor, currentSelection);
   // get the selection encompassing the appropriate set of lines
   ITextSelection selection = getLineSelection(editor, document, currentSelection);
   if (selection != null) {
     int offset = selection.getOffset();
     int endOffset = offset + selection.getLength();
     int begin = document.getLineOfOffset(offset);
     int end = document.getLineOfOffset(endOffset);
     if (begin != end && begin < end) {
       ArrayList<String> alst = new ArrayList<String>();
       IRegion region = document.getLineInformation(begin);
       // get text from point or mark
       alst.add(document.get(offset, region.getLength() - (offset - region.getOffset())));
       for (int i = begin + 1; i < end; i++) {
         region = document.getLineInformation(i);
         // get full line of text
         alst.add(document.get(region.getOffset(), region.getLength()));
       }
       region = document.getLineInformation(end);
       // get text to point or mark
       alst.add(document.get(region.getOffset(), endOffset - region.getOffset()));
       Collections.sort(alst, (getComparator(isUniversalPresent())));
       updateLines(document, selection, alst.toArray(new String[0]));
     } else {
       EmacsPlusUtils.showMessage(editor, NO_REGION, true);
     }
   } else {
     EmacsPlusUtils.showMessage(editor, NO_REGION, true);
   }
   return result;
 }
  /** @return the sortedRefs */
  protected IEditorReference[] getSortedRefs() {

    if (sortedRefs == null) {
      sortedRefs = EmacsPlusUtils.getSortedEditors(page);
      this.page = null;
      if (sortedRefs == null || sortedRefs.length == 0) {
        leave(true);
      }
    }
    return sortedRefs;
  }
 /**
  * @see
  *     com.mulgasoft.emacsplus.minibuffer.WithMinibuffer#initializeBuffer(org.eclipse.ui.texteditor.ITextEditor,
  *     org.eclipse.ui.IWorkbenchPage)
  */
 @Override
 protected boolean initializeBuffer(ITextEditor editor, IWorkbenchPage page) {
   this.page = page;
   EmacsPlusUtils.clearMessage(editor);
   IEditorReference[] refs = this.getSortedRefs();
   if (refs != null && refs.length > 0) {
     if (refs.length < 2) {
       defaultFile = refs[0];
     } else {
       defaultFile = refs[refs.length - 2];
     }
     defaultFilePrefix = prePre + defaultFile.getName() + prePost;
   }
   return true;
 }