1

在不破解源代码或创建我自己的 isearch-repeat... 函数的情况下,是否可以禁用isearch-repeat-forwardand的默认粘性突出显示isearch-repeat-backward

我正在使用 Emacs Trunk --with-ns 的最新开发人员版本。


这里有一些想法(正在进行中),但它们并不能解决问题——isearch-mode-end-hook似乎与isearch-repeat-forward和没有关联isearch-repeat-backwardlawlist-lazy-highlight-cleanup如果任何键盘输入(退出和/或箭头键)可以在退出时暂时链接到,那就太好了isearch-repeat

(add-hook 'isearch-mode-end-hook 'my-isearch-end)
(defun my-isearch-end ()
  "Custom behaviors for `isearch-mode-end-hook'."
  (when isearch-mode-end-hook-quit
    (lawlist-lazy-highlight-cleanup t)))

(defun lawlist-lazy-highlight-cleanup (&optional force)
  "Stop lazy highlighting and remove extra highlighting from current buffer.
FORCE non-nil means do it whether or not `lazy-highlight-cleanup'
is nil.  This function is called when exiting an incremental search if
`lazy-highlight-cleanup' is non-nil."
  (interactive '(t))
  (if (or force lazy-highlight-cleanup)
      (while isearch-lazy-highlight-overlays
        (delete-overlay (car isearch-lazy-highlight-overlays))
        (setq isearch-lazy-highlight-overlays
              (cdr isearch-lazy-highlight-overlays))))
  (when isearch-lazy-highlight-timer
    (cancel-timer isearch-lazy-highlight-timer)
    (setq isearch-lazy-highlight-timer nil))
(lawlist-isearch-dehighlight))

(defun lawlist-isearch-dehighlight ()
(interactive)
  (when isearch-overlay
    (delete-overlay isearch-overlay)))

(defun lawlist-isearch-repeat-forward ()
  "Repeat incremental search forwards."
  (interactive)
  (isearch-repeat 'forward)
;; need to add something that says sit-for any keyboard input before cleanup occurs.
;; (read-event) ;; read-char-exclusive | read-char | read-event
(sit-for 60)
(lawlist-lazy-highlight-cleanup))

(defun lawlist-isearch-repeat-backward ()
  "Repeat incremental search backwards."
  (interactive)
  (isearch-repeat 'backward)
;; need to add something that says sit-for any keyboard input before cleanup occurs.
;; (read-event) ;; read-char-exclusive | read-char | read-event
(sit-for 60)
(lawlist-lazy-highlight-cleanup))
4

2 回答 2

1

虽然这不能回答您的问题,但它可能会做您最终想要解决的事情:

(define-key isearch-mode-map [(control up)]   'isearch-ring-retreat)
(define-key isearch-mode-map [(control down)] 'isearch-ring-advance)

键入 CS 后,您可以使用 C-up 和 C-down 来浏览搜索历史。所以 CS C-up 会做你想做的事:重复最后一次搜索而不留下“粘性”覆盖。

另请参阅 search-ring-update,如果您愿意,可以进一步自定义。

于 2013-06-21T07:16:15.807 回答
0

使用源代码isearch.el作为指导,以下 OSX 附加键分配消除了上面问题中概述的粘滞突出问题。

(define-key global-map [?\s-f] 'isearch-forward)
(define-key esc-map [?\s-f] 'isearch-forward-regexp)
(define-key minibuffer-local-isearch-map [?\s-f] 'isearch-forward-exit-minibuffer)
(define-key isearch-mode-map [?\s-f] 'isearch-repeat-forward)

(define-key global-map [?\s-F] 'isearch-backward)
(define-key esc-map [?\s-F] 'isearch-backward-regexp)
(define-key minibuffer-local-isearch-map [?\s-F] 'isearch-reverse-exit-minibuffer)
(define-key isearch-mode-map [?\s-F] 'isearch-repeat-backward)
于 2013-06-20T20:12:21.727 回答