虽然我看到了很多有关归档子树的SO问题,但我每天都使用org-journal创建一个带有模板(例如select distinct o.part, o.cat, o.product, o.qty,
o.date_order, o.date_due, o.date_done,
julianday(date_due) - julianday(date_order) as days_due,
qs.stockQuantity as qty_stock
from orders as o
join stock as s on o.part = s.part
left join (select stock.part, sum(stock.qty) stockQuantity
from stock ss
join orders oo on ss.part = oo.part
where ss.location = 'stock' and oo.status = 1
group by stock.part
) qs on qs.part = o.part
where o.status = 1
order by o.date_due asc, o.product asc, o.part asc
)的每日文件,然后将其记录在为个人,工作或您所拥有的东西预先设计的结构,它们经历了各种状态,直到2018-09-14.org
或被取消DONE
为止(我发现这种方法很适合我,因为它也使我在视觉上在议程视图中查看任务自启动以来已经挂了多长时间了。
我正在尝试编写一个交互式函数,该函数:
KILL
和TODO
或DONE
(或不存在),则KILL
(开始看到议程变慢会导致使用组织模式5个月)。
我假设其他人已经在使用类似的方法(因为emacs),但我想知道是否有人可以指出我类似的功能或方法,这有助于解决这一问题。到目前为止,在骨盘上谷歌搜索和敲打一直是徒劳的。
===一个月后=== 好吧,自学些口齿帮助了我,但现在我可以使用这3个独立函数了,但是由于某种原因在调用最终函数时出现了错误。
但是,在第28行上我收到一个错误的函数,该函数无效:调用whatever.org_archive
时。如果某人可以看到问题所在,则可以解决我的用例(也可能是其他人的原因,这就是我将其粘贴回此处的原因。)。
rename-file-buffer-to-org-archive
答案 0 :(得分:0)
所以,最后,这就是我解决的方法。我敢肯定,这里有优化和重构,但是如果您需要弄清楚的话,这肯定是可行的并且是合理的模块化。只需在archive-done-org-journal-files中为您的org-file更改您使用的目录(我的目录在Dropbox中),这应该对您有用。我强烈建议您根据实际功能在~/Desktop/test_archives/
目录的测试存档上对此进行测试,以确保您可以确保它如所宣传的那样工作。 YMMV。希望它能对某人有所帮助!
(defun archive-done-org-journal-files ()
"Cycles all org files through checking function."
(interactive)
(save-excursion
(mapc 'check-org-file-finito (directory-files "~/Desktop/test_archives/" t ".org$"))
))
(defun check-org-file-finito (f)
"Checks TODO keyword items are DONE then archives."
(interactive)
(find-file f)
;; Shows open Todo items whether agenda or todo
(let (
(kwd-re
(cond (org-not-done-regexp)
(
(let ((kwd
(completing-read "Keyword (or KWD1|KWD2|...): "
(mapcar #'list org-todo-keywords-1))))
(concat "\\("
(mapconcat 'identity (org-split-string kwd "|") "\\|")
"\\)\\>")))
((<= (prefix-numeric-value) (length org-todo-keywords-1))
(regexp-quote (nth (1- (prefix-numeric-value))
org-todo-keywords-1)))
(t (user-error "Invalid prefix argument: %s")))))
(if (= (org-occur (concat "^" org-outline-regexp " *" kwd-re )) 0)
(rename-file-buffer-to-org-archive)
(kill-buffer (current-buffer))
)))
(defun rename-file-buffer-to-org-archive ()
"Renames current buffer and file it's visiting."
(interactive)
(let ((name (buffer-name))
(filename (buffer-file-name))
)
(if (not (and filename (file-exists-p filename)))
(error "Buffer '%s' is not visiting a file!" name)
(let ((new-name (concat (file-name-sans-extension filename) ".org_archive")))
(if (get-buffer new-name)
(error "A buffer named '%s' already exists!" new-name)
(rename-file filename new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil)
(kill-buffer (current-buffer))
(message "File '%s' successfully archived as '%s'."
name (file-name-nondirectory new-name)))))))