Skip to content

Instantly share code, notes, and snippets.

@tsuchm
Last active May 10, 2023 05:55
Show Gist options
  • Save tsuchm/2061d8b0250070dd33bd4065d49cdf56 to your computer and use it in GitHub Desktop.
Save tsuchm/2061d8b0250070dd33bd4065d49cdf56 to your computer and use it in GitHub Desktop.
Extension of make-frame-command to generate a frame on visible position
;; 2つ目のフレームを作成する時,1つ目のフレームと重なって表示されてしまうため,重ならないよう場所を指定する
(defun my-make-frame-command ()
"Make a new frame, on the same terminal as the selected frame.
If the terminal is a text-only terminal, this also selects the
new frame."
(interactive)
(if (display-graphic-p)
(let ((left (cdr (assq 'left (frame-parameters (selected-frame)))))
(width (+ (frame-pixel-width) (frame-scroll-bar-width))))
(make-frame (list
(cons 'left
(if (< left (/ (- (display-pixel-width) width) 2))
(+ left width)
(- left width)))
(cons 'width (frame-width))
(cons 'height (frame-height)))))
(select-frame (make-frame))))
(define-key global-map "\C-x52" 'my-make-frame-command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment