我正在使用Carbon Emacs 23并尝试在切换出全屏帧(由函数设置)之后将帧宽度设置为某个值。实际上,奇怪的是,不仅没有设置宽度,而且如果你反复切换全屏,框架会变得越来越小,就像一个消失的窗口。感谢任何想法,我尝试过几个不同的想法。这是代码:
(defun set-frame-size-according-to-resolution ()
(interactive)
(if window-system
(progn
;; use 120 char wide window for largeish displays
;; and smaller 80 column windows for smaller displays
;; pick whatever numbers make sense for you
(if (> (x-display-pixel-width) 1280)
(add-to-list 'default-frame-alist (cons 'width 140))
(add-to-list 'default-frame-alist (cons 'width 100)))
;; for the height, subtract a couple hundred pixels
;; from the screen height (for panels, menubars and
;; whatnot), then divide by the height of a char to
;; get the height we want
(add-to-list 'default-frame-alist
(cons 'height (/ (- (x-display-pixel-height) 200) (frame-char-height)))))))
;;; This used to be in Carbon Emacs, puttin' it back in with my own twist
(defun mac-toggle-max-window ()
(interactive)
(set-frame-parameter nil 'fullscreen
(if (frame-parameter nil 'fullscreen)
(progn
(scroll-bar-mode 1) ;; turn on scrollbars when not in fullscreen mode
(set-frame-size-according-to-resolution)
nil)
(progn
(scroll-bar-mode -1) ;; turn off scrollbars when in fullscreen mode
'fullboth))))
;;; Toggle full screen via CMD-Return (my meta key is mapped to command on OS X
(define-key global-map [(meta return)]
'mac-toggle-max-window)
答案 0 :(得分:2)
没关系,我几分钟后就知道了。
以下是答案:
;;; Set frame width - used on toggle out of fullscreen mode
(defun default-frame-width ()
"Set width of selected frame."
(modify-frame-parameters
(selected-frame)
(list (cons 'width 140))))
;;; This used to be in Carbon Emacs, puttin' it back in with my own twist
(defun mac-toggle-max-window ()
(interactive)
(set-frame-parameter nil 'fullscreen
(if (frame-parameter nil 'fullscreen)
(progn
(scroll-bar-mode 1) ;; turn on scrollbars when not in fullscreen mode
(default-frame-width)
nil)
(progn
(scroll-bar-mode -1) ;; turn off scrollbars when in fullscreen mode
'fullboth))))
;;; Toggle full screen via CMD-Return (my meta key is mapped to command on OS X
(define-key global-map [(meta return)]
'mac-toggle-max-window)