New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support emacs compilation output mode #16

Closed
erik-stephens opened this Issue Feb 23, 2014 · 2 comments

Comments

Projects
None yet
3 participants
@erik-stephens

erik-stephens commented Feb 23, 2014

If you put the line number after the file, then will be much more useful to emacs users that use the compile command. This:

foo/__init__.py :
    L5:1 None: pyflakes - FL0001
    'ApiException' imported but unused

should be:

foo/__init__.py:5 :
    L5:1 None: pyflakes - FL0001
    'ApiException' imported but unused

carlio added a commit that referenced this issue Feb 26, 2014

carlio added a commit that referenced this issue Feb 26, 2014

@carlio

This comment has been minimized.

Contributor

carlio commented Feb 26, 2014

I've added a separate output formatter, as the default text one will also try to include module names sometimes. You can invoke it using prospector --output-format emacs

I'm not an emacs user so I'm not entirely sure what you need to be in that output. It will produce output in the format as requested:

foo/__init__.py:5 :
    L5:1 None: pyflakes - FL0001
    'ApiException' imported but unused

However I can easily change it to suit something more emacs-specific (or feel free to send a pull request).

@carlio carlio closed this Feb 26, 2014

@philroberts

This comment has been minimized.

Contributor

philroberts commented Oct 27, 2014

I just tweaked the emacs formatter to include character position in the part parsed by emacs. Works for me:

class EmacsFormatter(TextFormatter):
    def render_message(self, message):
        output = []

        output.append('%s:%s:%s:' % (
            message.location.path,
            message.location.line,
            message.location.character
        ))

        output.append(
            '    L%s:%s %s: %s - %s' % (
                message.location.line or '-',
                message.location.character if message.location.line else '-',
                message.location.function,
                message.source,
                message.code,
            )
        )

        output.append('    %s' % message.message)

        return '\n'.join(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment