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

后端 未结 5 1138
醉话见心
醉话见心 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:18

    for emacs I customize and modify this solution (for use install helm):

    (defun helm-occur-from-point (initial-value)
      "Invoke `helm-occur' from point."
      (interactive)
      (let ((input initial-value)
            (bufs (list (buffer-name (current-buffer)))))
        ;; (isearch-exit)
        (helm-occur-init-source)
        (helm-attrset 'moccur-buffers bufs helm-source-occur)
        (helm-set-local-variable 'helm-multi-occur-buffer-list bufs)
        (helm-set-local-variable
         'helm-multi-occur-buffer-tick
         (cl-loop for b in bufs
                  collect (buffer-chars-modified-tick (get-buffer b))))
        (helm :sources 'helm-source-occur
              :buffer "*helm occur*"
              :history 'helm-grep-history
              :input input
              :truncate-lines t)))
    
    (defun get-point-text ()
        "Get 'interesting' text at point; either word, or region"
        (if mark-active
            (buffer-substring (mark) (point))
          (thing-at-point 'symbol)))
      (defun helm-occur-1 (initial-value)
        "Preconfigured helm for Occur with initial input."
        (helm-occur-from-point initial-value))
      (defun bk-helm-occur ()
        "Invoke helm-occur with initial input configured from text at point"
        (interactive)
        (helm-occur-1 (get-point-text)))
      (global-set-key (kbd "M-s-o") 'bk-helm-occur)
    

    primary it based on @see https://news.ycombinator.com/item?id=6872508 but on last helm versions not work but fixed with my changes (just copy/paste from some internal helm modules)

提交回复
热议问题