Skip to content

Commit

Permalink
Add hooks to run before and after the popup appear
Browse files Browse the repository at this point in the history
  • Loading branch information
lthms committed Aug 6, 2022
1 parent ef86aad commit 558e6e4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions flycheck-popup-tip.el
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,18 @@
(defvar flycheck-popup-tip-old-display-function nil
"The former value of `flycheck-display-errors-function'.")

(defvar flycheck-popup-tip-show-hook nil
"Hook run before when showing a popup.")

(defvar flycheck-popup-tip-delete-hook nil
"Hook run before when deleting a popup.")

(defun flycheck-popup-tip-delete-popup ()
"Delete messages currently being shown if any."
(remove-hook 'pre-command-hook 'flycheck-popup-tip-delete-popup t)
(when (popup-live-p flycheck-popup-tip-object)
(popup-delete flycheck-popup-tip-object))
(remove-hook 'pre-command-hook 'flycheck-popup-tip-delete-popup t))
(popup-delete flycheck-popup-tip-object)
(run-hook-with-args 'flycheck-popup-tip-delete-hook)))

(defun flycheck-popup-tip-format-errors (errors)
"Formats ERRORS messages for display."
Expand All @@ -97,6 +104,7 @@
"Display ERRORS, using popup.el library."
(flycheck-popup-tip-delete-popup)
(when errors
(run-hook-with-args 'flycheck-popup-tip-show-hook)
(setq flycheck-popup-tip-object
(popup-tip
(flycheck-popup-tip-format-errors errors)
Expand Down

0 comments on commit 558e6e4

Please sign in to comment.