gpt4 book ai didi

Emacs:如何突破 ido minibuffer?

转载 作者:行者123 更新时间:2023-12-04 20:44:07 29 4
gpt4 key购买 nike

我一般使用 ido-switch-buffer ,但有时当候选人太多时,helm-buffers-list是可取的。但是脱离ido很麻烦,
调用 helm 并重新输入丢失的信息。

所以我写了这段代码,它直接在 helm 中重用了在 ido 中输入的信息:

(require 'helm-buffers)
(defun switch-to-helm-buffers-list ()
"Emulate `helm-buffers-list' call with ido contents as initial input."
(interactive)
(let ((str (minibuffer-contents-no-properties)))
(helm :sources '(helm-source-buffers-list
helm-source-ido-virtual-buffers
helm-source-buffer-not-found)
:buffer "*helm buffers*"
:keymap helm-buffer-map
:truncate-lines t
:input str)
;; (ido-exit-minibuffer)
))

(add-hook
'ido-setup-hook
(lambda()
(define-key ido-buffer-completion-map "\C-i"
'switch-to-helm-buffers-list)))

一个问题是 ido 会留在迷你缓冲区中。
当我添加电话时 ido-exit-minibuffer之前 helm ,它没有被调用。
当我在之后添加它时,它会重置窗口配置。
我怎么解决这个问题?

最佳答案

查看答案 https://stackoverflow.com/a/21165658/1937596

首先,我对您的函数进行了一些修补。

(require 'helm-buffers)
(defun switch-to-helm-buffers-list ()
"Emulate `helm-buffers-list' call with ido contents as initial input."
(interactive)
(let ((str ido-text))
(helm :sources '(helm-source-buffers-list
helm-source-ido-virtual-buffers
helm-source-buffer-not-found)
:buffer "*helm buffers*"
:keymap helm-buffer-map
:truncate-lines t
:input str)
))

我的配方修补了函数体 ido-buffer-internal (内部用于 ido-switch-buffer )也是。
您必须执行一次此代码。
(eval
(read
(replace-regexp-in-string
"cond"
"cond ((eq ido-exit 'eab-ido-helm) (call-interactively 'switch-to-helm-buffers-list)) "
(save-window-excursion
(find-function-do-it 'ido-buffer-internal nil 'switch-to-buffer)
(let ((bgn (point)))
(forward-sexp)
(let ((end (point)))
(buffer-substring-no-properties bgn end)))))))

我添加了一个辅助功能。
(defun eab/ido-helm ()
(interactive)
(setq ido-exit 'eab-ido-helm)
(exit-minibuffer))

注意,我使用 eab/ido-helm而不是 switch-to-helm-buffers-listdefine-key .
(add-hook
'ido-setup-hook
(lambda()
(define-key ido-buffer-completion-map "\C-i"
'eab/ido-helm)))

关于Emacs:如何突破 ido minibuffer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21000540/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com