本文介绍了组织模式-如何使用org-capture创建新文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个组织捕获模板,该模板创建一个动态文件名以便在emacs组织模式下捕获.

I want to create an org-capture template that create a dynamic file name for capture in emacs org-mode.

我希望文件名采用以下格式:(格式时间字符串%Y-%m-%d")-"(提示输入名称).txt"

I want that the name of the file takes the following form:(format-time-string "%Y-%m-%d") "-" (prompt for a name) ".txt"

示例:2012-08-10-MyNewFile.txt

Example : 2012-08-10-MyNewFile.txt

基于答案,我知道如何动态创建包含日期的文件名称:

Based on this answer, I know how to dynamically create the name the file to include the date:

`(defun capture-report-date-file (path)
(expand-file-name (concat path (format-time-string "%Y-%m-%d") ".txt")))

'(("t" "todo" entry (file (capture-report-date-file  "~/path/path/name"))
"* TODO")))

这使我可以创建文件2012-08-10.txt并在第一行插入* TODO

This allows me to create a file 2012-08-10.txt and to insert * TODO at the first line

如何添加提示以完成文件名?

How could I add a prompt to complete the file name?

推荐答案

您必须在 capture-report-data-file 即时生成文件名.

You'll have to use (read-string ...) in capture-report-data-file to generate the filename on the fly.

(defun capture-report-data-file (path)
  (let ((name (read-string "Name: ")))
    (expand-file-name (format "%s-%s.txt"
                              (format-time-string "%Y-%m-%d")
                              name) path)))

'(("t"
   "todo"
   entry
   (file (capture-report-date-file  "~/path/path/name"))
   "* TODO")))

这将在捕获时提示输入文件名,然后将打开捕获缓冲区.

This will prompt on capture for the file name, and then open the capture buffer will be created.

这篇关于组织模式-如何使用org-capture创建新文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 03:44