dired-do-search不使用isearch-face

时间:2013-07-03 19:27:04

标签: emacs dired font-lock emacs-faces isearch

如何使用直接搜索使用更明显的isearch-face,或者至少突出显示找到的整个令牌?

如果在编辑时没有分散注意力,那么闪烁的光标将是另一种选择。

重述

如果我在字符串“hello”上运行isearch-forward,则在搜索过程中该字符串会突出显示,如下图所示。

image1

如果我处于dired(-x)模式,请标记该文件,如下图所示,

image2

然后在字符串“hello”上运行dired-do-search,找到字符串,但不会突出显示,如下所示。

image3

如何让dired-do-search使用与isearch-forward相同的面孔?在这个例子中很容易发现光标,但是在大量使用font-lock的显示器上,并且在为光标选择了一个更温和,非突兀的面部之后,很难发现搜索的位置字符串。

更新

答案是否以最简洁的方式解决这个问题?

1 个答案:

答案 0 :(得分:0)

也许您正在寻找dired-do-isearchdired-do-isearch-regexp

如果您想要dired-do-search的同样感觉,看起来您也可以通过自定义tags-loop-continuetags-loop-operate操作进行调用tags-loop-scan

这是我想出的:

(defvar dired-do-search-overlay nil)
(defvar dired-do-search-region nil)
(defun dired-do-search (regexp)
  "Search through all marked files for a match for REGEXP.
Stops when a match is found.
To continue searching for next match, use command \\[tags-loop-continue]."
  (interactive "sSearch marked files (regexp): ")
  (setq 
   tags-loop-operate `(progn 
            (if dired-do-search-overlay
                (delete-overlay dired-do-search-overlay))
            (setq dired-do-search-overlay 
                  (make-overlay (car dired-do-search-region)
                        (cadr dired-do-search-region)))
            (overlay-put dired-do-search-overlay
                     'face isearch-face)
            (overlay-put dired-do-search-overlay
                     'priority 1001)    
            nil)
   tags-loop-scan `(progn
             (if (re-search-forward ',regexp nil t)
             (setq dired-do-search-region 
                   (list (match-beginning 0)
                     (match-end 0)))
               (if dired-do-search-overlay 
               (delete-overlay dired-do-search-overlay))
               nil)))
  (tags-loop-continue 
   (or '(dired-get-marked-files nil nil 'dired-nondirectory-p) t)))