Emacs org-mode - how can I override a subtree in a new file?

I support the org file with a lot of project messages ( here is the link to the file ). My workflow is to work on a draft message, and as soon as it is ready to publish, I will copy it into a new org file, which I then push to my Pelican blog .

What I would like to do is use the refile command to help me move the subtree that represents the message to a new message file.

My research led me to a few answers here in stack overflow. I implemented this function:

(require 'org-element)

(defun me/org-file-from-subtree (&optional name)
"Cut the subtree currently being edited and create a new file
from it.

If called with the universal argument, prompt for new filename,
otherwise use the subtree title."
(interactive "P")
(org-back-to-heading)
(let ((filename (cond
               (current-prefix-arg
                (expand-file-name
                 (read-file-name "New file name: ")))
               (t
                (concat
                 (expand-file-name
                  (org-element-property :title
                                        (org-element-at-point))
                  default-directory)
                 ".org")))))
(org-cut-subtree)
(find-file-noselect filename)
(with-temp-file filename
  (org-mode)
  (yank))))

Source: Jonathan Leech-Pepin is responsible here .

, , , . , ?

UPDATE: , . org:

* Drafts
** First Post
Lorem ipsum dolor sit amet, fermentum vulputate laoreet eligendi,[fn:1]
magna wisi elit scelerisque

** Second Post
Ultrices natoque sollicitudin duis curabitur, 
quam pellentesque ante aliquam nulla aenean, 
dui egestas ipsum adipiscing, sem nulla sit nisl, 
parturient[fn:2] habitasse ac amet at eget suspendisse.

* Footnotes

[fn:1] This is a footnote for the first post 

[fn:2] This is a footnote for the second post

, , (fn: 1) .

.

( , emacs - lisp, init..., - )

+4

Source: https://habr.com/ru/post/1617166/


All Articles