From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Create a view of just source-code blocks? Date: Tue, 05 Jul 2011 17:21:20 -0600 Message-ID: <8762nf7dzl.fsf@gmail.com> References: <1309896511.26199.YahooMailRC@web161910.mail.bf1.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:58592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeRr6-00073e-3U for emacs-orgmode@gnu.org; Wed, 06 Jul 2011 09:09:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QeRr4-0005PT-ES for emacs-orgmode@gnu.org; Wed, 06 Jul 2011 09:09:27 -0400 Received: from mail-yi0-f41.google.com ([209.85.218.41]:65453) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeRr4-0005PG-3F for emacs-orgmode@gnu.org; Wed, 06 Jul 2011 09:09:26 -0400 Received: by yia13 with SMTP id 13so3237213yia.0 for ; Wed, 06 Jul 2011 06:09:24 -0700 (PDT) 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: Michael Hannon Cc: Org-Mode List --=-=-= Content-Type: text/plain Michael Hannon writes: > Greetings. I'd like to be able to view just the source-code blocks in a Babel > file. I.e., I'd like to do something logically equivalent to "tangle", but > without creating a separate file, just a view within the current file. Any > suggestions? > > Thanks, > > -- Mike > Hi Mike, Something like the attached should work, although I'm not sure if/how this could be incorporated into Org-mode. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=hide-non-code.el Content-Transfer-Encoding: quoted-printable (defvar only-code-overlays nil "Overlays hiding non-code blocks.") (make-variable-buffer-local 'only-code-overlays) (defun hide-non-code () "Hide non-code-block content of the current Org-mode buffer." (interactive) (add-to-invisibility-spec '(non-code)) (let (begs ends) (save-excursion (goto-char (point-min)) (while (re-search-forward org-babel-src-block-regexp nil t) (push (match-beginning 5) begs) (push (match-end 5) ends)) (map 'list (lambda (beg end) (let ((ov (make-overlay beg end))) (push ov only-code-overlays) (overlay-put ov 'invisible 'non-code))) (cons (point-min) (reverse ends)) (append (reverse begs) (list (point-max))))))) (defun show-non-code () "Show non-code-block content of the current Org-mode buffer." (interactive) (mapc 'delete-overlay only-code-overlays)) --=-=-= Content-Type: text/plain -- Eric Schulte http://cs.unm.edu/~eschulte/ --=-=-=--