1

如何让 dired-do-search 使用更明显的 isearch-face,或者至少突出显示找到的整个令牌?

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

重述

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

图像1

如果我在 dired(-x) 模式下,标记文件,如下图所示,

图2

然后对字符串“hello”运行 dired-do-search,找到该字符串,但它没有突出显示,如下所示。

图3

如何让 dired-do-search 使用与 isearch-forward 相同的面孔?在这个例子中很容易找到光标,但是在较大的显示器上大量使用字体锁定,并且在为光标选择了一个更温和、不突兀的脸之后,很难找到搜索的位置细绳。

更新

下面的答案是解决此问题的最简单方法吗?

4

1 回答 1

0

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

如果你想要同样的感觉dired-do-search,看起来你也可以制作一个tags-loop-continue使用自定义tags-loop-operatetags-loop-scan操作调用的 defun。

这是我想出的:

(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)))
于 2013-07-04T02:53:01.703 回答