简体   繁体   English

如何设置 SLIME REPL 的高度?

[英]How do I set the height of the SLIME REPL?

When I start SLIME ( Mx slime ), the SLIME REPL window takes up the bottom half of the frame.当我启动 SLIME ( Mx slime ) 时,SLIME REPL window 占据了框架的下半部分。 Is there a setting for changing the default height of the REPL?是否有更改 REPL 的默认高度的设置? I want the REPL window to take up less than half of the height of the frame.我希望 REPL window 占用不到框架高度的一半。

In emacs you may use fit-window-to-buffer and call it (or a function using it) from a hook:在 emacs 中,您可以使用fit-window-to-buffer并从钩子中调用它(或使用它的 function):

(defun flux-fit-slime-repl ()
  ;; uncomment the following line:
  ;; (interactive)
  ;; if you want to call
  ;; flux-fit-slime-repl yourself to experiment
  (fit-window-to-buffer))

(add-hook 'slime-connected-hook 'flux-fit-slime-repl 'append)

The final argument to add-hook above, append , asks that this hook be placed at the end of the slime-connected hooks as we want slime to be done printing the welcome before we resize.上面添加钩子的最后一个参数append要求将此钩子放置在粘液连接钩子的末端,因为我们希望粘液在我们调整大小之前完成打印欢迎。

If you'd rather call fit-window-to-buffer from the lisp side, you could allow swank to send code to emacs by customizing slime-enable-evaluate-in-emacs in emacs prior to calling this in the slime repl:如果您更愿意从 lisp 端调用fit-window-to-buffer ,则可以允许 swank 通过在 Slime repl 中调用之前在 emacs 中自定义slime-enable-evaluate-in-emacs来将代码发送到 emacs:

(swank::eval-in-emacs '(swank-io-package::fit-window-to-buffer))  

Add the line above to ~/.swank.lisp in order to have it evaluated when slime starts.将上面的行添加到~/.swank.lisp以便在 slime 启动时对其进行评估。

You can reduce the size of the REPL window instead of making it as small as possible by making use the slime-connected-hook in the way described by @chrnybo, but then using window-resize to reduce the window size.您可以减小 REPL window 的大小,而不是通过以@chrnybo 描述的方式使用slime-connected-hook来使其尽可能小,然后使用window-resize来减小 window 的大小。 Since you can't vertically resize a window that is full-height in the frame, you should check to see that it is either at the top or at the bottom (but not both).由于您无法垂直调整框架中全高的 window 的大小,因此您应该检查它是否位于顶部或底部(但不能同时位于两者)。 Add the code below to your .emacs file to create Slime REPL windows that are 10 lines smaller than the default:将以下代码添加到您的.emacs文件中以创建比默认值小 10 行的 Slime REPL windows:

(defun my-reduced-slime-repl ()
  (when (xor (window-at-side-p 'nil 'bottom)
             (window-at-side-p 'nil 'top))
    (window-resize 'nil -10)))

(add-hook 'slime-connected-hook 'my-reduced-slime-repl 'append)

Here is another version that will make the REPL window *my-slime-repl-height* lines tall, unless the specifed height is larger than the default, in which case the default height is retained:这是另一个版本,它将使 REPL window *my-slime-repl-height*行高,除非指定的高度大于默认高度,在这种情况下,默认高度被保留:

(defvar *my-slime-repl-height* 10)

(defun my-reduced-slime-repl ()
  (let* ((win-height (window-total-height))
         (delta (- *my-slime-repl-height* win-height)))
    (when (and (< delta 0)
               (xor (window-at-side-p 'nil 'bottom)
                    (window-at-side-p 'nil 'top)))
      (window-resize 'nil delta))))

(add-hook 'slime-connected-hook 'my-reduced-slime-repl 'append)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM