Function: image-mode-fit-frame
image-mode-fit-frame is an interactive and byte-compiled function
defined in image-mode.el.gz.
Signature
(image-mode-fit-frame &optional FRAME TOGGLE)
Documentation
Fit FRAME to the current image.
If FRAME is omitted or nil, it defaults to the selected frame. All other windows on the frame are deleted.
If called interactively, or if TOGGLE is non-nil, toggle between
fitting FRAME to the current image and restoring the size and
window configuration prior to the last image-mode-fit-frame
call.
Probably introduced at or before Emacs version 24.4.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/image-mode.el.gz
;; Adjust frame and image size.
(defun image-mode-fit-frame (&optional frame toggle)
"Fit FRAME to the current image.
If FRAME is omitted or nil, it defaults to the selected frame.
All other windows on the frame are deleted.
If called interactively, or if TOGGLE is non-nil, toggle between
fitting FRAME to the current image and restoring the size and
window configuration prior to the last `image-mode-fit-frame'
call."
(interactive (list nil t) image-mode)
(let* ((buffer (current-buffer))
(saved (frame-parameter frame 'image-mode-saved-params))
(window-configuration (current-window-configuration frame))
(frame-width (frame-text-width frame))
(frame-height (frame-text-height frame)))
(with-selected-frame (or frame (selected-frame))
(if (and toggle saved
(= (caar saved) frame-width)
(= (cdar saved) frame-height))
(progn
(set-frame-width frame (car (nth 1 saved)) nil t)
(set-frame-height frame (cdr (nth 1 saved)) nil t)
(set-window-configuration (nth 2 saved))
(set-frame-parameter frame 'image-mode-saved-params nil))
(delete-other-windows)
(switch-to-buffer buffer t t)
(fit-frame-to-buffer frame)
;; The frame size after the above `set-frame-*' calls may
;; differ from what we specified, due to window manager
;; interference. We have to call `frame-width' and
;; `frame-height' to get the actual results.
(set-frame-parameter frame 'image-mode-saved-params
(list (cons (frame-text-width frame)
(frame-text-height frame))
(cons frame-width frame-height)
window-configuration))))))