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)."

View File

@ -68,7 +68,7 @@
("e6h" . "http://www.e6h.org/packages/"))))
'(package-selected-packages
(quote
(command-log-mode magithub nyan-prompt zone-nyan helm-google helm-projectile helm-spotify helm-swoop helm-unicode id-manager identica-mode mc-extras multiple-cursors electric-spacing flycheck-clojure flycheck-pkg-config focus git-messenger gitconfig github-notifier gnome-calendar gnugo google helm-chrome helm-company helm-flycheck clojure-quick-repls electric-case emamux flycheck drag-stuff django-manage clojure-mode hyde org-jekyll smart-mode-line-powerline-theme yaml-mode xlicense wakatime-mode vala-mode sass-mode nyan-mode muse markdown-mode mark magit-gerrit json-mode js2-mode jinja2-mode helm-make helm-gtags helm-flyspell helm-ag go-mode gitignore-mode gitconfig-mode git-gutter ggtags fiplr erlang django-mode company-shell company-quickhelp company-c-headers coffee-mode buffer-move ag)))
(wakatime-mode command-log-mode magithub nyan-prompt zone-nyan helm-google helm-projectile helm-spotify helm-swoop helm-unicode id-manager identica-mode mc-extras multiple-cursors electric-spacing flycheck-clojure flycheck-pkg-config focus git-messenger gitconfig github-notifier gnome-calendar gnugo google helm-chrome helm-company helm-flycheck clojure-quick-repls electric-case emamux flycheck drag-stuff django-manage clojure-mode hyde org-jekyll smart-mode-line-powerline-theme yaml-mode xlicense vala-mode sass-mode nyan-mode muse markdown-mode mark magit-gerrit json-mode js2-mode jinja2-mode helm-make helm-gtags helm-flyspell helm-ag go-mode gitignore-mode gitconfig-mode git-gutter ggtags fiplr erlang django-mode company-shell company-quickhelp company-c-headers coffee-mode buffer-move ag)))
'(safe-local-variable-values
(quote
((company-clang-arguments "-I.." "-I/home/polesz/jhbuild/install/include/atk-1.0" "-I/home/polesz/jhbuild/install/include/at-spi-2.0" "-I/home/polesz/jhbuild/install/include/at-spi2-atk/2.0" "-I/home/polesz/jhbuild/install/include/cairo" "-I/home/polesz/jhbuild/install/include/gdk-pixbuf-2.0" "-I/home/polesz/jhbuild/install/include/gio-unix-2.0/" "-I/home/polesz/jhbuild/install/include/glib-2.0" "-I/home/polesz/jhbuild/install/include/gtk-3.0" "-I/home/polesz/jhbuild/install/include/harfbuzz" "-I/home/polesz/jhbuild/install/include/libgda-5.0" "-I/home/polesz/jhbuild/install/include/libgda-5.0/libgda" "-I/home/polesz/jhbuild/install/include/librsvg-2.0" "-I/home/polesz/jhbuild/install/include/libsoup-2.4" "-I/home/polesz/jhbuild/install/include/pango-1.0" "-I/home/polesz/jhbuild/install/include/swe-glib" "-I/home/polesz/jhbuild/install/include/webkitgtk-4.0" "-I/home/polesz/jhbuild/install/lib/glib-2.0/include" "-I/usr/include/dbus-1.0" "-I/usr/include/freetype2" "-I/usr/include/libdrm" "-I/usr/include/libpng16" "-I/usr/include/libxml2" "-I/usr/include/pixman-1" "-I/usr/lib64/dbus-1.0/include")
@ -80,7 +80,6 @@
'(show-trailing-whitespace t)
'(sml/theme (quote powerline))
'(tab-width 4)
'(wakatime-api-key "3f97611e-c959-4ce3-a526-bf0241307e17")
'(wakatime-cli-path "/usr/local/bin/wakatime")
'(zone-nyan-hide-progress t))