Add acdw/org-export-copy

Better'n `acdw/copy-region-plain'
This commit is contained in:
Case Duckworth 2021-09-15 17:33:49 -05:00
parent 9d67993dd7
commit cbe051fd63
1 changed files with 24 additions and 0 deletions

View File

@ -395,6 +395,30 @@ first."
(setq deactivate-mark t)
nil)
(defun acdw/org-export-copy ()
"copy a tree"
(interactive)
(require 'ox-ascii)
(let ((extracted-heading (acdw/org-extract-heading-text)))
;; Export to ASCII - not async, subtree only, visible-only, body-only
(let ((org-export-show-temporary-export-buffer nil))
(org-ascii-export-as-ascii nil t t t))
(with-current-buffer "*Org ASCII Export*"
(goto-char (point-min))
(insert extracted-heading)
(newline)
(newline)
(unfill-region (point-min) (point-max))
(flush-lines "^$" (point-min) (point-max))
(copy-region-as-kill (point-min) (point-max)))
(when (called-interactively-p 'interactive)
(indicate-copied-region))
(setq deactivate-mark t)
nil))
(defun acdw/org-extract-heading-text ()
"Extract the heading text from an `org-mode' heading."
(let ((heading (org-no-properties (org-get-heading t t t t))))