简体   繁体   English

在emacs中搜索剪贴板文本

[英]Search for clipboard text in emacs

是否有可能在点击Cs时搜索当前存在于剪贴板中的文本,可能是在点击Cs时触发了某种钩子然后将剪贴板插入到迷你缓冲区中?

Isearch provides a set of standard keys to change the behaviour of the search process. Isearch提供了一组标准键来更改搜索过程的行为。 Typing Cs My invokes isearch-yank-kill that pulls string from kill ring (ie, clipboard) into search string. 键入Cs我调用isearch-yank-kill将字符串从kill ring(即剪贴板)拉入搜索字符串。

You could yank the text after starting isearch: 你可以在启动isearch后拉出文本:

(defun my-isearch-yank-clipboard ()
  (interactive)
  (isearch-yank-string (or (x-get-selection 'PRIMARY)
                           (x-get-selection 'CLIPBOARD)
                           "")))

(define-key isearch-mode-map (kbd "M-s c") 'my-isearch-yank-clipboard)

Start isearch then "Ms c" 然后开始isearch然后“Ms c”

您可以使用defadvice来改变命令isearch-forward的行为,默认情况下绑定到Cs,或者定义另一个可能包含isearch-forward并将其绑定到Cs而不是isearch-forward的函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM