在 Emacs 中以特定宽度从前一帧设置连续的新帧

Setting consecutive new frames at a specific width from the previous frame in Emacs

我的 init.el

中有以下内容
(if (display-graphic-p)
    (progn
      (setq initial-frame-alist
            '((tool-bar-lines . 0)
              (width . 106) ; chars
              (height . 60) ; lines
              (left . 50)
              (top . 50)))
      (setq default-frame-alist
            '((tool-bar-lines . 0)
              (width . 106)
              (height . 60)
              (left . 50)
              (top . 50))))
  (progn
    (setq initial-frame-alist '((tool-bar-lines . 0)))
    (setq default-frame-alist '((tool-bar-lines . 0)))))

我是 emacs 的新手,想知道如何打开前一帧的每个连续的新帧(左 + 10)。

我希望每次使用 C-x 5 2 打开新框架时都能直观地看到所有框架。使用 init.el 中的当前设置,新帧与前一帧重叠。

我认为这里最简单的方法是直接创建框架 emacs 将在变量之后创建框架:

ELISP> initial-frame-alist
((fullscreen . maximized)
 (left-fringe . 10)
 (right-fringe . 0))

我有这个 init.el

;; Default frame size
(add-to-list 'initial-frame-alist '(fullscreen . maximized))

我也用边缘模式

;; Turn on the left fringe
(set-fringe-mode '(10 . 0)) ;; 10px left, 0px right

所以这是我对 emacs 的初始设置,然后当我需要一个新框架时,我按 C-x 5-2 并且对 emacs 放置它的位置没有任何问题。但如果需要,可以创建它。我建议您尝试使用 ielm (M-x ielm) 和框架:

首先是创建框架的函数make-frame:

ELISP> (make-frame)
#<frame Emacs 0x1158fc150>
ELISP> 

这将创建与使用 C-x 5-2 创建的 emacs 框架完全相同的框架

让我们移动这个框架:

ELISP> (set-frame-position nil 50 50)
t

现在让我们研究一下 make-frame 函数 (C-h f):

(make-frame &optional PARAMETERS)

Return a newly created frame displaying the current buffer. Optional argument PARAMETERS is an alist of frame parameters for the new frame. Each element of PARAMETERS should have the form (NAME . VALUE), for example:

(name . STRING) The frame should be named STRING.

(width . NUMBER) The frame should be NUMBER characters in width. (height . NUMBER) The frame should be NUMBER text lines high.

(minibuffer . t) The frame should have a minibuffer. (minibuffer . nil) The frame should have no minibuffer. (minibuffer . only) The frame should contain only a minibuffer. (minibuffer . WINDOW) The frame should use WINDOW as its minibuffer window.

(window-system . nil) The frame should be displayed on a terminal device. (window-system . x) The frame should be displayed in an X window.

(display . ":0") The frame should appear on display :0.

(terminal . TERMINAL) The frame should use the terminal object TERMINAL.

In addition, any parameter specified in ‘default-frame-alist’, but not present in PARAMETERS, is applied.

Before creating the frame (via ‘frame-creation-function’), this function runs the hook ‘before-make-frame-hook’. After creating the frame, it runs the hook ‘after-make-frame-functions’ with one argument, the newly created frame.

If a display parameter is supplied and a window-system is not, guess the window-system from the display.

On graphical displays, this function does not itself make the new frame the selected frame. However, the window system may select the new frame according to its own rules.

我们在这里找不到真正的信息,但检查功能,查看源文件:我们发现框架有这样的参数:top',left', width',height', user-size' and用户位置'参数。

所以我们可以在创建新框架时指定这 4 件事,现在我们将只采用位置(这也取决于您的 window 经理、像素以及您希望如何放置)

ELISP> (make-frame '((top . 100) (left . 100) (width . 100) (height . 30)))
#<frame Emacs 0x111ca8c00>
ELISP> (make-frame '((top . 50) (left . 50) (width . 100) (height . 10)))
#<frame Emacs 0x115a5ed50>
ELISP> (make-frame '((top . 100) (left . 100) (width . 100) (height . 10)))
#<frame Emacs 0x1116e77a0>
ELISP> (make-frame '((top . 150) (left . 150) (width . 100) (height . 10)))
#<frame Emacs 0x111ac5aa0>
ELISP> (make-frame '((top . 200) (left . 200) (width . 100) (height . 10)))
#<frame Emacs 0x115c32e00>

你会得到这个:

(让我们使用