Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Making it clearer to say that a sub is defined within current package

by karlgoethebier (Abbot)
on Apr 12, 2019 at 15:36 UTC ( #1232495=note: print w/replies, xml ) Need Help??


in reply to Re: Making it clearer to say that a sub is defined within current package
in thread Making it clearer to say that a sub is defined within current package

"...right-click on a name..."

This doesn't work for hardboiled coders because they think using a mouse is for sissies. Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

  • Comment on Re^2: Making it clearer to say that a sub is defined within current package
  • Download Code

Replies are listed 'Best First'.
Re^3: Making it clearer to say that a sub is defined within current package
by LanX (Sage) on Apr 12, 2019 at 22:42 UTC
    Such information can be triggered by cursor position too.

    At least in the mother of all IDEs ...

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      "... the mother of all IDEs..."

      Probably this is emacs. May be i miss a command like M-x goto-definition in some mode? Best regards, Karl

      Update: Dialogue - a didactic device.

      «The Crux of the Biscuit is the Apostrophe»

      perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

        > Probably this is emacs.

        what else? ;-)

        > May be i miss a command like M-x goto-definition in some mode?

        well these are several questions ... point for point.

        • you said the mouse is needed

          nope

          every x-action is bound to a function and can be bound to a key too, and the function word-at-point gives you the word under the cursor. So you can freely combine any mouse-action with the word-at-point .

          Tip: C-h k doesn't only show you the keybinding of the next keystrokes, but also of the following mouse actions. Hence you can see what is triggered and use it in your own scripts.

        • getting all "local" subs

          cperl-mode supports imenu , which scans the current buffer for every sub declaration.

          Just go to the menu bar and click <menu-bar> <Perl> <Tools> <Imenu> and you'll see a list of all subs in the buffer.

        • jumping to the sub at point

          When called interactively with M-x imenu or a key-binding like C-c i or M-Ret (personal binding) offers all alternatives in the mini-buffer (the bottom line) but defaulting to the word at point.

          For instance in my bindings M-RET RET lets me jump to that definition.

        • automatically showing that a sub is local

          Cperl mode has a setting to automatically show a mini-description for any Perl construct under the cursor In the message area. See <menu-bar> <Perl> <Toggle...> <Auto-help on Perl constructs>

          One could also hack this interface to show information for the sub at point using the data from imenu

        • Choroba mentioned etags/ctags

          These is necessary for bigger projects where the definition is in another file. I was only replying to the "local" requirement. ( Tags are tricky in a language which can only be parse by its own runtime engine ;)

        HTH! :)

        TL DR

        M-x imenu

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        See etags, or, in recent Emacsen, xref. I use a script that (naïvely) recognises Moo(se) constructs as well: perl-etags.

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1232495]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-05-25 15:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?