gpt4 book ai didi

Emacs 外壳。如何在按 RET 时读取命令行的内容

转载 作者:行者123 更新时间:2023-12-04 19:14:03 25 4
gpt4 key购买 nike

我的意图是使用 bm.el Visible Bookmarks对于我按 RET 时的每个提示。我已经设法在某种程度上实现了这一点..请在下面评论我的代码,如果它缺少一些重要的问题:例如。我不知道我是否需要处理参数,而不仅仅是将它们传递给默认函数。

当我在空命令行上按 RET 时,我不想将该行添加为书签。如何在将控制传递给默认函数之前拦截命令行内容 eshell-send-input ?

(defun eshell-send-input-zAp (&optional use-region queue-p no-newline)
"eshell-send-input, customized to add bm-bookmark to prompt line"
(interactive)
(bm-bookmark-add)
(eshell-send-input use-region queue-p no-newline))

(add-hook 'eshell-mode-hook
#'(lambda ()
(define-key eshell-mode-map
[return]
'eshell-send-input-zAp)))

最佳答案

你的代码看起来不错。如果你阅读了eshell-send-input的代码,您将看到如何获取当前输入。

另请阅读 interactive论据。 "P"需要将用户区域传递给 eshell-send-input .

(defun eshell-send-input-zAp (&optional use-region queue-p no-newline)
"eshell-send-input, customized to add bm-bookmark to prompt line"
(interactive "*P")
(unless (string-equal (eshell-get-old-input use-region) "")
(bm-bookmark-add))
(eshell-send-input use-region queue-p no-newline))

关于Emacs 外壳。如何在按 RET 时读取命令行的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11946113/

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