tools/wakatime: add +wakatime-home variable
And fix 'wakatime-mode isn't setup' message referencing +wakatime/start instead of +wakatime/setup.
This commit is contained in:
parent
ca1b9ac1bd
commit
71922937ff
1 changed files with 17 additions and 8 deletions
|
@ -1,5 +1,8 @@
|
||||||
;;; tools/wakatime/autoload.el -*- lexical-binding: t; -*-
|
;;; tools/wakatime/autoload.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
(defvar +wakatime-home (concat doom-cache-dir "wakatime/")
|
||||||
|
"Path to the directory where wakatime files are stored.")
|
||||||
|
|
||||||
(defvar +wakatime-api-file (concat doom-cache-dir "wakatime.el")
|
(defvar +wakatime-api-file (concat doom-cache-dir "wakatime.el")
|
||||||
"Where the wakatime api key is cached.")
|
"Where the wakatime api key is cached.")
|
||||||
|
|
||||||
|
@ -40,9 +43,12 @@ warning)."
|
||||||
(interactive)
|
(interactive)
|
||||||
(unless (bound-and-true-p wakatime-api-key)
|
(unless (bound-and-true-p wakatime-api-key)
|
||||||
(ignore-errors (load +wakatime-api-file t t)))
|
(ignore-errors (load +wakatime-api-file t t)))
|
||||||
(if (bound-and-true-p wakatime-api-key)
|
(if (not (bound-and-true-p wakatime-api-key))
|
||||||
(global-wakatime-mode +1)
|
(message "wakatime-mode isn't set up. Run `M-x +wakatime/setup' to do so.")
|
||||||
(message "wakatime-mode isn't set up. Run `M-x +wakatime/start' to do so."))
|
(when +wakatime-home
|
||||||
|
(unless (file-directory-p +wakatime-home)
|
||||||
|
(make-directory +wakatime-home t)))
|
||||||
|
(global-wakatime-mode +1))
|
||||||
;;
|
;;
|
||||||
(remove-hook 'doom-before-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))
|
||||||
|
@ -55,8 +61,11 @@ open a file."
|
||||||
;; 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))
|
||||||
|
|
||||||
(defun +wakatime*append-hide-filenames-option (ret)
|
(defun +wakatime*append-options (ret)
|
||||||
"Enables filename obfuscation in wakatime if `+wakatime-hide-filenames' is
|
"Modifies the wakatime command string so that `+wakatime-hide-filenames' and
|
||||||
non-nil."
|
`+wakatime-home' are respected."
|
||||||
(concat ret (if +wakatime-hide-filenames " --hide-filenames")))
|
(concat (when +wakatime-home
|
||||||
(advice-add #'wakatime-client-command :filter-return #'+wakatime*append-hide-filenames-option )
|
(format "WAKATIME_HOME=%s " (shell-quote-argument +wakatime-home)))
|
||||||
|
ret
|
||||||
|
(if +wakatime-hide-filenames " --hide-filenames")))
|
||||||
|
(advice-add #'wakatime-client-command :filter-return #'+wakatime*append-options)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue