想要新竖直拆分一个窗口打开,而不是当前 buffer。
我尝试了一下新建类似 embark-consult-goto-grep
的函数,但是不知道怎么添加到 embark 的快捷键里(所以也不知道它现在能不能达到目的)。
(defun embark-consult-goto-grep-right (location)
(let ((default-directory (with-selected-window (previous-window)
(split-window-right)
(other-window 1)
default-directory)))
(consult--jump (consult--grep-position location))
(pulse-momentary-highlight-one-line (point))))
如果你想替换 embark 对 consult-grep
的默认操作 embark-consult-goto-grep
,可以修改 embark-default-action-overrides
。
也可以用 embark-define-keymap
针对 consult-grep
type 定制一系列操作。
改了一个能用的,不过命令结束后光标不在新窗口,不知道怎么能做到?大家能不能给点建议。
(defun embark-consult-goto-grep-right (location)
(let ((default-directory (with-selected-window (previous-window)
default-directory)))
(split-window-right)
(windmove-right)
(consult--jump (consult--grep-position location))
(pulse-momentary-highlight-one-line (point))))
(embark-define-keymap qi--embark-consult-grep-map
"Keymap for consult grep actions."
("o" embark-consult-goto-grep-right))
(add-to-list 'embark-keymap-alist '(consult-grep . qi--embark-consult-grep-map) 'append)