Aqui está uma função elisp rápida e imunda que pode ser modificada como você desejar.
(defun subtree-to-new-file ()
(interactive)
"sloppily assists in moving an org subtree to a new file"
(org-copy-subtree nil t)
;;; This long setq statement gets the title of the first heading, to use as a default filename for the new .org file.
(setq first-heading
(with-temp-buffer
(yank)
(beginning-of-buffer)
(search-forward " " nil nil 1)
(setq title-start (point))
(end-of-visual-line)
(setq title-end (point))
(setq first-heading (buffer-substring title-start title-end))
))
(setq def-filename (concat first-heading ".org"))
(let ((insert-default-directory t))
(find-file-other-window
(read-file-name "Move subtree to file:" def-filename)
))
(org-paste-subtree)
;;; this final command adds the new .org file to the agenda
(org-agenda-file-to-front)
)
Você pode dar uma rápida tentativa a este código colando no seu *scratch* buffer e pressionando Ctrl + j . Em seguida, vá para uma subárvore em um arquivo de modo de organização e pressione Alt + x para M-x subtree-to-new-file .
Se você quer que ele esteja no lugar toda vez que você usa o emacs e é completamente não familiarizado com o elisp, o mais fácil é colar esse código em algum lugar no arquivo de configuração .emacs e salvá-lo. Você também pode adicionar uma linha antes ou depois da função para dar uma atadura de teclado. A maneira mais fácil de fazer isso (mas talvez não seja a melhor) seria algo como: (global-set-key "\C-xw" 'subtree-to-new-file) .