关键和弦在搜索 [英] key chords in isearch

查看:119
本文介绍了关键和弦在搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很喜欢 key-chord.el 。它已成为我工作流程的一个组成部分,但有时我希望我能够在迷你缓存中(如恶意搜索)。具体来说,我想要 jj 退出 evil-search 并向下移动一行。这是可能的吗?

I really love key-chord.el. It's become an integral part of my workflow, but sometimes I wish I could have them in the minibuffer (for things like evil-search). Specifically, I'd like jj to exit out of evil-search and move down a line. Is this possible?

我知道我可以将一个充当前缀和命令的命令(见这个SO问题),所以我可以绑定 j 到一个自我插入命令,并且 jj 到我的特殊命令。在指定的空闲时间之后如何能够断开事件循环?我在蓝色的月亮中键入 jj ,我仍然喜欢超时的灵活性。

I know I can hack together a command that acts as both a prefix and a command (see this SO question), so I could bind j to a self inserting command, and jj to my special command. How would I be able to break the event loop after a specified idle time? I do type jj once in a blue moon, and I'd still like the flexibility of a timeout.

有没有什么其他方式,我不知道实现我想要什么?

Is there any other way which I am unaware of to achieve what I want?

编辑:

最初,这个问题一般是关于微型缓冲存储器。 key-chord.el 似乎适用于 minibuffer-local-map 。但是,它不适用于 isearch-mode-map 。将命令绑定到单个常规键,如 j 可以在isearch中工作。我正在尝试解决这个问题。

Origionally, this question was about the minibuffer in general. key-chord.el seems to work fine with minibuffer-local-map. It does not, however, work with isearch-mode-map. Binding a command to a single regular key like j does work in isearch. This is what I'm trying to solve.

推荐答案

我已经找到一个手动再现键和弦行为的解决方案。埃尔。

I have found a solution which manually reproduces the behaviour of key-chord.el.

(defun isearch-exit-chord-worker (&optional arg)
  (interactive "p")
  (execute-kbd-macro (kbd "<backspace> <return>")))

(defun isearch-exit-chord (arg)
  (interactive "p")
  (isearch-printing-char)
  (unless (fboundp 'smartrep-read-event-loop)
    (require 'smartrep))
  (run-at-time 0.3 nil 'keyboard-quit)
  (condition-case e
    (smartrep-read-event-loop
      '(("j" . isearch-exit-chord-worker)
         ("k" . isearch-exit-chord-worker)))
    (quit nil)))

;; example bindings
(define-key isearch-mode-map "j" 'isearch-exit-chord)
(define-key isearch-mode-map "k" 'isearch-exit-chord)

这种方法实际上比 key-chord.el


  • 它不使用输入法,因此您可以结合使用其他输入法。

  • 第一个字符立即显示,如果不正确,则退出,而 key-chord.el 仅在延迟后显示。

  • It does not use an input method, so you can use a different input method in conjunction with this.
  • The first character is shown immediately, and retracted if it is incorrect, while key-chord.el only shows it after a delay.

这篇关于关键和弦在搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