3
我正在使用Carbon Emacs 23,並試圖在切換出全屏框架(由函數設置)之後將框架寬度設置爲某個值。其實,奇怪的是,不僅寬度沒有設置,而且如果您重複切換出全屏,幀變得越來越小,就像一個消失的窗口。欣賞任何想法,我嘗試了幾個不同的想法。這裏是代碼:在Emacs中設置框架大小開啓全屏
(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)