18 March 2017
➜ brew install wakatime-cli

homebrew 安装的 wakatime 在 Mac 下的 emacs 下一直有一个报错

error in process sentinel: WakaTime Error (1)

一开始的配置是

(require 'wakatime-mode)

(setq
 wakatime-api-key "xxxxxx"
 wakatime-cli-path "/usr/local/bin/wakatime"
 wakatime-python-bin "/usr/local/bin/python"
 wakatime-python-path "/usr/local/bin/python"
 )

(global-wakatime-mode)

在 emacs 下的配置应该是这样的

(require 'wakatime-mode)

(setq wakatime-api-key "xxxxxx")

(global-wakatime-mode)

不必设置 cli-path 等变量,wakatime-mode.el 里面有自动判断

(defun wakatime-guess-actual-script-path (path)
  (let ((true-path (file-truename path)))
    (cond
     ...
     ((string-match-p "Cellar" true-path)  ; Homebrew
      (let* ((libexec (format "%slibexec/" (file-name-directory (directory-file-name (file-name-directory true-path)))))
             (python-path (format "%slib/python2.7/site-packages" libexec)))
        (setq wakatime-python-path python-path)
        (format "%sbin/wakatime" libexec)))
     (t path))))

(defun wakatime-init ()
  ...
  (when (null wakatime-cli-path)
    (customize-set-variable 'wakatime-cli-path
                            (wakatime-guess-actual-script-path (executable-find "wakatime"))))
  )