简体   繁体   中英

How can I load an Emacs capture template into an open file?

Please excuse my newness to Emacs Lisp. I started using org-mode and love it. In my workflow, I am trying to load a template into an open buffer or prompt the template to ask for a location to where the file is to be saved.

For example, I have a 'meetings' template. When I call that template, I would like to be prompted for a filename and then the template will be loaded into that file and file will be loaded in Emacs.

How can I do this within Emacs?

This is the best I could come up with so far:

(defun caputre-create-meeting-link ()
  (let ((new-file (read-file-name "Save meeting info in ")))
    (run-with-timer 1 nil (eval `(lambda () (find-file ,new-file))))
     (format "[[%s]]" new-file)))

(setq org-capture-templates
      '(("a" "Insert a link to meeting" plain
         (file "~/org/notes.org")
         "Meeting info: %(caputre-create-meeting-link)"
         :immediate-finish t)))

to more or less get the effect you describe. But you probably could simply substitute %(capture-create-meeting-link) with %^L and then Cc Co on the link to open it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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