[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Copy/Search Outline
From: |
Carsten Dominik |
Subject: |
Re: [O] Copy/Search Outline |
Date: |
Tue, 26 Jul 2011 11:54:41 +0200 |
On Jul 26, 2011, at 11:30 AM, Florian Beck wrote:
> Christian Moe <address@hidden> writes:
>
>>> Firstly, I want to copy the *visible* text (minus the …, but never mind
>>> that);
>
>> In other words: Begin exporting only the visible part with `C-c C-e
>> v', then press space at the prompt for output formats. This leaves you
>> in a second buffer with a copy of the visible part (and yes, you do
>> get rid of the ellipses). Then select all with `C-c h' (alternately,
>> select the region of your choice) and copy. Kill the copy buffer when
>> you're done with it.
>
> Thanks. Seems like `org-export-visible' does exactly what I want.
>
> I also wrote a function to copy the visible part of the region. For
> those curious:
>
> (defun copy-visible (beg end)
> (interactive "r")
> (let ((text "") 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))
> (setq text (concat text (buffer-substring s (point))))
> (setq s (goto-char (org-find-visible))))))
> (kill-new text)))
This is a very useful function, thanks! I have added it
to org-mode as `org-copy-visible', currently without a key
binding.
To speed it up a bit, you made it collect the snippets into
a list and then do the concat in one sweep - this might make a
difference for large buffers.
Cheers
- Carsten