[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a way to control where frames get created?

From: Michael Heerdegen
Subject: Re: Is there a way to control where frames get created?
Date: Sun, 30 Sep 2018 13:58:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

"Perry E. Metzger" <address@hidden> writes:

> I'd like to rig things up so that make-frame-command creates its new
> frame adjacent to the existing frame if that's geometrically
> possible on the GUI display. To do that, I'd need to both be able to
> find out where the existing frame is, and to tell make-frame-command
> where to create the new frame.

I want something similar if I understand you correctly: I want that all
frames appear slightly shifted horizontally.  I use
'after-make-frame-functions' to implement this:

#+begin_src emacs-lisp
(require 'cl-lib)

(defun my-reposition-frame-after-create (frame)
  (when window-system
    (if  (> (frame-pixel-width frame) (display-pixel-width))
        (set-frame-parameter nil 'fullscreen 'maximized)
      (let* ((frames (delq frame (filtered-frame-list (lambda (f) (eq t 
(frame-visible-p f))))))
             (xs (cl-remove-if (lambda (val) (not (integerp val)))
                               (mapcar (lambda (f) (frame-parameter f 'left)) 
             (new-x 0))
        (while (member new-x xs)
          (cl-incf new-x 20))
        (set-frame-parameter frame 'left new-x)
        (set-frame-parameter frame 'user-position t)))))

(add-hook 'after-make-frame-functions #'my-reposition-frame-after-create)

It's a hack but got enough for me.  I have some more related stuff,
e.g. to reorder frames to fill the gap of a deleted frame.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]