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:
parent
196638bf47
commit
30f1f8ab0c
1 changed files with 10 additions and 5 deletions
|
@ -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))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue