emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Sebastian Rose <sebastian_rose@gmx.de>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Cycling visibility of blocks
Date: Mon, 25 May 2009 11:19:21 +0200	[thread overview]
Message-ID: <87y6slmteu.fsf@kassiopeya.MSHEIMNETZ> (raw)
In-Reply-To: <04195B46-5D81-4E64-8315-CD2085E49357@gmail.com> (Carsten Dominik's message of "Mon, 25 May 2009 09:25:24 +0200")

Carsten Dominik <carsten.dominik@gmail.com> writes:
> 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"



aaahh, now that you say this, it does not work anymore ;-(
It seemed to work, but I had several blocks in that file .... Now it
doesn't ... I'll have to read the manual again ...


Puuuhaa - I'll never ever love regexps in elisp :-D
OK, I found it works now if I change 

     (let ((start (- (match-beginning 4) 1)) ;; beginning of body
to
     (let ((start (- (match-beginning 5) 1)) ;; beginning of body


and use 

  "#\\+begin_\\([^ ]+\\) \\(.+\\)[ \t]*\\([ \t]+\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end_\\1"


:)


  Sebastian


>
> - Carsten
>
>>
>>
>> Thanks for this wonderfull snippet!
>>
>>
>>  Sebastian
>>
>>
>> "Eric Schulte" <schulte.eric@gmail.com> 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
>

-- 
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.:  +49 (0)511 - 36 58 472
Fax:   +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Email: s.rose@emma-stil.de, sebastian_rose@gmx.de
Http:  www.emma-stil.de

  reply	other threads:[~2009-05-25  9:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-24 21:12 Cycling visibility of blocks emacs-orgmode
2009-05-24 22:58 ` Eric Schulte
2009-05-25  1:18   ` Sebastian Rose
2009-05-25  7:25     ` Carsten Dominik
2009-05-25  9:19       ` Sebastian Rose [this message]
2009-05-25 17:24         ` Eric Schulte
2009-05-25 20:40           ` Sebastian Rose
2009-05-26 17:26             ` Carsten Dominik
2009-05-26 21:22               ` Eric Schulte
2009-06-02 16:36                 ` Carsten Dominik
2009-06-02 16:47                   ` Eric Schulte
2009-06-02 17:12                     ` Carsten Dominik
2009-06-02 16:52                   ` Nicolas Goaziou
2009-05-26 21:27             ` Eric Schulte
2009-05-25 20:43           ` Sebastian Rose
2009-05-26 17:25             ` Carsten Dominik
2009-05-25  6:48   ` emacs-orgmode

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y6slmteu.fsf@kassiopeya.MSHEIMNETZ \
    --to=sebastian_rose@gmx.de \
    --cc=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).