问题描述
我正在使用https://github.com/mbork/org-toggl来跟踪我的时间。这对于每个日志条目一个简单的标题来说非常有用。
选择该组合的原因是我可以通过电话应用程序添加切换项。否则,组织当然就足够了。
工作时,我经常遇到以下问题:
当前,我无法轻松更新切换项: 我停止计时,将另一个条目添加到组织日志中并登录。然后,我在org和toggl Web应用程序中手动更新时间条目。
为了优化,我测试了以下内容:
(defun toggl-start-time-entry (description &optional pid show-message pt)
"Start Toggl time entry."
(interactive "MDescription: \ni\np")
(setq pid (or pid toggl-default-project))
(toggl-request-post
"time_entries/start"
(json-encode `(("time_entry" .
(("description" .,description)
("pid" .,pid)
("created_with" . "mbork's Emacs toggl client")))))
nil
(cl-function
(lambda (&key data pt &allow-other-keys)
(setq toggl-current-time-entry data)
(org-entry-put pt "toggl-id" (number-to-string (alist-get 'id (alist-get 'data toggl-current-time-entry))))
(when show-message (message "Toggl time entry started."))))
(cl-function
(lambda (&key error-thrown &allow-other-keys)
(when show-message (message "Starting time entry Failed because %s" error-thrown))))))
(defun org-toggl-update-clock ()
"Update time of heading at point."
(interactive)
(let* ((heading (substring-no-properties (org-get-heading t t t t)))
(project (org-entry-get (point) "toggl-project" org-toggl-inherit-toggl-properties))
(pid (toggl-get-pid project))
(toggl-entry-id (org-entry-get (point) "toggl-id" org-toggl-inherit-toggl-properties)))
(if toggl-entry-id (toggl-update-time-entry heading toggl-entry-id pid t (point))
(message "No toggle-entry-id found. No action..."))))
(defun toggl-update-time-entry (description toggle-entry-id &optional pid show-message pt)
"Update Toggl time entry. Only possible if toggl-id is present."
(interactive)
(setq pid (or pid toggl-default-project))
(toggl-request-put
(concat "time_entries/" toggle-entry-id)
(json-encode `(("time_entry" .
(("description" .,pid)
("created_with" . "mbork's Emacs toggl client")))))
nil
(cl-function
(lambda (&key data pt &allow-other-keys)
(setq toggl-current-time-entry data)
(org-entry-put pt "toggl-id" (number-to-string (alist-get 'id (alist-get 'data toggl-current-time-entry))))
(when show-message (message "Toggl time entry updated."))))
(cl-function
(lambda (&key error-thrown &allow-other-keys)
(when show-message (message "Updating time entry Failed because %s" error-thrown))))))
由于我不是一位精打细算的专业人士-我现在面临多个问题:
- 我的代码仅适用于同一标题的单个时钟条目。因此,使用我的代码,我只能为现有条目更新项目和标题。
- 我想使用C-c C-c钩子更新时钟条目-为此,我需要解析LOGBOOK抽屉,并在日志中的时钟条目和toggl-id之间建立独特的关系。 我发现这里有“插入抽屉”-是否有类似的API从时钟条目中获取时间等信息,并以相同的顺序添加具有相应toggl-id的抽屉?
Thx
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)