简体   繁体   English

Org Capture:确定目标文件时提示信息

[英]Org Capture: prompt for information when determining the target file

I'm looking to build a capture template that, when run, prompts the user for more information to determine the path of the target file.我正在寻找构建一个捕获模板,该模板在运行时会提示用户提供更多信息以确定目标文件的路径。

I have a few pieces already.我已经有几块了。

A function which asks the user for data and returns a string:一个 function 向用户询问数据并返回一个字符串:

(defun my/get-121-orgfile ()
  "Ask the user for the name of the participant so that we can build"
  (interactive)
  (read-string "Participant Name: ")
)

An org-capture-template which will run the prompt successfully when emacs loads:一个org-capture-template将在 emacs 加载时成功运行提示:

(setq org-capture-templates
    `(
      ("m1" "1-1 meetings")
      ("m1b" "prep for a 1-1 meeting" entry
       (file ,(concat "~/org/meetings/1-2-1/" (my/get-121-orgfile) ".org"))
       (file "~/org/templates/meeting-121-prep.org")
       :clock-in t)
))

I took the back quote and comma pattern from this SO answer , but I haven't been able to figure out how to scope this behaviour to when I select the template: I want the prompt to pop up each time I hit <org-capture>m1b .我从这个 SO 答案中取出了反引号和逗号模式,但是当我使用 select 模板时,我无法弄清楚如何 scope 这种行为:我希望每次点击<org-capture>m1b时都会弹出提示<org-capture>m1b

The backquote-comma pattern will not help here: it will call the function at the time that org-capture-template is set.反引号逗号模式在这里没有帮助:它会在设置org-capture-template时调用 function。 What you are trying to do is to call the function when the capture is executed.您要做的是在执行捕获时调用 function 。

The only way I know to do that would to use the (function foo) target mechanism of org-capture-templates .我知道这样做的唯一方法是使用org-capture-templates(function foo)目标机制。 The doc string says:文档字符串说:

 (function function-finding-location) Most general way: write your own function which both visits the file and moves point to the right location

So you would not be able to use the (file...) target as you do above.因此,您将无法像上面那样使用(file...)目标。 Instead you have to write a function that gets all the information you want and then visit the target file at the target location and add the filled-out template.相反,您必须编写一个 function 来获取您想要的所有信息,然后访问目标位置的目标文件并添加填写好的模板。

This is not a complete answer but it was too long for a comment, but maybe it helps to point you in the right direction.这不是一个完整的答案,但评论太长了,但也许它有助于为您指明正确的方向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM