如果我在emacs中运行M-x
shell来获取一个终端,它会知道在哪里自动换行.例如,ls的输出被格式化成适合窗口的列.
我的问题是如果我用C-x 3垂直分割窗口,shell模式仍然认为窗口填满整个框架.结果是命令输出的丑陋包装.有没有办法让shell-mode知道它必须更新屏幕宽度?
编辑:
使用HN的答案在下面,我想出了这个修复:
(defun my-resize-window () "Reset the COLUMNS environment variable to the current width of the window." (interactive) (let ((proc (get-buffer-process (current-buffer))) (str (format "export COLUMNS=%s" (window-width)))) (funcall comint-input-sender proc str))) (defun my-shell-mode-hook () (local-set-key "\C-cw" 'my-resize-window))
我晚点参加派对,但是COLUMNS不是这样做的.这是我的.emacs的摘录:
原文链接:https://www.f2er.com/bash/385139.html(defun comint-fix-window-size () "Change process window size." (when (derived-mode-p 'comint-mode) (set-process-window-size (get-buffer-process (current-buffer)) (window-height) (window-width)))) (defun my-shell-mode-hook () ;; add this hook as buffer local,so it runs once per window. (add-hook 'window-configuration-change-hook 'comint-fix-window-size nil t)) (add-hook 'shell-mode-hook 'my-shell-mode-hook)
每次不同于导出COLUMNS,此方法不需要您
bash在这一刻,它不会垃圾邮件您的会话与空白提示.这个
代码应该可能在comint本身,也许我会提交一个错误报告.
编辑:如果您以缓冲区本地方式修改窗口配置更改挂钩钩子每个窗口运行一次,而不是每帧一次.