当我启动Emacs时,我希望它能填满屏幕的左半部分。我用
完成了这个;; set initial window size to the left half of the screen
(defun set-frame-pixel-size (frame width height)
"Sets size of FRAME to WIDTH by HEIGHT, measured in pixels."
(let ((pixels-per-char-width (/ (frame-pixel-width) (frame-width)))
(pixels-per-char-height (/ (frame-pixel-height) (frame-height))))
(set-frame-size frame
(floor (/ width pixels-per-char-width))
(floor (/ height pixels-per-char-height)))))
(defun use-left-half-screen ()
(interactive)
(let* ((excess-width 32)
(excess-height 48)
(half-screen-width (- (/ (x-display-pixel-width) 2) excess-width))
(screen-height (- (x-display-pixel-height) excess-height)))
(set-frame-pixel-size (selected-frame) half-screen-width screen-height)))
(if window-system
(use-left-half-screen))
它的工作非常精彩。但是,我有时想在白天另一次打电话给同一个命令。因此,我做M-x use-left-half-screen
但没有任何事情发生。
即使我先运行M-: (set-frame-pixel-size (selected-frame) 1024 768)
(或类似的东西)。如果我这样做,并且我没有使用鼠标更改帧大小,那么use-left-half-screen
可以正常工作。只要我使用鼠标或操作系统快捷方式更改帧大小,它就会停止工作。
您对我如何使M-x use-left-half-screen
工作有任何想法吗?