From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Beck Subject: Re: Copy/Search Outline Date: Tue, 26 Jul 2011 11:30:12 +0200 Message-ID: <87y5zlcrtn.fsf@sophokles.streitblatt.de> References: <87d3h2xe2t.fsf@sophokles.streitblatt.de> <4E2E6027.5070906@christianmoe.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:47135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qldyj-00081J-VR for emacs-orgmode@gnu.org; Tue, 26 Jul 2011 05:31:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qldyi-0002CX-Sd for emacs-orgmode@gnu.org; Tue, 26 Jul 2011 05:31:05 -0400 Received: from mo-p05-ob.rzone.de ([81.169.146.182]:34931) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qldyi-0002CR-LL for emacs-orgmode@gnu.org; Tue, 26 Jul 2011 05:31:04 -0400 In-Reply-To: <4E2E6027.5070906@christianmoe.com> (Christian Moe's message of "Tue, 26 Jul 2011 08:35:19 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: mail@christianmoe.com Cc: emacs-orgmode@gnu.org, Florian Beck Christian Moe writes: >> Firstly, I want to copy the *visible* text (minus the =E2=80=A6, but nev= er mind >> that); > In other words: Begin exporting only the visible part with `C-c C-e=20 > 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 (=3D (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 =E2=80=93 but now with searching and copying working, I do not really have a use case. Thanks again. --=20 Florian Beck