emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Cycling visibility of blocks
@ 2009-05-24 21:12 emacs-orgmode
  2009-05-24 22:58 ` Eric Schulte
  0 siblings, 1 reply; 17+ messages in thread
From: emacs-orgmode @ 2009-05-24 21:12 UTC (permalink / raw)
  To: emacs-orgmode

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.

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  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  6:48   ` emacs-orgmode
  0 siblings, 2 replies; 17+ messages in thread
From: Eric Schulte @ 2009-05-24 22:58 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 323 bytes --]

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


[-- Attachment #2: org-block-hide.el --]
[-- Type: application/emacs-lisp, Size: 1577 bytes --]

[-- Attachment #3: Type: text/plain, Size: 421 bytes --]



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.

[-- Attachment #4: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-05-24 22:58 ` Eric Schulte
@ 2009-05-25  1:18   ` Sebastian Rose
  2009-05-25  7:25     ` Carsten Dominik
  2009-05-25  6:48   ` emacs-orgmode
  1 sibling, 1 reply; 17+ messages in thread
From: Sebastian Rose @ 2009-05-25  1:18 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

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"


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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-05-24 22:58 ` Eric Schulte
  2009-05-25  1:18   ` Sebastian Rose
@ 2009-05-25  6:48   ` emacs-orgmode
  1 sibling, 0 replies; 17+ messages in thread
From: emacs-orgmode @ 2009-05-25  6:48 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

Eric Schulte <schulte.eric@gmail.com> writes:

> 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.

Very nice ! Thank you.

> Maybe this would make sense for all org blocks, not just src blocks?

Sure, begin_src was just an example. It can be very useful in so many
cases.

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-05-25  1:18   ` Sebastian Rose
@ 2009-05-25  7:25     ` Carsten Dominik
  2009-05-25  9:19       ` Sebastian Rose
  0 siblings, 1 reply; 17+ messages in thread
From: Carsten Dominik @ 2009-05-25  7:25 UTC (permalink / raw)
  To: Sebastian Rose; +Cc: emacs-orgmode


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" <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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-05-25  7:25     ` Carsten Dominik
@ 2009-05-25  9:19       ` Sebastian Rose
  2009-05-25 17:24         ` Eric Schulte
  0 siblings, 1 reply; 17+ messages in thread
From: Sebastian Rose @ 2009-05-25  9:19 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-05-25  9:19       ` Sebastian Rose
@ 2009-05-25 17:24         ` Eric Schulte
  2009-05-25 20:40           ` Sebastian Rose
  2009-05-25 20:43           ` Sebastian Rose
  0 siblings, 2 replies; 17+ messages in thread
From: Eric Schulte @ 2009-05-25 17:24 UTC (permalink / raw)
  To: Sebastian Rose; +Cc: emacs-orgmode, Carsten Dominik

[-- Attachment #1: Type: text/plain, Size: 539 bytes --]

Sebastian Rose <sebastian_rose@gmx.de> 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


[-- Attachment #2: org-block-hide.el --]
[-- Type: application/emacs-lisp, Size: 1575 bytes --]

[-- Attachment #3: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  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:27             ` Eric Schulte
  2009-05-25 20:43           ` Sebastian Rose
  1 sibling, 2 replies; 17+ messages in thread
From: Sebastian Rose @ 2009-05-25 20:40 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, Carsten Dominik

"Eric Schulte" <schulte.eric@gmail.com> writes:
> 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?


Hmm - why don't you juste start a `Snippets' section? I don't mind Worg
to grow.
Didn't you see http://wiki.github.com/SebastianRose/org-search.php? Not
doing very much yet, but it's under way :) 


Another good place would be inside Org-mode's core IMHO.


   Sebastian


> ;;; 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-block-hide))
>                               (overlays-at start)))
>               (remove-overlays start end 'invisible 'org-block-hide)
>             (overlay-put (make-overlay start end) 'invisible 'org-block-hide)))
>       (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

-- 
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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-05-25 17:24         ` Eric Schulte
  2009-05-25 20:40           ` Sebastian Rose
@ 2009-05-25 20:43           ` Sebastian Rose
  2009-05-26 17:25             ` Carsten Dominik
  1 sibling, 1 reply; 17+ messages in thread
From: Sebastian Rose @ 2009-05-25 20:43 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, Carsten Dominik

"Eric Schulte" <schulte.eric@gmail.com> writes:

ahh - forgot - Carsten: note the unicorns:

http://cloud.github.com/downloads/SebastianRose/org-search.php/speedbar1.png

:-D

  Sebastian

> Sebastian Rose <sebastian_rose@gmx.de> 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
>
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-05-25 20:43           ` Sebastian Rose
@ 2009-05-26 17:25             ` Carsten Dominik
  0 siblings, 0 replies; 17+ messages in thread
From: Carsten Dominik @ 2009-05-26 17:25 UTC (permalink / raw)
  To: Sebastian Rose; +Cc: emacs-orgmode

That does look cool!

- Carsten

On May 25, 2009, at 10:43 PM, Sebastian Rose wrote:

> "Eric Schulte" <schulte.eric@gmail.com> writes:
>
> ahh - forgot - Carsten: note the unicorns:
>
> http://cloud.github.com/downloads/SebastianRose/org-search.php/speedbar1.png
>
> :-D
>
>  Sebastian
>
>> Sebastian Rose <sebastian_rose@gmx.de> 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
>>
>>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-05-25 20:40           ` Sebastian Rose
@ 2009-05-26 17:26             ` Carsten Dominik
  2009-05-26 21:22               ` Eric Schulte
  2009-05-26 21:27             ` Eric Schulte
  1 sibling, 1 reply; 17+ messages in thread
From: Carsten Dominik @ 2009-05-26 17:26 UTC (permalink / raw)
  To: Sebastian Rose; +Cc: emacs-orgmode


On May 25, 2009, at 10:40 PM, Sebastian Rose wrote:

> "Eric Schulte" <schulte.eric@gmail.com> writes:
>> 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?
>
>
> Hmm - why don't you juste start a `Snippets' section? I don't mind  
> Worg
> to grow.
> Didn't you see http://wiki.github.com/SebastianRose/org-search.php?  
> Not
> doing very much yet, but it's under way :)
>
>
> Another good place would be inside Org-mode's core IMHO.

I would be happy to integrate this into the core.  Eric, you agree?

- Carsten

>
>
>   Sebastian
>
>
>> ;;; 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-block-hide))
>>                              (overlays-at start)))
>>              (remove-overlays start end 'invisible 'org-block-hide)
>>            (overlay-put (make-overlay start end) 'invisible 'org- 
>> block-hide)))
>>      (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
>
> -- 
> 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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-05-26 17:26             ` Carsten Dominik
@ 2009-05-26 21:22               ` Eric Schulte
  2009-06-02 16:36                 ` Carsten Dominik
  0 siblings, 1 reply; 17+ messages in thread
From: Eric Schulte @ 2009-05-26 21:22 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> writes:

> On May 25, 2009, at 10:40 PM, Sebastian Rose wrote:
>
>> Another good place would be inside Org-mode's core IMHO.
>
> I would be happy to integrate this into the core.  Eric, you agree?
>
> - Carsten
>

Sounds good to me. -- Eric

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-05-25 20:40           ` Sebastian Rose
  2009-05-26 17:26             ` Carsten Dominik
@ 2009-05-26 21:27             ` Eric Schulte
  1 sibling, 0 replies; 17+ messages in thread
From: Eric Schulte @ 2009-05-26 21:27 UTC (permalink / raw)
  To: Sebastian Rose; +Cc: emacs-orgmode, Carsten Dominik

Sebastian Rose <sebastian_rose@gmx.de> writes:

> "Eric Schulte" <schulte.eric@gmail.com> writes:
>> 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?
>
>
> Hmm - why don't you juste start a `Snippets' section? I don't mind Worg
> to grow.
> Didn't you see http://wiki.github.com/SebastianRose/org-search.php? Not
> doing very much yet, but it's under way :) 
>

I've been tracking it on github, but haven't had a chance to try it out.
While I have a decent amount of experience with Ruby web applications
I've never before used php.  This looks very similar to blorgit[1], my
own org-mode web project.

I'm looking forward to taking a closer look. -- Eric

[1] http://github.com/eschulte/blorgit/tree/master

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-05-26 21:22               ` Eric Schulte
@ 2009-06-02 16:36                 ` Carsten Dominik
  2009-06-02 16:47                   ` Eric Schulte
  2009-06-02 16:52                   ` Nicolas Goaziou
  0 siblings, 2 replies; 17+ messages in thread
From: Carsten Dominik @ 2009-06-02 16:36 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, Carsten Dominik

Hello,

Isn't there something wrong with the regexp as the snippet is not
working well when #+END_SOMETHING is followed right away by a new line ?

I mean


#+BEGIN_QUOTE
    Test etn ntes thens hsne htsne nste thnes sne thsne htse nthes
    ehtse hntse hents
#+END_QUOTE  <--- notice the space

Blah blah


is showing the expected behavior when


#+BEGIN_QUOTE
    Test etn ntes thens hsne htsne nste thnes sne thsne htse nthes
    ehtse hntse hents
#+END_QUOTE  <---nothing


actually results in


#+BEGIN_QUOTE
    Test etn ntes thens hsne htsne nste thnes sne thsne htse nthes...
Blah blah


There's no problem when the text within is not split across two line,
though.


-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  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
  1 sibling, 1 reply; 17+ messages in thread
From: Eric Schulte @ 2009-06-02 16:47 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 141 bytes --]

