helm的弹出窗口如何固定弹出位置为下半屏?现在竖排多个窗口时会使用最右边窗口

helm的弹出窗口如何固定弹出位置为下半屏?现在竖排多个窗口时会使用最右边窗口

几乎啥也看不到了。。

期望无论我窗口如何,都使用下图的位置

分享给小配置给你

(setq split-width-threshold nil) ;分屏的时候使用上下分屏

1 个赞

:joy:我喜欢左右分,竖屏能看到的东西多一点。。

你不是要固定下面吗?

MM-x弹出的heml窗口会自己找一个我已打开的窗口显示,我想让helm-x固定出现在下半屏

第一楼不是告诉你方法了吗?

如果你要平常左右分屏, helm 固定下面分屏, 你就需要自己给 helm 关键函数写 advice.

1 个赞

我其实是想找多窗口时有没有固定below这样的设定,help里没找到。。

d:/software/MSYS2/home/Administrator/.emacs.d/elpa/helm-core-20221113.1706/helm-core.el

(defun helm-split-window-default-fn (window)
  "Default function to split windows before displaying `helm-buffer'.

It is used as default value for
`helm-split-window-preferred-function' which is then the
let-bounded value of `split-window-preferred-function' in
`helm-display-buffer'.  When `helm-display-function' which default
to `helm-default-display-buffer' is called from
`helm-display-buffer' the value of
`split-window-preferred-function' will be used by
`display-buffer'."
  (let* (split-width-threshold
         (win (if (and (fboundp 'window-in-direction)
                       ;; Don't try to split when starting in a minibuffer
                       ;; e.g M-: and try to use helm-show-kill-ring.
                       (not (minibufferp helm-current-buffer)))
                  ;; (if (or (one-window-p t)
                  ;;         helm-split-window-inside-p)
                      (split-window
                       (selected-window) nil
                       (if (eq helm-split-window-default-side 'other)
                           helm-split-window-other-side-when-one-window
                         helm-split-window-default-side))
                    ;; If more than one window reuse one of them.
                    ;; (cl-case helm-split-window-default-side
                    ;;   (left  (or (helm-window-in-direction 'left)
                    ;;              (helm-window-in-direction 'above)
                    ;;              (selected-window)))
                    ;;   (above (or (helm-window-in-direction 'above)
                    ;;              (helm-window-in-direction 'left)
                    ;;              (selected-window)))
                    ;;   (right (or (helm-window-in-direction 'right)
                    ;;              (helm-window-in-direction 'below)
                    ;;              (selected-window)))
                    ;;   (below (or (helm-window-in-direction 'below)
                    ;;              (helm-window-in-direction 'right)
                    ;;              (selected-window)))
                    ;;   (same  (selected-window))
                    ;;   (other (or (helm-other-window-for-scrolling)
                    ;;              (selected-window)))
                    ;;   (t     (or (window-next-sibling) (selected-window)))))
                (split-window-sensibly window))
              ))
    (setq helm-persistent-action-window-buffer (window-buffer win))
    win))

从源码找到了 如果多窗口时的分屏代码,虽然看不懂在干啥,但是注释掉只留下单窗口的情况,倒是实现了固定往下,但是我觉得肯定又什么设置可以实现,不至于这样。。我记得以前看过custom face还是啥的,见到有人设置过固定helm,可能是spacemacs时候看到的。

display-buffer-alist, 详见 文档

固定选用 bottom 的窗口:

(add-to-list 'display-buffer-alist
             '("^\\*helm .*"
               (display-buffer-at-bottom)))

也可以让它用 side window:

(add-to-list 'display-buffer-alist
             '("^\\*helm .*"
               (display-buffer-in-side-window)
               (side . bottom)))

display-buffer 机制是 emacs 里通用的,你可以用它来定制任何「弹窗」的位置。第三方的辅助包有 shackle 等,可以用来简化 display-buffer-alist 的定制。

1 个赞
  * *Helm Swoop*                 3717 Hmm              
  * *helm mini*                  2517 Hmm              
  * *helm M-x*                    125 Hmm              

Helm Swoop哪个没有被匹配上, “^\Helm .” “^\[Hh]elm .” 我试了这两个,都不行,这是啥问题。

看了下 helm-swoop 的代码,他用 helm-swoop-split-window-function 覆盖了 helm-display-function,所以 Emacs 自己的 display-buffer-alist 机制不起效。

一个解决办法是重新改回来:

(setq helm-swoop-split-window-function 'helm-default-display-buffer)
2 个赞

搞定,这个厉害了!

使用display-buffer-in-side-window的问题是,当对candidate使用tab键,打开helm action时,会报错「Cannot split side window or parent of side window」。因此此方法还需要对helm-show-action-buffer进行hack