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 Jul 29, 2022
1 parent ef86aad commit 3acb11b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion flycheck-popup-tip.el
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,17 @@
(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."
(when (popup-live-p flycheck-popup-tip-object)
(popup-delete flycheck-popup-tip-object))
(popup-delete flycheck-popup-tip-object)
(run-hook-with-args 'flycheck-popup-tip-delete-hook))
(remove-hook 'pre-command-hook 'flycheck-popup-tip-delete-popup t))

(defun flycheck-popup-tip-format-errors (errors)
Expand Down Expand Up @@ -102,6 +109,7 @@
(flycheck-popup-tip-format-errors errors)
:nostrip t
:nowait t))
(run-hook-with-args 'flycheck-popup-tip-show-hook)
(add-hook 'pre-command-hook 'flycheck-popup-tip-delete-popup nil t)))

;;;###autoload
Expand Down

0 comments on commit 3acb11b

Please sign in to comment.