Sublime Text 2's “Goto Anything” (or instant search) for Emacs?

后端 未结 5 1105
醉话见心
醉话见心 2021-01-30 17:36

I tried out Sublime Text 2 recently, and I found Goto Anything superbly useful for navigating source code (Ctrl-P file@symbol seems to work really well). Is there something simi

5条回答
  •  庸人自扰
    2021-01-30 18:30

    Just use helm.

    It is perhaps more configuration than you asked for, but once you get it configured how you like, it should be quite comfortable. Very much like Emacs ;).

    And you should file a bug with Thierry for getting some more newbie friendly defaults. He is quite responsive with issues.

    helm-multi-occur

    Primarily multi-buffer interactive "occur" is provided through helm-multi-occur. If you execute the command, you'll notice that you have to pick some buffers first (use C-SPC to select from the list, M-SPC to select all). Then you can enter your query at the next prompt. It's easy to make your own version that skips the buffer selection like so:

    (eval-after-load "helm-regexp"
        '(setq helm-source-moccur
               (helm-make-source "Moccur"
                   'helm-source-multi-occur :follow 1)))
    
    (defun my-helm-multi-all ()
      "multi-occur in all buffers backed by files."
      (interactive)
      (helm-multi-occur
       (delq nil
             (mapcar (lambda (b)
                       (when (buffer-file-name b) (buffer-name b)))
                     (buffer-list)))))
    

    helm-buffers-list

    Often you don't care about the exact occurrences of the query string, but want a list of all buffers that contain it.

    helm-buffers-list has some tricks up its sleeve. The first symbol you specify is filtering by major-mode, and you can use the "@" prefix to narrow the list to buffers that contain a string.

    To wit, "ruby @prompt" will show you a list of buffers whose major-mode contains "ruby" and whose contents contains "prompt". Or you can just use "@prompt" to show all buffers that contain "prompt".


    Powerful and comfortable once you get used to it.


    EDIT modified my-helm-multi-all to enable helm-follow-mode.

    EDIT 2 update helm-follow-mode code to reflect helm changes.

    EDIT 3 updated again to reflect helm changes

提交回复
热议问题