help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: browser for bash scripts?


From: Oleksandr Gavenko
Subject: Re: browser for bash scripts?
Date: Sat, 01 Dec 2012 13:28:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

On 2012-11-30, Stefan Monnier wrote:

> TR> Does anyone have code to make speedbar, ECB, or other code browser
> TR> display/navigate bash scripts?
>
> `sh-script.el' already provides support for `imenu', so Speedbar should
> already find the functions in the bash scripts, or at least there should
> be very little preventing it from happening.
>
I found imenu very useful. Especially when it driven by keyboard instead of
mouse:

  (defun my-popup-menu ()
    "Menu from keyboard by emulating mouse event."
    (interactive)
    (mouse-popup-menubar
     (list (list (/ (display-pixel-width) 2) 10) (get-buffer-window 
(buffer-name)))
     nil)
    )
  (global-set-key [f10] 'my-popup-menu)
  (global-set-key [apps] 'my-popup-menu)
  (global-set-key [menu] 'my-popup-menu)

  (require 'imenu)

  (defun my-imenu-to-menubar ()
    "Force imenu building when (menu-bar-mode -1)."
    (when imenu-generic-expression
      (imenu-add-menubar-index)
      (run-hooks 'menu-bar-update-hook) ))
  (mapc (lambda (hook) (add-hook hook 'my-imenu-to-menubar))
        my-devel-mode-hook-list)

> TR> I'd like, e.g., to easily navigate between variable and function
> TR> definitions and calls/uses.
>
> I guess we could add variables to sh-mode's `imenu' support.
>
I think this is useless as bash (and sh) allow local variables.

It will be useful to teach 'semantic-ia-*-jump' jump to definition.

Also modular bash scripts include common parts so definition may come from
another files...

For variable I can suggest to use 'occur' or 'lgrep/rgrep':

  (defun my-sh-var-occur ()
    (interactive)
    (let ( (name (thing-at-point 'symbol)) )
      (when name
        (occur (concat name "="))) ))

-- 
Best regards!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]