I want to create an org-capture template that create a dynamic file name for capture in emacs org-mode.
I want that the name of the file takes the following form: (format-time-string "%Y-%m-%d") "-" (prompt for a name) ".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")))
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?
The easiest way to create a table is to directly type the "|" character at the beginning of a line, or after any amount of white space. This will put you in the first field of an atomic table. Once you've finished editing this cell, you can jump to the next one by pressing TAB .
org-capture is a way to take notes in Emacs in an unobstructive way. It allows you to open a buffer to enter a note and it'll store it in the correct place based on the type of note you've selected. I must say that I took the term note from it's documentation, but I think that it's a very loose definition of the word.
vim is a minimal Org mode and Outline mode plugin for Vim providing only syntax highlighting and folding. This plugin aims to replicate Vim's existing Markdown editing experience on Org mode (and Outline mode) files, rather than trying to be a full featured Org mode plugin—that is what Emacs is for.
Org mode is routinely used to build and manage complex workflows. It does this using an elegantly simple syntax that scales from basic markup to full LaTeX typesetting and from plain text notes to literate programs. Everything you need to get started is demonstrated in the example.
You'll have to use (read-string ...)
in capture-report-data-file
to generate the filename on the fly.
(defun capture-report-date-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.
I use below template & function to create new file.
(defun psachin/create-notes-file ()
"Create an org file in ~/notes/."
(interactive)
(let ((name (read-string "Filename: ")))
(expand-file-name (format "%s.org"
name) "~/notes/")))
(setq org-capture-templates
'(("n" "Notes" entry
(file psachin/create-notes-file)
"* TITLE%?\n %U")))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With