在 emacs 中如何将窗口的垂直分割改为水平分割

文章目录

<2022-08-25 周四>

emacs中如何将窗口的垂直分割改为水平分割

emacs没有原生支持,所以抄了一个函数,如下:

emacs-lisp 复制代码
;;; https://www.emacswiki.org/emacs/ToggleWindowSplit
(defun toggle-window-split ()
  (interactive)
  (if (= (count-windows) 2)
      (let* ((this-win-buffer (window-buffer))
             (next-win-buffer (window-buffer (next-window)))
             (this-win-edges (window-edges (selected-window)))
             (next-win-edges (window-edges (next-window)))
             (this-win-2nd (not (and (<= (car this-win-edges)
                                         (car next-win-edges))
                                     (<= (cadr this-win-edges)
                                         (cadr next-win-edges)))))
             (splitter
              (if (= (car this-win-edges)
                     (car (window-edges (next-window))))
                  'split-window-horizontally
                'split-window-vertically)))
        (delete-other-windows)
        (let ((first-win (other-window 1)))
          (funcall splitter)
          (if this-win-2nd
              (other-window 1))
          (set-window-buffer (selected-window) this-win-buffer)
          (set-window-buffer (next-window) next-win-buffer)
          (if this-win-2nd
              (other-window 1))))))

emacs如何将两个窗口的内容交换?调用M-x window-swap-states即可。

相关推荐
weixin_46407807几秒前
ppt转为draw.io方法
编辑器
Masimaro2 天前
《elisp 每日一练》—— Major Mode 管理 abbrev-table
emacs
一木 之林2 天前
手搓家庭服务器:二手装机、Docker部署、端口映射与frp内网穿透
服务器·人工智能·git·编辑器
东木月3 天前
PyCharm 集成 Claude Code 插件:安装、配置与使用指南
python·pycharm·编辑器
boke112百科3 天前
WordPress经典编辑器【插入至文章】按钮怎么调到右上角?
编辑器·wordpress·wordpress教程·经典编辑器
AI情绪识别开源4 天前
检信AI学业生涯智选系统技术方案概述
emacs
我要见SA姐14 天前
DeepSeek Harness 开源贡献手记:从 Issue 到 Merge 的完整旅程
ide·vscode·python·自动化·编辑器
我要见SA姐15 天前
用 Claude Code 重构遗留系统:从评估到落地的完整实践指南
数据库·ide·vscode·oracle·编辑器
MR.P_H_6 天前
CCS(Code Composer Studio)修改编码格式
编辑器
Masimaro7 天前
《elisp 每日一练》—— Minor Mode 回顾与综合练习
emacs