Emacs 如何以交互方式调用函数
当我启动Emacs时,我希望它填满我屏幕的左半部分。我使用Emacs 如何以交互方式调用函数,emacs,elisp,interactive,Emacs,Elisp,Interactive,当我启动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-wid
;; 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使用了左半屏幕
,但什么也没发生
也就是说,除非我先运行M-:(设置帧像素大小(选定帧)1024768)
(或类似的东西)。如果我这样做了,并且我没有使用鼠标更改帧大小,那么使用左半屏幕
工作。只要我使用鼠标或操作系统快捷方式更改帧大小,它就会停止工作
你对我如何让M-x使用左半屏幕有什么想法吗?我相信这也取决于你的窗口管理器,以及它如何/是否尊重应用程序的定位等请求。@tripleee
设置帧像素大小
工作可靠,所以情况并非如此。好吧,它对我有效(我执行了2次调整,以交互方式运行了“使用左半屏幕”,成功了。我用鼠标调整了帧的大小,重新执行,再次成功)是否检查了用鼠标调整大小后返回的x-display-pixel-width
值?如何放置(设置帧像素大小(选定帧)1024 768)
在的开始部分使用左半屏幕
?问题似乎不太可能与交互性有关。@Bahbar您正在运行什么操作系统/Emacs?