Closed zhangda82 closed 6 years ago
Here is the email communication I had with the maintainer of flymake. The old API needs to be replaced with their new designs:
Hello --
I am a long term Emacs user and I use flymake together with flymake-cursor on a daily basis.
Starting Emacs 26.1, I noticed that flyamke was redesigned and no longer has the var flymake-err-info that contains the error info reported by the backend syntax checker.
This makes flymake-cursor and code like the following not work:
(defun elpy-flymake-error-at-point () "Return the flymake error at point, or nil if there is none." (when (boundp 'flymake-err-info) (let* ((lineno (line-number-at-pos)) (err-info (car (flymake-find-err-info flymake-err-info lineno)))) (when err-info (mapconcat #'flymake-ler-text err-info ", ")))))
I believe this is a potential issue and wonder if someone could direct me to any alternatives to flymake-err-info in the newly designed flyamke.
Hi -- I'm the responsible for the redesign. Although I tried to keep some backward compatibility to old flymake.el's API, the truth is that all of it was an API.
The bad news is that this variable is gone: it couldn't be backward-adapted. The good news is that it should be much easier to write your function:
(defun elpy-flymake-error-at-point () "Return the flymake error at point, or nil if there is none." (mapconcat #'flymake-diagnostic-text (flymake-diagnostics (point)) "\n"))
Notice that, to keep with the protocol, this returns a concatenation of the text strings of all the errors at point. You might be better served by returning and manipulating the objects returned by flymake-diagnostics instead.
See section "2.2.1 Flymake utility functions" of the Flymake manual bundled with Emacs for more information.
I don't know what flymake-cursor does, but I suspect it can be fixed accordingly.
Hope this helps, João
I tried the solution provided by Joao, the maintainer of the redesigned flymake. The solution works quite well.
If you replace the current implementation of elpy-flymake-error-at-point in elpy.el from: ;; (defun elpy-flymake-error-at-point () ;; "Return the flymake error at point, or nil if there is none." ;; (when (boundp 'flymake-err-info) ;; (let* ((lineno (line-number-at-pos)) ;; (err-info (car (flymake-find-err-info flymake-err-info ;; lineno)))) ;; (when err-info ;; (mapconcat #'flymake-ler-text ;; err-info ;; ", ")))))
to
(defun elpy-flymake-error-at-point () "Return the flymake error at point, or nil if there is none." (mapconcat #'flymake-diagnostic-text (flymake-diagnostics (point)) "\n"))
Then elpy will show error/warning message correctly at the minibuffer area when the cursor is on the same line of the error/warning.
Da
Elpy really should check whether flymake-diagnostics
is available, and use it then, and if not, use the old functionality … (PRs welcome, I'm afraid I do not have time to work on that right now :-( )
@jorgenschaefer After having this problem I changed to flycheck ...and been very happy with it and will not come back... You closed #1272 where you gave instructions on how to change to flycheck and then I shared my flycheck setup for python ... maybe that could be documented elsewhere? Maybe it will be helpful for someone
@pbgc Feel free to document it in the wiki (or in the official documentation?). Ideally, though, I'd love a module that does the flycheck setup, so users can enable it if they want flycheck over flymake …
Are you looking for something like this? I briefly tested it in Emasc 26.1RC, and it worked for me.
(defun elpy-flymake-error-at-point () "Return the flymake error at point, or nil if there is none." (when (boundp 'flymake-err-info) (let* ((lineno (line-number-at-pos)) (err-info (car (flymake-find-err-info flymake-err-info lineno)))) (when err-info (mapconcat #'flymake-ler-text err-info ", ")))) (when (and (fboundp 'flymake-diagnostics) (fboundp 'flymake-diagnostic-text)) (mapconcat #'flymake-diagnostic-text (flymake-diagnostics (point)) "\n") ) )
Just created a pull request. #1360 Let me know if it works. Thanks.
Summary
Hi there. I tried to call elpy-flymake-show-error on an error/warning annotated by flymake, but nothing showed up. After checking the code of elpy-flymake-show-error and the elpy-flymake-error-at-point, I noticed that elpy is still assuming "flymake-err-info" to be the error message.
However, in Emacs 26.1, flymake-err-info is no longer available. I think this is a compatibility issue.
Thanks.
Da