summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2011-07-26 11:53:13 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2011-07-26 11:53:13 +0200
commit7f742f12cf2643b470879e03052c956d0fdfb625 (patch)
tree9281775fd7b82f90014486eea2b0016853cf1830
parentc222e8f134de324025d623dfe4f6b7f4a22cfba5 (diff)
downloadorg-mode-7f742f12cf2643b470879e03052c956d0fdfb625.tar.gz
Add `org-copy-visible' command proposed by Florian Beck
* lisp/org.el (org-copy-visible): New command.
-rw-r--r--lisp/org.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 81a993f..06b77f5 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17664,6 +17664,20 @@ Depending on context, this does one of the following:
((org-at-table-p) (call-interactively 'org-table-hline-and-move))
(t (call-interactively 'org-insert-heading))))
+(defun org-copy-visible (beg end)
+ "Copy the visible parts of the region."
+ (interactive "r")
+ (let (snippets s)
+ (save-excursion
+ (save-restriction
+ (narrow-to-region beg end)
+ (setq s (goto-char (point-min)))
+ (while (not (= (point) (point-max)))
+ (goto-char (org-find-invisible))
+ (push (buffer-substring s (point)) snippets)
+ (setq s (goto-char (org-find-visible))))))
+ (kill-new (apply 'concat (nreverse snippets)))))
+
(defun org-copy-special ()
"Copy region in table or copy current subtree.
Calls `org-table-copy' or `org-copy-subtree', depending on context.