all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* cperl-mode - outline minor mode - subroutines
@ 2010-04-19 15:12 Terrence Brannon
  2010-04-19 16:16 ` LanX
  0 siblings, 1 reply; 20+ messages in thread
From: Terrence Brannon @ 2010-04-19 15:12 UTC (permalink / raw
  To: help-gnu-emacs

Hello, I'm using GNU Emacs 23. There is a huge subroutine that I want
to outline the various parts of.

I would like to know how to give hints to outline minor mode, so that
the subroutine can be broken down into
sections and subsections.



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

* Re: cperl-mode - outline minor mode - subroutines
  2010-04-19 15:12 cperl-mode - outline minor mode - subroutines Terrence Brannon
@ 2010-04-19 16:16 ` LanX
  2010-04-19 16:39   ` Terrence Brannon
  2010-04-19 16:41   ` LanX
  0 siblings, 2 replies; 20+ messages in thread
From: LanX @ 2010-04-19 16:16 UTC (permalink / raw
  To: help-gnu-emacs


> I would like to know how to give hints to outline minor mode, so that
> the subroutine can be broken down into
> sections and subsections.

I presume we are talking about cperl-mode?

Thats defined in a list of regex in the variable outline-regexp which
is derived  from cperl-outline-regexp


"^\\(\\([ 	]*package\\(\\([ 	\n]\\|#[^\n]*\n\\)+\\([a-zA-Z_0-9:']+\\)\
\)?\\)\\|[ 	]*sub\\(\\([ 	\n]\\|#[^\n]*\n\\)+\\(::[a-zA-Z_0-9:']+\\|[a-
zA-Z_'][a-zA-Z_0-9:']*\\)\\)\\([ 	\n]*\\(#[^\n]*\n[ 	\n]*\\)*\\
(([^()]*)\\)\\)?\\([ 	\n]*\\(#[^\n]*\n[ 	\n]*\\)*\\(:[^:]\\)\\)?[ 	\n]*
\\(#[^\n]*\n[ 	\n]*\\)*\\|=head\\([1-4]\\)[ 	]+\\([^\n]+\\)$\\)\\|\\`"

all of this derived as concat from


--------------------
;;; Details of groups in this are used in `cperl-imenu--create-perl-
index'
;;;  and `cperl-outline-level'.
;;;; Was: 2=sub|package; now 2=package-group, 5=package-name 8=sub-
name (+3)
(defvar cperl-imenu--function-name-regexp-perl
  (concat
   "^\\("				; 1 = all
       "\\([ \t]*package"		; 2 = package-group
          "\\("				; 3 = package-name-group
	    cperl-white-and-comment-rex ; 4 = pre-package-name
	       "\\([a-zA-Z_0-9:']+\\)\\)?\\)" ; 5 = package-name
       "\\|"
          "[ \t]*sub"
	  (cperl-after-sub-regexp 'named nil) ; 8=name 11=proto 14=attr-start
	  cperl-maybe-white-and-comment-rex	; 15=pre-block
   "\\|"
     "=head\\([1-4]\\)[ \t]+"		; 16=level
     "\\([^\n]+\\)$"			; 17=text
   "\\)"))

(defvar cperl-outline-regexp
  (concat cperl-imenu--function-name-regexp-perl "\\|" "\\`"))

--------------------------------

HTH please give a note if you are succesful! :)

Cheers
  rolf


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

* Re: cperl-mode - outline minor mode - subroutines
  2010-04-19 16:16 ` LanX
@ 2010-04-19 16:39   ` Terrence Brannon
  2010-04-19 16:49     ` LanX
  2010-04-19 16:41   ` LanX
  1 sibling, 1 reply; 20+ messages in thread
From: Terrence Brannon @ 2010-04-19 16:39 UTC (permalink / raw
  To: help-gnu-emacs

On Apr 19, 12:16 pm, LanX <lanx.p...@googlemail.com> wrote:
> > I would like to know how to give hints to outline minor mode, so that
> > the subroutine can be broken down into
> > sections and subsections.
>
> I presume we are talking about cperl-mode?

yes, sorry I must've forgotten to mention that

> HTH please give a note if you are succesful! :)
>

well, what I still dont know is how to outline a subroutine... how to
decompose it into sections and subsections:

sub somesub {

# A - do something

# A1 - do something within do something
# A2 - do something else within do something

# B - next step

# B1 - do something within next step
# B2 - do something else within next step

}



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

* Re: cperl-mode - outline minor mode - subroutines
  2010-04-19 16:16 ` LanX
  2010-04-19 16:39   ` Terrence Brannon
@ 2010-04-19 16:41   ` LanX
  2010-04-19 18:02     ` Terrence Brannon
  1 sibling, 1 reply; 20+ messages in thread
From: LanX @ 2010-04-19 16:41 UTC (permalink / raw
  To: help-gnu-emacs

i Terrance

changing the ending of outline-regexp to "\\|.*#---\\|\\`" helped
folding on comments starting with 3 minus.

Cheers
  rolf


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

* Re: cperl-mode - outline minor mode - subroutines
  2010-04-19 16:39   ` Terrence Brannon
@ 2010-04-19 16:49     ` LanX
  2010-04-21 18:28       ` Terrence Brannon
  0 siblings, 1 reply; 20+ messages in thread
From: LanX @ 2010-04-19 16:49 UTC (permalink / raw
  To: help-gnu-emacs

There is multiple possibilities to fold, eg. by indentation level!

http://www.emacswiki.org/emacs/CategoryHideStuff



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

* Re: cperl-mode - outline minor mode - subroutines
  2010-04-19 16:41   ` LanX
@ 2010-04-19 18:02     ` Terrence Brannon
  2010-04-20  8:22       ` LanX
  0 siblings, 1 reply; 20+ messages in thread
From: Terrence Brannon @ 2010-04-19 18:02 UTC (permalink / raw
  To: help-gnu-emacs

On Apr 19, 12:41 pm, LanX <lanx.p...@googlemail.com> wrote:
> i Terrance

Hi, outline-regexp's value is

"^\\(\\([ 	]*package\\(\\([ 	\n]\\|#[^\n]*\n\\)+\\([a-zA-Z_0-9:']+\\)\
\)?\\)\\|[ 	]*sub\\(\\([ 	\n]\\|#[^\n]*\n\\)+\\(::[a-zA-Z_0-9:']+\\|[a-
zA-Z_'][a-zA-Z_0-9:']*\\)\\)\\([ 	\n]*\\(#[^\n]*\n[ 	\n]*\\)*\\
(([^()]*)\\)\\)?\\([ 	\n]*\\(#[^\n]*\n[ 	\n]*\\)*\\(:[^:]\\)\\)?[ 	\n]*
\\(#[^\n]*\n[ 	\n]*\\)*\\|=head\\([1-4]\\)[ 	]+\\([^\n]+\\)$\\)\\|\\`"

>
> changing the ending of outline-regexp to "\\|.*#---\\|\\`" helped
> folding on comments starting with 3 minus.

Programmatically:

(let ( (some-string "some-extension-of-regexp"))
   (setq outline-regexp (concat some-string outline-regexp)) )

What would you set some-string to for changing the ending as you
suggest?

And how would the code look? Could you create sections and subsections
and subsubsections?



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

* Re: cperl-mode - outline minor mode - subroutines
  2010-04-19 18:02     ` Terrence Brannon
@ 2010-04-20  8:22       ` LanX
  2010-04-20 19:10         ` Terrence Brannon
  0 siblings, 1 reply; 20+ messages in thread
From: LanX @ 2010-04-20  8:22 UTC (permalink / raw
  To: help-gnu-emacs

Hi Terrence

On 19 Apr., 20:02, Terrence Brannon <metap...@gmail.com> wrote:
> What would you set some-string to for changing the ending as you
> suggest?

It's a regex to discover the headings of sections, "\\|" is the same
"or" like in perl-regex only with "slasheritis".

Only _you_ can know which headings precede the subsections in _your_
perl code.

> And how would the code look?

I did it manually with M-x set-variable.

> Could you create sections and subsections
> and subsubsections?

No idea how nesting is defined for "outline" ...

I think you want to fold by indentation, did you read the emacswiki
page I linked???

Cheers
  rolf


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

* Re: cperl-mode - outline minor mode - subroutines
  2010-04-20  8:22       ` LanX
@ 2010-04-20 19:10         ` Terrence Brannon
  2010-04-21 13:52           ` LanX
  0 siblings, 1 reply; 20+ messages in thread
From: Terrence Brannon @ 2010-04-20 19:10 UTC (permalink / raw
  To: help-gnu-emacs

On Apr 20, 4:22 am, LanX <lanx.p...@googlemail.com> wrote:

>
> I think you want to fold by indentation, did you read the emacswiki
> page I linked???

I looked at it. I think I will just settle for vanilla cperl and
outline-mode.

That is fine under normal circumstances. I'm just dealing with some
horrible unfactored legacy code.

That's why I need so much breaking down.




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

* Re: cperl-mode - outline minor mode - subroutines
  2010-04-20 19:10         ` Terrence Brannon
@ 2010-04-21 13:52           ` LanX
  2010-04-21 18:36             ` David Rogoff
  2010-04-23 20:49             ` cperl-mode - how people outline their code? Ilya Zakharevich
  0 siblings, 2 replies; 20+ messages in thread
From: LanX @ 2010-04-21 13:52 UTC (permalink / raw
  To: help-gnu-emacs

There plenty of questions you didn't answer.

Once again "outline-minor-mode" works on headlines like "sub {" and
"package"  so if you wanna fold chunks you have to mark them by  a
leading headline like "  #- Chunk to be folded\n".

But only appending ".*#- " to "cperl-outline-regexp" which is matching
these headlines isn't enough!

You have also to change the function "cperl-outline-level" such that
the folding levels don't get confused.

I have no big idea or time to fiddle out how to do this without
hacking into Ilya's code

Maybe he is reading a willing to update his mode to allow a variable
"cperl-outline-chunk-regexp"

Anyway if can't add extra heading-comment to the code in questions all
these efforts are useless!

Hope its clear now...



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

* Re: cperl-mode - outline minor mode - subroutines
  2010-04-19 16:49     ` LanX
@ 2010-04-21 18:28       ` Terrence Brannon
  2010-04-22  1:25         ` LanX
  0 siblings, 1 reply; 20+ messages in thread
From: Terrence Brannon @ 2010-04-21 18:28 UTC (permalink / raw
  To: help-gnu-emacs

On Apr 19, 12:49 pm, LanX <lanx.p...@googlemail.com> wrote:
> There is multiple possibilities to fold, eg. by indentation level!
>
> http://www.emacswiki.org/emacs/CategoryHideStuff

Actually I looked closer. I think the hs-mode that comes with Emacs 23
in combination with hideshowvis ( http://www.emacswiki.org/emacs/hideshowvis.el
)

will work naturally well for me.

thank you for your help :)


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

* Re: cperl-mode - outline minor mode - subroutines
  2010-04-21 13:52           ` LanX
@ 2010-04-21 18:36             ` David Rogoff
  2010-04-23 20:49             ` cperl-mode - how people outline their code? Ilya Zakharevich
  1 sibling, 0 replies; 20+ messages in thread
From: David Rogoff @ 2010-04-21 18:36 UTC (permalink / raw
  To: help-gnu-emacs

Anyone know if any of these methods work well with Verilog code / verilog-mode?

Thanks,

 David



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

* Re: cperl-mode - outline minor mode - subroutines
  2010-04-21 18:28       ` Terrence Brannon
@ 2010-04-22  1:25         ` LanX
  0 siblings, 0 replies; 20+ messages in thread
From: LanX @ 2010-04-22  1:25 UTC (permalink / raw
  To: help-gnu-emacs

> Actually I looked closer. I think the hs-mode that comes with Emacs 23
> in combination with hideshowvis (http://www.emacswiki.org/emacs/hideshowvis.el
> )
>
> will work naturally well for me.

good luck, I had to deactivate hideshowvis.el because my emacs was
hanging at startup.


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

* Re: cperl-mode - how people outline their code?
  2010-04-21 13:52           ` LanX
  2010-04-21 18:36             ` David Rogoff
@ 2010-04-23 20:49             ` Ilya Zakharevich
  2010-04-23 23:09               ` LanX
  1 sibling, 1 reply; 20+ messages in thread
From: Ilya Zakharevich @ 2010-04-23 20:49 UTC (permalink / raw
  To: help-gnu-emacs

On 2010-04-21, LanX <rolf.langsdorf@googlemail.com> wrote:
> There plenty of questions you didn't answer.
>
> Once again "outline-minor-mode" works on headlines like "sub {" and
> "package"  so if you wanna fold chunks you have to mark them by  a
> leading headline like "  #- Chunk to be folded\n".
>
> But only appending ".*#- " to "cperl-outline-regexp" which is matching
> these headlines isn't enough!
>
> You have also to change the function "cperl-outline-level" such that
> the folding levels don't get confused.
>
> I have no big idea or time to fiddle out how to do this without
> hacking into Ilya's code

Myself, I have not used outline mode more than a time or two.

So all I can suggest is for you people giving me suggestions how the
USERS may want/need to add their own "extra" outline levels.  Given this
information, I might be able to incorporate something into the CPerl's
puny outline support...

> Maybe he is reading a willing to update his mode to allow a variable
> "cperl-outline-chunk-regexp"

... only if I know some examples of what people like to do.

Yours,
Ilya


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

* Re: cperl-mode - how people outline their code?
  2010-04-23 20:49             ` cperl-mode - how people outline their code? Ilya Zakharevich
@ 2010-04-23 23:09               ` LanX
  2010-04-25  2:07                 ` Ilya Zakharevich
  0 siblings, 1 reply; 20+ messages in thread
From: LanX @ 2010-04-23 23:09 UTC (permalink / raw
  To: help-gnu-emacs

Hi Ilya

> So all I can suggest is for you people giving me suggestions how the
> USERS may want/need to add their own "extra" outline levels.  Given this
> information, I might be able to incorporate something into the CPerl's
> puny outline support...
>
> > Maybe he is reading a willing to update his mode to allow a variable
> > "cperl-outline-chunk-regexp"
>
> ... only if I know some examples of what people like to do.

I can only tell how I'm doing it, I'm not "the USERS" and I'm still
confused about the whishes of Terrence/Metaperl (hs-minor-mode simply
folds at all blocks "{"blocks"}" )

Chunks of code line  - normally but not necessarily paragraphs - get a
leading comment line like

---------------------------
sub do_data {

  #- fetching data
  open my $fh,"<","txt";
  $data=slurp $fh;

  #- processing data ...

  #- returning data ...
}
--------------------------

to be able to fold these with outline minor mode I add an extra hyphen
to distinguish these line comments from others.

(I don't think it's possible to design a regex that only folds single
comment lines on tops of code chunks.)


more folding on =pods would be nice, too.

But I'm not sure if outline or hide-show is the better choice.


If you want a more representative answer you should maybe ask at
perlmonks.org

Cheers
  Rolf


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

* Re: cperl-mode - how people outline their code?
  2010-04-23 23:09               ` LanX
@ 2010-04-25  2:07                 ` Ilya Zakharevich
  2010-04-25 10:15                   ` LanX
  2010-07-01 16:16                   ` Ted Zlatanov
  0 siblings, 2 replies; 20+ messages in thread
From: Ilya Zakharevich @ 2010-04-25  2:07 UTC (permalink / raw
  To: help-gnu-emacs

On 2010-04-23, LanX <lanx.perl@googlemail.com> wrote:
> more folding on =pods would be nice, too.

Right now I have no idea what this might mean: essentially, we have an
"interleaved" file with two different "channels": code, and POD.  Each
one of them has its notion of "outline level", so if they were
separate, one could outline them without much problem.

Now how would these two different outline semantics be reflected on
the "interleaved" file?  Would one want to have two different "active"
levels, one for POD, another for code?

Puzzled,
Ilya


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

* Re: cperl-mode - how people outline their code?
  2010-04-25  2:07                 ` Ilya Zakharevich
@ 2010-04-25 10:15                   ` LanX
  2010-04-25 11:36                     ` LanX
  2010-07-01 16:16                   ` Ted Zlatanov
  1 sibling, 1 reply; 20+ messages in thread
From: LanX @ 2010-04-25 10:15 UTC (permalink / raw
  To: help-gnu-emacs

Hi

> Now how would these two different outline semantics be reflected on
> the "interleaved" file?  Would one want to have two different "active"
> levels, one for POD, another for code?

I think the problem is how to map these two channels onto linear
outline levels...

I just sometimes want to fold all embedded pod - like function headers
- away... so maybe just a switch is enough?

hs-minor-mode has a flag to "hide all comments when hiding all"

> Puzzled,
> Ilya

me too, outline-minor-mode is not very intuitive to handle ... mabe
hideshow is better.

IMHO a brainstorm at perlmonks is the best strategy...

Cheers
  Rolf



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

* Re: cperl-mode - how people outline their code?
  2010-04-25 10:15                   ` LanX
@ 2010-04-25 11:36                     ` LanX
  2010-04-27  4:13                       ` Ilya Zakharevich
  0 siblings, 1 reply; 20+ messages in thread
From: LanX @ 2010-04-25 11:36 UTC (permalink / raw
  To: help-gnu-emacs

from perlpod:

-----------------------
=pod
=cut

    The ``=pod'' directive does nothing beyond telling the compiler to
lay off parsing code through the next ``=cut''. It's useful for adding
another paragraph to the doc if you're mixing up code and pod a lot.
-----------------------

maybe just assigning a high outline level to lines starting with
"=pod" might be sufficient.

BTW: did you see http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6013


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

* Re: cperl-mode - how people outline their code?
  2010-04-25 11:36                     ` LanX
@ 2010-04-27  4:13                       ` Ilya Zakharevich
  2010-05-04 14:59                         ` LanX
  0 siblings, 1 reply; 20+ messages in thread
From: Ilya Zakharevich @ 2010-04-27  4:13 UTC (permalink / raw
  To: help-gnu-emacs

On 2010-04-25, LanX <lanx.perl@googlemail.com> wrote:
> from perlpod:
>
> -----------------------
>=pod
>=cut
>
>     The ``=pod'' directive does nothing beyond telling the compiler to
> lay off parsing code through the next ``=cut''. It's useful for adding
> another paragraph to the doc if you're mixing up code and pod a lot.
> -----------------------
>
> maybe just assigning a high outline level to lines starting with
> "=pod" might be sufficient.

Unclear: do you say that the handling of =headN, =item etc is already
satisfactory, and only the =pod is mishandled, or what?

> BTW: did you see http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6013

Yes.  [This is a contributed code, so I might be very slow in
touching it...]

Ilya


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

* Re: cperl-mode - how people outline their code?
  2010-04-27  4:13                       ` Ilya Zakharevich
@ 2010-05-04 14:59                         ` LanX
  0 siblings, 0 replies; 20+ messages in thread
From: LanX @ 2010-05-04 14:59 UTC (permalink / raw
  To: help-gnu-emacs

Hi

> Unclear: do you say that the handling of =headN, =item etc is already
> satisfactory, and only the =pod is mishandled, or what?

I'm not sure about the best approach to mix POD with code, after long
meditation I started a thread at perlmonks:

http://perlmonks.org/index.pl?node_id=838289

maybe the best approach would be allowing to generally hide all pod...

Cheers
  rolf


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

* Re: cperl-mode - how people outline their code?
  2010-04-25  2:07                 ` Ilya Zakharevich
  2010-04-25 10:15                   ` LanX
@ 2010-07-01 16:16                   ` Ted Zlatanov
  1 sibling, 0 replies; 20+ messages in thread
From: Ted Zlatanov @ 2010-07-01 16:16 UTC (permalink / raw
  To: help-gnu-emacs

On Sun, 25 Apr 2010 02:07:58 +0000 (UTC) Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote: 

IZ> On 2010-04-23, LanX <lanx.perl@googlemail.com> wrote:
>> more folding on =pods would be nice, too.

IZ> Right now I have no idea what this might mean: essentially, we have an
IZ> "interleaved" file with two different "channels": code, and POD.  Each
IZ> one of them has its notion of "outline level", so if they were
IZ> separate, one could outline them without much problem.

IZ> Now how would these two different outline semantics be reflected on
IZ> the "interleaved" file?  Would one want to have two different "active"
IZ> levels, one for POD, another for code?

I would do outline levels on POD and also set up the next-error
framework to move back and forth between functions.

I used to use folding-mode in Perl but it's really dangerous to hide
code in my experience.  So I would only ever hide POD.

Ted


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

end of thread, other threads:[~2010-07-01 16:16 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-19 15:12 cperl-mode - outline minor mode - subroutines Terrence Brannon
2010-04-19 16:16 ` LanX
2010-04-19 16:39   ` Terrence Brannon
2010-04-19 16:49     ` LanX
2010-04-21 18:28       ` Terrence Brannon
2010-04-22  1:25         ` LanX
2010-04-19 16:41   ` LanX
2010-04-19 18:02     ` Terrence Brannon
2010-04-20  8:22       ` LanX
2010-04-20 19:10         ` Terrence Brannon
2010-04-21 13:52           ` LanX
2010-04-21 18:36             ` David Rogoff
2010-04-23 20:49             ` cperl-mode - how people outline their code? Ilya Zakharevich
2010-04-23 23:09               ` LanX
2010-04-25  2:07                 ` Ilya Zakharevich
2010-04-25 10:15                   ` LanX
2010-04-25 11:36                     ` LanX
2010-04-27  4:13                       ` Ilya Zakharevich
2010-05-04 14:59                         ` LanX
2010-07-01 16:16                   ` Ted Zlatanov

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.