unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Richard Riley <rileyrgdev@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Emacs 23, Python, epylint, pylint
Date: Thu, 22 Oct 2009 04:10:56 +0200	[thread overview]
Message-ID: <hboevi$u82$1@ger.gmane.org> (raw)
In-Reply-To: hbodlo$p7p$2@ger.gmane.org

Richard Riley <rileyrgdev@gmail.com> writes:

> Richard Riley <rileyrgdev@gmail.com> writes:
>
>> I have followed the advice here:
>>
>> http://stackoverflow.com/questions/1259873/how-can-i-use-emacs-flymake-mode-for-python-with-pyflakes-and-pylint-checking-cod
>>
>> or
>>
>> http://tinyurl.com/yfshb5b
>>
>> And successfully have pylint and emacs highlighting errors in my .py
>> files courtesy of flymake. The problem is that I can't see anywhere the
>> actually error description. Can anyone help please?
>>
>> The epylint script I have is this:
>>
>> ,----
>> | #!/usr/bin/env python
>> | 
>> | import re
>> | import sys
>> | 
>> | from subprocess import *
>> | 
>> | p = Popen(
>> |     "pylint -f parseable -r n %s"%
>> |     sys.argv[1], shell = True, stdout = PIPE).stdout
>> | 
>> | for line in p:
>> |     match = re.search("\\[([WECR])(, (.+?))?\\]", line)
>> |     if match:
>> |         kind = match.group(1)
>> |         func = match.group(3)
>> | 
>> |         if kind in ["W","C","R"]:
>> |            msg = "Warning"
>> |         else:
>> |            msg = "Error"
>> | 
>> |         if func:
>> |             line = re.sub("\\[([WECR])(, (.+?))?\\]",
>> |                           "%s (%s):" % (msg, func), line)
>> |         else:
>> |             line = re.sub("\\[([WECR])?\\]", "%s:" % msg, line)
>> |     print line,
>> | 
>> | p.close()
>> `----
>>
>
> OK, its done so that you need to (yuck!) hover your mouse over the
> hilited error. Kind of in the face of keyboard driven emacs, but at
> least one can see the error. If anyone has a patch/fix/advice on how to
> change this to show the errors in a buffer and maybe next error/previous
> error then that would be great. In fact pylint.el does something like
> that but it would be nice in conjunction with the flymake dynamic code
> checking and error hiliting.
>

A more careful read of the flymake wiki page 

http://www.emacswiki.org/emacs/FlyMake

provided the answer:

http://paste.lisp.org/display/60617

,----
| (defun show-fly-err-at-point ()
|   "If the cursor is sitting on a flymake error, display the
| message in the minibuffer"
|   (interactive)
|   (let ((line-no (line-number-at-pos)))
|     (dolist (elem flymake-err-info)
|       (if (eq (car elem) line-no)
| 	  (let ((err (car (second elem))))
| 	    (message "%s" (fly-pyflake-determine-message err)))))))
| 
| (defun fly-pyflake-determine-message (err)
|   "pyflake is flakey if it has compile problems, this adjusts the
| message to display, so there is one ;)"
|   (cond ((not (or (eq major-mode 'Python) (eq major-mode 'python-mode) t)))
| 	((null (flymake-ler-file err))
| 	 ;; normal message do your thing
| 	 (flymake-ler-text err))
| 	(t ;; could not compile err
| 	 (format "compile error, problem on line %s" (flymake-ler-line err)))))
| 
| (defadvice flymake-goto-next-error (after display-message activate compile)
|   "Display the error in the mini-buffer rather than having to mouse over it"
|   (show-fly-err-at-point))
| 
| (defadvice flymake-goto-prev-error (after display-message activate compile)
|   "Display the error in the mini-buffer rather than having to mouse over it"
|   (show-fly-err-at-point))
| 
| (defadvice flymake-mode (before post-command-stuff activate compile)
|   "Add functionality to the post command hook so that if the
| cursor is sitting on a flymake error the error information is
| displayed in the minibuffer (rather than having to mouse over
| it)"
|   (set (make-local-variable 'post-command-hook)
|        (cons 'show-fly-err-at-point post-command-hook))) 
`----


(I think this should be default behaviour as most Emacs users balk from
using the mouse :-;)






  reply	other threads:[~2009-10-22  2:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-22  1:30 Emacs 23, Python, epylint, pylint Richard Riley
2009-10-22  1:48 ` Richard Riley
2009-10-22  2:10   ` Richard Riley [this message]
     [not found] ` <mailman.9250.1256176158.2239.help-gnu-emacs@gnu.org>
2009-10-23 11:50   ` Anselm Helbig
2009-10-23 13:35     ` Richard Riley
     [not found]     ` <mailman.9306.1256304994.2239.help-gnu-emacs@gnu.org>
2009-11-01 19:23       ` Dave Love
2009-11-02 13:02         ` Richard Riley
2009-11-02 13:29         ` Richard Riley
     [not found] <mailman.9249.1256175078.2239.help-gnu-emacs@gnu.org>
2009-11-01 19:22 ` Dave Love

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='hboevi$u82$1@ger.gmane.org' \
    --to=rileyrgdev@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).