author Pierre-Yves David <pierre-yves.david@logilab.fr>
Mon, 09 Jun 2008 13:39:44 +0200
changeset 4 6ff5e87d288a
parent 0 7710b138d4eb
permissions -rw-r--r--
change position on __future__ import for compatibility

# Copyright (c) 2004 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
"""Basic editor adapters

__revision__ = '$Id: editors.py,v 1.2 2004-10-07 09:19:54 syt Exp $'

import os

from logilab.common.interface import Interface

class IEditor(Interface):
    def open(self, file, lineno=None):
        """open the given file in the editor. If a line number is given,
        go to this line in the opened buffer

class EmacsClient:
    __implements__ = IEditor,

    def open(self, filepath, lineno=None):
        """open the given file using emacs client. If a line number is given,
        go to this line in the opened buffer
        cmd = 'emacsclient --no-wait'
        if lineno:
            cmd = '%s +%s' % (cmd, lineno)
        cmd =  '%s %s' % (cmd, filepath)
        log(LOG_DEBUG, cmd)