Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you copy just the visible text from the folded state in an org-mode buffer?

Tags:

emacs

org-mode

How to copy org file to other buffer, if source is:

** TODO task #1
   - some text for task #1
** TODO task #2 
   - some text for task #2

but when you collapse all tasks it will look like

** TODO task #1 ...
** TODO task #2 ...

I want to mark all tasks and copy to another buffer and it must look like a second variant. Don't include texts for tasks which stored inside every task. How i can to do it ?

like image 499
RusAlex Avatar asked Jul 07 '10 10:07

RusAlex


People also ask

How do I use org Mode in Emacs?

To save the document, either press the save icon, or press C-x C-s, call it 1.org. Emacs does not actually understand you are editing an Org document, yet. To enable Org mode on your current document, type M-x org-mode which will enable the Org mode on the current document. Those are minuses, not underscores.

What can you do with Org mode?

Org mode is routinely used to build and manage complex workflows. It does this using an elegantly simple syntax that scales from basic markup to full LaTeX typesetting and from plain text notes to literate programs. Everything you need to get started is demonstrated in the example.


2 Answers

As per Hendy's comment, in current versions of org-mode you use org-copy-visible (C-c C-x v) to copy the visible content of the current region to the kill ring. (C-x h can be used first to mark the entire buffer, as usual.)

In addition, note that the export dispatch menu (C-x C-e) provides a "Visible only" switch, if you want to export that content to a different format.

For older versions of org-mode, the original answer below should still apply:


M-x org-export-visible RET SPC will copy only the currently-visible text of your org-mode buffer into a new buffer.

org-export-visible is an interactive compiled Lisp function in `org-exp.el'.

(org-export-visible TYPE ARG)

Create a copy of the visible part of the current buffer, and export it. The copy is created in a temporary buffer and removed after use. TYPE is the final key (as a string) that also select the export command in the `C-c C-e' export dispatcher. As a special case, if the you type SPC at the prompt, the temporary org-mode file will not be removed but presented to you so that you can continue to use it. The prefix arg ARG is passed through to the exporting command.

If you wanted to bind that (to C-c o in this example), you could use the following:

(add-hook 'org-mode-hook 'my-org-mode-hook)
(defun my-org-mode-hook ()
  "Custom behaviours when entering org-mode."
  (local-set-key (kbd "C-c o") (function (lambda () (interactive)
                                           (org-export-visible ?\s nil)))))
like image 99
phils Avatar answered Oct 17 '22 14:10

phils


There is org-copy-visible, that should do exactly what you need.

like image 36
Yisrael Dov Avatar answered Oct 17 '22 14:10

Yisrael Dov