Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eros--make-result-overlay doesn't show overlay if called from callback #12

Open
abcdw opened this issue Oct 21, 2023 · 1 comment
Open

Comments

@abcdw
Copy link

abcdw commented Oct 21, 2023

(run-at-time
 1 nil
 (lambda ()
   (eros--make-result-overlay
       "hi"
     :format " => %s"
     :where (point)
     :duration 'command)))

I expect it to show overlay, but it doesn't (the overaly is probably instantly removed by pre-command-hook).

If I set :duration to 2 it works.

@abcdw
Copy link
Author

abcdw commented Oct 21, 2023

The hacky solution:

(defun eros--remove-result-overlay-real ()
  "Remove result overlay from current buffer.

This function also removes itself from `pre-command-hook'."
  (remove-hook 'post-command-hook #'eros--remove-result-overlay-real 'local)
  (remove-overlays nil nil 'category 'result))

(defun eros--remove-result-overlay ()
  "Setup a callback to remove result overlay from current buffer."
  (remove-hook 'pre-command-hook #'eros--remove-result-overlay 'local)
  (add-hook 'post-command-hook #'eros--remove-result-overlay-real nil 'local))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant