emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Copy/Search Outline


From: Florian Beck
Subject: Re: [O] Copy/Search Outline
Date: Tue, 26 Jul 2011 11:30:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

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)))



>> secondly, I want to be able to search only the visible text.
>
> You can do that, albeit only in a copy of your document in a separate
> buffer, with the approach above. But why would you want to? Perhaps if
> you state a use case, someone can point out a different approach.

Actually (as I just found out) you can do it very easily by setting the
variable `search-invisible' no nil (found in isearch.el).

>
>> More generally (and less org specific), how do I restrict commands to
>> the visible parts of the buffer?
>
> I don't know.

I guess it's not possible because commands work on the buffer and
usually do not know about viviblity. Maybe something like
`with-visible-buffer' could be proposed – but now with searching and
copying working, I do not really have a use case.

Thanks again.


-- 
Florian Beck



reply via email to

[Prev in Thread] Current Thread [Next in Thread]