1

I have the following in my 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)))))

I am new to emacs and want to know how do I make every successive new frame open (left + 10) of the previous frame.

I want to be able to visually see all frames everytime I open a new frame with C-x 5 2. With the current setting in init.el new frames overlap the previous frame.

Drew
  • 29,895
  • 7
  • 74
  • 104

1 Answers1

1

I think that the easy way here is creating frames directly emacs will create the frame following the variable:

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

I have this on my init.el

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

I also Use fringe-mode

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

So this is my initial setup of the emacs, then when I need a new frame I press C-x 5-2 and do not have any problem about where emacs puts that. but if you need, to create it. I recommend you to experiment with ielm (M-x ielm), and with the frames:

First the function for creating frames make-frame:

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

This will create and emacs frame exactly as the one created with C-x 5-2

Lets move this frame:

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

moving frames

Now let's investigate the make-frame function (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.

We cannot find the real information here but inspecting the function, looking at the source file: we find that the frame has this parameters: top',left', width',height', user-size' anduser-position' parameters.

So we can specify when creating the new frame this 4 things, now we are agoing to take only the position (this also depends on your window manager, pixels and how want you to put)

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>

And you will get this:

frmaes

(lets use

anquegi
  • 11,125
  • 4
  • 51
  • 67