Good catch,

I'm not sure what is causing this problem, but the attached patch which
changes the regexp seems to solve it.

Thanks -- Eric



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: block-hide-regexp.patch --]
[-- Type: text/x-patch, Size: 515 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index 1c3dfe5..6792bed 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5146,8 +5146,7 @@ Optional argument N means, put the headline into the Nth line of the window."
 ;;; Folding of blocks
 
 (defconst org-block-regexp
-
-  "^[ \t]*#\\+begin_\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end_\\1"
+  "^[ \t]*#\\+begin_\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end_\\1[ \t]?"
   "Regular expression for hiding blocks.")
 
 (defvar org-hide-block-overlays nil

[-- Attachment #3: Type: text/plain, Size: 828 bytes --]





Carsten Dominik <carsten.dominik@gmail.com> writes:

> Hello,
>
> Isn't there something wrong with the regexp as the snippet is not
> working well when #+END_SOMETHING is followed right away by a new line ?
>
> I mean
>
>
> #+BEGIN_QUOTE
>     Test etn ntes thens hsne htsne nste thnes sne thsne htse nthes
>     ehtse hntse hents
> #+END_QUOTE  <--- notice the space
>
> Blah blah
>
>
> is showing the expected behavior when
>
>
> #+BEGIN_QUOTE
>     Test etn ntes thens hsne htsne nste thnes sne thsne htse nthes
>     ehtse hntse hents
> #+END_QUOTE  <---nothing
>
>
> actually results in
>
>
> #+BEGIN_QUOTE
>     Test etn ntes thens hsne htsne nste thnes sne thsne htse nthes...
> Blah blah
>
>
> There's no problem when the text within is not split across two line,
> though.

[-- Attachment #4: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-06-02 16:36                 ` Carsten Dominik
  2009-06-02 16:47                   ` Eric Schulte
@ 2009-06-02 16:52                   ` Nicolas Goaziou
  1 sibling, 0 replies; 17+ messages in thread
From: Nicolas Goaziou @ 2009-06-02 16:52 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, Carsten Dominik

Hum,

1. My apologies for the From: header in my previous post, I just
   realized I had messed up badly with my gnus-posting-style variable;
2. While I'm at it: two line --> two lines.

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Cycling visibility of blocks
  2009-06-02 16:47                   ` Eric Schulte
@ 2009-06-02 17:12                     ` Carsten Dominik
  0 siblings, 0 replies; 17+ messages in thread
From: Carsten Dominik @ 2009-06-02 17:12 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

Applied, thanks.

- Carsten

On Jun 2, 2009, at 6:47 PM, Eric Schulte wrote:

> Good catch,
>
> I'm not sure what is causing this problem, but the attached patch  
> which
> changes the regexp seems to solve it.
>
> Thanks -- Eric
>
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 1c3dfe5..6792bed 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -5146,8 +5146,7 @@ Optional argument N means, put the headline  
> into the Nth line of the window."
> ;;; Folding of blocks
>
> (defconst org-block-regexp
> -
> -  "^[ \t]*#\\+begin_\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\([^\000]+?\ 
> \)#\\+end_\\1"
> +  "^[ \t]*#\\+begin_\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\([^\000]+?\ 
> \)#\\+end_\\1[ \t]?"
>   "Regular expression for hiding blocks.")
>
> (defvar org-hide-block-overlays nil
>
>
>
>
> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> Hello,
>>
>> Isn't there something wrong with the regexp as the snippet is not
>> working well when #+END_SOMETHING is followed right away by a new  
>> line ?
>>
>> I mean
>>
>>
>> #+BEGIN_QUOTE
>>    Test etn ntes thens hsne htsne nste thnes sne thsne htse nthes
>>    ehtse hntse hents
>> #+END_QUOTE  <--- notice the space
>>
>> Blah blah
>>
>>
>> is showing the expected behavior when
>>
>>
>> #+BEGIN_QUOTE
>>    Test etn ntes thens hsne htsne nste thnes sne thsne htse nthes
>>    ehtse hntse hents
>> #+END_QUOTE  <---nothing
>>
>>
>> actually results in
>>
>>
>> #+BEGIN_QUOTE
>>    Test etn ntes thens hsne htsne nste thnes sne thsne htse nthes...
>> Blah blah
>>
>>
>> There's no problem when the text within is not split across two line,
>> though.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2009-06-02 17:12 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).