flycheck / flycheck-pos-tip

Flycheck errors display in tooltip
GNU General Public License v3.0
122 stars 10 forks source link

flycheck-pos-tip-mode does not always preserve flycheck-pos-tip-old-display-function #23

Closed Wilfred closed 7 years ago

Wilfred commented 7 years ago

If you have enabled flycheck-pos-tip-mode in multiple buffers, flycheck-pos-tip-old-display-function is overwritten.

The first time flycheck-pos-tip-mode is called, it sets flycheck-pos-tip-old-display-function correctly. However, on the second time it's activated, it sets flycheck-pos-tip-old-display-function to flycheck-pos-tip-error-messages.

As a result, disabling flycheck-pos-tip-mode with M-x flycheck-pos-tip-mode does not have the intended effect, because flycheck-display-errors-function stays as flycheck-pos-tip-error-messages.

I think a good solution would be to make flycheck-pos-tip-old-display-function a buffer-local variable.

swsnr commented 7 years ago

@Wilfred Thanks for the report, but I'm not sure what the problem is.

Considering that flycheck-pos-tip-mode is a global minor mode, how can it get activated twice without being deactivated in between? Can you provide a recipe to reproduce the issue in emacs -Q?

Wilfred commented 7 years ago

Ooh, this was a little subtle to debug.

It can get activated twice, but only if it's not called interactively:

(progn
   (setq flycheck-pos-tip-old-display-function #'flycheck-display-error-messages) 
   (flycheck-pos-tip-mode)
   (flycheck-pos-tip-mode)
   flycheck-pos-tip-old-display-function) ;; flycheck-pos-tip-error-messages

This issue does not occur if you just do M-x flycheck-pos-tip-mode. I had flycheck-pos-tip-mode activated by a hook, which was what triggered this behaviour.

swsnr commented 7 years ago

@Wilfred Oh, that's a bad surprise: I thought that a minor mode would implicitly guard against being activated twice, but apparently it doesn't :flushed:

I pushed a fix which activates this mode only if it's not already activated.

Wilfred commented 7 years ago

Thank you! :)