GNU bug report logs -
#7730
24.0.50; `image-mode-fit-frame': add optional FRAME arg
Previous Next
Reported by: "Drew Adams" <drew.adams <at> oracle.com>
Date: Fri, 24 Dec 2010 23:40:02 UTC
Severity: wishlist
Found in version 24.0.50
Done: Chong Yidong <cyd <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7730 in the body.
You can then email your comments to 7730 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7730
; Package
emacs
.
(Fri, 24 Dec 2010 23:40:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Drew Adams" <drew.adams <at> oracle.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 24 Dec 2010 23:40:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Here's a possible enhancement to `image-mode-fit-frame'.
These are the differences:
1. Added an optional FRAME arg.
2. The command only toggles if called interactively (actually, if the
first arg is non-nil).
#1 means you can use it for another frame. #2 means that only
interactive calls save the previous frame size and alternate between
fitting and restoring the old size.
Also, at the end of the function I changed the separate calls to
`set-frame-width' and `set-frame-height' to a single call to
`set-frame-size'. I did that because I was seeing that the frame was
not getting resized to fit in some cases. Dunno if there is a bug
associated with that.
FWIW, in my own use of this, my general command `fit-frame' calls it
for Emacs 23+ if the FRAME is in `image-mode' or `image-minor-mode':
(if (and (fboundp 'image-mode-fit-frame) ; Emacs 23+
(if (or (null frame) (eq frame (selected-frame)))
(or (eq major-mode 'image-mode) image-minor-mode)
(save-window-excursion
(select-frame frame)
(or (eq major-mode 'image-mode) image-minor-mode))))
(fit-frame-to-image (interactive-p) frame)
...)
(I also use a different name for the command.)
(defun fit-frame-to-image (interactivep &optional frame)
"Fit FRAME to the current image.
If FRAME is not the selected frame, fit it to its first image.
Interactively, if frame has already been fit to the image, then
restore the size from before it was fit.
This function assumes that FRAME has only one window."
;; FIXME: This does not take into account decorations
;; like mode-line, minibuffer, header-line, ...
(interactive "p")
(let* ((saved (frame-parameter frame 'image-mode-saved-size))
(display (if (or (null frame) (equal frame (selected-frame)))
(image-get-display-property)
(save-selected-window (select-frame frame)
(image-get-display-property))))
(size (image-display-size display nil frame)))
(setq frame (or frame (selected-frame)))
(if (and interactivep saved
(eq (caar saved) (frame-width frame))
(eq (cdar saved) (frame-height frame)))
(progn ; Restore previous size, before it was fit.
(set-frame-parameter frame 'image-mode-saved-size nil)
(setq size (cdr saved)))
;; Round up size, and save current size so we can toggle back to it.
(setcar size (ceiling (car size)))
(setcdr size (ceiling (cdr size)))
(set-frame-parameter
frame 'image-mode-saved-size
(cons size (cons (frame-width frame) (frame-height frame)))))
(set-frame-size frame (car size) (cdr size))))
In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
of 2010-12-20 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.4) --no-opt --cflags
-Ic:/imagesupport/include'
Reply sent
to
Chong Yidong <cyd <at> gnu.org>
:
You have taken responsibility.
(Sat, 19 Jan 2013 10:38:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
"Drew Adams" <drew.adams <at> oracle.com>
:
bug acknowledged by developer.
(Sat, 19 Jan 2013 10:38:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 7730-done <at> debbugs.gnu.org (full text, mbox):
"Drew Adams" <drew.adams <at> oracle.com> writes:
> Here's a possible enhancement to `image-mode-fit-frame'.
>
> 1. Added an optional FRAME arg.
>
> 2. The command only toggles if called interactively (actually, if the
> first arg is non-nil).
Thanks. I've committed something similar.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 16 Feb 2013 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 63 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.