捕获组织议程并在动态块中显示一些输入文本

问题描述 投票:0回答:1

总而言之,我想用某些输入文本将org-agenda捕获到动态块中。

[在本周结束时,我会提供一份关于我一直在做什么的报告,以及一份我打算在下周进行的工作清单。为了列出我一直在做什么,我使用clocktable来显示我花费的时间。对于尚要做的事情,我使用了一个自定义的议程视图,该视图捕获特定的标签并按优先级对列表进行排序。对于这两项任务,我一直在手动将clocktable和议程中的项目复制到我的报告中。

因此,如何在报告缓冲区中自动创建org-agenda块?

emacs org-mode
1个回答
0
投票

对于第二部分(插入组织议程),这是我想出的,我想知道是否还有其他方法?使用组织版本9.3.6。

#+begin_src emacs-lisp
(defun org-dblock-write:sjm/org-insert-agenda (params)
  "Writes agenda items with some some text from the entry as context to dynamic block.
Parameters are:

:key

  If key is a string of length 1, it is used as a key in
  `org-agenda-custom-commands` and triggers this command.
  If it is a longer string it is used as a tags/todo match string.

:leaders

  String to place before context text.  Do not use \"* \"!
  Defaults to \"  \"

:replace-star

  String to replace the org-heading star with.
  Defaults to \"- \" such that headings become list items.

Somewhat adapted from org-batch-agenda.
"
  (let ((data)
    (cmd-key (or (plist-get params :key) "b"))
    (org-agenda-buffer-name (or (plist-get params :temp) "*SJM/org-dynamic-buffer*"))
    (org-agenda-entry-text-leaders (or (plist-get params :leaders) "  "))
    (replace-star (or (plist-get params :replace-star) "- "))
    (org-agenda-sticky))
    (save-excursion
      (if (> (length cmd-key) 1)
      (org-tags-view nil cmd-key)
    (org-agenda nil cmd-key))
      (with-current-buffer org-agenda-buffer-name
    (setq data (buffer-string))
    (with-temp-buffer
      (insert data)
      (goto-char (point-max))
      (beginning-of-line 1)
      (while (not (bobp))
        (when (org-get-at-bol 'org-hd-marker)
          (sjm/org-agenda-entry-text))
        (beginning-of-line 0))
      (setq data (buffer-string))))
      (kill-buffer org-agenda-buffer-name)) ; Not needed now.
    (insert (replace-regexp-in-string "^\\* [A-Z-]* " replace-star data))))

                    ;
(defun sjm/org-agenda-entry-text ()
  "Add some text from the entry as context to the current line.
Adapted from `org-agenda-entry-text-show-here."
  (save-excursion
    (let (m txt o)
    (setq m (org-get-at-bol 'org-hd-marker))
    (unless (marker-buffer m)
      (error "No marker points to an entry here"))
    (setq txt (concat "\n" (org-no-properties
                (org-agenda-get-some-entry-text
                 m org-agenda-entry-text-maxlines
                 org-agenda-entry-text-leaders))))
    (when (string-match "\\S-" txt)
      (forward-line 1)
      (insert txt "\n\n")))))
#+end_src

我还没有真正看过第一部分。

© www.soinside.com 2019 - 2024. All rights reserved.