From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Cycling visibility of blocks Date: Mon, 25 May 2009 10:24:06 -0700 Message-ID: References: <87skiuryr2.fsf@selenimh.orion.org> <87ljomnfni.fsf@kassiopeya.MSHEIMNETZ> <04195B46-5D81-4E64-8315-CD2085E49357@gmail.com> <87y6slmteu.fsf@kassiopeya.MSHEIMNETZ> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M8duK-0000SP-Vn for emacs-orgmode@gnu.org; Mon, 25 May 2009 13:24:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M8duG-0000S5-Gn for emacs-orgmode@gnu.org; Mon, 25 May 2009 13:24:16 -0400 Received: from [199.232.76.173] (port=47902 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M8duG-0000S2-AG for emacs-orgmode@gnu.org; Mon, 25 May 2009 13:24:12 -0400 Received: from wf-out-1314.google.com ([209.85.200.168]:4978) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M8duF-0007zz-OO for emacs-orgmode@gnu.org; Mon, 25 May 2009 13:24:12 -0400 Received: by wf-out-1314.google.com with SMTP id 23so1013343wfg.24 for ; Mon, 25 May 2009 10:24:10 -0700 (PDT) In-Reply-To: <87y6slmteu.fsf@kassiopeya.MSHEIMNETZ> (Sebastian Rose's message of "Mon, 25 May 2009 11:19:21 +0200") 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, Carsten Dominik --=-=-= Sebastian Rose writes: > > and use > > "#\\+begin_\\([^ ]+\\) \\(.+\\)[ \t]*\\([ \t]+\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end_\\1" > > > :) > > > Sebastian > Hi Sebastian, Thanks for the update! I've applied a slightly changed version of your regexp, and this is now working for all block types (the resulting file is attached). Where could this file be saved? The contrib directory seems like overkill for such a small piece of functionality maybe I should post it up somewhere on worg? Thanks -- Eric --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=org-block-hide.el Content-Transfer-Encoding: quoted-printable ;;; org-block-hide.el --- hide blocks in org-mode files (defvar org-block-hide-src-block-regexp "#\\+begin_\\([^ ]+\\) ?\\([ \t]+\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end= _\\1") (defun org-block-hide-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-src-block-cycle) t) ;; to signal that we took action nil))) ;; to signal that we did not (defun org-block-hide-src-block-cycle () "Cycle the visibility of the current block" (interactive) ;; should really do this once in an (org-mode hook) (add-to-invisibility-spec '(org-block-hide . 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-b= lock-hide)) (overlays-at start))) (remove-overlays start end 'invisible 'org-block-hide) (overlay-put (make-overlay start end) 'invisible 'org-block-hid= e))) (error "not looking at a source block")))) ;; org-tab-after-check-for-cycling-hook (add-hook 'org-tab-first-hook 'org-block-hide-src-block-cycle-maybe) ;;; org-block-hide.el ends here --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --=-=-=--