in reply to Emacs shows xrefs in code but needs an interface that's good for humans

I use the built-in "occur" when I want to see where things are referenced. It's not smart but usually does its job.

However, I'm just an amateur programmer and my needs of specialist tools may be limited. I don't have to deal with crappy code or work under pressure.

  • Comment on Re: Emacs shows xrefs in code but needs an interface that's good for humans

Replies are listed 'Best First'.
Re^2: Emacs shows xrefs in code but needs an interface that's good for humans
by diotalevi (Canon) on Mar 27, 2006 at 14:10 UTC

    Hey that's neat! Here's an example for anyone that's watching. I'd never seen occur before and had to try it out.

    Typing M-x occur "current_balance" gets me a new pane of info. If I move the cursor to any and hit enter, the source pane will automatically seek there.

    5 lines matching "current_balance" in buffer RBCUWatcher2. 23:my $current_balance = eval { 39:exit unless length $current_balance; 41:write_file( BALANCE_FILE, $current_balance ); 43:my $difference = $current_balance - $old_balance; 45: my $message = "\$$current_balance "

    ~/bin/BankBalanceWatcher

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re^2: Emacs shows xrefs in code but needs an interface that's good for humans
by educated_foo (Vicar) on Mar 27, 2006 at 21:22 UTC
    I've found this little gem makes occur quite a bit more useful:
    (defun isearch-occur () "Invoke `occur' from within isearch." (interactive) (let ((case-fold-search isearch-case-fold-search)) (occur (if isearch-regexp isearch-string (regexp-quote isearch-str +ing))))) (define-key isearch-mode-map (kbd "C-o") 'isearch-occur)
    Then you can isearch to the word you want, hit C-w to grab the rest of it, then C-o to get a list of occurrences.