tools/wakatime: fix lazy loader

Also the cause of errors during package management, because
after-find-file was being advised too early.

Reported by @freddian
This commit is contained in:
Henrik Lissner 2018-06-24 22:33:30 +02:00
parent 196638bf47
commit 30f1f8ab0c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -4,10 +4,7 @@
"Where the wakatime api key is cached.") "Where the wakatime api key is cached.")
;;;###autoload ;;;###autoload
(add-hook 'doom-after-switch-buffer-hook #'+wakatime|autostart) (add-hook 'doom-post-init-hook #'+wakatime|delayed-autostart)
;;;###autoload
(advice-add 'after-find-file :before #'wakatime|autostart)
;;;###autoload ;;;###autoload
(defun +wakatime/setup () (defun +wakatime/setup ()
@ -40,5 +37,13 @@ warning)."
(global-wakatime-mode +1) (global-wakatime-mode +1)
(message "wakatime-mode isn't set up. Run `M-x +wakatime/start' to do so (only necessary once).")) (message "wakatime-mode isn't set up. Run `M-x +wakatime/start' to do so (only necessary once)."))
;; ;;
(remove-hook 'doom-after-switch-buffer-hook #'+wakatime|autostart) (remove-hook 'doom-before-switch-buffer-hook #'+wakatime|autostart)
(advice-remove 'after-find-file #'wakatime|autostart)) (advice-remove 'after-find-file #'wakatime|autostart))
;;;###autoload
(defun +wakatime|delayed-autostart (&rest _)
"Lazily initialize `wakatime-mode' until the next time you switch buffers or
open a file."
(add-hook 'doom-before-switch-buffer-hook #'+wakatime|autostart)
;; this is necessary in case the user opens emacs with file arguments
(advice-add 'after-find-file :before #'wakatime|autostart))