如何集成任何东西 - 发生在isearch模式中

时间:2011-05-05 05:35:34

标签: emacs

我非常喜欢anything.el。任何UI都很精彩。

我也经常使用isearch,它提供了键绑定 M-s o 来使用occur输入字符串调用isearch。但本机发生模式不够强大。

occur-mode中,您无法再次过滤结果。跳跃功能也很基本。

我发现anything-occuroccur更强大,你可以过滤结果,以任何风格跳转一个位置。

但是有一个问题,如何整合anything-occur?我的最后一次尝试是:

(defun occur-in-isearch ()
  (interactive)
  (let ((case-fold-search isearch-case-fold-search))
    (occur (if isearch-regexp isearch-string (regexp-quote isearch-string)))))

我将occur替换为anything-occur,但没有用。 anything-occur是一个不带参数的defun。我无法将isearch字符串传递给anything-occur

我如何整合anything-occur?或者有更好的方法在anything-occur中使用isearch-mode吗?

2 个答案:

答案 0 :(得分:1)

我不是任何用户,但这段代码可以达到你想要的99%。唯一需要注意的是,当您键入 backspace 时,初始输入字符串无法正确更新。我不知道为什么会这样。其他所有工作似乎都按预期工作。

(eval-after-load "isearch"
  '(define-key isearch-mode-map (kbd "M-s o") 'isearch-anything-occur))

(defun isearch-anything-occur (regexp &optional nlines)
  "isearch anything occur"
  (interactive
   ;; from isearch-occur
   (list
    (cond
     (isearch-word (concat "\\b" (replace-regexp-in-string
                                  "\\W+" "\\W+"
                                  (replace-regexp-in-string
                                   "^\\W+\\|\\W+$" "" isearch-string)
                                  nil t)
                           "\\b"))
     (isearch-regexp isearch-string)
     (t (regexp-quote isearch-string)))
    (if current-prefix-arg (prefix-numeric-value current-prefix-arg))))
  ;; from occur-anything
  (let ((anything-compile-source-functions
         ;; rule out anything-match-plugin because the input is one regexp.
         (delq 'anything-compile-source--match-plugin
               (copy-sequence anything-compile-source-functions))))
    (anything :sources 'anything-c-source-occur
              :input regexp
              :buffer "*Anything Occur*")))

答案 1 :(得分:0)

非常相似 -

冰柱中,在Isearch期间点击S-TAB。点击RET接受相同的搜索模式,或先修改后再点击RET

这会打开 Icicles 搜索所有匹配作为搜索上下文。要使用更多模式缩小/过滤这些上下文,只需键入更多文本。

要逐步过滤多个模式,请在模式之间点击M-SPC。使用C-down(等)在匹配项中循环或完成其中任何一项,或点击C-mouse-2中任意一项的*Completions

http://www.emacswiki.org/emacs/Icicles_-_Isearch_Enhancements#IciclesSearchFromIsearch

相关问题