From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Cycling visibility of blocks Date: Mon, 25 May 2009 09:25:24 +0200 Message-ID: <04195B46-5D81-4E64-8315-CD2085E49357@gmail.com> References: <87skiuryr2.fsf@selenimh.orion.org> <87ljomnfni.fsf@kassiopeya.MSHEIMNETZ> Mime-Version: 1.0 (Apple Message framework v935.3) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M8UYt-0004u4-GE for emacs-orgmode@gnu.org; Mon, 25 May 2009 03:25:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M8UYs-0004ts-AB for emacs-orgmode@gnu.org; Mon, 25 May 2009 03:25:31 -0400 Received: from [199.232.76.173] (port=43900 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M8UYs-0004tp-4q for emacs-orgmode@gnu.org; Mon, 25 May 2009 03:25:30 -0400 Received: from mx20.gnu.org ([199.232.41.8]:38540) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M8UYr-0001Ls-Ho for emacs-orgmode@gnu.org; Mon, 25 May 2009 03:25:29 -0400 Received: from ey-out-1920.google.com ([74.125.78.149]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M8UYq-0002Kf-Jc for emacs-orgmode@gnu.org; Mon, 25 May 2009 03:25:28 -0400 Received: by ey-out-1920.google.com with SMTP id 13so551911eye.24 for ; Mon, 25 May 2009 00:25:27 -0700 (PDT) In-Reply-To: <87ljomnfni.fsf@kassiopeya.MSHEIMNETZ> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Sebastian Rose Cc: emacs-orgmode@gnu.org On May 25, 2009, at 3:18 AM, Sebastian Rose wrote: > Wow, this is great! > > And yes, it indeed makes sense to hide other blocks too, e.g. big > ditaa > blocks or #+BEGIN_HTML when working on LaTeX stuff (here a `S-TAB' > action would be great, that hides all blocks of that sort at once). > > In fact, I changed the `org-block-hide-src-block-regexp' to > > "#\\+begin_\\w+ \\(.+\\)[ \t]*\\([ \t]+\\([^\n]+\\)\\)?\n\\([^ > \000]+?\\)#\\+end_src" :-) This is not going to work. You need to capture the block type into a regexp group and then use a back reference like "#\\+end_\\1" at the end. "#\\+begin_\\w+ \\(.+\\)[ \t]*\\([ \t]+\\([^\n]+\\)\\)?\n\\([^ \000]+?\\)#\\+end_src" - Carsten > > > Thanks for this wonderfull snippet! > > > Sebastian > > > "Eric Schulte" writes: >> Hi, >> >> The attached file should implement this feature, just load the file >> and >> then press tab while at the beginning of a source block. Note that >> it >> requires a newish version of org-mode which includes the >> `org-tab-first-hook' variable. >> >> Maybe this would make sense for all org blocks, not just src blocks? >> >> Cheers -- Eric >> >> >> ;;; org-block-hide --- hide src blocks in org-mode files >> >> (defvar org-block-hide-src-block-regexp "#\\+begin_src \\(.+\\) >> [ \t]*\\([ \t]+\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end_src") >> >> (defun org-block-hide-ui-src-block-cycle-maybe () >> (let ((case-fold-search t)) >> (if (save-excursion >> (beginning-of-line 1) >> (looking-at org-block-hide-src-block-regexp)) >> (progn (call-interactively 'org-block-hide-ui-src-block-cycle) >> t) ;; to signal that we took action >> nil))) ;; to signal that we did not >> >> (defun org-block-hide-ui-src-block-cycle () >> "Cycle the visibility of the current source code block" >> (interactive) >> ;; should really do this once in an (org-mode hook) >> (add-to-invisibility-spec '(org-block-hide-ui . t)) >> (message "trying out source block") >> (save-excursion >> (beginning-of-line) >> (if (re-search-forward org-block-hide-src-block-regexp nil t) >> (let ((start (- (match-beginning 4) 1)) ;; beginning of body >> (end (match-end 0))) ;; end of entire body >> (if (memq t (mapcar (lambda (overlay) >> (eq (overlay-get overlay 'invisible) >> 'org-block-hide-ui)) >> (overlays-at start))) >> (remove-overlays start end 'invisible 'org-block-hide- >> ui) >> (overlay-put (make-overlay start end) 'invisible 'org- >> block-hide-ui))) >> (error "not looking at a source block")))) >> >> ;; org-tab-after-check-for-cycling-hook >> (add-hook 'org-tab-first-hook 'org-block-hide-ui-src-block-cycle- >> maybe) >> >> >> emacs-orgmode@gnu.org writes: >> >>> Hello, >>> >>> I perhaps have missed it in the manual, but, would it be possible to >>> cycle visibility in blocks like in the example below ? >>> >>> #+BEGIN_something >>> blah blah blah >>> blah >>> blah blah >>> and so much blah yet to come >>> #+END_something >>> >>> becomes >>> >>> #+BEGIN_something >>> ... >>> #+END_something >>> >>> It could help when you have those big BEGIN_SRC getting in the way. >>> >>> Thanks. >> _______________________________________________ >> Emacs-orgmode mailing list >> Remember: use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode