tools/wakatime: conform to new conventions

This commit is contained in:
Henrik Lissner 2019-07-23 00:01:13 +02:00
parent 38d06446ba
commit 271920b42a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -7,7 +7,7 @@
"If non-nil, obfuscate files and only show what projects you're working on.") "If non-nil, obfuscate files and only show what projects you're working on.")
;;;###autoload ;;;###autoload
(add-hook 'doom-init-modules-hook #'+wakatime|delayed-autostart) (add-hook 'doom-init-modules-hook #'+wakatime-delayed-autostart-h)
;;;###autoload ;;;###autoload
(defun +wakatime/setup () (defun +wakatime/setup ()
@ -32,7 +32,7 @@ changes."
(message "Wakatime enabled. You're good to go!"))) (message "Wakatime enabled. You're good to go!")))
;;;###autoload ;;;###autoload
(defun +wakatime|autostart (&rest _) (defun +wakatime-autostart-h (&rest _)
"Initialize wakatime (if `wakatime-api-key' is set, otherwise no-op with a "Initialize wakatime (if `wakatime-api-key' is set, otherwise no-op with a
warning)." warning)."
(interactive) (interactive)
@ -44,22 +44,22 @@ warning)."
(make-directory +wakatime-home t))) (make-directory +wakatime-home t)))
(global-wakatime-mode +1)) (global-wakatime-mode +1))
;; ;;
(remove-hook 'doom-switch-buffer-hook #'+wakatime|autostart) (remove-hook 'doom-switch-buffer-hook #'+wakatime-autostart-h)
(advice-remove 'after-find-file #'+wakatime|autostart)) (advice-remove 'after-find-file #'+wakatime-autostart-h))
;;;###autoload ;;;###autoload
(defun +wakatime|delayed-autostart (&rest _) (defun +wakatime-delayed-autostart-h (&rest _)
"Lazily initialize `wakatime-mode' until the next time you switch buffers or "Lazily initialize `wakatime-mode' until the next time you switch buffers or
open a file." open a file."
(add-hook 'doom-switch-buffer-hook #'+wakatime|autostart) (add-hook 'doom-switch-buffer-hook #'+wakatime-autostart-h)
;; this is necessary in case the user opens emacs with file arguments ;; this is necessary in case the user opens emacs with file arguments
(advice-add 'after-find-file :before #'+wakatime|autostart)) (advice-add 'after-find-file :before #'+wakatime-autostart-h))
(defun +wakatime*append-options (ret) (def-advice! +wakatime-append-options-a (ret)
"Modifies the wakatime command string so that `+wakatime-hide-filenames' and "Modifies the wakatime command string so that `+wakatime-hide-filenames' and
`+wakatime-home' are respected." `+wakatime-home' are respected."
:filter-return #'wakatime-client-command
(concat (when +wakatime-home (concat (when +wakatime-home
(format "WAKATIME_HOME=%s " (shell-quote-argument +wakatime-home))) (format "WAKATIME_HOME=%s " (shell-quote-argument +wakatime-home)))
ret ret
(if +wakatime-hide-filenames " --hide-filenames"))) (if +wakatime-hide-filenames " --hide-filenames")))
(advice-add #'wakatime-client-command :filter-return #'+wakatime*append-options)