比如在使用 C-u C-c . 这样的命令,或者capture模板中的 %^T 时,能不能自动让分钟的个位数只使用5分钟的跨度?
不清楚 Org 有没有内置的方法。以下代码能得到你说的格式(向下取整,第 4 分也算作 0),还没考虑过如何跟 Org 整合。
(format-time-string "<%Y-%m-%d %a %H:%M>")
;; => "<2018-04-12 Thu 17:21>"
(concat (format-time-string "<%Y-%m-%d %a %H:")
(thread-first (format-time-string "%M")
(string-to-number)
(/ 5)
(* 5)
(number-to-string))
">")
;; => "<2018-04-12 Thu 17:20>"
1 个赞
thread-first
是 Emacs 25.1 在 subr-x.el
中引入的,而且你得先 (require 'subr-x)
才能使用。
此外,这段代码只是返回你说的时间,加到配置里也什么用。
1 个赞
好像是不起作用。
能否分享下您的org相关的配置,让我等学习一下? 我主要想了解下agenda中的clock in/out 能不能按照日期累计,很多活不必要累计为几小时几分钟,能统计到几天就足够了。
我只是个“普通人”使用emacs了。 不好意思了,我并没有这样的配置。 我使用的场景是工作上有非常多的琐碎事件,我基本只是拿来当作记事提醒来用的。
> ;; init-org
>
> ;; org-mode
> (global-set-key (kbd "C-c c") 'org-capture)
> (global-set-key (kbd "C-c l") 'org-store-link)
> (global-set-key (kbd "C-c a") 'org-agenda)
> (global-set-key (kbd "C-c b") 'org-iswitchb)
>
> ;; chinese can truncate lines in org mode
> (add-hook 'org-mode-hook
> (lambda () (setq truncate-lines nil)))
>
> ;; to turn on native code fontification in org buffer
> (setq org-src-fontify-natively t)
>
> ;; calendar
> (setq calendar-week-start 1)
>
> ;; TODO KEYWORDS
> (setq org-todo-keywords
> '((sequence "TODO(t!)" "START(s!)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@/!)" "ABORT(a@/!)")))
> (setq org-todo-keyword-faces
> '(("TODO" . (:foreground "blue" :weight bold))
> ("START" . (:foreground "green" :weight bold))
> ("WAIT" . (:foreground "magenta" :weight bold))
> ("DONE" . (:foreground "orange" :weight bold))
> ("CANCELED" . (:foreground "gray30" :weight bold))
> ("ABORT" . (:foreground "black" :weight bold))
> ))
>
> ;; TODO PRIORITY
> (setq org-highest-priority ?A)
> (setq org-lowest-priority ?C)
> (setq org-default-priority ?C)
> (setq org-priority-faces
> '((?A . (:foreground "red" :weight bold))
> (?B . (:foreground "magenta" :weight bold))
> (?C . (:foreground "blue" :weight bold))
> ))
>
> ;; TODO TAGS
> (setq org-tag-alist '((:startgroup . nil)
> ("@work" . ?w) ("@home" . ?h) ("@openair" . ?o)
> (:endgroup . nil)
> (:startgroup . nil)
> ("@personal" . ?p) ("@group" . ?g)
> (:endgroup . nil)))
>
> ;; org-tim-stamp-rounding-minutes
> (setq org-time-stamp-rounding-minutes '(5 5))
>
> ;; org capture
>
> (setq org-default-notes-file "~/org/.notes.org")
> (setq bookmark-default-file "~/org/bookmarks")
>
> (setq org-directory "~/org")
>
> (setq org-capture-templates nil)
>
> (add-to-list 'org-capture-templates
> '("a" "Attendance" table-line
> (file+headline "attendance.org" "Attendance")
> " | %^u | %^g | %^{Note} |"))
>
> (add-to-list 'org-capture-templates
> '("c" "Contacts" table-line
> (file+headline "secretive.org" "Contacts")
> " | %u | %^{Name} | %^{Phone} | %^{E-mail} | %^{Address} | %^{Note} | "))
>
> (add-to-list 'org-capture-templates
> '("p" "Password" table-line
> (file+headline "secretive.org" "Password")
> " | %u | %^{Title} | %^{User} | %^{Password} | %^{Note} |"))
>
> (add-to-list 'org-capture-templates
> '("td" "Tasks with DEADLINE" entry
> (file+headline "gtd.org" "Tasks")
> "* TODO [#C] %^{Title} %^g\n\ DEADLINE:%^T\n"
> :empty-lines 2))
> (add-to-list 'org-capture-templates
> '("ts" "Tasks with SCHEDULED" entry
> (file+headline "gtd.org" "Tasks")
> "* TODO [#C] %^{Title} %^g\n SCHEDULED:%^T\n"
> :empty-lines 2))
> (add-to-list 'org-capture-templates
> '("tc" "Tasks custom" entry
> (file+headline "gtd.org" "Tasks")
> "* TODO [#C] %^{Title} %^g\n %^T\n"
> :empty-lines 2))
> (add-to-list 'org-capture-templates '("t" "Tasks"))
>
> (add-to-list 'org-capture-templates
> '("n" "Notes" entry
> (file+headline "notes.org" "Notes")
> "* %? %^g\n%U"
> :empty-lines 2))
>
> (add-to-list 'org-capture-templates
> '("b" "Bookmarks" table-line
> (file+headline "notes.org" "Bookmarks")
> " | %U | %^g | [[%x][%^{link description}]] |"))
>
> (add-to-list 'org-capture-templates
> '("j" "Journal" entry
> (file+datetree "journal.org")
> "* %?\n"
> :empty-lines 2))
>
> (add-to-list 'org-capture-templates
> '("i" "Inbox" entry
> (file+headline "inbox.org" "Inbox")
> "* %? \n%^U\n"
> :empty-lines 2))
>
> ;; agenda files
> (setq org-agenda-files (list "~/org/"))
>
> ;; progress record
> (setq org-log-done 'time)
> (setq org-log-done 'note)
>
> ;; Switch entry to DONE when all subentries are done, to TODO otherwise.
> (defun org-summary-todo (n-done n-not-done)
> (let (org-log-done org-log-states) ; turn off logging
> (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
> (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
>
> ;; if subtask is not set to DONE , the master task cannot be set to DONE
> (setq org-enforce-todo-dependencies t)
>
> ;; archive
> (setq org-archive-location "~/org/archive.org::* From %s")
>
> ;; refiling
> (setq org-refile-targets (quote (("~/org/inbox.org" :level . 1)
> ("~/org/gtd.org" :level . 1)
> ("~/org/notes.org" :level . 1))))
>
> ;; Save all org buffers after each refile operation
> (defadvice org-refile (after save-all-after-refile activate)
> "Save all org buffers after each refile operation."
> (org-save-all-org-buffers))
>
> ;; org-agenda-custom-commans
> (setq org-agenda-custom-commands
> '(("P" . "Tasks Priorities")
> ("PA" "A items" tags-todo "+PRIORITY=\"A\"")
> ("PB" "B items" tags-todo "+PRIORITY=\"B\"")
> ("PC" "C items" tags-todo "+PRIORITY=\"C\"")))
>
> ;; end
>
> (provide 'init-org)
1 个赞