1

I use the following function to make a new text file that is named with date and time:

(defun myfun-create-file-by-date ()
  (interactive)
  (find-file (format-time-string "C:/journal/%Y-%m-%d--%H-%M-%S.txt")))
  (global-set-key "\C-cn" ' myfun-create-file-by-date)

How can I add to this code, so it produces a new file with some text added?

I would like a headline with a property drawer like this:

#+STARTUP: content

* my headline

I would like to do this without using the capture-functionality of org-mode, because the capture files so produced are not stored before I push C-c C-c, but then the capture file is closed. This is ok for short notes, but not for files I will work in for hours.

  • insert? insert-file-contents? Depends on what you need. – Drew Sep 5 '17 at 14:47
  • 1
    You might want to rethink your objection to org-capture. You can set the :jump-to-captured property in your org-capture template entry. Then you can finish the capture with C-c C-c after entering minimal info, then carry on working on the entry for hours (or days!) after it has been filed. Alternatively, you can manually jump to the last filed entry with C-u C-u C-c c – deprecated Sep 5 '17 at 14:54
  • @deprecated, thanks! What value to set this property to? I tried with :jump-to-captured: t but it did not jump me back to the file after C-c C-c – myotis Sep 7 '17 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.