Update wakatime-mode

It still has a small bug, but it will be corrected soon!
This commit is contained in:
Gergely Polonkai
2016-10-03 13:42:16 +02:00
parent 9518507c49
commit d3a225a59e
5 changed files with 58 additions and 37 deletions

View File

@@ -1 +0,0 @@
(define-package "wakatime-mode" "20160417.109" "Automatic time tracking extension for WakaTime" 'nil :keywords '("calendar" "comm"))

View File

@@ -1,10 +1,10 @@
;;; wakatime-mode-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))
(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "wakatime-mode" "wakatime-mode.el" (22297 21797
;;;;;; 788718 327000))
;;;### (autoloads nil "wakatime-mode" "wakatime-mode.el" (22510 25032
;;;;;; 328539 79000))
;;; Generated autoloads from wakatime-mode.el
(autoload 'wakatime-mode "wakatime-mode" "\
@@ -13,8 +13,9 @@ Toggle WakaTime (WakaTime mode).
\(fn &optional ARG)" t nil)
(defvar global-wakatime-mode nil "\
Non-nil if Global-Wakatime mode is enabled.
See the command `global-wakatime-mode' for a description of this minor mode.
Non-nil if Global Wakatime mode is enabled.
See the `global-wakatime-mode' command
for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `global-wakatime-mode'.")
@@ -23,7 +24,7 @@ or call the function `global-wakatime-mode'.")
(autoload 'global-wakatime-mode "wakatime-mode" "\
Toggle Wakatime mode in all buffers.
With prefix ARG, enable Global-Wakatime mode if ARG is positive;
With prefix ARG, enable Global Wakatime mode if ARG is positive;
otherwise, disable it. If called from Lisp, enable the mode if
ARG is omitted or nil.

View File

@@ -0,0 +1,2 @@
;;; -*- no-byte-compile: t -*-
(define-package "wakatime-mode" "20160929.624" "Automatic time tracking extension for WakaTime" 'nil :keywords '("calendar" "comm"))

View File

@@ -6,7 +6,7 @@
;; Maintainer: Alan Hamlett <alan@wakatime.com>
;; Website: https://wakatime.com
;; Keywords: calendar, comm
;; Package-Version: 20160417.109
;; Package-Version: 20160929.624
;; Version: 1.0.2
;; This program is free software; you can redistribute it and/or modify
@@ -83,9 +83,6 @@
(defun wakatime-init ()
(unless wakatime-init-started
(setq wakatime-init-started t)
(when (or (not wakatime-api-key) (string= "" wakatime-api-key))
(wakatime-prompt-api-key)
)
(when (null wakatime-cli-path)
(customize-set-variable 'wakatime-cli-path
(wakatime-guess-actual-script-path (executable-find "wakatime")))
@@ -142,25 +139,32 @@
(= (condition-case nil (call-process location nil nil nil "--version") (error 1)) 0)
)
(defun wakatime-client-command (savep)
(defun wakatime-client-command (savep &optional dont-use-key)
"Return client command executable and arguments.
Set SAVEP to non-nil for write action."
(format "%s %s --file \"%s\" %s --plugin %s/%s --key %s --time %.2f"
wakatime-python-bin
wakatime-cli-path
(buffer-file-name (current-buffer))
(if savep "--write" "")
wakatime-user-agent
wakatime-version
wakatime-api-key
(float-time)
Set SAVEP to non-nil for write action.
Set DONT-USE-KEY to t if you want to omit --key from the command
line."
(let ((key (if dont-use-key
(format "--key %s" wakatime-api-key)
"")))
(format "%s %s --file \"%s\" %s --plugin %s/%s %s --time %.2f"
wakatime-python-bin
wakatime-cli-path
(buffer-file-name (current-buffer))
(if savep "--write" "")
wakatime-user-agent
wakatime-version
key
(float-time)
)
)
)
(defun wakatime-call (command)
"Call WakaTime COMMAND."
(defun wakatime-call (savep &optional retrying)
"Call WakaTime command."
(let*
(
(command (wakatime-client-command savep t))
(process-environment (if wakatime-python-path
(cons (format "PYTHONPATH=%s" wakatime-python-path) process-environment)
process-environment))
@@ -176,15 +180,25 @@
)
(set-process-sentinel process
(lambda (process signal)
(when (memq (process-status process) '(exit signal))
(kill-buffer (process-buffer process))
(let ((exit-status (process-exit-status process)))
(when (and (not (= 0 exit-status)) (not (= 102 exit-status)))
(error "WakaTime Error (%s)" exit-status)
)
)
)
`(lambda (process signal)
(when (memq (process-status process) '(exit signal))
(kill-buffer (process-buffer process))
(let ((exit-status (process-exit-status process)))
(when (and (not (= 0 exit-status)) (not (= 102 exit-status)))
(error "WakaTime Error (%s)" exit-status)
)
(when (= 102 exit-status)
; If we are retrying already, error out
(if retrying
(error "WakaTime Error (%s)" exit-status)
; otherwise, ask for an API key and call ourselves
; recursively
(wakatime-prompt-api-key)
(wakatime-call savep t)
)
)
)
)
)
)
@@ -195,12 +209,12 @@
(defun wakatime-ping ()
"Send ping notice to WakaTime."
(when (buffer-file-name (current-buffer))
(wakatime-call (wakatime-client-command nil))))
(wakatime-call nil)))
(defun wakatime-save ()
"Send save notice to WakaTime."
(when (buffer-file-name (current-buffer))
(wakatime-call (wakatime-client-command t))))
(wakatime-call t)))
(defun wakatime-bind-hooks ()
"Watch for activity in buffers."
@@ -235,6 +249,12 @@
(wakatime-unbind-hooks)
)
(defun wakatime-validate-api-key (key)
"Check if the provided key is a valid API key."
(not (not (string-match "^[[:xdigit:]]\\{32\\}$"
(replace-regexp-in-string "-" "" key)))))
;;;###autoload
(define-minor-mode wakatime-mode
"Toggle WakaTime (WakaTime mode)."